Page 1 of 1

Don't pick through walls

Posted: Sun Sep 23, 2007 10:05 pm
by horvim
Hi!

I have a house modell and a desk modell.
I made collision with SceneManager->getSceneCollisionManager()->getSceneNodeFromCameraBB and the collision itself works fine.
My problem is, that I can pick the desk modell through the walls too.
I tried something with masking but it didn't work.
Any idea how to solve this?

Posted: Tue Sep 25, 2007 2:07 pm
by rogerborg
Step 1: Create and set a triangle selector for each scene node. For example:

Code: Select all

scene::ITriangleSelector* selector = 0;
	
selector = smgr->createOctTreeTriangleSelector(houseNode->getMesh(0), houseNode, 128);
houseNode->setTriangleSelector(selector);
selector->drop();

selector = smgr->createTriangleSelector(deskNode);
deskNode->setTriangleSelector(selector);
selector->drop();
Step 2a: When you do your collisions checking, loop though all of your scene nodes, and for each one which is touched by your ray (including the house node) transformed into the node's object space, retrieve its triangle selector, and call getCollisionPoint() on it using your ray. The scene node that produces the collision point nearest to your camera/start of your ray is the one that you should select.

Step 2b: Alternatively, download the latest version of Irrlicht, apply this patch, then call getSceneNodeAndCollisionPointFromRay().

Posted: Tue Sep 25, 2007 10:21 pm
by horvim
Latest you mean 1.3.1?
And how to "apply" this patch? Edit manually the .h and .cpp files?

Posted: Tue Sep 25, 2007 11:02 pm
by hybrid
No, latest means SVN development version. Applying a patch works with SVN capable tools such as TortoiseSVN or simple 'patch' from command line.

Posted: Thu Sep 27, 2007 10:27 am
by Umbra
if you use the camera for col checking this will hapeen in some areas becourse the "char" dont stop until the cam hit the wall same thing that makes it so you can "look" through walls. you can make an object and attatch the cam to it and then use the object for col checking instead.