bool keyPressed( const OIS::KeyEvent &e )
  {
#if OGRE_PLATFORM != OGRE_PLATFORM_APPLE_IOS
    switch( e.key )
    {
      case OIS::KC_S:
        // CTRL-S to save
        if( mInputContext.isKeyDown( OIS::KC_LCONTROL ) || mInputContext.isKeyDown( OIS::KC_RCONTROL ) )
        {
          saveTerrains( true );
        }
        else
          return SdkSample::keyPressed( e );
        break;
      case OIS::KC_F10:
        // dump
      {
        TerrainGroup::TerrainIterator ti = mTerrainGroup->getTerrainIterator();
        while( ti.hasMoreElements() )
        {
          Ogre::uint32 tkey = ti.peekNextKey();
          TerrainGroup::TerrainSlot* ts = ti.getNext();
          if( ts->instance && ts->instance->isLoaded() )
          {
            ts->instance->_dumpTextures( "terrain_" + StringConverter::toString( tkey ), ".png" );
          }
        }
      }
      break;
      /*
    case OIS::KC_F7:
      // change terrain size
      if (mTerrainGroup->getTerrainSize() == 513)
        mTerrainGroup->setTerrainSize(1025);
      else
        mTerrainGroup->setTerrainSize(513);
      break;
    case OIS::KC_F8:
      // change terrain world size
      if (mTerrainGroup->getTerrainWorldSize() == TERRAIN_WORLD_SIZE)
        mTerrainGroup->setTerrainWorldSize(TERRAIN_WORLD_SIZE * 2);
      else
        mTerrainGroup->setTerrainWorldSize(TERRAIN_WORLD_SIZE);
      break;
      */
      default:
        return SdkSample::keyPressed( e );
    }
#endif
    return true;
  }
Esempio n. 2
0
Ogre::String TerrainGeometryManager::getCompositeMaterialName()
{
	TerrainGroup::TerrainIterator ti = mTerrainGroup->getTerrainIterator();

	while (ti.hasMoreElements())
	{
		Terrain *terrain = ti.getNext()->instance;
		if (!terrain) continue;
		MaterialPtr mat = terrain->getCompositeMapMaterial();
		if (!mat.isNull())
			return mat->getName();
	}

	return String();
}
Esempio n. 3
0
	void SnowTerrain::dumpTextures()
	{
		if(!mTerrainGroup) return;

		TerrainGroup::TerrainIterator ti = mTerrainGroup->getTerrainIterator();
		while (ti.hasMoreElements())
		{
			Ogre::uint32 tkey = ti.peekNextKey();
			TerrainGroup::TerrainSlot* ts = ti.getNext();
			if (ts->instance && ts->instance->isLoaded())
			{
				ts->instance->_dumpTextures("terrain_" + StringConverter::toString(tkey), ".png");
			}
		}
	}
Esempio n. 4
0
void TerrainGeometryManager::updateLightMap()
{
	TerrainGroup::TerrainIterator ti = mTerrainGroup->getTerrainIterator();

	while (ti.hasMoreElements())
	{
		Terrain *terrain = ti.getNext()->instance;
		if (!terrain) continue;
		//ShadowManager::getSingleton().updatePSSM(terrain);
		if (!terrain->isDerivedDataUpdateInProgress())
		{
			terrain->dirtyLightmap();
			terrain->updateDerivedData();
		}
	}
}
Esempio n. 5
0
void TerrainManager::initWater()
{
	String waterSettingsString = SSETTING("Water effects", "Hydrax");

	// disabled in global config
	if (waterSettingsString == "None") return;
	// disabled in map config
	if (!StringConverter::parseBool(m_terrain_config.getSetting("Water", "General"))) return;

	if (waterSettingsString == "Hydrax")
	{
		// try to load hydrax config
		String hydraxConfig = m_terrain_config.getSetting("HydraxConfigFile", "General");

		if (!hydraxConfig.empty() && ResourceGroupManager::getSingleton().resourceExistsInAnyGroup(hydraxConfig))
		{
			hw = new HydraxWater(m_terrain_config, hydraxConfig);
		}
		else
		{
			// no config provided, fall back to the default one
			hw = new HydraxWater(m_terrain_config);
		}

		
		water = hw;

		//Apply depth technique to the terrain
		TerrainGroup::TerrainIterator ti = geometry_manager->getTerrainGroup()->getTerrainIterator();
		while (ti.hasMoreElements())
		{
			Terrain* t = ti.getNext()->instance;
			MaterialPtr ptr = t->getMaterial();
			hw->GetHydrax()->getMaterialManager()->addDepthTechnique(ptr->createTechnique());
		}

	} else
	{
		if (water == nullptr)
			water = new Water(m_terrain_config);
		else if (water != nullptr)
		{
			delete(water);
			water = new Water(m_terrain_config);
		}
	}
}
Esempio n. 6
0
NxScene3DObjectPagedGrass::NxScene3DObjectPagedGrass( Ogre::Camera * Cam, NxScene3DObjectTerrain * TerrainPtr, const NxPagedGrassDesc & GrassDesc )
{
	TerrainGroup::TerrainIterator ti = TerrainPtr->GetTerrainGroup()->getTerrainIterator();
	Terrain * LastTerrain; int i = 0;
	while( ti.hasMoreElements()){
		i++;
		LastTerrain = ti.getNext()->instance; 
	}

	mGrass = new PagedGeometry( Cam, GrassDesc.mPageSize );
	mGrass->addDetailLevel<GrassPage>( GrassDesc.mMaxRange );

	//Create a GrassLoader object
	GrassLoader * grassLoader = new GrassLoader(mGrass);
	mGrass->setPageLoader(grassLoader);	//Assign the "treeLoader" to be used to load geometry for the PagedGeometry instance
	grassLoader->setHeightFunction(&getGrassTerrainHeight, LastTerrain );
	mGrass->setShadersEnabled(true);
}
Esempio n. 7
0
void TerrainManager::initWater()
{
    // disabled in global config
    if (App::gfx_water_mode.GetActive() == GfxWaterMode::NONE)
        return;

    // disabled in map config
    if (!m_def.has_water)
    {
        return;
    }

    if (App::gfx_water_mode.GetActive() == GfxWaterMode::HYDRAX)
    {
        // try to load hydrax config
        if (!m_def.hydrax_conf_file.empty() && ResourceGroupManager::getSingleton().resourceExistsInAnyGroup(m_def.hydrax_conf_file))
        {
            m_hydrax_water = new HydraxWater(m_def.water_height, m_def.hydrax_conf_file);
        }
        else
        {
            // no config provided, fall back to the default one
            m_hydrax_water = new HydraxWater(m_def.water_height);
        }

        m_water = std::unique_ptr<IWater>(m_hydrax_water);

        //Apply depth technique to the terrain
        TerrainGroup::TerrainIterator ti = m_geometry_manager->getTerrainGroup()->getTerrainIterator();
        while (ti.hasMoreElements())
        {
            Terrain* t = ti.getNext()->instance;
            MaterialPtr ptr = t->getMaterial();
            m_hydrax_water->GetHydrax()->getMaterialManager()->addDepthTechnique(ptr->createTechnique());
        }
    }
    else
    {
        m_water = std::unique_ptr<IWater>(new Water());
        m_water->SetStaticWaterHeight(m_def.water_height);
        m_water->SetWaterBottomHeight(m_def.water_bottom_height);
    }
}
Esempio n. 8
0
	Terrain* SnowTerrain::getTerrain()
	{
		if(!mTerrainGroup) return NULL;

		Terrain *t =  mTerrainGroup->getTerrain(0,0);
		return t;

		TerrainGroup::TerrainIterator ti = mTerrainGroup->getTerrainIterator();
		while (ti.hasMoreElements())
		{
			Ogre::uint32 tkey = ti.peekNextKey();
			TerrainGroup::TerrainSlot* ts = ti.getNext();
			if (ts->instance && ts->instance->isLoaded())
			{

				float* heights = ts->instance->getHeightData();

				//PixelBox* pBox = ts->instance->calculateNormals());
				TexturePtr texturePtr = ts->instance->getTerrainNormalMap();
				HardwarePixelBufferSharedPtr buf = texturePtr->getBuffer();

				size_t bytes = buf->getSizeInBytes();
				size_t h = buf->getHeight();
				size_t w = buf->getWidth();
				size_t d = buf->getDepth();
				PixelFormat f = PF_BYTE_RGB;//buf->getFormat();


				uint8* tmpData = (uint8*)OGRE_MALLOC(w * h * 3, MEMCATEGORY_GENERAL);
				memset(tmpData,0,w*h*3);
				PixelBox pBox(w, h, d, f, tmpData);
				buf->blitToMemory(pBox);
				OGRE_FREE(tmpData, MEMCATEGORY_GENERAL);
				
			}
		}
		return NULL;
	}
