Lighting a 3DS Model.

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
Gabumon
Posts: 10
Joined: Wed Feb 21, 2007 6:26 pm

Lighting a 3DS Model.

Post by Gabumon »

Hello All,

Noob Irrlicht user here.

I am using Irrlicht for a graduation project, having to do with sound so I don't know much about graphics programming.

I built a very simple model in SketchUp and exported it as a 3DS file, and got that to load into Irrlicht fairly easily. The only downside is that the map is very dark. Since SketchUp doesn't offer a way to add lights, is there a way I add some lights to my scene in Irrlicht fairly easily?

I do not need anything fancy, just I need the general ambiance light raised.

Thanks in advance.

Peace

Staque
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You should disable lighting of the model if you don't need the light. Ambient light can be changed through the scene manager without adding lights. And finally, using dynamic lights is easily possible by simply adding a light scene node.
Luben
Posts: 568
Joined: Sun Oct 09, 2005 10:12 am
Location: #irrlicht @freenode

Post by Luben »

Check out irrEdit, it'll probably help some.
http://www.ambiera.com/irredit/index.html
If you don't have anything nice to say, don't say anything at all.
franklyn
Posts: 36
Joined: Thu Mar 15, 2007 7:03 pm

Post by franklyn »

heres the code your looking for.

Code: Select all

ISceneNode * light = smgr->addLightSceneNode(0,vector3df(40,30,0),SColorf(1.f, 1.f, 1.f,0.f), 200.f);
Gabumon
Posts: 10
Joined: Wed Feb 21, 2007 6:26 pm

No Luck.

Post by Gabumon »

franklyn wrote:heres the code your looking for.

Code: Select all

ISceneNode * light = smgr->addLightSceneNode(0,vector3df(40,30,0),SColorf(1.f, 1.f, 1.f,0.f), 200.f);
I tried the code... but I didn't notice much difference...

:(
franklyn
Posts: 36
Joined: Thu Mar 15, 2007 7:03 pm

Post by franklyn »

post your code here so we can have a look.
Luben
Posts: 568
Joined: Sun Oct 09, 2005 10:12 am
Location: #irrlicht @freenode

Post by Luben »

Otherwise if you just want ambient light do SceneManager->setAmbientLight(LightColor)
If you don't have anything nice to say, don't say anything at all.
franklyn
Posts: 36
Joined: Thu Mar 15, 2007 7:03 pm

Post by franklyn »

you mean the video driver right ?.
Gabumon
Posts: 10
Joined: Wed Feb 21, 2007 6:26 pm

Here is the code.

Post by Gabumon »

Okie Dokie... Here is my code.

As you can tell this... is pretty much just a variation of the "Quake Map" Tutorial and the "Collision" tutorial. Which I part of the reason why I am stumped with the lighting problem.

I should note... I only need to raise the lighting a bit for debugging purposes, and that later on I will need to make the screen gradually go completely dark [IE You see absolutely nothing.]

Sorry if this is a completely Noob problem... but thanks for the help in advance.

Also... To note an earlier suggestion... I did original try to use IrrEdit and Irr Files. Which I did achieve correct lighting with. But I need to use createOctTreeTriangleSelector() to create collision. From reading the forums as I understand it, I couldn't use Irr files because there isn't a way to pull a mesh from a Irr Scene that is needed for the createOctTreeTriangleSelector() function. [Plus I was getting tired of correcting the paths to the textures, but that is another story]. At least nothing simple. And since I am only using one Mesh, I figured it would be easier to load the mesh in directly.

Anyway here is the code.

Peace and thanks again. :)

Code: Select all

	IrrlichtDevice *device = createDevice(EDT_OPENGL, dimension2d<s32>(640, 480), 16, false, false, false, 0 );

	if (device == 0)
		return 1;

	//We Say Hello.
	device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo");

	//Now we store a pointer to the video driver, the SceneManager, and the graphical user interface environment
	//so that we do not always have to write device->getVideoDriver(), device->getSceneManager(), and device->getGUIEnvironment().
	IVideoDriver* driver = device->getVideoDriver();
	ISceneManager* smgr = device->getSceneManager();


	//Load each Mesh Individually
	IAnimatedMesh* mesh  = smgr->getMesh("TestPlane.3ds");
	ISceneNode* node = 0;

	if (mesh) node = smgr->addOctTreeSceneNode( mesh->getMesh(0) );

	ITriangleSelector* selector = 0;
	
	if (node)
	{
		node->setMaterialFlag( EMF_LIGHTING, false );
		selector = smgr->createOctTreeTriangleSelector(mesh->getMesh(0), node, 128);
		node->setTriangleSelector(selector);
		selector->drop();
	}

	//Suggestion 1
	//This one doesn't seem to effect the lighting, and I tried setting the EMF_LIGHTING flage to true & false
	//ISceneNode * light = smgr->addLightSceneNode( 0, vector3df( 30, 40,0), SColorf(1.f, 1.f, 1.f,0.f), 600.f);

	//Suggestion2
	//SceneManager->setAmbientLight(LightColor)
	//The Scene::  Class doesn't not seem to havee a 'setAmbientLight(LightColor)' method.
	//I could only find something in the Video:: class which is below and did not work.
	//driver->setAmbientLight( SColorf(1.f, 1.f, 1.f,1.f) );

	//Then we add a FPS camera to the scene graph.
	ICameraSceneNode *camera = smgr->addCameraSceneNodeFPS(0, 100.0f, 300.0f, -1, 0, 0, true);

	ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator( selector, camera, vector3df(30,50,30), vector3df(0,-3,0), vector3df(0,50,0) );

	camera->addAnimator(anim);
	anim->drop();
Gabumon
Posts: 10
Joined: Wed Feb 21, 2007 6:26 pm

GOT IT

Post by Gabumon »

I figured out the problem...

I had to make the radius size of the light node really big to see anything, probably because my map is a a little big.

Thanks for the pointers again.
Post Reply