Code: Select all
void PlayState::createPlayer(){
Vector3 size = Vector3::ZERO; // size of the box
Vector3 position = _nodePerson->_getDerivedPosition();
position.y +=2;
Ogre::Quaternion rotation = _nodePerson->_getDerivedOrientation();
// Obtenemos la bounding box de la entidad creada... ------------
AxisAlignedBox boundingB = _sceneMgr->getEntity("BoxPlayer")->getBoundingBox();
size = boundingB.getSize();
// size.y*=2;
size /= 2.0f; // El tamano en Bullet se indica desde el centro
// after that create the Bullet shape with the calculated size
OgreBulletCollisions::BoxCollisionShape *boxShape = new
OgreBulletCollisions::BoxCollisionShape(size);
// and the Bullet rigid body
_rigidBox = new
OgreBulletDynamics::RigidBody("rigidBox", _world);
_rigidBox->setShape(_nodePerson, boxShape,
0 /* Restitucion */, 0 /* Friccion */,
30 /* Masa */, position /* Posicion inicial */,
rotation /* Orientacion */);
_rigidBox->setLinearVelocity(
_camera->getDerivedDirection().normalisedCopy() * 3.0);
_rigidBox->showDebugShape(true);
_rigidBox->setKinematicObject(true);
// Anadimos los objetos a las deques
_shapes.push_back(boxShape); _bodies.push_back(_rigidBox);
}
MOVE...
Code: Select all
_rigidBox->enableActiveState();
_rigidBox->getBulletRigidBody()->setLinearVelocity(btVector3(0,0,1));
_rigidBox->getBulletRigidBody()->activate(true);
_rigidBox->getBulletRigidBody()->translate(btVector3(0,0,10));
Wrapper: OgreBullet