Esempio n. 9
0
///--------------------------------------------------------------------------------------------------------------
//  Create Terrain
///--------------------------------------------------------------------------------------------------------------
void CScene::CreateTerrain(bool bNewHmap, bool bTer, bool terLoad)
{
	Ogre::Timer tm;
	terrain = 0;

	
	///  sky
	Vector3 scl = app->pSet->view_distance*Vector3::UNIT_SCALE;
	CreateSkyDome(sc->skyMtr, scl, sc->skyYaw);
	UpdFog();

	//  light
	app->mSceneMgr->destroyAllLights();
	sun = app->mSceneMgr->createLight("Sun");
	sun->setType(Light::LT_DIRECTIONAL);  UpdSun();


if (bTer)
{
	///.
	UpdShaderParams();
	UpdLayerPars();
	

	///  --------  fill HeightField data --------
	//Ogre::Timer ti;
	if (terLoad || bNewHmap)
	{
		int wx = sc->td.iVertsX, wy = sc->td.iVertsY, wxy = wx * wy;  //wy=wx
		delete[] sc->td.hfHeight;  sc->td.hfHeight = new float[wxy];
		const int size = wxy * sizeof(float);

		String name = app->gcom->TrkDir() + (bNewHmap ? "heightmap-new.f32" : "heightmap.f32");

		//  load from f32 HMap +
		{
			std::ifstream fi;
			fi.open(name.c_str(), std::ios_base::binary);
			fi.read((char*)&sc->td.hfHeight[0], size);
			fi.close();
		}
	}

	CreateBlendTex();  //+

	//LogO(String("::: Time Hmap: ") + fToStr(ti.getMilliseconds(),0,3) + " ms");  ti.reset();  // 4MB ~13ms


	///.
	UpdBlendmap();
	

	//  Terrain
	{
		if (!mTerrainGlobals)
			mTerrainGlobals = OGRE_NEW TerrainGlobalOptions();
		OGRE_DELETE mTerrainGroup;

		mTerrainGroup = OGRE_NEW TerrainGroup(app->mSceneMgr, Terrain::ALIGN_X_Z,
			sc->td.iTerSize, sc->td.fTerWorldSize);
		mTerrainGroup->setOrigin(Vector3::ZERO);

		SetupTerrain();

		if (sc->td.hfHeight)
			mTerrainGroup->defineTerrain(0,0, sc->td.hfHeight);
		else
			mTerrainGroup->defineTerrain(0,0, 0.f);

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

		TerrainGroup::TerrainIterator ti = mTerrainGroup->getTerrainIterator();
		while (ti.hasMoreElements())
		{
			Terrain* t = ti.getNext()->instance;
			terrain = t;  //<set
			terrain->setVisibilityFlags(RV_Terrain);
		}
		mTerrainGroup->freeTemporaryResources();
	}

	//  Horizon  ----------
	if (app->pSet->horizon)
	{
		if (!mHorizonGlobals)
			mHorizonGlobals = OGRE_NEW TerrainGlobalOptions();
		OGRE_DELETE mHorizonGroup;

		mHorizonGroup = OGRE_NEW TerrainGroup(app->mSceneMgr, Terrain::ALIGN_X_Z,
			sc->td.iTerSize, sc->td.fTerWorldSize * 16.f);
		mHorizonGroup->setOrigin(Vector3::ZERO);

		SetupHorizon();

		//if (sc->td.hfHeight)
		//	mHorizonGroup->defineTerrain(0,0, sc->td.hfHeight);
		//else
			mHorizonGroup->defineTerrain(0,0, 0.f);

		mHorizonGroup->loadAllTerrains(true);

		TerrainGroup::TerrainIterator ti = mHorizonGroup->getTerrainIterator();
		while (ti.hasMoreElements())
		{
			Terrain* t = ti.getNext()->instance;
			//initBlendMaps(t);
			horizon = t;  //<set
			horizon->setVisibilityFlags(RV_Terrain);
		}
		mHorizonGroup->freeTemporaryResources();
	}
}//bTer

	
	///.
	changeShadows();

	//UpdBlendmap();  //-

	LogO(String("::: Time Terrain: ") + fToStr(tm.getMilliseconds(),0,3) + " ms");
}
Esempio n. 10
0
Geometry::Geometry()
	: mTerrainGroup(0)
	, mTerrainPaging(0)
	, mPageManager(0)
	, mPagedWorld(0)
	, mTerrainPagedWorldSection(0)
	, mTerrainPos(0, 0, 0) {
		
		setupView();
		m_TrayMgr = InputHandler::getSingleton()->getSdkTrayMgr();
		mInfoLabel = m_TrayMgr->createLabel(OgreBites::TL_TOP, "TInfo", "", 350);

		mTerrainGlobals = OGRE_NEW TerrainGlobalOptions();

		//setDragLook(true);

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

		//OgreTrip::getSceneMgr()->setFog(FOG_LINEAR, ColourValue(0.7, 0.7, 0.8), 0, 4000, 10000);

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

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

		Light * l = OgreTrip::getSceneMgr()->createLight("tstLight");
		l->setType(Light::LT_DIRECTIONAL);
		l->setDirection(lightdir);
		l->setDiffuseColour(ColourValue::White);
		l->setSpecularColour(ColourValue(0.4, 0.4, 0.4));

		OgreTrip::getSceneMgr()->setAmbientLight(ColourValue(0.5f, 0.5f, 0.5f));

		mTerrainGroup = OGRE_NEW TerrainGroup(OgreTrip::getSceneMgr(), Terrain::ALIGN_X_Z, TERRAIN_SIZE, TERRAIN_WORLD_SIZE);
		mTerrainGroup->setFilenameConvention(ENDLESS_TERRAIN_FILE_PREFIX, ENDLESS_TERRAIN_FILE_SUFFIX);
		mTerrainGroup->setOrigin(mTerrainPos);
		mTerrainGroup->setAutoUpdateLod( TerrainAutoUpdateLodFactory::getAutoUpdateLod(BY_DISTANCE) );

		configureTerrainDefaults(l);

		// Paging setup
		mPageManager = OGRE_NEW PageManager();
		// Since we're not loading any pages from .page files, we need a way just
		// to say we've loaded them without them actually being loaded
		mPageManager->setPageProvider( & mDummyPageProvider);
		mPageManager->addCamera(OgreTrip::getCamera());
		mPageManager->setDebugDisplayLevel(0);
		mTerrainPaging = OGRE_NEW TerrainPaging(mPageManager);
		mPagedWorld = mPageManager->createWorld();
		mTerrainPagedWorldSection = mTerrainPaging->createWorldSection(mPagedWorld, mTerrainGroup, 400, 500,
			ENDLESS_PAGE_MIN_X, ENDLESS_PAGE_MIN_Y,
			ENDLESS_PAGE_MAX_X, ENDLESS_PAGE_MAX_Y);

		//      mPerlinNoiseTerrainGenerator = OGRE_NEW PerlinNoiseTerrainGenerator;
		//      mTerrainPagedWorldSection->setDefiner( mPerlinNoiseTerrainGenerator );
		mTerrainPagedWorldSection->setDefiner( OGRE_NEW SimpleTerrainDefiner );
		TerrainGroup::TerrainIterator ti = mTerrainGroup->getTerrainIterator();
		while(ti.hasMoreElements())
		{
			Terrain* t = ti.getNext()->instance;
			initBlendMaps(t);
		}
		mTerrainGroup->freeTemporaryResources();

		OgreTrip::getSceneMgr()->setSkyBox(true, "Examples/CloudyNoonSkyBox");
		


}
Esempio n. 11
0
	//-------------------------------------------------------------------------------------
	void SnowTerrain::createScene(Ogre::SceneManager* sceneMgr, Light* terrainLight)
	{
		mSceneMgr = sceneMgr;

		mTerrainGroup = OGRE_NEW TerrainGroup(mSceneMgr, Terrain::ALIGN_X_Z, mTerrainSize, mTerrainWorldSize);
		mTerrainGroup->setFilenameConvention(TERRAIN_FILE_PREFIX, TERRAIN_FILE_SUFFIX);
		//mTerrainGroup->setOrigin(mTerrainPos);
		mTerrainGroup->setOrigin(mTerrainPos + Ogre::Vector3(mTerrainWorldSize / 2, 0, mTerrainWorldSize / 2));

		// Configure global
		mTerrainGlobals->setMaxPixelError(20); // set to 1 if using 1 unit/1 metre (ie pagesize of 1024)
		//mTerrainGlobals->setCompositeMapDistance(3000);
		mTerrainGlobals->setCompositeMapDistance(100000);
		//mTerrainGlobals->setUseRayBoxDistanceCalculation(true);
		//mTerrainGlobals->getDefaultMaterialGenerator()->setDebugLevel(1);
		mTerrainGlobals->setLightMapSize(256);

		//matProfile->setLightmapEnabled(false);

		// Important to set these so that the terrain knows what to use for derived (non-realtime) data
		mTerrainGlobals->setLightMapDirection(terrainLight->getDerivedDirection());
		mTerrainGlobals->setCompositeMapAmbient(mSceneMgr->getAmbientLight());
		//mTerrainGlobals->setCompositeMapAmbient(ColourValue::Red);
		mTerrainGlobals->setCompositeMapDiffuse(terrainLight->getDiffuseColour());

		// Configure default import settings for if we use imported image
		Terrain::ImportData& defaultimp = mTerrainGroup->getDefaultImportSettings();
		defaultimp.terrainSize = mSnowConfig->terrainSettings.size;
		defaultimp.worldSize = mTerrainWorldSize;
		defaultimp.inputScale = mSnowConfig->terrainSettings.worldScale;
		defaultimp.inputBias = 0;

		defaultimp.minBatchSize = 33;
		defaultimp.maxBatchSize = 65;

		// textures
		TextureLayerFileList diffSpecList = mSnowConfig->terrainSettings.textureLayerDiffSpecFileList;
		TextureLayerFileList normalHeightList = mSnowConfig->terrainSettings.textureLayerNormalHeightFileList;

		size_t textureLayers = std::max(diffSpecList.size(), normalHeightList.size());

		defaultimp.layerList.resize(std::max((size_t)1,textureLayers));
		for(int i = 0; i < textureLayers; i++)
		{
			defaultimp.layerList[i].worldSize =  mTerrainWorldSize;
			if(diffSpecList.size() >= i)
				defaultimp.layerList[i].textureNames.push_back(diffSpecList[i]);

			if(normalHeightList.size() >= i)
				defaultimp.layerList[i].textureNames.push_back(normalHeightList[i]);
		}

		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, mSnowConfig->terrainSettings.flat);

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

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

		mTerrainGroup->freeTemporaryResources();

		// create/show debug normals
		if(mSnowConfig->terrainSettings.showDebugNormals)
		{
			mDebugNormalsManualObject = createDebugNormals(mSceneMgr);
			mDebugNormalsNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
			mDebugNormalsNode->attachObject(mDebugNormalsManualObject);
		}

	}
  void setupContent()
  {
    bool blankTerrain = false;
    //blankTerrain = true;
    mTerrainGlobals = OGRE_NEW TerrainGlobalOptions();

    ResourceGroupManager::getSingleton().createResourceGroup( "Terrain" );
    ResourceGroupManager::getSingleton().addResourceLocation( mFSLayer->getWritablePath( "" ), "FileSystem", "Terrain", false, false );

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

    setupControls();

    mCameraMan->setTopSpeed( 50 );

    setDragLook( true );

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

    mSceneMgr->setFog( FOG_LINEAR, ColourValue( 0.7, 0.7, 0.8 ), 0, 10000, 25000 );

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

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

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

    mSceneMgr->setAmbientLight( ColourValue( 0.2, 0.2, 0.2 ) );

    mTerrainGroup = OGRE_NEW TerrainGroup( mSceneMgr, Terrain::ALIGN_X_Z, TERRAIN_SIZE, TERRAIN_WORLD_SIZE );
    mTerrainGroup->setFilenameConvention( TERRAIN_FILE_PREFIX, TERRAIN_FILE_SUFFIX );
    mTerrainGroup->setOrigin( mTerrainPos );
    mTerrainGroup->setResourceGroup( "Terrain" );

    configureTerrainDefaults( l );
#ifdef PAGING
    // Paging setup
    mPageManager = OGRE_NEW PageManager();
    // Since we're not loading any pages from .page files, we need a way just 
    // to say we've loaded them without them actually being loaded
    mPageManager->setPageProvider( &mDummyPageProvider );
    mPageManager->addCamera( mCamera );
    mTerrainPaging = OGRE_NEW TerrainPaging( mPageManager );
    PagedWorld* world = mPageManager->createWorld();
    mTerrainPaging->createWorldSection( world, mTerrainGroup, 2000, 3000,
      TERRAIN_PAGE_MIN_X, TERRAIN_PAGE_MIN_Y,
      TERRAIN_PAGE_MAX_X, TERRAIN_PAGE_MAX_Y );
#else
    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, blankTerrain );
    // sync load since we want everything in place when we start
    mTerrainGroup->loadAllTerrains( true );
