gaz99
23-02-2014 19:04:10
Hi I'm trying to create a collision shape for my child nodes but i can't seem to get it to work. If i don't add any bullet code for the child nodes they appear in the correct position but as soon as i apply bullet code the bullet collision shape is in the correct place but the entity is not.
I have a machine class which holds a vector of moles. First the machine is positioned, scaled and rotated
Then for each mole i create a new entity and child node from the machine node and then set up the bullet collision shape
As you can see from the screen shots it only works for either the collision shape or the entity if bullet isn't used.
Any help would be appreciated.
Thanks
I have a machine class which holds a vector of moles. First the machine is positioned, scaled and rotated
sceneNode->translate(position);
sceneNode->scale(2,2,2);
sceneNode->yaw(Ogre::Degree(rotation));
Then for each mole i create a new entity and child node from the machine node and then set up the bullet collision shape
count++;
entity = sceneMgr->createEntity("mole"+std::to_string(count), "mole.mesh");
this->sceneNode = parentNode->createChildSceneNode("moleNode"+std::to_string(count));
sceneNode->attachObject(entity);
sceneNode->setPosition(position);
//set up bullet .. if i dont do this the entity is in the correct position
Ogre::Vector3 scale = sceneNode->getScale();
sceneNode->setScale(sceneNode->getParentSceneNode()->getScale());
BtOgre::StaticMeshToShapeConverter converter(entity);
collShape = converter.createTrimesh();
btScalar mass(1);
btVector3 localInertia(0, 0, 0);
collShape->calculateLocalInertia(mass,localInertia);
BtOgre::RigidBodyState* myMotionState = new BtOgre::RigidBodyState(sceneNode,btTransform(btQuaternion(0,0,0,1),BtOgre::Convert::toBullet(sceneNode->_getDerivedPosition())));
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,collShape,localInertia);
rigidBody = new btRigidBody(rbInfo);
rigidBody->setActivationState(DISABLE_DEACTIVATION);
rigidBody->setGravity(btVector3(0, 0, 0));
rigidBody->setLinearFactor(btVector3(0, 0, 0));
rigidBody->setAngularFactor(btVector3(0, 0, 0));
rigidBody->setLinearVelocity(btVector3(0, 0, 0));
rigidBody->setAngularVelocity(btVector3(0, 0, 0));
sceneNode->setScale(scale);
As you can see from the screen shots it only works for either the collision shape or the entity if bullet isn't used.
Any help would be appreciated.
Thanks