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.
AlexvtVeer
Posts: 2 Joined: Mon Jun 04, 2007 2:35 pm
Post
by AlexvtVeer » Mon Jun 04, 2007 2:37 pm
Hi I tried to add lighting to my scene but nothing is actually showing up. Can anyone tell me what i'm doing wrong? Thank you very much!
this is my code:
Code: Select all
LightSceneNode lightNode1 = smgr.AddLightSceneNode(smgr.RootSceneNode, new Vector3D(1.0f, 300.0f, 1.0f), new Colorf(255,255,255,255), 200.0f, -1);
Light light = lightNode1.LightData;
light.AmbientColor = new Colorf(0.065f, 0.075f, 0.75f, 0.8f);
light.DiffuseColor = new Colorf(0.065f, 0.075f, 0.75f, 0.8f);
light.SpecularColor = new Colorf(0.065f, 0.25f, 0.25f, 0.2f);
lightNode1.LightData = light;
vizzy
Posts: 10 Joined: Mon May 21, 2007 2:55 pm
Location: Dresden, Germany
Post
by vizzy » Mon Jun 04, 2007 3:47 pm
do you wan't this as sample how do you add an pointlight ?
Code: Select all
//-------------------------------------------------------------
//Standard Punktlicht über Editor setzen
//-------------------------------------------------------------
int CLightEntity::addStdLightEntity(irr::s32 id, irr::f32 x, irr::f32 y, irr::f32 z)
{
irr::scene::ILightSceneNode* l;
l = device->getSceneManager()->addLightSceneNode( 0, core::vector3df( x, y, z), //<-position
video::SColorf( 1.0f, 1.0f, 1.0f), 5.0f, id );//change colors you need
l->setDebugDataVisible( irr::scene::EDS_BBOX );//uncomment this if you don't need debugdata
irr::video::SLight& lData = l->getLightData();
lData.CastShadows = TRUE;
lData.Type = irr::video::ELT_POINT;
//lData ambient stuff
//lData diffuse stuff
//...
return 0;
}
then you have to call this func
Code: Select all
addStdLightEntity( 1/*or_somewhat_id*/, your_pos_x, your_pos_y, your_pos_z )
regards
vitek
Bug Slayer
Posts: 3919 Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR
Post
by vitek » Mon Jun 04, 2007 5:23 pm
Light sources are not visible unless you provide someting for them to light up, or you add something that shows where the light is. Something like this should help [taken from example
11.PerPixelLighting ].
Code: Select all
// add light 2 (gray)
scene::ISceneNode* light2 =
smgr->addLightSceneNode(0, core::vector3df(0,0,0),
video::SColorf(1.0f, 0.2f, 0.2f, 0.0f), 200.0f);
// add fly circle animator to light 2
anim = smgr->createFlyCircleAnimator (core::vector3df(0,150,0),200.0f, 0.001f, core::vector3df ( 0.2f, 0.9f, 0.f ));
light2->addAnimator(anim);
anim->drop();
// attach billboard to light
bill = smgr->addBillboardSceneNode(light2, core::dimension2d<f32>(120, 120));
bill->setMaterialFlag(video::EMF_LIGHTING, false);
bill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
bill->setMaterialTexture(0, driver->getTexture("../../media/particlewhite.bmp"));
AlexvtVeer
Posts: 2 Joined: Mon Jun 04, 2007 2:35 pm
Post
by AlexvtVeer » Mon Jun 04, 2007 7:08 pm
Ok I changed this,
now the code looks like this:
Code: Select all
LightSceneNode lightNode1 = smgr.AddLightSceneNode(smgr.RootSceneNode, new Vector3D(xpos, ypos, zpos), new Colorf(1.0f,1.0f,1.0f,1.0f), 200.0f, 10006);
Light light = lightNode1.LightData;
light.AmbientColor = new Colorf(0.065f, 0.075f, 0.75f, 0.8f);
light.DiffuseColor = new Colorf(0.065f, 0.075f, 0.75f, 0.8f);
light.SpecularColor = new Colorf(0.065f, 0.25f, 0.25f, 0.2f);
light.CastShadows = true;
light.Type = LightType.Point;
lightNode1.LightData = light;
I still get the same effect (noting)
I also added the billboardscene to see where the light _SHOULD_ come from, but there is no light comming from there
vi-wer
Posts: 93 Joined: Sun May 20, 2007 7:15 pm
Location: Germany
Contact:
Post
by vi-wer » Mon Jun 04, 2007 8:35 pm
Are you using irrlicht.NET? I don't know much about it but do you need "new" to set a value?
Add a cube to the scene somewhere near the light, to see if the light is ok. Maybe something's wrong with your scene?
GuerillaSoftworks
Posts: 83 Joined: Wed May 23, 2007 6:11 pm
Post
by GuerillaSoftworks » Mon Jun 04, 2007 9:30 pm
To make sure your light isnt in some daft place, i would create a cube and position it where the light is (not using return values from the light but by inputting the actual values). Make sure the cube is a decent size, based on your camera settings and posiion in 3d space. If you do find that you cant see a cube then youve put some stupid position in; change it untill you can the cube. Then you can move it out of the way and add your light again in the new position. Also check u light has a big enough radius (in that theres a big area that it covers).
i know its a simple idea but I dont see what else could be wrong.