Game Development Community

dev|Pro Game Development Curriculum

Day/Night cycle for TGEA v2

by Jack Stone · 08/27/2007 (1:45 pm) · 18 comments

Instructions:
-Make sure your Sun object is called "Sun"
-execute the DayNight.cs file.
-call the loadSky() function sometime before the mission has finished loading
-Call the startDayNightCycle() function at the start of your mission

Modify the $TRANSITIONTIME variable to control the speed of the transition. (Its set very low for demonstration purposes) To add new skyboxes, just create a new sky object in loadSky() and add its variable name to SwapSky(). Then modify the appropriate code (It's annotated) to determine which skybox should be displayed. (I'm using the DRL values of the sun object)


To enable dynamic placing of light objects:
You will first need to place the lights in your mission using an fxfoliage replicator object. (The name of the fxfoliagereplicator doesn't matter)
Then, in fxfoliagereplicator.cpp, after the lines:
// Set Shape Scale.
fxStatic->setScale(ShapeScale);

// Lock it.
fxStatic->setLocked(true);

(around line 424), add these lines:

Con::printf("SHAPE = :%s" , mFieldData.mShapeFile );

// Store Shape in Replicated Shapes Vector.
mReplicatedShapes[mCurrentShapeCount++] = fxStatic;
int id = fxStatic->getId();
static char buf[32];
dSprintf(buf, sizeof(buf), "%d", id);
char* ch = buf;
const char* argv[] = {"addmissionlight", ch , mFieldData.mShapeFile};
Con::printf("Fx Shape Object ID: %s" , ch);
Con::execute(3, argv);

This will go call the script function "addmissionlight" for every object in every shapereplicator in your mission.

Then, in addmissionlight, change:
if(%file $= "Simulation/data/shapes/lanternfreestanding.dts")
to the directory of the object that you want to use for your lamppost, lantern, etc.
The day/night cycle will then automatically add a light to every object of the type specified in addmissionlight during the night, and delete them during the day.
$lightoffsetz controls the height the light be will placed above the object, so you will probably want to change this.

The light I have used in this file is called "lantern". Its datablock is here:

//--- OBJECT WRITE BEGIN ---
datablock sgLightObjectData(lantern) {
canSaveDynamicFields = "1";
className = "sgLightObjectData";
LightOn = "1";
Radius = "10";
Brightness = "1";
Colour = "1 0.898039 0.494118 1";
FlareOn = "1";
FlareTP = "1";
FlareBitmap = "~/lighting/corona";
FlareColour = "1 1 1 1";
ConstantSizeOn = "0";
ConstantSize = "2";
NearSize = "2";
FarSize = "2";
NearDistance = "10";
FarDistance = "30";
FadeTime = "0.1";
BlendMode = "0";
AnimColour = "1";
AnimBrightness = "1";
AnimRadius = "0";
AnimOffsets = "0";
AnimRotation = "0";
LinkFlare = "1";
LinkFlareSize = "0";
MinColour = "0.917647 0.712644 0.219608 1";
MaxColour = "1 0.898039 0.494118 1";
MinBrightness = "0.7";
MaxBrightness = "1";
MinRadius = "80";
MaxRadius = "10";
StartOffset = "-5 0 0";
EndOffset = "5 0 0";
MinRotation = "0";
MaxRotation = "359";
SingleColourKeys = "1";
RedKeys = "AZA";
GreenKeys = "AZA";
BlueKeys = "AZA";
BrightnessKeys = "AZA";
RadiusKeys = "AZA";
OffsetKeys = "AZA";
RotationKeys = "AZA";
ColourTime = "1";
BrightnessTime = "1.5";
RadiusTime = "1.5";
OffsetTime = "5";
RotationTime = "5";
LerpColour = "1";
LerpBrightness = "1";
LerpRadius = "1";
LerpOffset = "1";
LerpRotation = "1";
StaticLight = "0";
SpotLight = "0";
SpotAngle = "1";
AdvancedLightingModel = "1";
EffectsDTSObjects = "1";
CastsShadows = "1";
DiffuseRestrictZone = "0";
AmbientRestrictZone = "0";
LocalAmbientAmount = "0";
SmoothSpotLight = "0";
DoubleSidedAmbient = "1";
LightingModelName = "SG - Original Stock (Lighting Pack)";
UseNormals = "0";
SupportedFeatures = "Full";
MountPoint = "0";
MountPosition = "0 0 0";
MountRotation = "1 0 0 0";
};
//--- OBJECT WRITE END ---


If you notice that only some of your lights are showing up in game, or that the light shows up, but it doesn't cast any light on the terrain, try going to your game/client/prefs.cs file, and increasing the values of the following variables:
$pref::LightManager::sgAtlasMaxDynamicLights = "50"; (Line 45 in my build)
$pref::LightManager::sgMaxBestLights = "50"; (Line 50 in my build)

These variable control the max number of lights that can illuminate an atlas terrain, (first variable) and the max number of lights per mission. (Second variable) If you are creating more lights than these max values, the additional ones won't show up.
You can also change these variables by using the options dialog:
canvas.pushdialog(optionsdlg);



//Daynight.cs:
//Jack Stone, 11 April, 2007


//$TRANSITIONTIME = 3000;

$TRANSITIONTIME = 600000; // one cycle every 10 minutes = full day of 4 hours 1:6 ratio
//$TRANSITIONTIME = 3000; // 1 second
$lightoffsetz = 9.5;

$DrlMIN = 0.0;
$DrlMAX = 0.17;


$DrlMult = 1.3;
$NDToggle = 1; // 1 means its getting darker, 2 means its getting brighter


$LDTMin = 0;
$LDTMax = 0;


$AZIMUTH = 90;
$ELEVATION = 0;

$Skyloaded = 0;

//function to add ID's of replicated lights to a missiongroup:

new SimGroup(missionlights);
new SimGroup(missionlights2);



function clearmissionlights()
{
missionlights.clear();
}


//function placelights

function addmissionlight(%lightid , %file)
{
//have light id, add to missionlights:

echo("FILE: " @ %file);
if(%file $= "Simulation/data/shapes/lanternfreestanding.dts")
{

missionlights.add(%lightid);

echo("addmissionlight: " @ %lightid SPC missionlights.getCount());
}

}
function deletelights()
{
echo("de: " @ missionlights2.getCount());
%numl = missionlights2.getCount();
while(missionlights2.getCount() )
missionlights2.getObject(0).delete();
//%set.delete();


//missionlights2.clear();
}
function addlights()
{

//only the last half of the missionlight entries are the valid object ID's for some reason.

//clear previous lights:

%numlights = missionlights2.getCount();
%num2 = %num /2;
%num = missionlights.getCount();
//%num2 = %num /2;
%num2 = 0;
echo("NUM: " @ %num SPC %num2);
for(%i = %num2 ; %i < %num ; %i++)
{

%objid = missionlights.getObject(%i);

echo("ID: " @ %objid);

//now create a light at the mount point of each object:

%pos = %objid.getPosition();

%z = getWord(%pos , 2);
%z += $lightoffsetz; //this will control how far the light is offset on the z axis of the object
%newpos = setWord(%pos, 2, %z);




%l = new sgLightObject() {
canSaveDynamicFields = "1";
position = %newpos;
rotation = "1 0 0 0";
scale = "1 1 1";
dataBlock = "lantern";
Enable = "1";
IconSize = "1";
ParticleColorAttenuation = "1";
};

missionlights2.add(%l);
echo("d: " @ missionlights2.getCount() SPC %l);

}

}


function movesun()
{

// fxSun


// $AZIMUTH = 0;
// $ELEVATION = 0;

//starts at 90

fxSun.SunElevation -= 10;
fxSun.SunAzimuth = 0;

fxSun.apply();

//darkest at -90
if (fxSun.SunElevation == -90 )
fxSun.SunElevation = 270;

schedule(2000 , 0 , movesun);
}


function startDayNightCycle(){

//if( $Skyloaded == 0 ) //hasnt been loaded
//loadsky();


//Some general values:

//Midday (Maximum brightness) is:

//Sun.DRLMin = "0.7";
//Sun.DRLMax = "1.6";


//Maxiumum Darkness is:
//Sun.DRLMin = 0.0;
//Sun.DRLMax = 0.17;

//start cycle at midday, $DRL = 1.3


fxSun.SunElevation -= 15;
fxSun.SunAzimuth = 0;



//darkest at -90
if (fxSun.SunElevation == -90 )
fxSun.SunElevation = 270;

fxSun.apply();

$localTT = $TRANSITIONTIME;


echo(": " @ $DrlMult);

if($NDToggle == 1)
{

$DrlMult -= 0.1;
// fxSun.Elevation -=10;
// fxSun.Azimuth = 0;
}
else
{

$DrlMult += 0.1;
//fxSun.Elevation +=10;
// fxSun.Azimuth = 0;


}


echo("SUNSET2" SPC fxSun.Elevation SPC fxSun.Azimuth );




// if($DrlMult <= 0.9 && $DrlMult >= 0.7 && $NDToggle == 1 )
if($DrlMult <= 0.7 && $DrlMult >= 0.6 && $NDToggle == 1 )
{
//pause here for a while, because we want to have sunset slightly longer than normal
echo("SUNSET2");


SwapSky("Sunrise");


//hardcode values for sunset?
fxSun.SunElevation = 0;
fxSun.SunAzimuth = 0;


//SwapSky("Night");

// echo("SUNSET");

//turn on all lights at once for the moment:
addlights();

//$localTT += 4000;


}
// if($DrlMult == 0.7 ) addlights();
if($DrlMult < 0.3&& $DrlMult >= 0.2 )
{

$locatTT += 5000;
echo("NIGHT");
SwapSky("Night");

}

if($DrlMult <= 0.4 && $DrlMult >= 0.3 && $NDToggle == 2 )
{
//pause here for a while, because we want to have sunset slightly longer than normal
// $localTT += 4000;
echo("SUNRISE");
SwapSky("Sunset");


fxSun.SunElevation = 180;
fxSun.SunAzimuth = 0;


//turn off lights:
deletelights();

if($DrlMult > 0.5 && $DrlMult <= 1.3 && $NDToggle == 2 )
{

// $locatTT += 5000;
echo("Day");
SwapSky("Day");

}

if($DrlMult >= 0.11 && $DrlMult <= 0.21)
{
echo("Incease Brightness");
$NDToggle = 2; // increase brightness
}

if($DrlMult >= 1.21 && $DrlMult <= 1.31)
{
echo("decrease Brightness");
$NDToggle = 1; // increase brightness
}
if($DrlMult == 1.3)
{
$NDToggle = 1;
}




echo("end");


Sun.DrlMultiplier = $DrlMult;

Sun.apply();



schedule($localTT , 0 , startDayNightCycle);
}




function loadSky(){


$Sky2 = new Sky("Sky2") {
canSaveDynamicFields = "1";
position = "0 0 0";
rotation = "1 0 0 0";
scale = "1 1 1";
materialList= "C:/Torque/TGEA_1_0_3/example/JackStone/data/skies/ST.dml " ;
cloudHeightPer[0] = "0.349971";
cloudHeightPer[1] = "0.3";
cloudHeightPer[2] = "0.199973";
cloudSpeed1 = "0.0005";
cloudSpeed2 = "0.001";
cloudSpeed3 = "0.0003";
visibleDistance = "30000";
fogDistance = "8000";


fogColor = "0.6 0.6 0.7 1";
fogStorm1 = "1";
fogStorm2 = "1";
fogStorm3 = "1";
fogVolume1 = "0 39 39";
fogVolume2 = "0 100 100";
fogVolume3 = "0 100 100";
windVelocity = "1 1 0";
SkySolidColor = "0.113 0.148 0.215 0";
useSkyTextures = "1";
renderBottomTexture = "1";
noRenderBans = "1";
renderBanOffsetHeight = "1";
skyGlow = "1";
skyGlowColor = "0.3 0.4 0.2 0.4";
locked = "false";
windEffectPrecipitation = "1";
};

$Sky2.setName("Sky2");




$Sky3 = new Sky("Sky3") {
canSaveDynamicFields = "1";
position = "0 0 0";
rotation = "1 0 0 0";
scale = "1 1 1";
materialList= "C:/Torque/TGEA_1_0_3/example/Simulation/data/skies/sunset.dml " ;
cloudHeightPer[0] = "0.349971";
cloudHeightPer[1] = "0.3";
cloudHeightPer[2] = "0.199973";
cloudSpeed1 = "0.0005";
cloudSpeed2 = "0.001";
cloudSpeed3 = "0.0003";
visibleDistance = "30000";
fogDistance = "8000";
fogColor = "0.6 0.6 0.7 1";
fogStorm1 = "1";
fogStorm2 = "1";
fogStorm3 = "1";
fogVolume1 = "0 39 39";
fogVolume2 = "0 100 100";
fogVolume3 = "0 100 100";
windVelocity = "1 1 0";
SkySolidColor = "0.113 0.148 0.215 0";
useSkyTextures = "1";
renderBottomTexture = "1";
noRenderBans = "1";
renderBanOffsetHeight = "1";
skyGlow = "1";
skyGlowColor = "0.3 0.4 0.2 0.4";
locked = "false";
windEffectPrecipitation = "1";
};

$Sky3.setName("Sky3");


$Sky4 = new Sky("Sky4") {
canSaveDynamicFields = "1";
position = "0 0 0";
rotation = "1 0 0 0";
scale = "1 1 1";
materialList= "C:/Torque/TGEA_1_0_3/example/Simulation/data/skies/sunrise.dml " ;
cloudHeightPer[0] = "0.349971";
cloudHeightPer[1] = "0.3";
cloudHeightPer[2] = "0.199973";
cloudSpeed1 = "0.0005";
cloudSpeed2 = "0.001";
cloudSpeed3 = "0.0003";
visibleDistance = "30000";
fogDistance = "8000";
fogColor = "0.6 0.6 0.7 1";
fogStorm1 = "1";
fogStorm2 = "1";
fogStorm3 = "1";
fogVolume1 = "0 39 39";
fogVolume2 = "0 100 100";
fogVolume3 = "0 100 100";
windVelocity = "1 1 0";
SkySolidColor = "0.113 0.148 0.215 0";
useSkyTextures = "1";
renderBottomTexture = "1";
noRenderBans = "1";
renderBanOffsetHeight = "1";
skyGlow = "1";
skyGlowColor = "0.3 0.4 0.2 0.4";
locked = "false";
windEffectPrecipitation = "1";
};

$Sky4.setName("Sky4");

















$Sky5 = new Sky("Sky5") {
canSaveDynamicFields = "1";
position = "0 0 0";
rotation = "1 0 0 0";
scale = "1 1 1";
materialList= "C:/Torque/TGEA_1_0_3/example/Simulation/data/skies/storm.dml " ;
cloudHeightPer[0] = "0.349971";
cloudHeightPer[1] = "0.3";
cloudHeightPer[2] = "0.199973";
cloudSpeed1 = "0.0005";
cloudSpeed2 = "0.001";
cloudSpeed3 = "0.0003";
visibleDistance = "30000";
fogDistance = "8000";
fogColor = "0.6 0.6 0.7 1";
fogStorm1 = "1";
fogStorm2 = "1";
fogStorm3 = "1";
fogVolume1 = "0 39 39";
fogVolume2 = "0 100 100";
fogVolume3 = "0 100 100";
windVelocity = "1 1 0";
SkySolidColor = "0.113 0.148 0.215 0";
useSkyTextures = "1";
renderBottomTexture = "1";
noRenderBans = "1";
renderBanOffsetHeight = "1";
skyGlow = "1";
skyGlowColor = "0.3 0.4 0.2 0.4";
locked = "false";
windEffectPrecipitation = "1";
};

$Sky5.setName("Sky5");










$Sky1 = new Sky("Sky1") {
canSaveDynamicFields = "1";
position = "0 0 0";
rotation = "1 0 0 0";
scale = "1 1 1";
materialList= "C:/Torque/TGEA_1_0_3/example/JackStone/data/skies/brightsky.dml " ;


cloudHeightPer[0] = "0.349971";
cloudHeightPer[1] = "0.3";
cloudHeightPer[2] = "0.199973";
cloudSpeed1 = "0.0005";
cloudSpeed2 = "0.001";
cloudSpeed3 = "0.0003";
visibleDistance = "30000";
fogDistance = "8000";
fogColor = "0.6 0.6 0.7 1";
fogStorm1 = "1";
fogStorm2 = "1";
fogStorm3 = "1";
fogVolume1 = "0 39 39";
fogVolume2 = "0 100 100";
fogVolume3 = "0 100 100";
windVelocity = "1 1 0";
SkySolidColor = "0.113 0.148 0.215 0";
useSkyTextures = "1";
renderBottomTexture = "1";
noRenderBans = "1";
renderBanOffsetHeight = "1";
skyGlow = "1";
skyGlowColor = "0.3 0.4 0.2 0.4";
locked = "false";
windEffectPrecipitation = "1";
};

$Sky1.setName("Sky1");

new Sky(Sky) {
canSaveDynamicFields = "1";
position = "0 0 0";
rotation = "1 0 0 0";
scale = "1 1 1";
materialList = "C:/Torque/TGEA_1_0_3/example/Simulation/data/skies/brightsky.dml ";
cloudHeightPer[0] = "0.349971";
cloudHeightPer[1] = "0.3";
cloudHeightPer[2] = "0.199973";
cloudSpeed1 = "0.0005";
cloudSpeed2 = "0.001";
cloudSpeed3 = "0.0003";
visibleDistance = "30000";
fogDistance = "8000";
fogColor = "0.6 0.6 0.7 1";
fogStorm1 = "1";
fogStorm2 = "1";
fogStorm3 = "1";
fogVolume1 = "0 39 39";
fogVolume2 = "0 100 100";
fogVolume3 = "0 100 100";
windVelocity = "1 1 0";
SkySolidColor = "0.113 0.148 0.215 0";
useSkyTextures = "1";
renderBottomTexture = "1";
noRenderBans = "1";
renderBanOffsetHeight = "1";
skyGlow = "1";
skyGlowColor = "0.3 0.4 0.2 0.4";
locked = "false";
windEffectPrecipitation = "1";
};


$Sky.setName("Sky");


MissionGroup.add($Sky1);
MissionGroup.add($Sky2);
MissionGroup.add($Sky3);
MissionGroup.add($Sky4);
MissionGroup.add($Sky5);

MissionGroup.add($Sky);



}

function SwapSky(%ID){


if(%ID $= "Night" || %ID == 1)
{
Sky.materialList = $Sky2.materialList;
Sky.visibleDistance = "1000";
Sky.fogDistance = "700";
Sky.inspectPostApply();

}

if(%ID $= "Day" || %ID == 2)
{
Sky.materialList = $Sky1.materialList;
Sky.inspectPostApply();
echo("DAY");

}

if(%ID $= "Sunset" || %ID == 3)
{
echo("sunset");
Sky.materialList = Sky3.materialList;
Sky.inspectPostApply();

}

if(%ID $= "Sunrise" || %ID == 4)
{
Sky.materialList = Sky4.materialList;
Sky.inspectPostApply();

}

if(%ID $= "Storm" || %ID == 5)
{
Sky.materialList = Sky5.materialList;
Sky.inspectPostApply();

// Sun.DrlMultiplier -= 0.3 ;
// Sun.apply();

}



}





function MGSwapSky(%ID)
{


if(%ID $= "Night" || %ID == 1)
{
Sky.materialList = $Sky2.materialList;
Sky.visibleDistance = "1000";
Sky.fogDistance = "700";
Sky.inspectPostApply();


Sun.DrlMultiplier = 0.2;
Sun.apply();

// Sunlight.azimuth = -90;

Sunlight.SunElevation = -90;
Sunlight.SunAzimuth = 0;
Sunlight.apply();

$currentsky = $Sky2;

}

if(%ID $= "Day" || %ID == 2)
{
Sky.materialList = $Sky1.materialList;
Sky.inspectPostApply();

Sun.DrlMultiplier = 1.3;
Sun.apply();

$currentsky = $Sky1;

}

if(%ID $= "Sunset" || %ID == 3)
{
echo("sunset");
Sky.materialList = Sky3.materialList;
Sky.inspectPostApply();

Sun.DrlMultiplier = 0.9;
Sun.apply();
$currentsky = $Sky3;

}

if(%ID $= "Sunrise" || %ID == 4)
{
Sky.materialList = Sky4.materialList;
Sky.inspectPostApply();

Sun.DrlMultiplier = 0.9;
Sun.apply();
$currentsky = $Sky4;

}

if(%ID $= "Storm" || %ID == 5)
{
Sky.materialList = Sky5.materialList;
Sky.inspectPostApply();


Sun.DrlMultiplier = 1.0;
Sun.apply();

$currentsky = $Sky5;

// Sun.DrlMultiplier -= 0.3 ;
// Sun.apply();

}



}






function createSun(){
$Sun1 = new Sun(Sun) {
canSaveDynamicFields = "1";
azimuth = "0";
elevation = "35";
color = "1 1 0.8 1";
ambient = "0.4 0.4 0.5 1";
CastsShadows = "1";
useBloom = "0";
useToneMapping = "0";
useDynamicRangeLighting = "1";
DRLHighDynamicRange = "1";
DRLTarget = "0.5";
DRLMax = "1.6";
DRLMin = "0.7";
DRLMultiplier = "1.3";
bloomCutOff = "0.9";
bloomAmount = "0.2";
bloomSeedAmount = "1";
rotation = "1 0 0 0";
direction = "0 0.954268 -0.298953";
locked = "true";
position = "0 0 0";
scale = "1 1 1";
};
$Sun1.setName("Sun");
}

#1
08/27/2007 (2:31 pm)
Hmm, never thought about adjusting DRL. I use an updated version of Josh's original code which adjusts colors. I'll have to add this one in as well, see if there's any big improvement.
How's the shadowing working? Thats the one stickler I have. As I move the sun object, the player shadows go pretty wild.
#2
08/27/2007 (3:06 pm)
Where do you put startDayNightCycle() and loadSky()? I cant get it to work.
#3
08/27/2007 (5:31 pm)
Being this is a clientside solution, StartGame() is probably your best choice.
#4
08/28/2007 (11:03 am)
Erik, I didnt consider shadowing when I was writing this, but ive just done some quick testing, and modyifing the Sun's "elevation" property (essentially its position) doesnt seem to do anything it shouldnt do. The players shadows do change, but theyre supposed to do that as the suns position is the sky changes. What kind of wild behaviour did you notice?

Adam, as Erik said, StartGame() would be a good place to put those function calls. You could put them in any function called before the mission begins really, like onMissionLoaded(); (both in game.cs btw)
#5
08/29/2007 (12:16 pm)
What I do is a lot more complex than this; my sun object however does move a few degrees every hour. I would expect my players shadow to move (lengthen/shorten) about the same. It currently moves as though the planet is spinning 10-20x faster than I have it doing. Just an oddity I haven't gotten back to yet, nor have I tried your version yet (sometimes simpler is the better solution!). I'm pretty sure my problem lies in how I register the sun with the SG light manager.
#6
08/31/2007 (11:46 am)
I havent considered the ratio of the shadow moving compared to the Sun. It seems to be realistic enough that the majority of users wont notice it. Are you making a standard FPS game, or are you looking for a more realistic simulation?
JS
#7
09/01/2007 (11:05 am)
does this work in TGE, i meanthis works off the TLK right? which includes a version of the DRL, as i understand it.
#8
09/01/2007 (1:20 pm)
Edward, theoretically you could do something similar to this with the DRL resource. Out of the box, no. This does not work with the DRL resource.
#9
09/04/2007 (8:50 am)
I never bought the TLK for TGE, so I'm not sure what functionality it (TLK) adds unfortunatly. I just used the settings that were there, I assumed DRL was TGEA only.
#10
09/24/2007 (12:16 am)
This is good and will be useful in the future thanks!
#11
12/26/2007 (10:52 pm)
I have a few questions about this:

What about sunflares? Is there some way to get rid of them when you switch to night?

Additionally, is there some way you can make a moon?

Does the sun transition across the sky? I don't see anything that does that.

Finally, does the lighting properly affect Interior objects? One of the big problems in the Clestials resource was that the interiors still looked like they where lit by the sun even though it was at night.
#12
01/25/2008 (6:10 pm)
This seems to be a great resource. I am finally able to make the lighting grow darker and lighter in accordance to the day. I have to say that as I am adding interiors, even though it gets really dark at various timings, it still thrills me. The only issue that I am having is getting the sky-textures to swap. I have tried so many different things (I am using TGEA) and still no result on this aspect. Any help -- assuming if it is still available on this post would be appreciated.

Irregardless -- Jack Stone, Thank You for getting me at least this far!!!
#13
01/26/2008 (8:56 pm)
Ron, Currently, there is no moon. I can't think of an easy way to put one in, except for some kind of billboard, or dts object that moves throughout the night.
However, I do have an updated resource (which I haven't posted yet, I still have to clean it up a bit) that does transition the sun through the sky.
It also has triggers to add lights to the mission (such as lampposts, lanterns, etc), and it will turn them on and off at certain preset levels of daylight. (http://www.phoenixgamedevelopment.com/lights3.JPG)

As for the interior objects, I havent dont anything special with them, so their shadows won't change direction when the sun moves across the sky. In order to update the interior lighting with this resource, I would have to relight the scene, which would take several seconds at best, which would be unacceptable. (The game would freeze while relighting was taking place)

Chad, Your welcome, and I emailed you.
#14
01/26/2008 (9:07 pm)
Thank you Jack. I would really like to see that update.
#15
02/10/2008 (10:01 am)
@Jack:
Great resource! Just wondering if the updated resouce is ready?
#16
02/14/2008 (4:37 am)
I just posted the updated resource, sorry for the delay. I wanted to make some changes to the code to add lights to a mission before I posted the resouce, theres a bit of a hack still in there.
This version is a bit more complex than the last, especially with that code change, so if anyone has any problems implementing it, or if I've forgotten anything, feel free to email me. (jackstone@phoenixgamedevelopment.com)

Jack
#17
04/16/2008 (9:05 pm)
I have a problem wher the terrain and ambient lighting are not being adjusted. I setup the sun datablock similar to the one you have in the script and still nothing.
#18
04/19/2008 (6:43 pm)
Ron, Do you mean that the lights are being created, but that they are not casting light on the actual terrain?

If so, have you tried doing this:

If you notice that only some of your lights are showing up in game, or that the light shows up, but it doesn't cast any light on the terrain, try going to your game/client/prefs.cs file, and increasing the values of the following variables:
$pref::LightManager::sgAtlasMaxDynamicLights = "50"; (Line 45 in my build)
$pref::LightManager::sgMaxBestLights = "50"; (Line 50 in my build)

These variable control the max number of lights that can illuminate an atlas terrain, (first variable) and the max number of lights per mission. (Second variable) If you are creating more lights than these max values, the additional ones won't show up.
You can also change these variables by using the options dialog:
canvas.pushdialog(optionsdlg);

Hope that helps,
Jack