Directional Light

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
tharshan
Posts: 19
Joined: Sun Jun 17, 2007 1:39 am
Contact:

Directional Light

Post by tharshan »

Hello,

i want to create a DIRECTIOOAL LIGHT and rotate that to -90,0,0
so it will light the whole scene.

mine is looking like this : http://img505.imageshack.us/img505/1392/cube3dca2.jpg


i used the code like as this :

Code: Select all

IrrlichtDevice *device = createDevice(EDT_DIRECT3D9,dimension2d<s32>(800,600),32,false,true,false,0);
	
	device->setWindowCaption(L"Hello World Program");

	IVideoDriver* driver = device->getVideoDriver();
	ISceneManager* smngr = device->getSceneManager();
	IGUIEnvironment* guienv = device->getGUIEnvironment();
		
	



	smngr->addLightSceneNode(0,vector3df(0,100,-100),SColorf(1.0,1.0,1.0),1000.0,1);
	
	
		
	smngr->addCameraSceneNode(0,vector3df(0,0,-5),vector3df(0,0,0));
	
	
	ISceneNode* node = smngr->addCubeSceneNode(1,0,-1,vector3df(0.0f,0.0f,0.0f));
	

	
	while(device->run())
	{
		driver->beginScene(true,true,SColor(255,0,0,0));
		
		
		node->setRotation(vector3df(node->getRotation().X+0.1,node->getRotation().Y+0.1,0));

		smngr->drawAll();
	

		driver->endScene();


	}

	device->drop();
Venkadesan V Tharshan
tharshan
Posts: 19
Joined: Sun Jun 17, 2007 1:39 am
Contact:

Post by tharshan »

sorry for the newbie questions. :(
Venkadesan V Tharshan
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

You need to tell the light that it is supposed to be directional. Something like this should do the trick [note: this code is untested]...

Code: Select all

scene::ILightSceneNode* light = smgr->addLightSceneNode();

video::SLight lightData = light->getLightData();
lightData.Type = video::ELT_DIRECTIONAL;
lightData.DiffuseColor.set(1.f, 1.f, 1.f);
lightData.Position.set(0, -1, 0); // this is actually the direction that the light shines, straight down in this example.
lightData.Radius = 1000.f;

light->setLightData(lightData);
Travis
Post Reply