void TerrainManager::createTerrain(Ogre::Light* light)
{
  mTerrainGlobals = OGRE_NEW Ogre::TerrainGlobalOptions();
 
  mTerrainGroup = OGRE_NEW Ogre::TerrainGroup(mSceneMgr, Ogre::Terrain::ALIGN_X_Z, 513, 12000.0f);
  mTerrainGroup->setFilenameConvention(Ogre::String("BasicTutorial3Terrain"), Ogre::String("dat"));
  mTerrainGroup->setOrigin(mTerrainPos);
  mTerrainGroup->setTerrainWorldSize(8000);
  mTerrainGroup->setTerrainSize(513);
  configureTerrainDefaults(light);
 
  for (long x = 0; x <= 0; ++x)
    for (long y = 0; y <= 0; ++y)
      defineTerrain(x, y);
 
  // sync load since we want everything in place when we start
  mTerrainGroup->loadAllTerrains(true);
 
  if (mTerrainsImported)
    {
      Ogre::TerrainGroup::TerrainIterator ti = mTerrainGroup->getTerrainIterator();
      while(ti.hasMoreElements())
        {
	  Ogre::Terrain* t = ti.getNext()->instance;
	  initBlendMaps(t);
        }
    }
 
  mTerrainGroup->freeTemporaryResources();
}
Exemplo n.º 2
0
	CTerrain::CTerrain(Ogre::SceneManager* sceneMgr, std::list<Logic::CTerrainTile*>* terrainList, Logic::CGridMap* terrainMap)
	{
		_sceneMgr = sceneMgr;
		_terrainMap = terrainMap;
		_worldSize = _terrainMap->getMapSize();
		_mapSize = 129.0f;
		_terrainsImported = false;

		_nTerrains = terrainList->size();
		_terrainList = new Logic::CTerrainTile*[_nTerrains];

		int i = 0;
		std::list<Logic::CTerrainTile*>::iterator terrain_tile = terrainList->begin();
		for (int i = 0; i < _nTerrains; ++i)
		{
			_terrainList[i] = (*terrain_tile);
			++terrain_tile;
		}

		Ogre::MaterialManager::getSingleton().setDefaultTextureFiltering(Ogre::TFO_ANISOTROPIC);
		Ogre::MaterialManager::getSingleton().setDefaultAnisotropy(7);

		// TerrainSystem initialization..
		printf("Terrain: Creating new terrain.\n");
		_terrainGlobals = OGRE_NEW Ogre::TerrainGlobalOptions();

		_terrainGroup = OGRE_NEW Ogre::TerrainGroup(_sceneMgr, Ogre::Terrain::ALIGN_X_Z, _mapSize, _worldSize);
		_terrainGroup->setFilenameConvention(Ogre::String("DamnedSunsetTerrain"), Ogre::String("dat"));
		_terrainGroup->setOrigin(Ogre::Vector3::ZERO);

		configureTerrainDefaults();

		for (long x = 0; x <= 0; ++x)
			for (long y = 0; y <= 0; ++y)
				defineTerrain(x, y);

		// sync load since we want everything in place when we start
		_terrainGroup->loadAllTerrains(true);

		if (_terrainsImported)
		{
			printf("Terrain: terrain imported, blending it.\n");
			Ogre::TerrainGroup::TerrainIterator ti = _terrainGroup->getTerrainIterator();
			while(ti.hasMoreElements())
			{
				Ogre::Terrain* t = ti.getNext()->instance;
				initBlendMaps(t);
			}
		}

		_terrainGroup->freeTemporaryResources();

		while (_terrainGroup->isDerivedDataUpdateInProgress());
		_terrainGroup->saveAllTerrains(true);

		configureShadows();

	} // CTerrain