#endif
    if( mTerrainsImported )
    {
      TerrainGroup::TerrainIterator ti = mTerrainGroup->getTerrainIterator();
      while( ti.hasMoreElements() )
      {
        Terrain* t = ti.getNext()->instance;
        initBlendMaps( t );
      }
    }

    mTerrainGroup->freeTemporaryResources();
    // create a few entities on the terrain
    Entity* e = mSceneMgr->createEntity( "tudorhouse.mesh" );
    Vector3 entPos( mTerrainPos.x + 2043, 0, mTerrainPos.z + 1715 );
    Quaternion rot;
    entPos.y = mTerrainGroup->getHeightAtWorldPosition( entPos ) + 65.5 + mTerrainPos.y;
    rot.FromAngleAxis( Degree( Math::RangeRandom( -180, 180 ) ), Vector3::UNIT_Y );
    SceneNode* sn = mSceneMgr->getRootSceneNode()->createChildSceneNode( entPos, rot );
    sn->setScale( Vector3( 0.12, 0.12, 0.12 ) );
    sn->attachObject( e );
    mHouseList.push_back( e );

    e = mSceneMgr->createEntity( "tudorhouse.mesh" );
    entPos = Vector3( mTerrainPos.x + 1850, 0, mTerrainPos.z + 1478 );
    entPos.y = mTerrainGroup->getHeightAtWorldPosition( entPos ) + 65.5 + mTerrainPos.y;
    rot.FromAngleAxis( Degree( Math::RangeRandom( -180, 180 ) ), Vector3::UNIT_Y );
    sn = mSceneMgr->getRootSceneNode()->createChildSceneNode( entPos, rot );
    sn->setScale( Vector3( 0.12, 0.12, 0.12 ) );
    sn->attachObject( e );
    mHouseList.push_back( e );

    e = mSceneMgr->createEntity( "tudorhouse.mesh" );
    entPos = Vector3( mTerrainPos.x + 1970, 0, mTerrainPos.z + 2180 );
    entPos.y = mTerrainGroup->getHeightAtWorldPosition( entPos ) + 65.5 + mTerrainPos.y;
    rot.FromAngleAxis( Degree( Math::RangeRandom( -180, 180 ) ), Vector3::UNIT_Y );
    sn = mSceneMgr->getRootSceneNode()->createChildSceneNode( entPos, rot );
    sn->setScale( Vector3( 0.12, 0.12, 0.12 ) );
    sn->attachObject( e );
    mHouseList.push_back( e );

    mSceneMgr->setSkyBox( true, "Examples/CloudyNoonSkyBox" );
  }
