Page 1 of 1

addDynamicLight

Posted: Sun Mar 21, 2004 1:21 am
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?

Posted: Sun Mar 21, 2004 2:42 am
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);

Posted: Sun Mar 21, 2004 8:12 pm
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??

Posted: Sun Mar 21, 2004 8:54 pm
by Robomaniac
Shadows are handled inside the item's defs, check the api, as i'm forgetting the command right now (anyone wanna help?)

Posted: Sun Mar 21, 2004 8:58 pm
by LagAlot
i'm digging through the source now.. can i just overload the addLightSceneNode function and CLightSceneNode to allow for shadows on/off??

Posted: Sun Mar 21, 2004 9:13 pm
by Robomaniac
See the special effects tutorial ;-)

Posted: Sun Mar 21, 2004 10:50 pm
by LagAlot
the specialfx demo simply calls
addLightSceneNode

Posted: Sun Mar 21, 2004 11:17 pm
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.... :)

Posted: Mon Mar 22, 2004 1:53 pm
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 :)

Posted: Mon Mar 22, 2004 7:06 pm
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?? :?

Posted: Mon Mar 22, 2004 8:28 pm
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!!

Posted: Mon Mar 22, 2004 10:31 pm
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..

Posted: Mon Mar 22, 2004 10:44 pm
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..