Exemplo n.º 3
0
void TerrainManager::CreatePhysicsShape(void)
{
    Ogre::TerrainGroup::TerrainIterator ti = mTerrainGroup->getTerrainIterator();
    while (ti.hasMoreElements())
    {
        Ogre::Terrain *t = ti.getNext()->instance;
        LoadTerrainGeometry(t->getMaterialName(), t->getHeightData(),
                            t->getSize(), t->getWorldSize(), t->getMinHeight(), t->getMaxHeight(), t->getPosition());
    }
}
Exemplo n.º 4
0
//-------------------------------------------------------------------------------------
void BasicTutorial3::createScene(void)
{
    mCamera->setPosition(Ogre::Vector3(1683, 50, 2116));
    mCamera->lookAt(Ogre::Vector3(1963, 50, 1660));
    mCamera->setNearClipDistance(0.1);
    mCamera->setFarClipDistance(50000);
 
    if (mRoot->getRenderSystem()->getCapabilities()->hasCapability(Ogre::RSC_INFINITE_FAR_PLANE))
    {
        mCamera->setFarClipDistance(0);   // enable infinite far clip distance if we can
    }
 
    Ogre::MaterialManager::getSingleton().setDefaultTextureFiltering(Ogre::TFO_ANISOTROPIC);
    Ogre::MaterialManager::getSingleton().setDefaultAnisotropy(7);
 
    Ogre::Vector3 lightdir(0.55, -0.3, 0.75);
    lightdir.normalise();
 
    Ogre::Light* light = mSceneMgr->createLight("tstLight");
    light->setType(Ogre::Light::LT_DIRECTIONAL);
    light->setDirection(lightdir);
    light->setDiffuseColour(Ogre::ColourValue::White);
    light->setSpecularColour(Ogre::ColourValue(0.4, 0.4, 0.4));
 
    mSceneMgr->setAmbientLight(Ogre::ColourValue(0.2, 0.2, 0.2));
 
    mTerrainGlobals = OGRE_NEW Ogre::TerrainGlobalOptions();
 
    mTerrainGroup = OGRE_NEW Ogre::TerrainGroup(mSceneMgr, Ogre::Terrain::ALIGN_X_Z, 513, 12000.0f);
    mTerrainGroup->setFilenameConvention(Ogre::String("BasicTutorial3Terrain"), Ogre::String("dat"));
    mTerrainGroup->setOrigin(Ogre::Vector3::ZERO);
 
    configureTerrainDefaults(light);
 
    for (long x = 0; x <= 0; ++x)
        for (long y = 0; y <= 0; ++y)
            defineTerrain(x, y);
 
    // sync load since we want everything in place when we start
    mTerrainGroup->loadAllTerrains(true);
 
    if (mTerrainsImported)
    {
        Ogre::TerrainGroup::TerrainIterator ti = mTerrainGroup->getTerrainIterator();
        while(ti.hasMoreElements())
        {
            Ogre::Terrain* t = ti.getNext()->instance;
            initBlendMaps(t);
        }
    }
 
    mTerrainGroup->freeTemporaryResources();
 
}
Exemplo n.º 5
0
TerrainGenerator::TerrainGenerator(Ogre::SceneManager *scene) 
  : terrains_imported_(false),
    scene_manager_(scene)
{
  /*mCamera->setPosition(Ogre::Vector3(1683, 50, 2116));
  mCamera->lookAt(Ogre::Vector3(1963, 50, 1660));
  mCamera->setNearClipDistance(0.1);
  mCamera->setFarClipDistance(50000);*/

  Ogre::MaterialManager::getSingleton().setDefaultTextureFiltering(Ogre::TFO_ANISOTROPIC);
  Ogre::MaterialManager::getSingleton().setDefaultAnisotropy(7);

  Ogre::Light* light = scene_manager_->createLight("tstLight");
  light->setDiffuseColour(Ogre::ColourValue::White);
  light->setSpecularColour(Ogre::ColourValue(1, 1, 1));

  scene_manager_->setAmbientLight(Ogre::ColourValue(0.9, 0.9, 0.9));
  light->setAttenuation(100000, 1, 1, 1);
  terrain_globals_ = OGRE_NEW Ogre::TerrainGlobalOptions();

  terrain_group_ = OGRE_NEW Ogre::TerrainGroup(scene_manager_, Ogre::Terrain::ALIGN_X_Z, 513, 12000.0f);
  terrain_group_->setFilenameConvention(Ogre::String("BasicTutorial3Terrain"), Ogre::String("dat"));
  terrain_group_->setOrigin(Ogre::Vector3::ZERO);



  configureTerrainDefaults(light);

  for (long x = 0; x <= 0; ++x)
      for (long y = 0; y <= 0; ++y)
          defineTerrain(x, y);

  // sync load since we want everything in place when we start
  terrain_group_->loadAllTerrains(true);

  if (terrains_imported_)
  {
      Ogre::TerrainGroup::TerrainIterator ti = terrain_group_->getTerrainIterator();
      while(ti.hasMoreElements())
      {
          Ogre::Terrain* t = ti.getNext()->instance;
          t->setPosition(Ogre::Vector3(0, -315, 0));
          initBlendMaps(t);
      }
  }

  terrain_group_->freeTemporaryResources();
  
  scene_manager_->setSkyDome(true, "Examples/CloudySky", 5, 8);

  //Optional skybox
  //Graphics::instance()->getSceneManager()->setSkyDome(true, "Examples/CloudySky", 5, 8);
}
Exemplo n.º 6
0
void TerrainLoader::loadTerrain(std::string filename) {
	Ogre::Image img;
    img.load(filename, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
	terrainGroup->defineTerrain(0, 0, &img);
	terrainGroup->loadAllTerrains(true);
	Ogre::TerrainGroup::TerrainIterator ti = terrainGroup->getTerrainIterator();
	while(ti.hasMoreElements()) {
		Ogre::Terrain* t = ti.getNext()->instance;		
		initBlendMaps(t);
	}
	terrainGroup->freeTemporaryResources();
}
Exemplo n.º 7
0
//-------------------------------------------------------------------------------------
void TutorialApplication::createScene(void)
{
    /*Setting up the Camera*/
    mCamera->setPosition(Ogre::Vector3(1683,50,2116));
    mCamera->lookAt(Ogre::Vector3(1963,50,1660));
    mCamera->setNearClipDistance(0.1);
    bool infiniteClip = mRoot->getRenderSystem()->getCapabilities()->hasCapability(Ogre::RSC_INFINITE_FAR_PLANE);
    if(infiniteClip)
      mCamera->setFarClipDistance(0);
    else
      mCamera->setFarClipDistance(50000);
    
    /*Setting up a Light*/
    mSceneMgr->setAmbientLight(Ogre::ColourValue(0.2,0.2,0.2));
    Ogre::Vector3 lightdir(0.55,-0.3,0.75);
    lightdir.normalise();
    Ogre::Light* light = mSceneMgr->createLight("TestLight");
    light->setType(Ogre::Light::LT_DIRECTIONAL);
    light->setDirection(lightdir);
    light->setDiffuseColour(Ogre::ColourValue::White);
    light->setSpecularColour(Ogre::ColourValue(0.4,0.4,0.4));
    
    /*Configuring the Terrain*/
    mTerrainGlobals = OGRE_NEW Ogre::TerrainGlobalOptions();
    mTerrainGroup = OGRE_NEW Ogre::TerrainGroup(mSceneMgr,Ogre::Terrain::ALIGN_X_Z,513,12000.0);
    mTerrainGroup->setFilenameConvention(Ogre::String("terrain"),Ogre::String("dat"));
    mTerrainGroup->setOrigin(Ogre::Vector3::ZERO);
    configureTerrainDefaults(light);
    for(long x=0; x<=0; ++x)
      for(long y=0; y<=0; ++y)
         defineTerrain(x,y);
   mTerrainGroup->loadAllTerrains(true);
   if(mTerrainsImported)
   {
      Ogre::TerrainGroup::TerrainIterator ti = mTerrainGroup->getTerrainIterator();
      while(ti.hasMoreElements())
      {
         Ogre::Terrain* t = ti.getNext()->instance;
         initBlendMaps(t);
      }
   }
   mTerrainGroup->freeTemporaryResources();
   
   /*Writing configureTerrainDefaults*/
   /*Writing defineTerrain*/
   /*Writing getTerrainImage*/
   /*Writing initBlendMaps*/
   //LE TEST MARCHE PAS :D //
   /*Terrain Loading Label*/
   /*Cleaning Up*/
   /*TODO SkyBoxes*/
}
Exemplo n.º 8
0
//------------------------------------------------------------------------------
void Application::createScene()
{
    Ogre::MaterialManager::getSingleton().setDefaultTextureFiltering(Ogre::TFO_ANISOTROPIC);
    Ogre::MaterialManager::getSingleton().setDefaultAnisotropy(7);

    Ogre::Vector3 lightdir(0.55, -0.3, 0.75);
    lightdir.normalise();

    Ogre::Light* light = scene->createLight("tstLight");
    light->setType(Ogre::Light::LT_DIRECTIONAL);
    light->setDirection(lightdir);
    light->setDiffuseColour(Ogre::ColourValue::White);
    light->setSpecularColour(Ogre::ColourValue(0.4, 0.4, 0.4));

    scene->setAmbientLight(Ogre::ColourValue(0.2, 0.2, 0.2));

    mTerrainGlobals = OGRE_NEW Ogre::TerrainGlobalOptions();

    mTerrainGroup = OGRE_NEW Ogre::TerrainGroup(scene, Ogre::Terrain::ALIGN_X_Z, 513, 12000.0f);
    mTerrainGroup->setFilenameConvention(Ogre::String("BasicTutorial3Terrain"), Ogre::String("dat"));
    mTerrainGroup->setOrigin(Ogre::Vector3::ZERO);

    configureTerrainDefaults(light);

    for (long x = 0; x <= 0; ++x)
        for (long y = 0; y <= 0; ++y)
            defineTerrain(x, y);

    // sync load since we want everything in place when we start
    mTerrainGroup->loadAllTerrains(true);

    if (mTerrainsImported)
    {
        Ogre::TerrainGroup::TerrainIterator ti = mTerrainGroup->getTerrainIterator();
        while(ti.hasMoreElements())
        {
            Ogre::Terrain* t = ti.getNext()->instance;
            initBlendMaps(t);
        }
    }

    mTerrainGroup->freeTemporaryResources();

	// CEGUI setup
  gui_renderer = &CEGUI::OgreRenderer::bootstrapSystem();

  // Mouse
  CEGUI::SchemeManager::getSingleton().create((CEGUI::utf8*)"TaharezLook.scheme");
  CEGUI::MouseCursor::getSingleton().setImage("TaharezLook", "MouseArrow");
}
Exemplo n.º 9
0
void Scene::setup(Sim* sim) {
	mSim = sim;
	mSim->scene = this;

	// Lighting and sky
	mSceneMgr->setAmbientLight(Ogre::ColourValue(0.4, 0.4, 0.4));

	Ogre::Vector3 lightDir(0.55, -0.3f, 0.75);
	lightDir.normalise();

	sun = mSceneMgr->createLight("SunLight");
	sun->setType(Ogre::Light::LT_DIRECTIONAL);
	sun->setDirection(lightDir);
	sun->setDiffuseColour(Ogre::ColourValue::White);
	sun->setSpecularColour(Ogre::ColourValue(0.4, 0.4, 0.4));

	mSceneMgr->setSkyDome(true, "CloudySky");

	// Terrain
	mTerrainGlobals = OGRE_NEW Ogre::TerrainGlobalOptions();
	mTerrainGroup = OGRE_NEW Ogre::TerrainGroup(mSceneMgr, Ogre::Terrain::ALIGN_X_Z,
												terrSize, worldSize);

	configureTerrainDefaults();
	defineTerrain();

	mTerrainGroup->loadAllTerrains(true);
	Ogre::TerrainGroup::TerrainIterator ti = mTerrainGroup->getTerrainIterator();
	while (ti.hasMoreElements()) {
		Ogre::Terrain* t = ti.getNext()->instance;
		t->setVisibilityFlags(RV_Terrain);
	}
	mTerrainGroup->freeTemporaryResources();

	createBulletTerrain();

	// Road
//	setupRoad();

	// Objects
	setupObjects();
}
Exemplo n.º 10
0
void TerrainManager::CreateTerrain(std::string terrainName, std::string fileExtension,
                                   std::string heightMapFileName, std::string directionalLightName,
                                   Ogre::uint16 terrainSize, Ogre::Real worldSize, Ogre::Real inputScale)
{
    mHeightMapFileName = heightMapFileName;
    mTerrainSize = terrainSize;
    mWorldSize = worldSize;
    mInputScale = inputScale;

    mTerrainGlobals = OGRE_NEW Ogre::TerrainGlobalOptions();
    mTerrainGroup = OGRE_NEW Ogre::TerrainGroup(GameManager::GetInstance()->GetSceneManager(),
                    Ogre::Terrain::ALIGN_X_Z, mTerrainSize, mWorldSize);
    mTerrainGroup->setFilenameConvention(Ogre::String(terrainName), fileExtension);
    mTerrainGroup->setOrigin(Ogre::Vector3::ZERO);

    ConfigureTerrainDefaults(GameManager::GetInstance()->GetSceneManager()->getLight(directionalLightName));

    for (long x = 0; x <= 0; ++x)
        for (long y = 0; y <= 0; ++y)
            DefineTerrain(x, y);

    // sync load since we want everything in place when we start
    mTerrainGroup->loadAllTerrains(true);

    if (mTerrainsImported)
    {
        Ogre::TerrainGroup::TerrainIterator ti = mTerrainGroup->getTerrainIterator();
        while(ti.hasMoreElements())
        {
            Ogre::Terrain* t = ti.getNext()->instance;
            InitBlendMaps(t);
        }
        //mTerrainGroup->saveAllTerrains(true);
        mTerrainsImported = false;
    }

    mTerrainGroup->freeTemporaryResources();

    CreatePhysicsShape();
}
Exemplo n.º 11
0
//-----------------------------------------------------------------------------------------
bool CTerrainGroupEditor::_setCompositeMapDistance(OgitorsPropertyBase* property, const int& value)
{
    if(value < 1)
        return false;

    mTerrainGlobalOptions->setCompositeMapDistance(value);

    Ogre::TerrainGroup::TerrainIterator it = mHandle->getTerrainIterator();

    Ogre::Rect drect(0, 0, mMapSize->get(), mMapSize->get());

    while(it.hasMoreElements())
    {
        Ogre::TerrainGroup::TerrainSlot *terrain = it.getNext();
        if(terrain && terrain->instance)
            terrain->instance->dirtyRect(drect);
    }

    mHandle->update();

    return true;
}
Exemplo n.º 12
0
void MyTerrain::InitNxOgre()
{
    m_pWorld=NxOgre::World::createWorld();
    NxOgre::ResourceSystem::getSingleton()->openProtocol(new Critter::OgreResourceProtocol());

    m_pWorld->getRemoteDebugger()->connect();

    NxOgre::SceneDescription scene_description;
    scene_description.mGravity = NxOgre::Constants::MEAN_EARTH_GRAVITY;
    scene_description.mUseHardware = false;

    m_pScene = m_pWorld->createScene(scene_description);

    m_pScene->getMaterial(0)->setAll(0.1f, 0.9f, 0.5f);
    m_pScene->getMaterial(0)->setRestitution(0.1f);
    m_pScene->getMaterial(0)->setDynamicFriction(0.9);
    m_pScene->getMaterial(0)->setStaticFriction(0.5);
    m_pScene->setGravity(NxOgre::Vec3(0,Global::Gravity,0));

    m_pScene->createSceneGeometry(NxOgre::PlaneGeometryDescription());
    Ogre::TerrainGroup::TerrainIterator ti = m_pTerrainGroup->getTerrainIterator();

    while(ti.hasMoreElements())
    {
        Ogre::Terrain* t = ti.getNext()->instance;
        InitNxOgreTerrain(t);
    }



    m_pRenderSystem=new Critter::RenderSystem(m_pScene,m_pSceneMgr);



    //m_pRenderSystem->createBody(NxOgre::BoxDescription(),v3+NxOgre::Vec3(0,35,0), "shaizi.mesh", bodyDescription);


}
Exemplo n.º 13
0
//-------------------------------------------------------------------------------------
void Environment::initEnvironment(Ogre::SceneManager* SceneMgr, 
		Ogre::RenderWindow* mWindow, Physics* Bullet)
{	
	cout<<"Entered initEnvironment()"<<endl;
	mSceneMgr = SceneMgr;
	mBullet = Bullet;
	
	Ogre::MaterialManager::getSingleton().setDefaultTextureFiltering(Ogre::TFO_ANISOTROPIC);
	Ogre::MaterialManager::getSingleton().setDefaultAnisotropy(7);
 
	Ogre::Vector3 lightdir(0.55, -0.3, 0.75);
	lightdir.normalise();
 
	Ogre::Light* light = mSceneMgr->createLight("tstLight");
	light->setType(Ogre::Light::LT_DIRECTIONAL);
	light->setDirection(lightdir);
	light->setDiffuseColour(Ogre::ColourValue::White);
	light->setSpecularColour(Ogre::ColourValue(0.4, 0.4, 0.4));
 
	mSceneMgr->setAmbientLight(Ogre::ColourValue(0.3, 0.3, 0.3));
 
	mTerrainGlobals = OGRE_NEW Ogre::TerrainGlobalOptions();
 
	mTerrainGroup = OGRE_NEW Ogre::TerrainGroup(mSceneMgr, Ogre::Terrain::ALIGN_X_Z, 513, 12000.0f);
	mTerrainGroup->setFilenameConvention(Ogre::String("GTFinal"), Ogre::String("dat"));
	//mTerrainGroup->setFilenameConvention(Ogre::String("BasicTutorial3Terrain"), Ogre::String("dat"));
	mTerrainGroup->setOrigin(Ogre::Vector3::ZERO);
 
	configureTerrainDefaults(light);
 
	for (long x = 0; x <= 0; ++x)
		for (long y = 0; y <= 0; ++y)
			defineTerrain(x, y);
 	
	// sync load since we want everything in place when we start
	mTerrainGroup->loadAllTerrains(true);
 
	if (mTerrainsImported)
	{
		Ogre::TerrainGroup::TerrainIterator ti = mTerrainGroup->getTerrainIterator();
		while(ti.hasMoreElements())
		{
			Ogre::Terrain* t = ti.getNext()->instance;
			initBlendMaps(t);
		}
	}
 
	mTerrainGroup->freeTemporaryResources();
	
	
		int dim = 1000;
		
    	//Water-----------------------------------------------------------------------
    	{   
    		Ogre::Plane plane(Ogre::Vector3::UNIT_Y, 0);
 
	   		Ogre::MeshManager::getSingleton().createPlane("base", 
	    		Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
	    	    plane, 10000, 10000, 100, 100, true, 1, 10, 10, Ogre::Vector3::UNIT_X);
    	
    		Ogre::Vector3 shapeDim = Ogre::Vector3(dim, 1, dim);
    		Ogre::Vector3 position = Ogre::Vector3(0, 249, 0);
    		    			    
			Ogre::Entity* ent = mSceneMgr->createEntity("WaterEntity", "base");
    		Ogre::SceneNode* snode = mSceneMgr->getRootSceneNode()->
    			createChildSceneNode("snode0", position);
 			    		
 			snode->attachObject(ent);
    		ent->setMaterialName("Examples/WaterStream");
    		ent->setCastShadows(false);
    	}

    	//Ocean Floor

		{   
    		Ogre::Plane plane(Ogre::Vector3::UNIT_Y, 0);
 
	   		Ogre::MeshManager::getSingleton().createPlane("base2", 
	    		Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
	    	    plane, 7000, 7000, 255, 255, true, 1, 10, 10, Ogre::Vector3::UNIT_X);
    	
    		Ogre::Vector3 shapeDim = Ogre::Vector3(dim, 1, dim);
    		Ogre::Vector3 position = Ogre::Vector3(100, 242, 0);
    		    			    
			Ogre::Entity* ent = mSceneMgr->createEntity("OceanFloor", "base2");
    		Ogre::SceneNode* snode = mSceneMgr->getRootSceneNode()->
    			createChildSceneNode("snode2", position);
 			    		
 			snode->attachObject(ent);
    		ent->setMaterialName("01-Default");
    		ent->setCastShadows(false);
    	}


    	/*//Ground----------------------------------------------------------------------
    	{   
	    	//Ogre::Vector3 shapeDim = Ogre::Vector3(dim/100, 1, dim/100);
			Ogre::Vector3 shapeDim = Ogre::Vector3(500, 30, 500);
    		Ogre::Vector3 position = Ogre::Vector3(700, 225, -700);

		//Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().create("RustedMetal", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
		//Ogre::TextureUnitState* tuisTexture = mat->getTechnique(0)->getPass(0)->createTextureUnitState("RustedMetal.jpg");

		//Ogre::Plane plane(Ogre::Vector3::UNIT_Y, 0);
		//Ogre::MeshManager::getSingleton().createPlane("platform",
                //        Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
                //    plane, 1000, 1000, 20, 20, true, 1, 10, 10, Ogre::Vector3::UNIT_Z);
	
		//Ogre::Entity* ent = mSceneMgr->createEntity("GroundEntity", "cube.mesh");
		Ogre::Entity* ent = mSceneMgr->createEntity("GroundEntity1", "cube.mesh");
    		Ogre::SceneNode* snode = mSceneMgr->getRootSceneNode()->
    			createChildSceneNode("snode1", position);
    		
 		snode->attachObject(ent);
 		//snode->scale(shapeDim.x, .01, shapeDim.z);
		snode->scale(5, .3, 5);
	 		//snode->translate(position);
    		//ent->setMaterialName("Examples/Rocky");
		ent->setMaterialName("Examples/RustySteel");
    		ent->setCastShadows(true);

		mBullet->setRigidBoxBody(snode, shapeDim, position, 0.0, false);
    	}
    	//Wall-----------------------------------------------------------------------
    	{   
	    	//Ogre::Vector3 shapeDim = Ogre::Vector3(dim/100, 1, dim/100);
			Ogre::Vector3 shapeDim = Ogre::Vector3(30, 500, 500);
    		Ogre::Vector3 position = Ogre::Vector3(950, 475, -700);

			//Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().create("RustedMetal", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
			//Ogre::TextureUnitState* tuisTexture = mat->getTechnique(0)->getPass(0)->createTextureUnitState("RustedMetal.jpg");

			//Ogre::Plane plane(Ogre::Vector3::UNIT_Y, 0);
			//Ogre::MeshManager::getSingleton().createPlane("platform",
                //        Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
                //    plane, 1000, 1000, 20, 20, true, 1, 10, 10, Ogre::Vector3::UNIT_Z);
	
			//Ogre::Entity* ent = mSceneMgr->createEntity("GroundEntity", "cube.mesh");
			Ogre::Entity* ent = mSceneMgr->createEntity("GroundEntity2", "cube.mesh");
    		Ogre::SceneNode* snode = mSceneMgr->getRootSceneNode()->
    			createChildSceneNode("snode2", position);
    		//snode->yaw(Ogre::Radian(Ogre::Degree(90)));
 			snode->attachObject(ent);
 			//snode->scale(shapeDim.x, .01, shapeDim.z);
			snode->scale(.3, 5, 5);
	 		//snode->translate(position);
    		//ent->setMaterialName("Examples/Rocky");
			ent->setMaterialName("Examples/RustySteel");
    		ent->setCastShadows(true);

			mBullet->setRigidBoxBody(snode, shapeDim, position, 0.0, false);
    	}*/
        //Dynamic--------------------------------------------------------------------
        {
		//Ogre::Vector3 shapeDim = Ogre::Vector3(.5, .5, .5);
		/*Ogre::Vector3 shapeDim = Ogre::Vector3(100, 100, 100);

		for (int i = 0; i < 1; i++) {
			for (int j = 0; j < 1; j++) {
				Ogre::Vector3 position = Ogre::Vector3(650 + (i * 10), 500, -750 + (j * 10));
				Ogre::String entname = "DynamicEntity" + Ogre::StringConverter::toString(i)
				                        + Ogre::StringConverter::toString(j);
				Ogre::String nodename = "snode" + Ogre::StringConverter::toString(i)
				                    	+ Ogre::StringConverter::toString(j);
				Ogre::Entity* ent = mSceneMgr->createEntity(entname,"cube.mesh");
				Ogre::SceneNode* snode = mSceneMgr->getRootSceneNode()->
					createChildSceneNode(nodename, position);

				snode->attachObject(ent);
		//snode->scale(shapeDim.x, shapeDim.y, shapeDim.z);
				//snode->scale(.1, .1, .1);
				ent->setMaterialName("Examples/Chrome");
				ent->setCastShadows(true);

				mBullet->setRigidBoxBody(snode, shapeDim, position, 200.0, false);
			}
		}*/
	}
	
	Ogre::ColourValue fadeColour(0.0, 0.0, 0.0);
	//Ogre::ColourValue fadeColour(0.2, 0.2, 0.2);
	mSceneMgr->setFog(Ogre::FOG_LINEAR, fadeColour, 0.0, 10, 3000);
	mWindow->getViewport(0)->setBackgroundColour(fadeColour);
	
	Ogre::Plane plane;
	plane.d = 100;
	plane.normal = Ogre::Vector3::NEGATIVE_UNIT_Y;
 
	//mSceneMgr->setSkyDome(true, "Examples/CloudySky", 5, 8, 500);
	mSceneMgr->setSkyPlane(true, plane, "Examples/CloudySky", 500, 75, true, 0.5, 150, 150);
	cout<<"Exiting initEnvironment()"<<endl;
}
Exemplo n.º 14
0
void CSceneEditorView::EngineSetup(void)
{
	Ogre::Root *Root = ((CSceneEditorApp*)AfxGetApp())->m_Engine->GetRoot();
	m_SceneManager = Root->createSceneManager(Ogre::ST_GENERIC, "SceneEditor");
 
    //
    // Create a render window
    // This window should be the current ChildView window using the externalWindowHandle
    // value pair option.
    //

    Ogre::NameValuePairList parms;
    parms["externalWindowHandle"] = Ogre::StringConverter::toString((long)m_hWnd);
    parms["vsync"] = "true";

	CRect   rect;
    GetClientRect(&rect);
	Ogre::RenderTarget *RenderWindow = Root->getRenderTarget("SceneEditor");

	if (RenderWindow == NULL)
	{
	try
	{
		m_RenderWindow = Root->createRenderWindow("SceneEditor", rect.Width(), rect.Height(), false, &parms);
	}
    catch(...)
	{
		MessageBox("Cannot initialize\nCheck that graphic-card driver is up-to-date", "Initialize Render System", MB_OK | MB_ICONSTOP);
		exit(EXIT_SUCCESS);
	}
	}
// Load resources
	Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();

    // Create the camera
	m_Camera = m_SceneManager->createCamera("Camera");
	m_Camera->setPosition(Ogre::Vector3(1683, 50, 2116));
    m_Camera->lookAt(Ogre::Vector3(0, 0, 0));
    m_Camera->setNearClipDistance(0.1);
    m_Camera->setFarClipDistance(50000);
 
    if (m_Root->getRenderSystem()->getCapabilities()->hasCapability(Ogre::RSC_INFINITE_FAR_PLANE))
    {
        m_Camera->setFarClipDistance(0);   // enable infinite far clip distance if we can
    }

	m_Camera->setAutoTracking(false);
	m_Camera->setFixedYawAxis(true);
	m_Camera->yaw(Ogre::Radian(0));
	m_Camera->pitch(Ogre::Radian(0));

	Ogre::SceneNode *CameraNode = NULL;
	CameraNode = m_SceneManager->getRootSceneNode()->createChildSceneNode("CameraNode");
 
	m_SceneManager->setAmbientLight(Ogre::ColourValue(0.2, 0.2, 0.2));

	//Create viewport
	Ogre::Viewport* Viewport = NULL;
	
	if (0 == m_RenderWindow->getNumViewports())
	{
		Viewport = m_RenderWindow->addViewport(m_Camera);
		Viewport->setBackgroundColour(Ogre::ColourValue(0.0f, 0.0f, 0.0f));
	}

    // Alter the camera aspect ratio to match the viewport
    m_Camera->setAspectRatio(Ogre::Real(rect.Width()) / Ogre::Real(rect.Height()));
	
	m_SceneManager->setSkyDome(true, "Examples/CloudySky", 5, 8);
	Ogre::MaterialManager::getSingleton().setDefaultTextureFiltering(Ogre::TFO_ANISOTROPIC);
    Ogre::MaterialManager::getSingleton().setDefaultAnisotropy(7);
 
    Ogre::Vector3 lightdir(0.55, -0.3, 0.75);
    lightdir.normalise();
 
	Ogre::Light* light = m_SceneManager->createLight("tstLight");
    light->setType(Ogre::Light::LT_DIRECTIONAL);
    light->setDirection(lightdir);
    light->setDiffuseColour(Ogre::ColourValue::White);
    light->setSpecularColour(Ogre::ColourValue(0.4, 0.4, 0.4));
 
	m_SceneManager->setAmbientLight(Ogre::ColourValue(0.2, 0.2, 0.2));
	
	mTerrainGlobals = OGRE_NEW Ogre::TerrainGlobalOptions();
	mTerrainGroup = OGRE_NEW Ogre::TerrainGroup(m_SceneManager, Ogre::Terrain::ALIGN_X_Z, 513, 12000.0f);
    mTerrainGroup->setFilenameConvention(Ogre::String("Terrain"), Ogre::String("dat"));
    mTerrainGroup->setOrigin(Ogre::Vector3::ZERO);
 
    configureTerrainDefaults(light);
 
    for (long x = 0; x <= 0; ++x)
        for (long y = 0; y <= 0; ++y)
            defineTerrain(x, y);
 
    // sync load since we want everything in place when we start
    mTerrainGroup->loadAllTerrains(true);
 
    if (mTerrainsImported)
    {
        Ogre::TerrainGroup::TerrainIterator ti = mTerrainGroup->getTerrainIterator();
        while(ti.hasMoreElements())
        {
            Ogre::Terrain* t = ti.getNext()->instance;
            initBlendMaps(t);
        }
    }
 
    mTerrainGroup->freeTemporaryResources();
}
Exemplo n.º 15
0
void OgreWidget::setupTerrain()
{
    //    bool blankTerrain = false;


    mTerrainPos = Ogre::Vector3(1.0, -75.1, 1.0);

    //    mEditMarker = ogreSceneManager->createEntity("editMarker", "sphere.mesh");
    //    mEditNode = ogreSceneManager->getRootSceneNode()->createChildSceneNode();
    //    mEditNode->attachObject(mEditMarker);
    //    mEditNode->setScale(0.05, 0.05, 0.05);

    // These two lines makes the terrain textures look nicer:
    Ogre::MaterialManager::getSingleton().setDefaultTextureFiltering(Ogre::TFO_ANISOTROPIC);
    Ogre::MaterialManager::getSingleton().setDefaultAnisotropy(7);

    //mSceneManager->setFog(Ogre::FOG_EXP, Ogre::ColourValue(0.1, 0.1, 0.1), 0.01, 500, 1000);

    Ogre::LogManager::getSingleton().setLogDetail(Ogre::LL_BOREME);

    // Set up directional and ambient lights
    // THis first light is used for terrain shadows
    Ogre::Vector3 lightdir(-0.55, -0.3, 0.75);
    lightdir.normalise();
    Ogre::Light* light = mSceneManager->createLight("tstLight");
    light->setType(Ogre::Light::LT_DIRECTIONAL);
    light->setDirection(lightdir);
    light->setDiffuseColour(Ogre::ColourValue(1.0, 1.0, 1.0));
    light->setSpecularColour(Ogre::ColourValue(0.4, 0.4, 0.4));

    mSceneManager->setAmbientLight(Ogre::ColourValue(0.3, 0.3, 0.3));

    Ogre::Vector3 lightdir2(-0.55, -0.3, -0.75);
    lightdir2.normalise();
    Ogre::Light* light2 = mSceneManager->createLight("tstLight2");
    light2->setType(Ogre::Light::LT_DIRECTIONAL);
    light2->setDirection(lightdir2);
    light2->setDiffuseColour(Ogre::ColourValue(0.4, 0.4, 0.4));
    light2->setSpecularColour(Ogre::ColourValue(0.2, 0.2, 0.2));

    Ogre::Vector3 lightdir3(0.55, -0.2, -0.75);
    lightdir3.normalise();
    Ogre::Light* light3 = mSceneManager->createLight("tstLight3");
    light3->setType(Ogre::Light::LT_DIRECTIONAL);
    light3->setDirection(lightdir3);
    light3->setDiffuseColour(Ogre::ColourValue(0.5, 0.5, 0.5));
    light3->setSpecularColour(Ogre::ColourValue(0.1, 0.1, 0.1));

    Ogre::Vector3 lightdir4(-0.55, -0.2, 0.75);
    lightdir4.normalise();
    Ogre::Light* light4 = mSceneManager->createLight("tstLight4");
    light4->setType(Ogre::Light::LT_DIRECTIONAL);
    light4->setDirection(lightdir4);
    light4->setDiffuseColour(Ogre::ColourValue(0.3, 0.3, 0.3));
    light4->setSpecularColour(Ogre::ColourValue(0.2, 0.2, 0.2));


    mTerrainGroup = new Ogre::TerrainGroup(mSceneManager, Ogre::Terrain::ALIGN_X_Z, TERRAIN_SIZE, TERRAIN_WORLD_SIZE);
    mTerrainGroup->setFilenameConvention(Ogre::String("cachedterrain"), Ogre::String("dat"));
    mTerrainGroup->setOrigin(mTerrainPos);

    mTerrainGlobals = new Ogre::TerrainGlobalOptions();
    configureTerrainDefaults(light);

    for(long x = TERRAIN_PAGE_MIN_X; x <= TERRAIN_PAGE_MAX_X; ++x)
        for (long y = TERRAIN_PAGE_MIN_Y; y <= TERRAIN_PAGE_MAX_Y; ++y)
            defineTerrain(x, y);

    // sync load since we NEED everything in place when we start
    mTerrainGroup->loadAllTerrains(true);

    // calculate the blend maps of all terrains
    if(mTerrainsImported)
    {
        Ogre::TerrainGroup::TerrainIterator ti = mTerrainGroup->getTerrainIterator();
        while(ti.hasMoreElements())
        {
            Ogre::Terrain* t = ti.getNext()->instance;
            initBlendMaps(t);
        }
    }

    mTerrainGroup->freeTemporaryResources();

    // create a few entities on the terrain
    placeObjectOnTerrain("tudorhouse.mesh", Ogre::Vector3(10, 6.4, -10), 0, Ogre::Vector3(0.012, 0.012, 0.012));
    placeObjectOnTerrain("church.mesh", Ogre::Vector3(-7, 0, 22), 90);
    placeObjectOnTerrain("house1.mesh", Ogre::Vector3(-23, 0, -10), 20);
    placeObjectOnTerrain("house2.mesh", Ogre::Vector3(22, 3, 20), -120);
    placeObjectOnTerrain("windmill.mesh", Ogre::Vector3(-35, -0.2, 20), 120);

    // palmtree placeObjectOnTerrain("tree1.mesh", Ogre::Vector3(0, 0, 10), 00, Ogre::Vector3(0.002, 0.002, 0.002));

    placeObjectOnTerrain("tree2.mesh", Ogre::Vector3(0, 0, -30), 10, Ogre::Vector3(0.01, 0.01, 0.01));

    // big wind-skewed guy
    placeObjectOnTerrain("tree3.mesh", Ogre::Vector3(10, 0, 35), 20, Ogre::Vector3(0.01, 0.01, 0.01));

    // ???
    placeObjectOnTerrain("tree4.mesh", Ogre::Vector3(33, 0, -15), 30, Ogre::Vector3(0.01, 0.01, 0.01));

    // ???
    placeObjectOnTerrain("tree5.mesh", Ogre::Vector3(-40, 0, -25), 40, Ogre::Vector3(0.01, 0.01, 0.01));

    // the bald tree goes into the center
    placeObjectOnTerrain("tree6.mesh", Ogre::Vector3(-3, 0, -2), 50, Ogre::Vector3(0.008, 0.008, 0.008));

    // tanne
    placeObjectOnTerrain("tree7.mesh", Ogre::Vector3(-22, 0, 28), 60, Ogre::Vector3(0.003, 0.003, 0.003));

    mSceneManager->setSkyBox(true, "Examples/CloudyNoonSkyBox");
}
Exemplo n.º 16
0
void MyGame::createScene(void)
{   
	//tutorial 3
	mSceneMgr->setSkyDome(true, "Examples/CloudySky", 5, 8); // um coubo em volta da camera com textura

	mCamera->setPosition(Ogre::Vector3(100, 400, 100));
    mCamera->lookAt(Ogre::Vector3(10, 400, 0));
    mCamera->setNearClipDistance(0.1);
    mCamera->setFarClipDistance(50000);
 
    if (mRoot->getRenderSystem()->getCapabilities()->hasCapability(Ogre::RSC_INFINITE_FAR_PLANE))
    {
        mCamera->setFarClipDistance(0);   // enable infinite far clip distance if we can
    }

	Ogre::Vector3 lightdir(0.55, -0.3, 0.75);
    lightdir.normalise();
 
    Ogre::Light* light = mSceneMgr->createLight("tstLight");
    light->setType(Ogre::Light::LT_DIRECTIONAL);
    light->setDirection(lightdir);
    light->setDiffuseColour(Ogre::ColourValue::White);
    light->setSpecularColour(Ogre::ColourValue(0.4, 0.4, 0.4));
 
    mSceneMgr->setAmbientLight(Ogre::ColourValue(0.2, 0.2, 0.2));
	mTerrainGlobals = OGRE_NEW Ogre::TerrainGlobalOptions();
	mTerrainGroup = OGRE_NEW Ogre::TerrainGroup(mSceneMgr, Ogre::Terrain::ALIGN_X_Z, 513, 12000.0f);
    mTerrainGroup->setFilenameConvention(Ogre::String("BasicTutorial3Terrain"), Ogre::String("dat"));
    mTerrainGroup->setOrigin(Ogre::Vector3::ZERO);

	configureTerrainDefaults(light);
	for (long x = 0; x <= 0; ++x)
        for (long y = 0; y <= 0; ++y)
            defineTerrain(x, y);
 
    // sync load since we want everything in place when we start
    mTerrainGroup->loadAllTerrains(true);

	if (mTerrainsImported)
    {
        Ogre::TerrainGroup::TerrainIterator ti = mTerrainGroup->getTerrainIterator();
        while(ti.hasMoreElements())
        {
            Ogre::Terrain* t = ti.getNext()->instance;
            initBlendMaps(t);
        }
    }

	mTerrainGroup->freeTemporaryResources();

	//ate o tutorial 2
//	//== faz o chao =================================================
//	Ogre::Plane plane(Ogre::Vector3::UNIT_Y, -10);
//	Ogre::MeshManager::getSingleton().createPlane("plane", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane,
//1500,1500,20,20,true,1,5,5,Ogre::Vector3::UNIT_Z);// até aqui é como se eu criasse a .mesh do plano
//	Ogre::Entity* floor = mSceneMgr->createEntity("floor", "plane");
//	mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(floor);
//	floor->setMaterialName("Examples/BeachStones"); //põe uma textura no plano/chão
//
/*	//== coloca um boneco na cena  ==================================
	Ogre::Entity* someGuy = mSceneMgr->createEntity("someGuy","Sinbad.mesh");
	Ogre::SceneNode* node_someGuy = mSceneMgr->createSceneNode("node_someGuy"); //criei um nó para o someGuy
	mSceneMgr->getRootSceneNode()->addChild(node_someGuy);// colocoquei o nó do someGuy no nó raiz
	node_someGuy->attachObject(someGuy); //coloquei o someGuy (entidade) no nó correspondente
	node_someGuy->setPosition(10,450,0);
	node_someGuy->scale(8,8,8);
*/
	
	Ogre::Entity *sphere = mSceneMgr->createEntity("sphere", "Sinbad.mesh");
	Ogre::SceneNode* node_sphere = mSceneMgr->createSceneNode("node_sphere"); //criei um nó para o someGuy
	
	mSceneMgr->getRootSceneNode()->addChild(node_sphere);// colocoquei o nó do someGuy no nó raiz
	node_sphere->attachObject(sphere); //coloquei o someGuy (entidade) no nó correspondente
	node_sphere->setPosition(-10,450,0);
	node_sphere->scale(5,5,5);	
	
	physicsManager.createGround();
	physicsManager.createSphere();

	
//	Ogre::SceneNode* node1 = mSceneMgr->getRootSceneNode()->createChildSceneNode(name);
     
//    btRigidBody &body = mPhysics.createBody(btTransform(btQuaternion::getIdentity(), btVector3(pos.x, pos.y, pos.z)), mass, shape);
     
//    mObjects.push_back(new SceneObject(*node1, body));
     
//    Ogre::Entity *entity = mSceneMgr->createEntity(name, "Prefab_Cube");
//    node1->attachObject(entity);
 
//    node1->setScale(size.x / 100.0f, size.y / 100.0f, size.z / 100.0f);
	
//	//== outro boneco na cena  =======================================
//	Ogre::Entity* anotherGuy = mSceneMgr->createEntity("anotherGuy","ninja.mesh");
//	Ogre::SceneNode* node_anotherGuy = mSceneMgr->createSceneNode("node_anotherGuy"); //criei um nó para o anotherGuy
//	mSceneMgr->getRootSceneNode()->addChild(node_anotherGuy);// colocoquei o nó do anotherGuy no nó raiz
//	node_anotherGuy->attachObject(anotherGuy); //coloquei o anotherGuy (entidade) no nó correspondente
//	node_anotherGuy->setPosition(10,-10,20);
//	node_anotherGuy->scale(0.15,0.15,0.15);
//	
//	//== luz =========================================================
//	Ogre::SceneNode* node_light = mSceneMgr->createSceneNode("node_light");
//	mSceneMgr->getRootSceneNode()->addChild(node_light);
//	Ogre::Light* light1 = mSceneMgr->createLight("light1");
//	light1->setType(Ogre::Light::LT_DIRECTIONAL);//
//	//light1->setPosition(0,20,0);
//    light1->setDiffuseColour(1.0f,1.0f,1.0f);// cor em RGB de 0 a 1
//	light1->setDirection(Ogre::Vector3(1,-1,0));
//	mSceneMgr->setAmbientLight(Ogre::ColourValue(0.7, 0.7, 0.7)); // alterea aqui pra clarear ou escurecer a tela
//	mSceneMgr->setShadowTechnique(Ogre:: SHADOWTYPE_STENCIL_ADDITIVE);// ativa sombra dos 3d no plano
	//btBroadphaseInterface* broadphase = new btDbvtBroadphase();
}
Exemplo n.º 17
0
void Game::initialize(Ogre::Camera *camera, EventManager *handler)
{
	_handler = handler;
	_camera = camera;
	
	gSceneManager->setAmbientLight(Ogre::ColourValue(0.5, 0.5, 0.5));
	gSceneManager->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_MODULATIVE);
	
	Ogre::Vector3 lightdir(0.55, -0.3, 0.75); lightdir.normalise();  
	Ogre::Light* light = gSceneManager->createLight("tstLight"); 
	light->setType(Ogre::Light::LT_DIRECTIONAL); 
	light->setDirection(lightdir); 
	light->setDiffuseColour(Ogre::ColourValue::White); 
	light->setSpecularColour(Ogre::ColourValue(0.4, 0.4, 0.4));

	mTerrainGlobals = OGRE_NEW Ogre::TerrainGlobalOptions(); 
	mTerrainGroup = OGRE_NEW Ogre::TerrainGroup(gSceneManager, Ogre::Terrain::ALIGN_X_Z, 513, 12000.0f); 
	mTerrainGroup->setFilenameConvention(Ogre::String("BasicTutorial3Terrain"), Ogre::String("dat"));
	mTerrainGroup->setOrigin(Ogre::Vector3::ZERO);  
	configureTerrainDefaults(light); 

	for (long x = 0; x <= 0; ++x) 
		for (long y = 0; y <= 0; ++y) 
			defineTerrain(x, y);
	
	// sync load since we want everything in place when we start 
	mTerrainGroup->loadAllTerrains(true);
	if (mTerrainsImported) { 
		Ogre::TerrainGroup::TerrainIterator ti = mTerrainGroup->getTerrainIterator();
		while(ti.hasMoreElements()) { 
			Ogre::Terrain* t = ti.getNext()->instance; 
			initBlendMaps(t);
		}
	}
	mTerrainGroup->freeTemporaryResources();

	_werewolf.create("Werewolf");
	_werewolf.setMesh("Werewolf", "WereVixen.mesh");
	_werewolf.setPosition(Ogre::Vector3(1693, 20, 2090));
	_werewolf.setScale(Ogre::Vector3(5, 5, 5));
	_werewolf.rotate(Ogre::Radian(1.57), Ogre::Radian(3.14), Ogre::Radian(0));

	_monster.create("Mobbie");
	_monster.setMesh("Mobbie", "Spider.mesh", Action::ACT_IDLE | Action::ACT_WALK);
	_monster.setPosition(Ogre::Vector3(1708, 20, 2005));
	_monster.setScale(Ogre::Vector3(2, 2, 2));
	_monster.rotate(Ogre::Radian(0), Ogre::Radian(3.14), Ogre::Radian(0));
	
	_streetLamp.create("StreetLamp");
	_streetLamp.setMesh("StreetLamp", "StreetLamp1.mesh");
	_streetLamp.setPosition(Ogre::Vector3(1703, mTerrainGroup->getHeightAtWorldPosition(Ogre::Vector3(1703, 0, 1110)), 1110));
	_streetLamp.setScale(Ogre::Vector3(2.5, 2.5, 2.5));
	_streetLamp.setRotation(Ogre::Radian(0), Ogre::Radian(1.57), Ogre::Radian(0));

	_sellingHouse.create("SellingHouse");
	_sellingHouse.setMesh("SellingHouse", "SellingHouse.mesh");
	_sellingHouse.setPosition(Ogre::Vector3(1803,mTerrainGroup->getHeightAtWorldPosition(Ogre::Vector3(1903, 0, 1870)), 1570));
	_sellingHouse.setScale(Ogre::Vector3(2.0, 2.0, 2.0));

	Ogre::Plane skybox;
	skybox.d = 100; 
	skybox.normal = Ogre::Vector3::NEGATIVE_UNIT_Y;  
	gSceneManager->setSkyPlane(true, skybox, "Examples/CloudySky", 500, 20, true, 0.5, 150, 150); 

	// set camera
	_camera->setPosition(_werewolf.position()+Ogre::Vector3(0, 10, 100)); 
	_camera->lookAt(_werewolf.position());
	_camera->setNearClipDistance(5);  
	_camera->setFarClipDistance(0);
}
Exemplo n.º 18
0
void TerrainManager::terrainInit(Ogre::String file, OgreManager* o)
{
	_OgreManager = o;

	initialiseResources();

	createLight();

	setGlobalOptions();

	_TerrainGroup = OGRE_NEW Ogre::TerrainGroup(_OgreManager->getSceneManager(), Ogre::Terrain::ALIGN_X_Z, 513, 12000.0f);
	_TerrainGroup->setFilenameConvention(Ogre::String("GameTerrain"), Ogre::String("dat"));
	_TerrainGroup->setOrigin(Ogre::Vector3::ZERO);

	setDefaultImportSettings();

	bool lTerrainsImported = false;
	 for (long x = 0; x <= 0; ++x)
	 {
        for (long y = 0; y <= 0; ++y)
		{
			//Define terrain function
			 Ogre::String filename = _TerrainGroup->generateFilename(x, y);
			if (Ogre::ResourceGroupManager::getSingleton().resourceExists(_TerrainGroup->getResourceGroup(), filename))
			{
				_TerrainGroup->defineTerrain(x, y);
			}
			else
			{
				Ogre::Image img;
				//Get terrain image
				Ogre::String tempFile = Ogre::StringConverter::toString(x * 10 + y);
				tempFile.append(".bmp");
				img.load("terrain.bmp", Ogre::String("TerrainResources"));
					if (x % 2 != 0)
						img.flipAroundY();
					if (y % 2 != 0)
						img.flipAroundX();
				//Get terrain image end
				_TerrainGroup->defineTerrain(x, y, &img);
				lTerrainsImported = true;
			}
			//Define terrain function end
		}
	}
	
	_TerrainGroup->loadAllTerrains(true);

	if (lTerrainsImported)
    {
        Ogre::TerrainGroup::TerrainIterator ti = _TerrainGroup->getTerrainIterator();
        while(ti.hasMoreElements())
        {
            Ogre::Terrain* t = ti.getNext()->instance;
            //Init blend maps function start
			Ogre::TerrainLayerBlendMap* blendMap0 = t->getLayerBlendMap(1);
			Ogre::TerrainLayerBlendMap* blendMap1 = t->getLayerBlendMap(2);
			Ogre::Real minHeight0 = -10;
			Ogre::Real fadeDist0 = 0;//40;
			Ogre::Real minHeight1 = -10;
			Ogre::Real fadeDist1 = 0;//15;
			float* pBlend0 = blendMap0->getBlendPointer();
			float* pBlend1 = blendMap1->getBlendPointer();
			for (Ogre::uint16 y = 0; y < t->getLayerBlendMapSize(); ++y)
			{
				for (Ogre::uint16 x = 0; x < t->getLayerBlendMapSize(); ++x)
				{
					Ogre::Real tx, ty;
 
					blendMap0->convertImageToTerrainSpace(x, y, &tx, &ty);
					Ogre::Real height = t->getHeightAtTerrainPosition(tx, ty);
					Ogre::Real val = (height - minHeight0) / fadeDist0;
					val = Ogre::Math::Clamp(val, (Ogre::Real)0, (Ogre::Real)1);
					*pBlend0++ = val;
 
					val = (height - minHeight1) / fadeDist1;
					val = Ogre::Math::Clamp(val, (Ogre::Real)0, (Ogre::Real)1);
					*pBlend1++ = val;
				}
			}
			blendMap0->dirty();
			blendMap1->dirty();
			blendMap0->update();
			blendMap1->update();
			//Init blend maps end
        }
    }

	_TerrainGroup->freeTemporaryResources();

	_OgreManager->getSceneManager()->setSkyBox(true, "Examples/EarlyMorningSkyBox", 5000, true, Ogre::Quaternion::IDENTITY, "GameResources");
}