Please if you could help me carry my team and I with this problem for a few weeks.
The problem is that i have a plane defined with his rigid body
Code: Select all
Plane plane1(Vector3(0,1,0), -3);
MeshManager::getSingleton().createPlane("p1",
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane1,
1000, 1000, 1, 1, true, 1, 20, 20, Vector3::UNIT_Z);
//--------------------------------------------------------
SceneNode* _groundNode = _sceneMgr->createSceneNode("ground");
Entity* _groundEnt = _sceneMgr->createEntity("planeEnt", "p1");
_groundEnt->setMaterialName("Ground");
_groundNode->attachObject(_groundEnt);
_sceneMgr->getRootSceneNode()->addChild(_groundNode);
OgreBulletCollisions::CollisionShape *Shape;
Shape = new OgreBulletCollisions::StaticPlaneCollisionShape
(Ogre::Vector3(0,1,0), -3); // Vector normal y distancia (antes estaba a 0)
OgreBulletDynamics::RigidBody *rigidBodyPlane = new
OgreBulletDynamics::RigidBody("ground", _world,PhysicsMask::COL_StaticWalls,PhysicsMask::staticwalls_collides_with);
rigidBodyPlane->setStaticShape(Shape, 0.1, 0.8);
_shapes.push_back(Shape);
_bodies.push_back(rigidBodyPlane);
That is in the method of detecting collisions it take the name of all the objects and plane not
Code: Select all
void PhysicsManager::detectHeroCollision(){
//Colisiones------------------------------
btCollisionWorld *bulletWorld = _world->getBulletCollisionWorld();
int numManifolds = bulletWorld->getDispatcher()->getNumManifolds();
for (int i=0;i<numManifolds;i++) {
btPersistentManifold* contactManifold =
bulletWorld->getDispatcher()->getManifoldByIndexInternal(i);
btCollisionObject* obA =
(btCollisionObject*)(contactManifold->getBody0());
btCollisionObject* obB =
(btCollisionObject*)(contactManifold->getBody1());
//EXTRA--------------------------------------------------------
btCollisionObject* _aux;
//-------------------------------------------------------------
//Compruebo colisiones con el hero -----------------------------
OgreBulletCollisions::Object *obHero = _world->findObject(_hero->getSceneNode());
OgreBulletCollisions::Object *obOB_A = _world->findObject(obA);
OgreBulletCollisions::Object *obOB_B = _world->findObject(obB);
if ((obOB_A == obHero) || (obOB_B == obHero)) { //si uno de los objetos colisionados es el hero
Ogre::SceneNode* node = NULL;
if ((obOB_A != obHero) && (obOB_A)) {
node = obOB_A->getRootNode();
_aux=obA;
}
else if ((obOB_B != obHero) && (obOB_B)) {
node = obOB_B->getRootNode();
//delete obOB_B;
_aux=obB;
}
[b]if (node) {
cout << "Hero choca con: " << node->getName() << "\n" << endl;
if(Ogre::StringUtil::startsWith(node->getName(),"SN_Floor")){
if(_hero->getRigidBody()->getLinearVelocity().z < 0.0){
if(_hero->getNumJumps() < N_JUMPS){
_hero->setNumJumps(N_JUMPS);
}
}
}
else if(Ogre::StringUtil::startsWith(node->getName(),"SN_Thread")){
//Eliminar SceneNode, Entity y Cuerpo Fisico asi--------------
Entity* _e = static_cast<Entity*>(node->getAttachedObject(0));
_sceneMgr->destroyEntity(_e);
_sceneMgr->getRootSceneNode()->removeChild(node);
_world->getBulletDynamicsWorld()->removeCollisionObject(_aux);
//------------------------------------------------------------
_hero->increaseScore(10);
//Actualizar los puntos en la UI
}
else if(Ogre::StringUtil::startsWith(node->getName(),"SN_Reel")){
PlayState::getSingletonPtr()->changeScenarioQ();
}
else if(Ogre::StringUtil::startsWith(node->getName(),"SN_Enemy")){
_hero->loseLife();
MovementManager::getSingletonPtr()->repositionHero(btVector3(0,0,0),_hero->getRigidBody()->getBulletRigidBody()->getOrientation());
//Actualizar las vidas en la UI
}
}
}
//------------------------------------------------[/b]
}
}
//----------------------------------------
Thanks you for the help