collision problem

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
lobbin
Posts: 11
Joined: Wed Jun 02, 2004 1:41 pm
Location: Sweden
Contact:

collision problem

Post by lobbin »

I followed the collision tutorial slightly changed, it isn't that camera but a user-controlled node that should be affected but I can't get it to work

This is my sort of pseudo-code

Code: Select all

IAnimated* mesh = smgr->getMesh("level.3ds");
ISceneNode* node = smgr->addOctTreeSceneNode(mesh->getMesh(0))
ITriangleSelector *selector = smgr->addOctTreeTriangleSelector(mesh->getMesh(0), node);
node->setTriangleSelector(selector);
selector->drop();
(--set rotation of node here)

ISceneNode* player = smgr->addAnimatedMeshSceneNode( smgr->getMesh("another.3ds"));
aabbox3d<f32> box = player->getBoundingBox();
ISceneNodeAnimator *anim = smgr->createCollisionResponseAnimator(selector, player, box.MaxEdge - box.getCenter(), vector3df(0, 0, 0));
player->addAnimator(anim);
anim->drop();
Is there something obvious I missed? As the code isn't working :)
lobbin
Posts: 11
Joined: Wed Jun 02, 2004 1:41 pm
Location: Sweden
Contact:

Post by lobbin »

I might add that gravitation seems to work on player-node, so something is correct I guess.
thesmileman
Posts: 360
Joined: Tue Feb 10, 2004 2:20 am
Location: Lubbock, TX

Post by thesmileman »

It appears that you drop the triangle selector and then you try to add it to the collision response animator. This can't work because you have removed the triangle selector from memory therefore the collision response animator has nothing to use. So wait to drop the triangle selector until you do not need collision detection anymore.
lobbin
Posts: 11
Joined: Wed Jun 02, 2004 1:41 pm
Location: Sweden
Contact:

Post by lobbin »

thesmileman wrote:It appears that you drop the triangle selector and then you try to add it to the collision response animator. This can't work because you have removed the triangle selector from memory therefore the collision response animator has nothing to use. So wait to drop the triangle selector until you do not need collision detection anymore.
I think that shouldn't matter. The example does it the way I do it and I guess that the scene-node is adding a reference to the selector so I can safely drop it after I added to the scene-node. And like I said in the last post, gravitation is working and I i take my affected node outside the map it drops like a stone, but it can still run through objects on the node where the selector is.
Post Reply