kulebril
02-03-2011 18:20:20
Hi, I'm new to OgreBullet and I was following the instructions on the tutorials.
Strangely, after creating the bodies and physical shapes, the nodes appear to reubicate on the cartesian origin (0,0,0).
After this all, when I use the Bullet FrameListener, the Nodes automatically reset to 0,0,0.
Any clue on what I'm missing here?
Thanks in advance.
Strangely, after creating the bodies and physical shapes, the nodes appear to reubicate on the cartesian origin (0,0,0).
//------- there I create the Box
Entity *entity = mSceneMgr->createEntity( "Box", "cube.mesh");
entity->setCastShadows(true);
AxisAlignedBox boundingB = entity->getBoundingBox();
Vector3 BoxSize = Vector3::ZERO;
BoxSize = boundingB.getSize();
entity->setMaterialName("MetalPlate");
SceneNode *BoxNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
BoxNode->attachObject(entity);
//-------------------------- Here I set the BOXNode to certain position (definitelly not origin).
BoxNode->setPosition(0.0, entity->getBoundingBox().getMaximum().y+0.01, -10.0);
BoxNode->scale(0.05f, 0.05f, 0.05f); // the cube is too big for us
BoxSize /= 2.0f; // only the half needed
BoxSize *= 0.05f; // don't forget to scale down the Bullet-box too
BoxSize *= 0.96f; // Bullet margin is a bit bigger so we need a smaller size
// (Bullet 2.76 Physics SDK Manual page 18)
//------------------------------- now I start with the Physics stuff
OgreBulletCollisions::BoxCollisionShape *sceneBoxShape =
new OgreBulletCollisions::BoxCollisionShape(BoxSize);
// and the Bullet rigid body
OgreBulletDynamics::RigidBody *BoxBody = new OgreBulletDynamics::RigidBody(
"defaultBoxRigid",
mPhysicsFrameListener->mWorld);
BoxBody->setShape(
BoxNode, //<-- Here is the BoxNode
sceneBoxShape,
0.01f, // dynamic body restitution
0.01f, // dynamic body friction
500.0f, // dynamic bodymass
BoxNode->getPosition(), // starting position of the box <-- here i set the same //position as the OgreNode.
Quaternion(0,0,0,1));// orientation of the box
mPhysicsFrameListener->mShapes.push_back(sceneBoxShape);
mPhysicsFrameListener->mBodies.push_back(BoxBody);
After this all, when I use the Bullet FrameListener, the Nodes automatically reset to 0,0,0.
Any clue on what I'm missing here?
Thanks in advance.