示例#1
0
void OgreSample13App::createStaticGeom()
{
	Entity * ent = mSceneMgr->createEntity(meshes[mSelectedMesh],meshes[mSelectedMesh] + ".mesh");
	renderStatic.reserve(mNumRendered);
	renderStatic.resize(mNumRendered);

	StaticGeometry * geom = new StaticGeometry(mSceneMgr,meshes[mSelectedMesh] + "s");
	geom->setRegionDimensions(Vector3(1000000,1000000,1000000));
	size_t k=0;
	size_t y=0;

	for(size_t i=0;i<mNumMeshes;i++)
	{
		if (y == maxObjectsPerBatch)
		{
			y=0;
			k++;
		}
		geom->addEntity(ent,posMatrices[k][y]);
		y++;
	}
	geom->setCastShadows(true);
	geom->build();
	renderStatic[0] = geom;
	mSceneMgr->destroyEntity(ent);
}
// -------------------------------------------------------------------------
RigidBody *OgreBulletListener::addStaticPlane( const Ogre::Real bodyRestitution, 
                                              const Ogre::Real bodyFriction)
{
    // Use a load of meshes to represent the floor
    int i = 0;
    StaticGeometry* s;
    s = mSceneMgr->createStaticGeometry("StaticFloor");
    s->setRegionDimensions(Ogre::Vector3(160.0, 100.0, 160.0));
    // Set the region origin so the center is at 0 world
    s->setOrigin(Ogre::Vector3::ZERO);
    for (Real z = -80.0;z <= 80.0;z += 20.0)
    {
        for (Real x = -80.0;x <= 80.0;x += 20.0)
        {
            String name = String("Plane_") + StringConverter::toString(i++);

            Entity* entity = mSceneMgr->createEntity(name, "plane.mesh");
			entity->setMaterialName("BulletPlane");
            entity->setQueryFlags (STATIC_GEOMETRY_QUERY_MASK);
            //entity->setUserObject(_plane);
            entity->setCastShadows(false);
            s->addEntity(entity, Ogre::Vector3(x,0,z));
        }
    }
    s->build();
    //SceneNode* mPlaneNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(name);


    CollisionShape *Shape = new StaticPlaneCollisionShape (Ogre::Vector3(0,1,0), 0);

    RigidBody *defaultPlaneBody = new RigidBody(
        "Plane" + StringConverter::toString(mNumEntitiesInstanced), 
        mWorld);


    defaultPlaneBody->setStaticShape (Shape, bodyRestitution, bodyFriction);

    mBodies.push_back(defaultPlaneBody);
    mShapes.push_back(Shape);

    mNumEntitiesInstanced++;

    return defaultPlaneBody;
}
示例#3
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();
}
void ArtifexLoader::staticsLoader(Ogre::String which, float renderDistance)
{
	Ogre::String meshName="", meshFile="", xPos="", yPos="", zPos="", rot="", tmp="",
		typeName="", entName="", scale="", rotX="", rotZ="";

	int counter=1;

	if (which.empty()) typeName = "static";
	else typeName = which;

	StaticGeometry *staticGeometry;
	staticGeometry = mSceneMgr->createStaticGeometry((string)mZoneName+typeName);
	staticGeometry->setRenderingDistance(renderDistance);

	Ogre::String filename = mZonePath+mZoneName+"/spawns_" + typeName + ".cfg";

	std::ifstream fp;

	fp.open(filename.c_str(), std::ios::in | std::ios::binary);
	if(!fp) return;

	DataStreamPtr stream(new FileStreamDataStream(filename, &fp, false));

	Ogre::String line;

	do {
		for (int a=0;a<=10;a++)
		{
			line = stream->getLine();
			if(stream->eof()) break;
			tmp = line;
			line = "";
			Ogre::StringUtil::trim(tmp);

			if (Ogre::StringUtil::startsWith(tmp,"//",false) || tmp.empty())
			{
				a--;
				continue;
			}
			else {
				switch (a)
				{
					case 0:
						meshName = tmp;
						break;
					case 1:
						// bracket
						break;
					case 2:
						meshFile = tmp;
						break;
					case 3:
						xPos = tmp;
						break;
					case 4:
						yPos = tmp;
						break;
					case 5:
						zPos = tmp;
						break;
					case 6:
						rot = tmp;
						break;
					case 7:
						scale = tmp;
						break;
					case 8:
						rotX = tmp;
						break;
					case 9:
						rotZ = tmp;
						break;
					case 10:
						// bracket close
						break;
					default:
						break;
				}
				tmp = "";
			}
		}
		try {
			//***************************
			entName = meshName;
			//***************************
			Entity *newModel = mSceneMgr->createEntity((string) entName, (string) meshFile);
			newModel->setQueryFlags(ENTITY_MASK);
			//****************************
			float x=0,y=0,z=0,r=0,s=0,rx=0,rz=0;
			x = Ogre::StringConverter::parseReal(xPos);
			y = Ogre::StringConverter::parseReal(yPos);
			z = Ogre::StringConverter::parseReal(zPos);
			r = Ogre::StringConverter::parseReal(rot);
			s = Ogre::StringConverter::parseReal(scale);
			rx = Ogre::StringConverter::parseReal(rotX);
			rz = Ogre::StringConverter::parseReal(rotZ);

			// auto drop models on terrain
			if (y==0) {
				float tmpY = getMeshYAdjust(meshFile)* s;
				//y = (float) mTerrainInfo->getHeightAt(x,z)+tmpY;
				y = getHeightAt(x,z)+tmpY;
			}

			//****************************
			staticGeometry->addEntity(newModel,Ogre::Vector3(x,y,z),Quaternion ((Degree(r)), Vector3::UNIT_Y), Vector3(s,s,s));
			mSceneMgr->destroyEntity(newModel);
			//***************************
		} catch (Exception &e){
			cout << "Troubles adding entity " << entName.c_str() << " to static geometry :" << e.what() << "\n";
		};

		counter ++;
	} while (!stream->eof() && !StringUtil::startsWith(tmp,"[END]",false));

	staticGeometry->build();
}
示例#5
0
table::table ( Ogre::SceneManager * SceneMgr )
{

	Scene * _mScene = mWorld->getScenes()->getFirst();

	
	NxOgre::Material * RubberMat = mScene->createMaterial("Wood");
	RubberMat->setRestitution(.3);
	RubberMat->setStaticFriction(.1);
	RubberMat->setDynamicFriction(.1);
	
	
	_mainTable = _mScene->createBody("table_collision",
		new NxOgre::TriangleMeshShape("table_collision.mesh","Group:TableGroup, material: Wood"),
		Vector3(0,0,0),"static: yes");
	
	_mainTable->getNxActor()->setName("Table");

	
	loadinganimation::getSingleton()->increment("Building(10)");
	Entity * Posts = SceneMgr->createEntity("posts", "posts.mesh");
	loadinganimation::getSingleton()->increment("Building(9)");
	Entity * Bands = SceneMgr->createEntity("bands", "Bands.mesh");
	loadinganimation::getSingleton()->increment("Building(8)");
	Entity * Covers = SceneMgr->createEntity("covers", "covers.mesh");
	loadinganimation::getSingleton()->increment("Building(7)");
	Entity * Floor = SceneMgr->createEntity("floor", "floor.mesh");
	loadinganimation::getSingleton()->increment("Building(6)");
	Entity * Walls = SceneMgr->createEntity("walls", "walls.mesh");
	loadinganimation::getSingleton()->increment("Building(5)");
	Entity * ScrewsRails = SceneMgr->createEntity("screws_rails", "metal.mesh");
	loadinganimation::getSingleton()->increment("Building(4)");
	Entity * LaneCovers = SceneMgr->createEntity("lanecovers", "lane_covers.mesh");
	loadinganimation::getSingleton()->increment("Building(3)");
	Entity * Targets = SceneMgr->createEntity("targets", "targets.mesh");

	
	//Entity * LightMap = SceneMgr->createEntity("light_map","fulltable_lightmap3.mesh");
	//LightMap->setMaterialName("tablelightbake.material");

	loadinganimation::getSingleton()->increment("Building(2)");
	
	
	Posts->setMaterialName("Gile[s]_posts");
	Bands->setMaterialName("Gile[s]_bands");
	Covers->setMaterialName("Gile[s]_covers");
	Floor->setMaterialName("Gile[s]_floor");
	Walls->setMaterialName("Gile[s]_walls");
	ScrewsRails->setMaterialName("Gile[s]_metals");
	LaneCovers->setMaterialName("Gile[s]_lanecovers");
	Targets->setMaterialName("Gile[s]_targets");
	
	Posts->setCastShadows(false);
	Covers->setCastShadows(false);
	Floor->setCastShadows(false);
	
	Bands->setCastShadows(false);
	Walls->setCastShadows(false);
	ScrewsRails->setCastShadows(false);
	LaneCovers->setCastShadows(false);
	Targets->setCastShadows(false);
	
	const Vector3 _default(0,0,0);

	StaticGeometry * sg = SceneMgr->createStaticGeometry("TableParts");
	const int size=50;
	const int amount = 8;
	sg->setRegionDimensions(Vector3(20,10,60));
	sg->setOrigin(Vector3(10,0,30));
	sg->addEntity(Posts,_default);
	sg->addEntity(Bands,_default);
	sg->addEntity(Covers,_default);
	sg->addEntity(Floor,_default);
	sg->addEntity(Walls,_default);
	sg->addEntity(ScrewsRails,_default);
	sg->addEntity(LaneCovers,_default);
	sg->addEntity(Targets,_default);
	//sg->addEntity(LightMap,_default);
	sg->build();
	

	loadinganimation::getSingleton()->increment("Building(1)");



}