void FoliageSystem::SyncFoliageWithLandscape() { if(landscapeEntity && foliageEntity) { Landscape* landscapeRO = GetLandscape(landscapeEntity); VegetationRenderObject* vegetationRO = GetVegetation(foliageEntity); vegetationRO->SetHeightmap(landscapeRO->GetHeightmap()); vegetationRO->SetHeightmapPath(landscapeRO->GetHeightmapPathname()); vegetationRO->SetWorldSize(Vector3(landscapeRO->GetLandscapeSize(), landscapeRO->GetLandscapeSize(), landscapeRO->GetLandscapeHeight())); } }
void SceneSaver::SaveScene(Scene *scene, const FilePath &fileName, Set<String> &errorLog) { DVASSERT(0 == texturesForSave.size()) String relativeFilename = fileName.GetRelativePathname(sceneUtils.dataSourceFolder); sceneUtils.workingFolder = fileName.GetDirectory().GetRelativePathname(sceneUtils.dataSourceFolder); FileSystem::Instance()->CreateDirectory(sceneUtils.dataFolder + sceneUtils.workingFolder, true); scene->Update(0.1f); FilePath oldPath = SceneValidator::Instance()->SetPathForChecking(sceneUtils.dataSourceFolder); SceneValidator::Instance()->ValidateScene(scene, errorLog); texturesForSave.clear(); SceneDataManager::EnumerateTextures(scene, texturesForSave); CopyTextures(scene, errorLog); ReleaseTextures(); Landscape *landscape = EditorScene::GetLandscape(scene); if (landscape) { sceneUtils.CopyFile(landscape->GetHeightmapPathname(), errorLog); } CopyReferencedObject(scene, errorLog); CopyEffects(scene, errorLog); CopyCustomColorTexture(scene, fileName.GetDirectory(), errorLog); //save scene to new place FilePath tempSceneName = sceneUtils.dataSourceFolder + relativeFilename; tempSceneName.ReplaceExtension(".saved.sc2"); SceneFileV2 * outFile = new SceneFileV2(); outFile->EnableSaveForGame(true); outFile->EnableDebugLog(false); outFile->SaveScene(tempSceneName, scene); SafeRelease(outFile); bool moved = FileSystem::Instance()->MoveFile(tempSceneName, sceneUtils.dataFolder + relativeFilename, true); if(!moved) { errorLog.insert(Format("Can't move file %s", fileName.GetAbsolutePathname().c_str())); } SceneValidator::Instance()->SetPathForChecking(oldPath); }
void HeightmapModificationCommand::UpdateLandscapeHeightmap(String filename) { SceneData *activeScene = SceneDataManager::Instance()->SceneGetActive(); LandscapesController* landscapesController = activeScene->GetLandscapesController(); Landscape* landscapeNode = landscapesController->GetCurrentLandscape(); Heightmap* heightmap = new Heightmap(); heightmap->Load(filename); landscapeNode->SetHeightmap(heightmap); heightmap->Save(landscapeNode->GetHeightmapPathname()); SafeRelease(heightmap); }