[SOLVED] Boucing collisions...

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
Linaxys
Posts: 47
Joined: Tue Feb 24, 2009 10:46 pm

[SOLVED] Boucing collisions...

Post by Linaxys »

Hello,
I copy/pasted my code from a single file into multiple files to make it cleaner, I haven't changed anything from the collision animators and triangle selectors and it does that...

http://www.youtube.com/watch?v=b2hrP48w72E

I don't bounce on the ground but I bounce on the floor, weird...
I'm sure I missed something but I don't really see what.

Here's the ground's code (where I don't bounce):

Code: Select all

	IAnimatedMesh * groundMesh = CynEngine->getScene()->addHillPlaneMesh("Plane", dimension2d<f32>(100.0f, 100.0f), dimension2d<u32>(100,100), 0, 0, dimension2d<f32>(0,0), dimension2d<f32>(250,250));
	ground = CynEngine->getScene()->addAnimatedMeshSceneNode(groundMesh);
	ground->setPosition(vector3df(0,0,0));
	ground->setMaterialTexture(0, CynEngine->getDriver()->getTexture("./assets/textures/grass/grass002.jpg"));

	groundSelector = CynEngine->getScene()->createOctTreeTriangleSelector(groundMesh->getMesh(0), ground, 128);
	ground->setTriangleSelector(groundSelector);

	ISceneNodeAnimator *groundAnim = CynEngine->getScene()->createCollisionResponseAnimator(
			groundSelector, CynEngine->getCamera()->getNode(), vector3df(3,5,3),
			core::vector3df(0,-5,0));
	CynEngine->getCamera()->getNode()->addAnimator(groundAnim);
	groundAnim->drop();
	groundSelector->drop();
Here's the floor's code (where I bounce) :

Code: Select all

	node = CynEngine->getScene()->addMeshSceneNode(mesh);
	node->setPosition(position);
	selector = CynEngine->getScene()->createTriangleSelector(mesh, node);
	node->setTriangleSelector(selector);
	anim = CynEngine->getScene()->createCollisionResponseAnimator(selector, CynEngine->getCamera()->getNode(), vector3df(3,5,3), vector3df(0,-5,0));
	CynEngine->getCamera()->getNode()->addAnimator(anim);
	anim->drop();
	selector->drop();
Thanks for your replies !
Last edited by Linaxys on Sat Mar 07, 2009 12:48 pm, edited 1 time in total.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

It looks like you are adding two collision response animators to the camera. I'd be willing to bet that this is your problem. If you want to have collision with multiple different objects, you need to use one collision response animator and IMetaTriangleSelector. If you do a search, you should find examples of how to do it.

Travis
Linaxys
Posts: 47
Joined: Tue Feb 24, 2009 10:46 pm

Post by Linaxys »

Thanks, it was that indeed.
Post Reply