// 保存场景 void TerrainEditorPlugin::onPreSaveScene(const String &fileName ,IScene *scene) { // 找到所有地形,保存之 IScene::SceneObjectIterator iter = scene->getSceneObjectIterator(); while(iter.hasMoreElements()) { ISceneObject *obj = iter.getNext(); if(obj->getType() == TerrainObjectFactory::FACTORY_TYPE) { TerrainObject *terrain = static_cast<TerrainObject*>(obj); String outBasename; String outExtention; String outPath; StringUtil::splitFullFilename(fileName , outBasename , outExtention , outPath); removeTerrainBlockerPass(terrain->getOgreTerrain()); terrain->save(outBasename); addTerrainBlockerPass(terrain->getOgreTerrain()); } } }
// 新建场景 void TerrainEditorPlugin::onNewScene(IScene *scene) { // 找到所有地形,激活之 IScene::SceneObjectIterator iter = scene->getSceneObjectIterator(); while(iter.hasMoreElements()) { ISceneObject *obj = iter.getNext(); if(obj->getType() == TerrainObjectFactory::FACTORY_TYPE) { TerrainObject *terrain = static_cast<TerrainObject*>(obj); activateTerrain(terrain->getOgreTerrain()); } } }