void LandscapePropertyControl::SetLandscapeTexture(LandscapeNode::eTextureLevel level, const String &texturePathname) { Texture::EnableMipmapGeneration(); LandscapeNode *landscape = dynamic_cast<LandscapeNode*> (currentSceneNode); landscape->SetTexture(level, texturePathname); SceneValidator::Instance()->ValidateTexture(landscape->GetTexture(level)); Texture::DisableMipmapGeneration(); if(LandscapeNode::TEXTURE_TILE_FULL != level) { landscape->UpdateFullTiledTexture(); } }
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 LandscapePropertyControl::CreateMaskTexture(const String &lightmapPath, const String &alphamaskPath) { Image *lightMap = Image::CreateFromFile(lightmapPath); Image *alphaMask = Image::CreateFromFile(alphamaskPath); if(lightMap && alphaMask) { if( (lightMap->GetPixelFormat() == FORMAT_RGBA8888) && (alphaMask->GetPixelFormat() == FORMAT_RGBA8888)) { if( (lightMap->GetHeight() == alphaMask->GetHeight()) && (lightMap->GetWidth() == alphaMask->GetWidth()) ) { uint8 *lightMapData = lightMap->GetData(); uint8 *alphaMaskData = alphaMask->GetData(); int32 dataSize = lightMap->GetHeight() * lightMap->GetWidth() * 4; for(int32 i = 0; i < dataSize; i += 4) { lightMapData[i + 3] = alphaMaskData[i]; } String extension = FileSystem::Instance()->GetExtension(lightmapPath); String path, fileName; FileSystem::Instance()->SplitPath(lightmapPath, path, fileName); String resultPath = path + "EditorMaskTexture" + extension; FileSystem::Instance()->DeleteFile(resultPath); lightMap->Save(resultPath); propertyList->SetFilepathPropertyValue("property.landscape.lightmap", ""); propertyList->SetFilepathPropertyValue("property.landscape.alphamask", ""); propertyList->SetFilepathPropertyValue("property.landscape.texture.color", resultPath); LandscapeNode *landscape = dynamic_cast<LandscapeNode*> (currentSceneNode); if(landscape) { Texture::EnableMipmapGeneration(); landscape->SetTexture(LandscapeNode::TEXTURE_COLOR, resultPath); SceneValidator::Instance()->ValidateTexture(landscape->GetTexture(LandscapeNode::TEXTURE_COLOR)); Texture::DisableMipmapGeneration(); } } } } SafeRelease(lightMap); SafeRelease(alphaMask); }
void LandscapePropertyControl::AddFilepathProperty(const String &key, const String &filter, LandscapeNode::eTextureLevel level) { LandscapeNode *landscape = dynamic_cast<LandscapeNode*> (currentSceneNode); 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("")); } }
void TextureConverterDialog::EnumerateTexturesFromNodes(SceneNode * node) { int32 count = node->GetChildrenCount(); for(int32 iChild = 0; iChild < count; ++iChild) { SceneNode *child = node->GetChild(iChild); LandscapeNode *landscape = dynamic_cast<LandscapeNode*>(child); if (landscape) { for(int32 iTex = 0; iTex < LandscapeNode::TEXTURE_COUNT; ++iTex) { Texture *t = landscape->GetTexture((LandscapeNode::eTextureLevel)iTex); CollectTexture(t); } } EnumerateTexturesFromNodes(child); } }
void TextureConverterDialog::RestoreTexturesFromNodes(Texture *t, const String &newTexturePath, SceneNode * node) { int32 count = node->GetChildrenCount(); for(int32 iChild = 0; iChild < count; ++iChild) { SceneNode *child = node->GetChild(iChild); LandscapeNode *landscape = dynamic_cast<LandscapeNode*>(child); if (landscape) { for(int32 iTex = 0; iTex < LandscapeNode::TEXTURE_COUNT; ++iTex) { Texture *tex = landscape->GetTexture((LandscapeNode::eTextureLevel)iTex); if(t == tex) { landscape->SetTexture((LandscapeNode::eTextureLevel)iTex, newTexturePath); } } } RestoreTexturesFromNodes(t, newTexturePath, child); } }