void LandscapeEditorCustomColors::ShowAction() { landscapeSize = GetLandscape()->GetTexture(Landscape::TEXTURE_TILE_FULL)->GetWidth(); workingLandscape->CursorEnable(); //save fog status and disable it for more convenience isFogEnabled = workingLandscape->IsFogEnabled(); workingLandscape->SetFog(false); texSurf = SafeRetain( workingLandscape->GetTexture(Landscape::TEXTURE_TILE_FULL)); FilePath loadFileName = GetCurrentSaveFileName(); if(!loadFileName.IsEmpty()) LoadTextureAction(loadFileName); if(NULL == colorSprite) { Texture* tex = workingLandscape->GetTexture(Landscape::TEXTURE_TILE_FULL); colorSprite = Sprite::CreateAsRenderTarget(tex->width, tex->height, FORMAT_RGBA8888); RenderManager::Instance()->SetRenderTarget(colorSprite); const Vector<Color> & colors = EditorConfig::Instance()->GetColorPropertyValues("LandscapeCustomColors"); if(!colors.empty()) { RenderManager::Instance()->ClearWithColor(colors[0].r, colors[0].g, colors[0].b, colors[0].a); } RenderManager::Instance()->RestoreRenderTarget(); } PerformLandscapeDraw(); // TODO: mainwindow //QtMainWindowHandler::Instance()->SetCustomColorsWidgetsState(true); }
void Test::PreparePath() { SettingsManager *settings = SettingsManager::Instance(); int32 partX = settings->GetLandscapePartitioning().x; int32 partY = settings->GetLandscapePartitioning().y; Landscape *land = GetLandscape(); AABBox3 boundingBox = land->GetBoundingBox(); Vector3 min = boundingBox.min; Vector3 max = boundingBox.max; float32 landWidth = max.x - min.x; float32 landLength = max.y - min.y; Vector2 rectSize(landWidth / partX, landLength / partY); int32 x = 0; int32 xDir = 1; for(int32 y = 0; y < partY; ++y) { Rect curRect; for(int32 i = 0; i < partX; ++i, x += xDir) { Vector2 v; v.Set(min.x + x * rectSize.x, min.y + y * rectSize.y); curRect.SetPosition(v); curRect.SetSize(rectSize); rectSequence.push_back(curRect); } x -= xDir; xDir = -xDir; } }
void LandscapeEditorDrawSystem::RemoveEntity(DAVA::Entity * entity) { if (entity == landscapeNode) { SceneEditor2* sceneEditor = static_cast<SceneEditor2*>(GetScene()); bool needRemoveBaseLandscape = sceneEditor->IsToolsEnabled(SceneEditor2::LANDSCAPE_TOOLS_ALL & ~SceneEditor2::LANDSCAPE_TOOL_TILEMAP_EDITOR); sceneEditor->DisableTools(SceneEditor2::LANDSCAPE_TOOLS_ALL); if (needRemoveBaseLandscape) { sceneEditor->renderUpdateSystem->RemoveEntity(entity); } DeinitLandscape(); Entity* entity = FindLandscapeEntity(sceneEditor); if (entity != NULL) { InitLandscape(entity, GetLandscape(entity)); } } }
void LandscapePropertyControl::OnBoolPropertyChanged(PropertyList *forList, const String &forKey, bool newValue) { if("property.landscape.showgrid" == forKey) { // RETURN TO THIS CODE LATER // LandscapeNode *landscape = dynamic_cast<LandscapeNode*> (currentSceneNode); // // if(newValue) // { // landscape->SetDebugFlags(landscape->GetDebugFlags() | DebugRenderComponent::DEBUG_DRAW_GRID); // } // else // { // landscape->SetDebugFlags(landscape->GetDebugFlags() & ~DebugRenderComponent::DEBUG_DRAW_GRID); // } } else if (String("property.material.fogenabled") == forKey) { LandscapeNode *landscape = GetLandscape(); if (!landscape) return; landscape->SetFog(newValue); } NodesPropertyControl::OnBoolPropertyChanged(forList, forKey, newValue); }
void LandscapeEditorDrawSystem::AddEntity(DAVA::Entity * entity) { Landscape* landscape = GetLandscape(entity); if (landscape != NULL) { InitLandscape(entity, landscape); } }
Vector3 Test::GetRealPoint(const Vector2& point) { Vector3 realPoint(point); Landscape *land = GetLandscape(); land->PlacePoint(realPoint, realPoint); realPoint.z += SettingsManager::Instance()->GetCameraElevation(); return realPoint; }
void LandscapePropertyControl::SaveHeightmapToPng(DAVA::BaseObject *object, void *userData, void *callerData) { LandscapeNode *landscape = GetLandscape(); if (!landscape) return; Heightmap * heightmap = landscape->GetHeightmap(); String heightmapPath = landscape->GetHeightmapPathname(); heightmapPath = FileSystem::ReplaceExtension(heightmapPath, ".png"); heightmap->SaveToImage(heightmapPath); }
void LandscapePropertyControl::OnColorPropertyChanged(PropertyList *forList, const String &forKey, const Color& newColor) { if("property.material.fogcolor" == forKey) { LandscapeNode *landscape = GetLandscape(); if (!landscape) return; landscape->SetFogColor(newColor); } if("property.landscape.texture.tilecolor0" == forKey) { LandscapeNode *landscape = GetLandscape(); if (!landscape) return; landscape->SetTileColor(LandscapeNode::TEXTURE_TILE0, newColor); } if("property.landscape.texture.tilecolor1" == forKey) { LandscapeNode *landscape = GetLandscape(); if (!landscape) return; landscape->SetTileColor(LandscapeNode::TEXTURE_TILE1, newColor); } if("property.landscape.texture.tilecolor2" == forKey) { LandscapeNode *landscape = GetLandscape(); if (!landscape) return; landscape->SetTileColor(LandscapeNode::TEXTURE_TILE2, newColor); } if("property.landscape.texture.tilecolor3" == forKey) { LandscapeNode *landscape = GetLandscape(); if (!landscape) return; landscape->SetTileColor(LandscapeNode::TEXTURE_TILE3, newColor); } PropertyListDelegate::OnColorPropertyChanged(forList, forKey, newColor); }
void LandscapePropertyControl::OnComboIndexChanged( PropertyList *forList, const String &forKey, int32 newItemIndex, const String &newItemKey) { if("property.landscape.tilemode" == forKey) { LandscapeNode *landscape = GetLandscape(); if (!landscape) return; landscape->SetTiledShaderMode((LandscapeNode::eTiledShaderMode)newItemIndex); } NodesPropertyControl::OnComboIndexChanged(forList, forKey, newItemIndex, newItemKey); }
void LandscapePropertyControl::SetLandscapeTexture(LandscapeNode::eTextureLevel level, const String &texturePathname) { LandscapeNode *landscape = GetLandscape(); if (!landscape) return; landscape->SetTexture(level, texturePathname); SceneValidator::Instance()->ValidateTextureAndShowErrors(landscape->GetTexture(level), landscape->GetTextureName(level), Format("Landscape. TextureLevel %d", level)); if(LandscapeNode::TEXTURE_TILE_FULL != level) { landscape->UpdateFullTiledTexture(); } }
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 Test::PrepareFpsStat() { testData.Clear(); fpsStatItem.rect = rectSequence[testData.GetItemCount()]; Landscape *land = GetLandscape(); AABBox3 boundingBox = land->GetBoundingBox(); Vector2 landPos(boundingBox.min.x, boundingBox.min.y); Vector2 landSize((boundingBox.max - boundingBox.min).x, (boundingBox.max - boundingBox.min).x); testData.SetLandscapeRect(Rect(landPos, landSize)); }
void Test::LoadResources() { time = 0.f; isFinished = false; skipFrames = 100; Scene *scene = new Scene(); scene->AddNode(scene->GetRootNode(fullName)); DVASSERT_MSG(scene, "Could not load the scene"); Camera* cam = new Camera(); scene->AddCamera(cam); Core* core = DAVA::Core::Instance(); float32 aspect = core->GetVirtualScreenHeight() / core->GetVirtualScreenWidth(); cam->Setup(70.f, aspect, 1.f, 5000.f); cam->SetLeft(Vector3(1, 0, 0)); cam->SetUp(Vector3(0, 0, 1)); scene->SetCurrentCamera(cam); SafeRelease(cam); UI3DView *sceneView = new UI3DView(Rect(0, 0, GetSize().x, GetSize().y)); sceneView->SetScene(scene); AddControl(sceneView); SafeRelease(sceneView); Landscape* landscape = GetLandscape(); DVASSERT_MSG(scene, "There is no landscape in a scene"); landscape->SetTiledShaderMode(Landscape::TILED_MODE_TEXTURE); uint32 textureMemory = TextureHelper::GetSceneTextureMemory(scene, GetFilePath()); testData.SetTextureMemorySize(textureMemory); File* file = File::Create(fullName, File::OPEN | File::READ); DVASSERT_MSG(file, "Could not open file scene file"); testData.SetSceneFileSize(file->GetSize()); SafeRelease(file); PreparePath(); PrepareFpsStat(); PrepareCameraAnimation(); ZeroCurFpsStat(); MoveToNextPoint(); SafeRelease(scene); }
void LandscapePropertyControl::AddFilepathProperty(const String &key, const String &filter, LandscapeNode::eTextureLevel level) { LandscapeNode *landscape = GetLandscape(); if (!landscape) return; Texture * t = landscape->GetTexture(level); propertyList->AddFilepathProperty(key, filter, true, PropertyList::PROPERTY_IS_EDITABLE); if(t && !t->isRenderTarget) { propertyList->SetFilepathPropertyValue(key, landscape->GetTextureName(level)); } else { propertyList->SetFilepathPropertyValue(key, String("")); } }
Entity * FindLandscapeEntity(Entity * rootEntity) { if(GetLandscape(rootEntity)) { return rootEntity; } DAVA::int32 count = rootEntity->GetChildrenCount(); for(DAVA::int32 i = 0; i < count; ++i) { Entity *landscapeEntity = FindLandscapeEntity(rootEntity->GetChild(i)); if(landscapeEntity) { return landscapeEntity; } } return NULL; }
void LandscapePropertyControl::GenerateFullTiledTexture(DAVA::BaseObject *object, void *userData, void *callerData) { LandscapeNode *landscape = GetLandscape(); if (!landscape) return; String texPathname = landscape->SaveFullTiledTexture(); String descriptorPathname = TextureDescriptor::GetDescriptorPathname(texPathname); TextureDescriptor *descriptor = TextureDescriptor::CreateFromFile(descriptorPathname); if(!descriptor) { descriptor = new TextureDescriptor(); descriptor->pathname = descriptorPathname; descriptor->Save(); } propertyList->SetFilepathPropertyValue(String("property.landscape.texture.tiledtexture"), descriptor->pathname); landscape->SetTexture(LandscapeNode::TEXTURE_TILE_FULL, descriptor->pathname); SafeRelease(descriptor); }
void FoliageSystem::AddEntity(Entity * entity) { Landscape* landscapeRO = GetLandscape(entity); if(landscapeRO && entity != landscapeEntity) { SafeRelease(landscapeEntity); landscapeEntity = SafeRetain(entity); landscapeRO->SetFoliageSystem(this); SyncFoliageWithLandscape(); } VegetationRenderObject* vegetationRO = GetVegetation(entity); if(vegetationRO && entity != foliageEntity) { SafeRelease(foliageEntity); foliageEntity = SafeRetain(entity); SyncFoliageWithLandscape(); } }
Landscape * FindLandscape(Entity * rootEntity) { Entity *entity = FindLandscapeEntity(rootEntity); return GetLandscape(entity); }
void LandscapePropertyControl::OnFilepathPropertyChanged(PropertyList *forList, const String &forKey, const String &newValue) { Set<String> errorsLog; if("property.landscape.heightmap" == forKey) { bool isValid = SceneValidator::Instance()->ValidateHeightmapPathname(newValue, errorsLog); if(isValid) { LandscapeNode *landscape = GetLandscape(); if (!landscape) return; Vector3 size( propertyList->GetFloatPropertyValue("property.landscape.size"), propertyList->GetFloatPropertyValue("property.landscape.size"), propertyList->GetFloatPropertyValue("property.landscape.height")); AABBox3 bbox; bbox.AddPoint(Vector3(-size.x/2.f, -size.y/2.f, 0.f)); bbox.AddPoint(Vector3(size.x/2.f, size.y/2.f, size.z)); if(newValue.length()) { landscape->BuildLandscapeFromHeightmapImage(newValue, bbox); } } } else { bool isValid = (newValue.empty()) ? true: SceneValidator::Instance()->ValidateTexturePathname(newValue, errorsLog); if(isValid) { String descriptorPathname = String(""); if(!newValue.empty()) { descriptorPathname = TextureDescriptor::GetDescriptorPathname(newValue); } if("property.landscape.texture.tile0" == forKey) { SetLandscapeTexture(LandscapeNode::TEXTURE_TILE0, descriptorPathname); } else if("property.landscape.texture.tile1" == forKey) { SetLandscapeTexture(LandscapeNode::TEXTURE_TILE1, descriptorPathname); } else if("property.landscape.texture.tile2" == forKey) { SetLandscapeTexture(LandscapeNode::TEXTURE_TILE2, descriptorPathname); } else if("property.landscape.texture.tile3" == forKey) { SetLandscapeTexture(LandscapeNode::TEXTURE_TILE3, descriptorPathname); } else if("property.landscape.texture.tilemask" == forKey) { SetLandscapeTexture(LandscapeNode::TEXTURE_TILE_MASK, descriptorPathname); } else if("property.landscape.texture.color" == forKey) { SetLandscapeTexture(LandscapeNode::TEXTURE_COLOR, descriptorPathname); } else if("property.landscape.texture.tiledtexture" == forKey) { SetLandscapeTexture(LandscapeNode::TEXTURE_TILE_FULL, descriptorPathname); } } } if(0 == errorsLog.size()) { NodesPropertyControl::OnFilepathPropertyChanged(forList, forKey, newValue); } else { ShowErrorDialog(errorsLog); } }
void LandscapePropertyControl::ReadFrom(SceneNode * sceneNode) { NodesPropertyControl::ReadFrom(sceneNode); LandscapeNode *landscape = GetLandscape(); if (!landscape) return; propertyList->AddSection("property.landscape.landscape", GetHeaderState("property.landscape.landscape", true)); propertyList->AddFloatProperty("property.landscape.size", PropertyList::PROPERTY_IS_EDITABLE); propertyList->AddFloatProperty("property.landscape.height", PropertyList::PROPERTY_IS_EDITABLE); Vector3 size(445.0f, 445.0f, 50.f); AABBox3 bbox = landscape->GetBoundingBox(); AABBox3 emptyBox; if((emptyBox.min != bbox.min) && (emptyBox.max != bbox.max)) { AABBox3 transformedBox; bbox.GetTransformedBox(*landscape->GetWorldTransformPtr(), transformedBox); size = transformedBox.max - transformedBox.min; } propertyList->SetFloatPropertyValue("property.landscape.size", size.x); propertyList->SetFloatPropertyValue("property.landscape.height", size.z); propertyList->AddComboProperty("property.landscape.tilemode", tiledModes); propertyList->SetComboPropertyIndex("property.landscape.tilemode", landscape->GetTiledShaderMode()); propertyList->AddFilepathProperty("property.landscape.heightmap", ".png;.heightmap", false, PropertyList::PROPERTY_IS_EDITABLE); propertyList->SetFilepathPropertyValue("property.landscape.heightmap", landscape->GetHeightmapPathname()); propertyList->AddSubsection("property.landscape.subsection.textures"); AddFilepathProperty(String("property.landscape.texture.color"), TextureDescriptor::GetSupportedTextureExtensions(), LandscapeNode::TEXTURE_COLOR); AddFilepathProperty(String("property.landscape.texture.tile0"), TextureDescriptor::GetSupportedTextureExtensions(), LandscapeNode::TEXTURE_TILE0); AddFilepathProperty(String("property.landscape.texture.tile1"), TextureDescriptor::GetSupportedTextureExtensions(), LandscapeNode::TEXTURE_TILE1); AddFilepathProperty(String("property.landscape.texture.tile2"), TextureDescriptor::GetSupportedTextureExtensions(), LandscapeNode::TEXTURE_TILE2); AddFilepathProperty(String("property.landscape.texture.tile3"), TextureDescriptor::GetSupportedTextureExtensions(), LandscapeNode::TEXTURE_TILE3); AddFilepathProperty(String("property.landscape.texture.tilemask"), TextureDescriptor::GetSupportedTextureExtensions(), LandscapeNode::TEXTURE_TILE_MASK); AddFilepathProperty(String("property.landscape.texture.tiledtexture"), TextureDescriptor::GetSupportedTextureExtensions(), LandscapeNode::TEXTURE_TILE_FULL); propertyList->AddColorProperty("property.landscape.texture.tilecolor0"); propertyList->SetColorPropertyValue("property.landscape.texture.tilecolor0", landscape->GetTileColor(LandscapeNode::TEXTURE_TILE0)); propertyList->AddColorProperty("property.landscape.texture.tilecolor1"); propertyList->SetColorPropertyValue("property.landscape.texture.tilecolor1", landscape->GetTileColor(LandscapeNode::TEXTURE_TILE1)); propertyList->AddColorProperty("property.landscape.texture.tilecolor2"); propertyList->SetColorPropertyValue("property.landscape.texture.tilecolor2", landscape->GetTileColor(LandscapeNode::TEXTURE_TILE2)); propertyList->AddColorProperty("property.landscape.texture.tilecolor3"); propertyList->SetColorPropertyValue("property.landscape.texture.tilecolor3", landscape->GetTileColor(LandscapeNode::TEXTURE_TILE3)); propertyList->AddMessageProperty(String("property.landscape.generatefulltiled"), Message(this, &LandscapePropertyControl::GenerateFullTiledTexture)); propertyList->AddMessageProperty(String("property.landscape.saveheightmaptopng"), Message(this, &LandscapePropertyControl::SaveHeightmapToPng)); propertyList->AddBoolProperty("property.landscape.showgrid", PropertyList::PROPERTY_IS_EDITABLE); // RETURN TO THIS CODE LATER // bool showGrid = (0 != (landscape->GetDebugFlags() & DebugRenderComponent::DEBUG_DRAW_GRID)); bool showGrid = false; propertyList->SetBoolPropertyValue("property.landscape.showgrid", showGrid); propertyList->AddIntProperty("lightmap.size"); propertyList->SetIntPropertyValue("lightmap.size", currentSceneNode->GetCustomProperties()->GetInt32("lightmap.size", 1024)); propertyList->AddFloatProperty("property.landscape.texture0.tilex"); propertyList->SetFloatPropertyValue("property.landscape.texture0.tilex", landscape->GetTextureTiling(LandscapeNode::TEXTURE_TILE0).x); propertyList->AddFloatProperty("property.landscape.texture0.tiley"); propertyList->SetFloatPropertyValue("property.landscape.texture0.tiley", landscape->GetTextureTiling(LandscapeNode::TEXTURE_TILE0).y); propertyList->AddFloatProperty("property.landscape.texture1.tilex"); propertyList->SetFloatPropertyValue("property.landscape.texture1.tilex", landscape->GetTextureTiling(LandscapeNode::TEXTURE_TILE1).x); propertyList->AddFloatProperty("property.landscape.texture1.tiley"); propertyList->SetFloatPropertyValue("property.landscape.texture1.tiley", landscape->GetTextureTiling(LandscapeNode::TEXTURE_TILE1).y); propertyList->AddFloatProperty("property.landscape.texture2.tilex"); propertyList->SetFloatPropertyValue("property.landscape.texture2.tilex", landscape->GetTextureTiling(LandscapeNode::TEXTURE_TILE2).x); propertyList->AddFloatProperty("property.landscape.texture2.tiley"); propertyList->SetFloatPropertyValue("property.landscape.texture2.tiley", landscape->GetTextureTiling(LandscapeNode::TEXTURE_TILE2).y); propertyList->AddFloatProperty("property.landscape.texture3.tilex"); propertyList->SetFloatPropertyValue("property.landscape.texture3.tilex", landscape->GetTextureTiling(LandscapeNode::TEXTURE_TILE3).x); propertyList->AddFloatProperty("property.landscape.texture3.tiley"); propertyList->SetFloatPropertyValue("property.landscape.texture3.tiley", landscape->GetTextureTiling(LandscapeNode::TEXTURE_TILE3).y); ControlsFactory::AddFogSubsection(propertyList, landscape->IsFogEnabled(), landscape->GetFogDensity(), landscape->GetFogColor()); }
void LandscapePropertyControl::OnFloatPropertyChanged(PropertyList *forList, const String &forKey, float newValue) { if("property.landscape.size" == forKey || "property.landscape.height" == forKey) { LandscapeNode *landscape = GetLandscape(); if (landscape) { Vector3 size( propertyList->GetFloatPropertyValue("property.landscape.size"), propertyList->GetFloatPropertyValue("property.landscape.size"), propertyList->GetFloatPropertyValue("property.landscape.height")); AABBox3 bbox; bbox.AddPoint(Vector3(-size.x/2.f, -size.y/2.f, 0.f)); bbox.AddPoint(Vector3(size.x/2.f, size.y/2.f, size.z)); Set<String> errorsLog; String heightMap = propertyList->GetFilepathPropertyValue("property.landscape.heightmap"); if(SceneValidator::Instance()->ValidateHeightmapPathname(heightMap, errorsLog) && heightMap.length()) { landscape->BuildLandscapeFromHeightmapImage(heightMap, bbox); } } } if ("property.landscape.texture0.tilex" == forKey || "property.landscape.texture0.tiley" == forKey) { LandscapeNode *landscape = GetLandscape(); if (landscape) { Vector2 tiling(propertyList->GetFloatPropertyValue("property.landscape.texture0.tilex"), propertyList->GetFloatPropertyValue("property.landscape.texture0.tiley")); landscape->SetTextureTiling(LandscapeNode::TEXTURE_TILE0, tiling); } } if ("property.landscape.texture1.tilex" == forKey || "property.landscape.texture1.tiley" == forKey) { LandscapeNode *landscape = GetLandscape(); if (landscape) { Vector2 tiling(propertyList->GetFloatPropertyValue("property.landscape.texture1.tilex"), propertyList->GetFloatPropertyValue("property.landscape.texture1.tiley")); landscape->SetTextureTiling(LandscapeNode::TEXTURE_TILE1, tiling); } } if ("property.landscape.texture2.tilex" == forKey || "property.landscape.texture2.tiley" == forKey) { LandscapeNode *landscape = GetLandscape(); if (landscape) { Vector2 tiling(propertyList->GetFloatPropertyValue("property.landscape.texture2.tilex"), propertyList->GetFloatPropertyValue("property.landscape.texture2.tiley")); landscape->SetTextureTiling(LandscapeNode::TEXTURE_TILE2, tiling); } } if ("property.landscape.texture3.tilex" == forKey || "property.landscape.texture3.tiley" == forKey) { LandscapeNode *landscape = GetLandscape(); if (landscape) { Vector2 tiling(propertyList->GetFloatPropertyValue("property.landscape.texture3.tilex"), propertyList->GetFloatPropertyValue("property.landscape.texture3.tiley")); landscape->SetTextureTiling(LandscapeNode::TEXTURE_TILE3, tiling); } } if ("property.material.dencity" == forKey) { LandscapeNode *landscape = GetLandscape(); if (landscape) landscape->SetFogDensity(newValue); } NodesPropertyControl::OnFloatPropertyChanged(forList, forKey, newValue); }
Texture* Test::GetLandscapeTexture() { Landscape* landscape = GetLandscape(); return landscape->GetTexture(Landscape::TEXTURE_TILE_FULL); };