addDynamicLight

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
LagAlot
Posts: 13
Joined: Thu Mar 18, 2004 2:04 am

addDynamicLight

Post by LagAlot »

i have:
rr::video::SLight DynamicLight1;
DynamicLight1.DiffuseColor = irr::video::SColorf(254.0f, 254.0f, 254.0f);
DynamicLight1.Radius= 200.0f;
DynamicLight1.CastShadows = true;
DynamicLight1.Position = irr::core::vector3df(0,0,10);

then i call
driver->addDynamicLight(DynamicLight1);


yet i see no light or shadows...what am i doing wrong?
thesmileman
Posts: 360
Joined: Tue Feb 10, 2004 2:20 am
Location: Lubbock, TX

Post by thesmileman »

You have to set up a node's material to use dynamic light. You have to do this for each item that you want effected by dynamic ligt.

You do it like this:

Code: Select all

node->setMaterialFlag(video::EMF_LIGHTING, true);
LagAlot
Posts: 13
Joined: Thu Mar 18, 2004 2:04 am

Post by LagAlot »

yah i checked that and still no dice.. the only way i can get lights in is to use:

levelNode = smgr->addLightSceneNode(0, irr::core::vector3df(100,0,0),
irr::video::SColorf(0.0f, 0.0f, 0.0f, 0.0f), 100.0f);

Yet I have no control over stuff lick cast shodows or not..thats why i was looking at addDynamicLight.. am i missing something??
Robomaniac
Posts: 602
Joined: Sat Aug 23, 2003 2:03 am
Location: Pottstown, PA
Contact:

Post by Robomaniac »

Shadows are handled inside the item's defs, check the api, as i'm forgetting the command right now (anyone wanna help?)
The Robomaniac
Project Head / Lead Programmer
Centaur Force
LagAlot
Posts: 13
Joined: Thu Mar 18, 2004 2:04 am

Post by LagAlot »

i'm digging through the source now.. can i just overload the addLightSceneNode function and CLightSceneNode to allow for shadows on/off??
Robomaniac
Posts: 602
Joined: Sat Aug 23, 2003 2:03 am
Location: Pottstown, PA
Contact:

Post by Robomaniac »

See the special effects tutorial ;-)
The Robomaniac
Project Head / Lead Programmer
Centaur Force
LagAlot
Posts: 13
Joined: Thu Mar 18, 2004 2:04 am

Post by LagAlot »

the specialfx demo simply calls
addLightSceneNode
LagAlot
Posts: 13
Joined: Thu Mar 18, 2004 2:04 am

Post by LagAlot »

ok i changed CLightSceneNode to accept a flag to cast shadows or not. but when i set it to false --no shadow..but no light as well.... :)
PadrinatoR
Posts: 50
Joined: Tue Mar 09, 2004 9:53 pm
Location: Spain

Post by PadrinatoR »

After you load the model, you must call addShadowVolumeSceneNode (see Irrlicht doc for more info), and you must change the ambient light with pVideoDriver->setAmbientLight(255,255,255);
I think it should work :)
There are only 10 types of people: those who understand binary and those who don't

--------------------------------------------

Image
LagAlot
Posts: 13
Joined: Thu Mar 18, 2004 2:04 am

Post by LagAlot »

let me explain what i'm trying to do..I want a dynamic light that does NOT cast shadows..but there will be others that will so just setting the flag on the model will not work..
after digging a little through the source i found the following..

in slight.h we have:
struct SLight
{
SLight() : AmbientColor, DiffuseColor,
SpecularColor,Position,Radius,
CastShadows
{};

but when the slight gets translated to directx in (CVideoDirectX9.cpp)
we get
D3DLIGHT9 light

in the D3DLIGHT9 structure there is no flag for cast shadows or not..so i think i'm going to have to look elsewhere... any clues niko?? :?
PadrinatoR
Posts: 50
Joined: Tue Mar 09, 2004 9:53 pm
Location: Spain

Post by PadrinatoR »

When you want to create a light that doesn't cast shadows, do this:
irr::video::SLight DynamicLight1;
DynamicLight1.DiffuseColor = irr::video::SColorf(254.0f, 254.0f, 254.0f);
DynamicLight1.Radius= 200.0f;
DynamicLight1.CastShadows = false; //<=== NO SHADOWS
DynamicLight1.Position = irr::core::vector3df(0,0,10);

driver->addDynamicLight(DynamicLight1);

For the other lights, you have to create them switching CastShadows to true, but although you need to call addShadowVolumeSceneNode (see the doc) every time you load an object, because if you don't do this, the objects won't cast any shadow. You have to know that the lights don't cast shadows, the objects cast shadows (I think I'm right xD).
Try that, I hope it works. Byee!!
There are only 10 types of people: those who understand binary and those who don't

--------------------------------------------

Image
LagAlot
Posts: 13
Joined: Thu Mar 18, 2004 2:04 am

Post by LagAlot »

PadrinatoR wrote: DynamicLight1.CastShadows = false; //<=== NO SHADOWS
have you verified this works..becausde that was what i originally did..there were in fact no shadows..but the light did not emit any light either...

i'll dig some more when i get home tonite..
LagAlot
Posts: 13
Joined: Thu Mar 18, 2004 2:04 am

Post by LagAlot »

PadrinatoR wrote:You have to know that the lights don't cast shadows, the objects cast shadows
I think this is were the problem lies..I guess DynamicLight1.CastShadows is if the light ITSELF has a shadow..that would make since because when it gets translated to D3DLIGHT9 there is no option for shadows..I think i'll be able to achieve the effect i am after by looking at the ambient light settings..
Post Reply