Page 1 of 1
Lighting a terrain generated from a heightmap
Posted: Mon Jul 11, 2005 9:59 pm
by Guest
Is there a way to light a terrain generated from a heightmap? I tried to add a light scene node onto my terrain and moved it close to the surface of the terrain, but the light doesn't seem to...uhh...light the terrain.
Any ideas?
thanks in advance
Posted: Mon Jul 11, 2005 10:13 pm
by Guest
enable the lightning of the terrain and place a dynamic light high above the terrain with a big radius, then it should get the light (i do it the same way)
if you setup the lightning right you can get some pretty good looking results. i remember that one of my first irrlicht screenshots was this one here where i did the exact same thing:
http://mitglied.lycos.de/animespy2003/s ... hading.JPG
hope you like it
bye and good night, i need some sleep
Posted: Tue Jul 12, 2005 8:43 am
by Guest
thanks for the tip GFXstyLER! I got the lighting to work..heh i had to figure out how to get and set light data using SLight. Oh and that image you attached was awesome. Nice work.
thanks again
Posted: Tue Jul 12, 2005 9:26 am
by Guest
ok i have another problem. How do you change the light's settings at runtime? I made a little function that changes the radius of the light at runtime, BUT there's one problem, the light doesn't update in real time, i.e. it only updates when the dos-console is the active window.
I know that the radius changes works, since when i alt+tab and switch between the dos console and the main window i see that the light radius has changed.I may have placed the function in the wrong location. Currently i have the following:
Code: Select all
while(device->run() && isRunning == true)
{
enviroObj.runtimeEnvironment(0,0,0);
if (device->isWindowActive())
{
driver->beginScene(true, true, 0 );
smgr->drawAll();
env->drawAll();
driver->endScene();
...etc
enviroObj.runtimeEnvironment() is the function that updates the light's radius.
any help would be appreciated
[/code]
Posted: Tue Jul 12, 2005 11:04 am
by Guest
Code: Select all
while(device->run() && isRunning == true)
{
if (device->isWindowActive())
{
driver->beginScene(true, true, 0 );
smgr->drawAll();
env->drawAll();
driver->endScene();
enviroObj.runtimeEnvironment(0,0,0);
...etc
it has to be inside the if(device ... bla) i think.
Posted: Tue Jul 12, 2005 8:13 pm
by Guest
weird. i tried what you suggested and now the radius won't change at all. Maybe it's my function's code. this is what the function has:
Code: Select all
void classEnvironment::runtimeEnvironment(int a, int b, int c)
{
timerCounter++;
if (timerCounter >= 1000000)
{
timerCounter = 0;
// darken light
if (brightnessIsDescending == true)
{
lightData = &light->getLightData();
lightData->Radius--;
}
else if (brightnessIsDescending == false)
{
lightData = &light->getLightData();
lightData->Radius++;
}
if (lightData->Radius >= 10)
{
brightnessIsDescending = true;
}
else if (lightData->Radius <= 0)
{
brightnessIsDescending = false;
}
}
}
i was browsing the API and there doesn't seem to be any function that updates the light, so i'm assuming that changing the light data values directly would automatically update the light.
Posted: Tue Jul 12, 2005 8:13 pm
by Guest
weird. i tried what you suggested and now the radius won't change at all. Maybe it's my function's code. this is what the function has:
Code: Select all
void classEnvironment::runtimeEnvironment(int a, int b, int c)
{
timerCounter++;
if (timerCounter >= 1000000)
{
timerCounter = 0;
// darken light
if (brightnessIsDescending == true)
{
lightData = &light->getLightData();
lightData->Radius--;
}
else if (brightnessIsDescending == false)
{
lightData = &light->getLightData();
lightData->Radius++;
}
if (lightData->Radius >= 10)
{
brightnessIsDescending = true;
}
else if (lightData->Radius <= 0)
{
brightnessIsDescending = false;
}
}
}
i was browsing the API and there doesn't seem to be any function that updates the light, so i'm assuming that changing the light data values directly would automatically update the light.
Posted: Tue Jul 12, 2005 8:23 pm
by rsdl
heh n/m...it works...the iteration run was too slow
thanks again for the help man!