Page 1 of 1

Problem with lightnode

Posted: Mon Jun 04, 2007 2:37 pm
by AlexvtVeer
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;

Posted: Mon Jun 04, 2007 3:47 pm
by vizzy
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

Posted: Mon Jun 04, 2007 5:23 pm
by vitek
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"));

Posted: Mon Jun 04, 2007 7:08 pm
by AlexvtVeer
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

Posted: Mon Jun 04, 2007 8:35 pm
by vi-wer
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?

Posted: Mon Jun 04, 2007 9:30 pm
by GuerillaSoftworks
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.