void NxOgreSample_TerrainApp::createScene()
{
	using namespace Ogre;
	ColourValue background = ColourValue(135.0f/255.f, 206.f/255.f, 235.f/255.f);
	//mCameraMan->getCamera()->getViewport()->setBackgroundColour(background);

	// add a bright light above the scene
	mLight = mSceneMgr->createLight();
	mLight->setType(Light::LT_POINT);
	mLight->setPosition(-10, 40, 20);
	mLight->setSpecularColour(ColourValue::White);

	mCameraMan->getCamera()->setPosition(10,10,10);
	mCameraMan->getCamera()->lookAt(0,0,0);
	mCameraMan->getCamera()->setNearClipDistance(0.02f);
	mCameraMan->getCamera()->setFarClipDistance(1000);
	mCameraMan->setTopSpeed(200);

	mSceneMgr->setSkyBox(true, "Examples/CloudyNoonSkyBox");
	mSceneMgr->setAmbientLight(ColourValue::White);

	setupPhysX();

	mTerrainGlobals = OGRE_NEW TerrainGlobalOptions();
	mTerrainGroup = OGRE_NEW TerrainGroup(mSceneMgr, Terrain::ALIGN_X_Z, 65, 1000);
	mTerrainGroup->setOrigin(Ogre::Vector3(0,-40,0));

	// Configure global
	mTerrainGlobals->setMaxPixelError(8);
	// testing composite map
	mTerrainGlobals->setCompositeMapDistance(3000);
	//mTerrainGlobals->setUseRayBoxDistanceCalculation(true);
	//mTerrainGlobals->getDefaultMaterialGenerator()->setDebugLevel(1);
	//mTerrainGlobals->setLightMapSize(256);

	//matProfile->setLightmapEnabled(false);
	// Important to set these so that the terrain knows what to use for derived (non-realtime) data
	mTerrainGlobals->setLightMapDirection(mLight->getDerivedDirection());
	mTerrainGlobals->setCompositeMapAmbient(mSceneMgr->getAmbientLight());
	//mTerrainGlobals->setCompositeMapAmbient(ColourValue::Red);
	mTerrainGlobals->setCompositeMapDiffuse(ColourValue::White);

	// Configure default import settings for if we use imported image
	Terrain::ImportData& defaultimp = mTerrainGroup->getDefaultImportSettings();
	defaultimp.terrainSize = 65;
	defaultimp.worldSize = 1000;
	defaultimp.inputScale = 10;
	defaultimp.minBatchSize = 33;
	defaultimp.maxBatchSize = 65;
	// textures
	defaultimp.layerList.resize(3);
	defaultimp.layerList[0].worldSize = 100;
	defaultimp.layerList[0].textureNames.push_back("dirt_grayrocky_diffusespecular.dds");
	defaultimp.layerList[0].textureNames.push_back("dirt_grayrocky_normalheight.dds");
	defaultimp.layerList[1].worldSize = 30;
	defaultimp.layerList[1].textureNames.push_back("grass_green-01_diffusespecular.dds");
	defaultimp.layerList[1].textureNames.push_back("grass_green-01_normalheight.dds");
	defaultimp.layerList[2].worldSize = 200;
	defaultimp.layerList[2].textureNames.push_back("growth_weirdfungus-03_diffusespecular.dds");
	defaultimp.layerList[2].textureNames.push_back("growth_weirdfungus-03_normalheight.dds");

	Image img;
	img.load("terrain.png", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
	mTerrainGroup->defineTerrain(0, 0,&img);
	//mTerrainGroup->defineTerrain(-1, 0,&img);
	//mTerrainGroup->defineTerrain(0, -1,&img);
	//mTerrainGroup->defineTerrain(0, 0,&img);

	mTerrainGroup->loadAllTerrains(true);
	TerrainGroup::TerrainIterator ti = mTerrainGroup->getTerrainIterator();
	while(ti.hasMoreElements())
	{
		Terrain* terrain = ti.getNext()->instance;
		TerrainLayerBlendMap* blendMap0 = terrain->getLayerBlendMap(1);
		TerrainLayerBlendMap* blendMap1 = terrain->getLayerBlendMap(2);
		Ogre::Real minHeight0 = 70;
		Ogre::Real fadeDist0 = 40;
		Ogre::Real minHeight1 = 70;
		Ogre::Real fadeDist1 = 15;
		float * pBlend0 = blendMap0->getBlendPointer();
		float* pBlend1 = blendMap1->getBlendPointer();
		for (Ogre::uint16 y = 0; y < terrain->getLayerBlendMapSize(); ++y)
		{
			for (Ogre::uint16 x = 0; x < terrain->getLayerBlendMapSize(); ++x)
			{
				Ogre::Real tx, ty;

				blendMap0->convertImageToTerrainSpace(x, y, &tx, &ty);
				Ogre::Real height = terrain->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->loadImage("blendmap1.png", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
		blendMap0->update();
		blendMap1->update();

		// set up a colour map
		
		/*if (!terrain->getGlobalColourMapEnabled())
		{
		terrain->setGlobalColourMapEnabled(true);
		Image colourMap;
		colourMap.load("RustedMetal.jpg", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
		terrain->getGlobalColourMap()->loadImage(colourMap);
		}*/
		
	}
	mTerrainGroup->freeTemporaryResources();	

	NxOgre::SceneGeometry * sg;
	mTruck = new Truck(mRenderSystem);

	ti = mTerrainGroup->getTerrainIterator();
	while (ti.hasMoreElements())
	{
		Terrain * t = ti.getNext()->instance;
		sg = mRenderSystem->createTerrain(t);
	}

	//mRaySceneQuery = mSceneMgr->createRayQuery(Ogre::Ray());
	//sg->getNxActor()->setForceFieldMaterial(0);
	NxOgre::Material * mat = mScene->getMaterial(0);
	mat->setAll(0.0f,2.0f,1.0f);
	
	NxOgre::MaterialDescription m;
	m.mRestitution = 0;
	m.mStaticFriction = 1.2;
	m.mDynamicFriction = 1;
	NxOgre::MaterialIdentifier wheelMat = mScene->createMaterial(m)->getIdentifier();
	m.mStaticFriction = 2;
	m.mDynamicFriction = 1;
	sg->getNxActor()->setForceFieldMaterial(mScene->createMaterial(m)->getIdentifier());

	mTruck->create(*mScene,*(sg->getNxActor()),wheelMat);	

	//mCameraMan->setStyle(OgreBites::CS_ORBIT);
	//mCameraMan->setTarget(mTruck->tractor->getSceneNode());
	//mCameraMan->setYawPitchDist(Ogre::Radian(5),Ogre::Radian(5),2);

 }
Esempio n. 14
0
void HydraxSample1App::createTerrain()
{
	using namespace Ogre;
	mTerrainGlobals = OGRE_NEW TerrainGlobalOptions();
	mTerrainGroup = OGRE_NEW TerrainGroup(mSceneMgr, Terrain::ALIGN_X_Z, 65, 10200);
	mTerrainGroup->setOrigin(Ogre::Vector3(0,22,0));

	// Configure global
	mTerrainGlobals->setMaxPixelError(8);
	// testing composite map
	mTerrainGlobals->setCompositeMapDistance(3000);

	//matProfile->setLightmapEnabled(false);
	// Important to set these so that the terrain knows what to use for derived (non-realtime) data
	//mTerrainGlobals->setLightMapDirection(mLight->getDerivedDirection());
	mTerrainGlobals->setCompositeMapAmbient(mSceneMgr->getAmbientLight());
	//mTerrainGlobals->setCompositeMapAmbient(ColourValue::Red);
	mTerrainGlobals->setCompositeMapDiffuse(ColourValue::White);

	// Configure default import settings for if we use imported image
	Terrain::ImportData& defaultimp = mTerrainGroup->getDefaultImportSettings();
	defaultimp.terrainSize = 65;
	defaultimp.worldSize = 10200;
	defaultimp.inputScale = 400;
	defaultimp.minBatchSize = 33;
	defaultimp.maxBatchSize = 65;
	// textures
	defaultimp.layerList.resize(3);
	defaultimp.layerList[0].worldSize = 100;
	defaultimp.layerList[0].textureNames.push_back("dirt_grayrocky_diffusespecular.dds");
	defaultimp.layerList[0].textureNames.push_back("dirt_grayrocky_normalheight.dds");
	defaultimp.layerList[1].worldSize = 30;
	defaultimp.layerList[1].textureNames.push_back("grass_green-01_diffusespecular.dds");
	defaultimp.layerList[1].textureNames.push_back("grass_green-01_normalheight.dds");
	defaultimp.layerList[2].worldSize = 200;
	defaultimp.layerList[2].textureNames.push_back("growth_weirdfungus-03_diffusespecular.dds");
	defaultimp.layerList[2].textureNames.push_back("growth_weirdfungus-03_normalheight.dds");

	Image img;
	img.load("terrain.png", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
	mTerrainGroup->defineTerrain(0, 0,&img);

	mTerrainGroup->loadAllTerrains(true);
	TerrainGroup::TerrainIterator ti = mTerrainGroup->getTerrainIterator();
	while(ti.hasMoreElements())
	{
		Terrain* terrain = ti.getNext()->instance;
		TerrainLayerBlendMap* blendMap0 = terrain->getLayerBlendMap(1);
		TerrainLayerBlendMap* blendMap1 = terrain->getLayerBlendMap(2);
		Ogre::Real minHeight0 = 70;
		Ogre::Real fadeDist0 = 40;
		Ogre::Real minHeight1 = 70;
		Ogre::Real fadeDist1 = 15;
		float * pBlend0 = blendMap0->getBlendPointer();
		float* pBlend1 = blendMap1->getBlendPointer();
		for (Ogre::uint16 y = 0; y < terrain->getLayerBlendMapSize(); ++y)
		{
			for (Ogre::uint16 x = 0; x < terrain->getLayerBlendMapSize(); ++x)
			{
				Ogre::Real tx, ty;

				blendMap0->convertImageToTerrainSpace(x, y, &tx, &ty);
				Ogre::Real height = terrain->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();
	}
	mTerrainGroup->freeTemporaryResources();	
}
Esempio n. 15
0
void begin_terrain(BATB& batb)
{
// http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Basic+Tutorial+3
// http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Ogre+Terrain+System
// libs/ogre/Samples/EndlessWorld/include/EndlessWorld.h

#ifdef USE_SAMPLE_TERRAIN
    if (!Ogre::ResourceGroupManager::getSingleton().resourceGroupExists("Terrain"))
        Ogre::ResourceGroupManager::getSingleton().createResourceGroup("Terrain");
#endif

    // create object, which becomes a singleton
    // Terrain::setResourceGroup overrides this (??)
    terrain_globals = OGRE_NEW TerrainGlobalOptions();


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

#ifdef USE_SAMPLE_ENDLESSWORLD
    scenemgr->setFog(FOG_LINEAR, ColourValue(0.7, 0.7, 0.8), 0, 4000, 10000);
#endif
#ifdef USE_SAMPLE_TERRAIN
    scenemgr->setFog(FOG_LINEAR, ColourValue(0.7, 0.7, 0.8), 0, 10000, 25000); // Terrain
#endif


    //LogManager::getSingleton().setLogDetail(LL_BOREME); // ??

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

    Light* l = scenemgr->createLight("tstLight");
    l->setType(Light::LT_DIRECTIONAL);
    l->setDirection(lightdir);
    l->setDiffuseColour(ColourValue::White);
#ifdef USE_SAMPLE_ENDLESSWORLD
    l->setSpecularColour(ColourValue(0.1, 0.1, 0.1));
#endif
#ifdef USE_SAMPLE_TERRAIN
    l->setSpecularColour(ColourValue(0.4, 0.4, 0.4));
#endif

    scenemgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5));

    terrain_group = OGRE_NEW TerrainGroup(scenemgr, Terrain::ALIGN_X_Z, TERRAIN_SIZE, TERRAIN_WORLD_SIZE);
#ifdef USE_SAMPLE_ENDLESSWORLD
    terrain_group->setFilenameConvention(ENDLESS_TERRAIN_FILE_PREFIX, ENDLESS_TERRAIN_FILE_SUFFIX);
    terrain_group->setAutoUpdateLod( TerrainAutoUpdateLodFactory::getAutoUpdateLod(BY_DISTANCE) );
#endif
#ifdef USE_SAMPLE_TERRAIN
    terrain_group->setFilenameConvention(TERRAIN_FILE_PREFIX, TERRAIN_FILE_SUFFIX);
    terrain_group->setResourceGroup("Terrain");
#endif


////////////////////////////////////////////////////////////////////////////////
// configureTerrainDefaults
//
    // Configure global
    terrain_globals->setMaxPixelError(8);
    // testing composite map
    terrain_globals->setCompositeMapDistance(3000);
    //terrain_globals->setUseRayBoxDistanceCalculation(true);
    terrain_globals->getDefaultMaterialGenerator()->setLightmapEnabled(false);

    terrain_globals->setCompositeMapAmbient(scenemgr->getAmbientLight());
    terrain_globals->setCompositeMapDiffuse(l->getDiffuseColour());    terrain_globals->setLightMapDirection(l->getDerivedDirection());

    // Configure default import settings for if we use imported image
    Terrain::ImportData& defaultimp = terrain_group->getDefaultImportSettings();
    defaultimp.terrainSize = TERRAIN_SIZE;
    defaultimp.worldSize = TERRAIN_WORLD_SIZE;
    defaultimp.inputScale = 600;
    defaultimp.minBatchSize = 33;
    defaultimp.maxBatchSize = 65;
    // textures
    // see 'initBlendMaps' below 
    defaultimp.layerList.resize(3);
    defaultimp.layerList[0].worldSize = 100; // scale layer
    defaultimp.layerList[0].textureNames.push_back("dirt_grayrocky_diffusespecular.dds");
    defaultimp.layerList[0].textureNames.push_back("dirt_grayrocky_normalheight.dds");
    defaultimp.layerList[1].worldSize = 30; // scale layer
    defaultimp.layerList[1].textureNames.push_back("grass_green-01_diffusespecular.dds");
    defaultimp.layerList[1].textureNames.push_back("grass_green-01_normalheight.dds");
    defaultimp.layerList[2].worldSize = 200; // scale layer
    defaultimp.layerList[2].textureNames.push_back("growth_weirdfungus-03_diffusespecular.dds");
    defaultimp.layerList[2].textureNames.push_back("growth_weirdfungus-03_normalheight.dds");
////////////////////////////////////////////////////////////////////////////////

    // Paging setup
#ifndef USE_SAMPLE_TERRAIN
    page_manager = OGRE_NEW PageManager();
    // Since we're not loading any pages from .page files, we need a way just 
    // to say we've loaded them without them actually being loaded
    page_manager->setPageProvider(&dummy_page_provider);
    page_manager->addCamera(camera);
    page_manager->setDebugDisplayLevel(0);
    terrain_paging = OGRE_NEW TerrainPaging(page_manager);
    paged_world = page_manager->createWorld();
    paged_world_section = terrain_paging->createWorldSection(paged_world, terrain_group, 
#ifdef USE_SAMPLE_ENDLESSWORLD
            400, 500, 
            ENDLESS_PAGE_MIN_X, ENDLESS_PAGE_MIN_Y, 
            ENDLESS_PAGE_MAX_X, ENDLESS_PAGE_MAX_Y);
#endif
#ifdef USE_SAMPLE_TERRAIN
            400, 500, 
            ENDLESS_PAGE_MIN_X, ENDLESS_PAGE_MIN_Y, 
            ENDLESS_PAGE_MAX_X, ENDLESS_PAGE_MAX_Y);
            //2000, 3000,
            //TERRAIN_PAGE_MIN_X, TERRAIN_PAGE_MIN_Y,
            //TERRAIN_PAGE_MAX_X, TERRAIN_PAGE_MAX_Y);
#endif
#endif

#ifdef USE_SAMPLE_ENDLESSWORLD
    perlin_noise = OGRE_NEW PerlinNoiseTerrainGenerator( 3.3, 2.2, 10, 128, 0.4 );
    paged_world_section->setDefiner( perlin_noise );
//		paged_world_section->setDefiner( OGRE_NEW SimpleTerrainDefiner );

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

#endif
#ifdef USE_SAMPLE_TERRAIN
    bool blankTerrain = false;
    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, blankTerrain);
    // sync load since we want everything in place when we start
    terrain_group->loadAllTerrains(true);
    // ^FIXME:
    //  loadAllTerrains does something to our GL context/state, causing wrong output until
    //  OGRE::output called. the error is caused in OgreTerrainGroup::loadTerrainImpl when
    //  a work request is added to Ogre. The request handler is OgreTerrainGroup, but I 
    //  have not tracked the error there and further down.

    if (terrains_imported)
    {
        TerrainGroup::TerrainIterator ti = terrain_group->getTerrainIterator();
        while(ti.hasMoreElements())
        {
            Terrain* t = ti.getNext()->instance;
            initBlendMaps(t);
        }
    }
#endif

    terrain_group->freeTemporaryResources();

    scenemgr->setSkyBox(true, "Examples/CloudyNoonSkyBox");

#ifdef USE_SAMPLE_TERRAIN
    camera->setPosition(terrain_pos + Vector3(1683, 50, 2116));
    camera->lookAt(Vector3(1963, 50, 1660));
    camera->setNearClipDistance(0.1);
    camera->setFarClipDistance(50000);
#endif
#ifdef USE_SAMPLE_ENDLESSWORLD
    // view
    Vector3 worldCenter(
            (ENDLESS_PAGE_MAX_X+ENDLESS_PAGE_MIN_X) / 2 * TERRAIN_WORLD_SIZE,
            0,
            -(ENDLESS_PAGE_MAX_Y+ENDLESS_PAGE_MIN_Y) / 2 * TERRAIN_WORLD_SIZE
            );
    camera->setPosition(terrain_pos +worldCenter);
    camera->lookAt(terrain_pos);
    camera->setNearClipDistance(0.1);
    camera->setFarClipDistance(50000);

#endif

    if (batb.ogre.ogre_root->getRenderSystem()->getCapabilities()->hasCapability(RSC_INFINITE_FAR_PLANE))
    {
        camera->setFarClipDistance(0);   // enable infinite far clip distance if we can
    }
               
}
Esempio n. 16
0
void PGSampleApp::createScene(void)
{
	bool blankTerrain = false;
	mTerrainGlobals = OGRE_NEW TerrainGlobalOptions();

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


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

	mSceneMgr->setAmbientLight(ColourValue(0.2, 0.2, 0.2));


	mTerrainGroup = OGRE_NEW TerrainGroup(mSceneMgr, Terrain::ALIGN_X_Z, TERRAIN_SIZE, TERRAIN_WORLD_SIZE);
	mTerrainGroup->setFilenameConvention(TERRAIN_FILE_PREFIX, TERRAIN_FILE_SUFFIX);
	mTerrainGroup->setOrigin(mTerrainPos + Vector3(TERRAIN_WORLD_SIZE/2, 0, TERRAIN_WORLD_SIZE/2));

	configureTerrainDefaults(l);
#ifdef PAGING
	// Paging setup
	mPageManager = OGRE_NEW PageManager();
	// Since we're not loading any pages from .page files, we need a way just 
	// to say we've loaded them without them actually being loaded
	mPageManager->setPageProvider(&mDummyPageProvider);
	mPageManager->addCamera(mCamera);
	mTerrainPaging = OGRE_NEW TerrainPaging(mPageManager);
	PagedWorld* world = mPageManager->createWorld();
	mTerrainPaging->createWorldSection(world, mTerrainGroup, 2000, 3000, 
		TERRAIN_PAGE_MIN_X, TERRAIN_PAGE_MIN_Y, 
		TERRAIN_PAGE_MAX_X, TERRAIN_PAGE_MAX_Y);
#else
	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, blankTerrain);
	// sync load since we want everything in place when we start
	mTerrainGroup->loadAllTerrains(true);
#endif

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

	mTerrainGroup->freeTemporaryResources();



	// create a few entities on the terrain
	Entity* e = mSceneMgr->createEntity("tudorhouse.mesh");
	Vector3 entPos(mTerrainPos.x + 2043, 0, mTerrainPos.z + 1715);
	Quaternion rot;
	entPos.y = mTerrainGroup->getHeightAtWorldPosition(entPos) + 65.5 + mTerrainPos.y;
	rot.FromAngleAxis(Degree(Math::RangeRandom(-180, 180)), Vector3::UNIT_Y);
	SceneNode* sn = mSceneMgr->getRootSceneNode()->createChildSceneNode(entPos, rot);
	sn->setScale(Vector3(0.12, 0.12, 0.12));
	sn->attachObject(e);
	mHouseList.push_back(e);

	e = mSceneMgr->createEntity("tudorhouse.mesh");
	entPos = Vector3(mTerrainPos.x + 1850, 0, mTerrainPos.z + 1478);
	entPos.y = mTerrainGroup->getHeightAtWorldPosition(entPos) + 65.5 + mTerrainPos.y;
	rot.FromAngleAxis(Degree(Math::RangeRandom(-180, 180)), Vector3::UNIT_Y);
	sn = mSceneMgr->getRootSceneNode()->createChildSceneNode(entPos, rot);
	sn->setScale(Vector3(0.12, 0.12, 0.12));
	sn->attachObject(e);
	mHouseList.push_back(e);

	e = mSceneMgr->createEntity("tudorhouse.mesh");
	entPos = Vector3(mTerrainPos.x + 1970, 0, mTerrainPos.z + 2180);
	entPos.y = mTerrainGroup->getHeightAtWorldPosition(entPos) + 65.5 + mTerrainPos.y;
	rot.FromAngleAxis(Degree(Math::RangeRandom(-180, 180)), Vector3::UNIT_Y);
	sn = mSceneMgr->getRootSceneNode()->createChildSceneNode(entPos, rot);
	sn->setScale(Vector3(0.12, 0.12, 0.12));
	sn->attachObject(e);
	mHouseList.push_back(e);

	mSceneMgr->setSkyBox(true, "Examples/CloudyNoonSkyBox");


	configureShadows(true, false);

	mCamera->setPosition(mTerrainPos + Vector3(1683, 50, 2116));
	mCamera->lookAt(Vector3(1963, 50, 1660));
	mCamera->setNearClipDistance(0.1);
	mCamera->setFarClipDistance(50000);

	if (mRoot->getRenderSystem()->getCapabilities()->hasCapability(RSC_INFINITE_FAR_PLANE))
    {
        mCamera->setFarClipDistance(0);   // enable infinite far clip distance if we can
    }

}