Help about part of the Collision tutorial

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
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Help about part of the Collision tutorial

Post by MasterGod »

Hello, I'm a new Irrlicht user and I dont understand what this part of the collision tutorial does.
Can someone explain it to me Please?

Code: Select all

/*
		Another type of picking supported by the Irrlicht Engine is scene node picking
		based on bouding boxes. Every scene node has got a bounding box, and because of
		that, it's very fast for example to get the scene node which the camera looks
		at. Again, we ask the collision manager for this, and if we've got a scene node,
		we highlight it by disabling Lighting in its material, if it is not the 
		billboard or the quake 3 level.
		*/

		selectedSceneNode = smgr->getSceneCollisionManager()->getSceneNodeFromCameraBB(camera);

		if (lastSelectedSceneNode)
			lastSelectedSceneNode->setMaterialFlag(video::EMF_LIGHTING, true);

		if (selectedSceneNode == q3node || selectedSceneNode == bill)
			selectedSceneNode = 0;

		if (selectedSceneNode)
			selectedSceneNode->setMaterialFlag(video::EMF_LIGHTING, false);

		lastSelectedSceneNode = selectedSceneNode;


		/*
		That's it, we just have to finish drawing.
		*/
GameDude
Posts: 498
Joined: Thu May 24, 2007 12:24 am

Post by GameDude »

It means that when one node hits another node, collision dectection has happended.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Not really met the intention of that code :?
It handles the effect which is desired to mark the mesh the camera view's center is pointing on (i.e. the view straight ahead). First it gets the eselcted node. Then it disables lighting on the previously selected node (if there was one, lighting toggle is the mean to show the selected node). Then it avoids to select the static level and the flying billboard. If there is still a selected node it disables lighting (and thereby highlights the node, although it sounds weird). And finally it stores the highlighted node to disbale lighting later on.
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

WoW! I cant believe its that simple :shock:, I tryed to understand it for few hours and.. Thanks!

But can you just explain me please why making the Lightning OFF makes it highlighted and not otherwise?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

If the texture is lighted only the light strength will define how dark/lit the texture is. If lighting is off the texture will be completely visible and show with the texture colors without darkening. That's why it looks highlighted (the light in the example is somewhat farther away, and the back is always unlit with light being enabled).
smartwhiz
Posts: 120
Joined: Wed Jan 14, 2004 6:03 pm
Location: India

Post by smartwhiz »

it was basically done to simulate the tutorial that a ray frm the screen is send to the 3d space and is hittin an object... if its collidin then lit the object so that the user can understand that this is the object thats gettin hit by the camera ray... just a tut to make u understand the ray collision... thats all..
Thanks and With Regards
Smartwhiz
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

hybrid wrote:If lighting is off the texture will be completely visible and show with the texture colors without darkening.
Did you mean that it will be shown 'as is', without any light (darkening) modification?
Mastiff
Posts: 17
Joined: Thu Apr 19, 2007 9:55 pm

Post by Mastiff »

Yes, it's texture would be visible with no modifications just like if you opened the texture up in an image editor.
#include <"signature.h">

OS = Windows XP
IDE = Code::Blocks
Compiler = GCC MingW
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

Ok, Thanks!
Post Reply