// -------------------------------------------------------------------------
RigidBody *OgreBulletListener::addStaticTrimesh(const Ogre::String &instanceName,
                                                const Ogre::String &meshName,
                                                const Ogre::Vector3 &pos, 
                                                const Ogre::Quaternion &q, 
                                                const Ogre::Real bodyRestitution, 
                                                const Ogre::Real bodyFriction,
                                                bool castShadow)
{
    Entity *sceneEntity = mSceneMgr->createEntity(instanceName + StringConverter::toString(mNumEntitiesInstanced), meshName);
    sceneEntity->setCastShadows (castShadow);

    StaticMeshToShapeConverter *trimeshConverter = new StaticMeshToShapeConverter(sceneEntity);
    TriangleMeshCollisionShape *sceneTriMeshShape = trimeshConverter->createTrimesh();
    delete trimeshConverter;
    RigidBody *sceneRigid = new RigidBody(
        instanceName + "Rigid" + StringConverter::toString(mNumEntitiesInstanced),
        mWorld);

    SceneNode *node = mSceneMgr->getRootSceneNode ()->createChildSceneNode ();
    node->attachObject (sceneEntity);

    sceneRigid->setStaticShape(node, sceneTriMeshShape, bodyRestitution, bodyFriction, pos);

    mEntities.push_back(sceneEntity);
    mBodies.push_back(sceneRigid);
    mNumEntitiesInstanced++;

    return sceneRigid;
}
Beispiel #2
0
/*
 * Create Pacman Level
 *
 */
void PlayState::createLevel(){
  StaticGeometry* stage =   _sceneMgr->createStaticGeometry("SG");
  Entity* entLevel = _sceneMgr->  createEntity("level1.mesh");
  
  entLevel->setCastShadows(true);
  stage->addEntity(entLevel, Vector3(0,0,0));
  stage->build();
  
  StaticMeshToShapeConverter *trimeshConverter = new StaticMeshToShapeConverter(entLevel);
  TriangleMeshCollisionShape *trackTrimesh = trimeshConverter->createTrimesh();
  RigidBody *rigidLevel = new  RigidBody("level", _world,COL_WALL,COL_PILL | COL_PACMAN);
  rigidLevel->setStaticShape(trackTrimesh, 0.0, 0.0, Vector3::ZERO, Quaternion::IDENTITY);
  
  std::string fileName = "./blender/level1.xml";
  
  graphLevel = new graphml_boost();
  graphLevel->cargaGrafo(fileName);
  
   paintPills(false);
   paintPills(true);  
    
   createPacman();
  createPhantoms();
}