Page 1 of 1

[SOLVED] Boucing collisions...

Posted: Sat Mar 07, 2009 1:14 am
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 !

Posted: Sat Mar 07, 2009 1:55 am
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

Posted: Sat Mar 07, 2009 12:48 pm
by Linaxys
Thanks, it was that indeed.