TriangleCollisionShape appearing in wrong position.

PolyVox

04-03-2008 21:49:02

Hi, I am struggling with a very strange issue here which I think is a bug in OgreBullet (although I can't see it). I have three positions in space which I use as the three corners of a TriangleCollisionShape and also as the positions of three BoxCollisionShapes. Hence I would expect the boxes to lay at the corners of the triangles.

In reality the TriangleCollisionShape appears in a different position, apparently reflected in one (or more?) of the axis. The same problem occurs with TriangleMeshCollisionShape. As far as I can tell it is the boxes which are correct, though it is hard to be certain.

This is the code I use to construct the scene:


const float gDynamicBodyRestitution = 0.6f;
const float gDynamicBodyFriction = 0.6f;
const float gDynamicBodyMass = 1.0f;

Vector3 size(1.0,1.0,1.0);
Vector3 pos1(10.0,0.0,0.0);
Vector3 pos2(0.0,10.0,0.0);
Vector3 pos3(0.0,0.0,10.0);

//Init Bullet
const Ogre::Vector3 gravityVector = Ogre::Vector3 (0,-2,0);
const Ogre::AxisAlignedBox bounds = Ogre::AxisAlignedBox (Ogre::Vector3 (-10000, -10000, -10000),Ogre::Vector3 (10000, 10000, 10000));
mWorld = new DynamicsWorld(mSceneMgr, bounds, gravityVector);

//Add a cube
Entity *box1 = mSceneMgr->createEntity("Box1","Bulletbox.mesh");
box1->setMaterialName("Bullet/box");
BoxCollisionShape *collisionShape1 = new BoxCollisionShape(size);
RigidBody *rigidBody1 = new RigidBody("rigidBody1", mWorld);
SceneNode *node1 = mSceneMgr->getRootSceneNode ()->createChildSceneNode ();
node1->attachObject (box1);
rigidBody1->setShape (node1, collisionShape1, gDynamicBodyRestitution, gDynamicBodyFriction, 0.0, pos1, Quaternion(0,0,0,1));

//Add a cube
Entity *box2 = mSceneMgr->createEntity("Box2","Bulletbox.mesh");
box2->setMaterialName("Bullet/box");
BoxCollisionShape *collisionShape2 = new BoxCollisionShape(size);
RigidBody *rigidBody2 = new RigidBody("rigidBody2", mWorld);
SceneNode *node2 = mSceneMgr->getRootSceneNode ()->createChildSceneNode ();
node2->attachObject (box2);
rigidBody2->setShape (node2, collisionShape2, gDynamicBodyRestitution, gDynamicBodyFriction, 0.0, pos2, Quaternion(0,0,0,1));

//Add a cube
Entity *box3 = mSceneMgr->createEntity("Box3","Bulletbox.mesh");
box2->setMaterialName("Bullet/box");
BoxCollisionShape *collisionShape3 = new BoxCollisionShape(size);
RigidBody *rigidBody3 = new RigidBody("rigidBody3", mWorld);
SceneNode *node3 = mSceneMgr->getRootSceneNode ()->createChildSceneNode ();
node3->attachObject (box3);
rigidBody3->setShape (node3, collisionShape3, gDynamicBodyRestitution, gDynamicBodyFriction, 0.0, pos3, Quaternion(0,0,0,1));

TriangleCollisionShape* groundCollisionShape = new TriangleCollisionShape(pos1,pos2,pos3);
RigidBody *rigidBodyGround = new RigidBody("rigidBodyGround", mWorld);
SceneNode *nodeGround = mSceneMgr->getRootSceneNode ()->createChildSceneNode ();
rigidBodyGround->setShape (nodeGround, groundCollisionShape, gDynamicBodyRestitution, gDynamicBodyFriction, 0.0, Vector3(0.0,0.0,0.0), Quaternion(0,0,0,1));


The result is as shown in the image below:



Any idea what going on? If it helps I can send my solution file, etc.

Thanks!

tuan kuranes

16-04-2008 18:00:12

Can you get latest CVS version. (from today)
It has now Debug Draw version, just make it appears to find its true position.