本文整理汇总了C++中ogre::terraingroup::TerrainIterator类的典型用法代码示例。如果您正苦于以下问题:C++ TerrainIterator类的具体用法?C++ TerrainIterator怎么用?C++ TerrainIterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TerrainIterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createTerrain
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();
}
示例2:
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
示例3: CreatePhysicsShape
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());
}
}
示例4: lightdir
//-------------------------------------------------------------------------------------
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();
}
示例5: configureTerrainDefaults
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);
}
示例6: loadTerrain
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();
}
示例7: createScene
//-------------------------------------------------------------------------------------
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*/
}
示例8: createScene
//------------------------------------------------------------------------------
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");
}
示例9: setup
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();
}
示例10: CreateTerrain
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();
}
示例11: _setCompositeMapDistance
//-----------------------------------------------------------------------------------------
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;
}
示例12: InitNxOgre
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);
}
示例13: initEnvironment
//-------------------------------------------------------------------------------------
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);
//.........这里部分代码省略.........
示例14: EngineSetup
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();
//.........这里部分代码省略.........
示例15: setupTerrain
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));
//.........这里部分代码省略.........