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);
}
Esempio n. 2
0
void LandscapePropertyControl::OnFilepathPropertyChanged(PropertyList *forList, const String &forKey, const String &newValue)
{
    if(EditorSettings::IsValidPath(newValue))
    {
        LandscapeNode *landscape = dynamic_cast<LandscapeNode*> (currentSceneNode);
        if("property.landscape.heightmap" == forKey)
        {
            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 if("property.landscape.texture.tile0" == forKey)
        {
            SetLandscapeTexture(LandscapeNode::TEXTURE_TILE0, newValue);
        }
        else if("property.landscape.texture.tile1" == forKey)
        {
            SetLandscapeTexture(LandscapeNode::TEXTURE_TILE1, newValue);
        }
        else if("property.landscape.texture.tile2" == forKey)
        {
            SetLandscapeTexture(LandscapeNode::TEXTURE_TILE2, newValue);
        }
        else if("property.landscape.texture.tile3" == forKey)
        {
            SetLandscapeTexture(LandscapeNode::TEXTURE_TILE3, newValue);
        }
        else if("property.landscape.texture.tilemask" == forKey)
        {
            SetLandscapeTexture(LandscapeNode::TEXTURE_TILE_MASK, newValue);
        }        
        else if("property.landscape.texture.color" == forKey)
        {
            SetLandscapeTexture(LandscapeNode::TEXTURE_COLOR, newValue);
        }
        else if("property.landscape.texture.tiledtexture" == forKey)
        {
            SetLandscapeTexture(LandscapeNode::TEXTURE_TILE_FULL, newValue);
        }
        else if(    "property.landscape.lightmap" == forKey 
                ||  "property.landscape.alphamask" == forKey)
        {
            String lightMap = propertyList->GetFilepathPropertyValue("property.landscape.lightmap");
            String alphaMask = propertyList->GetFilepathPropertyValue("property.landscape.alphamask");
            
            CreateMaskTexture(lightMap, alphaMask);
        }
    }

    NodesPropertyControl::OnFilepathPropertyChanged(forList, forKey, newValue);
}
Esempio n. 3
0
void LandscapePropertyControl::GenerateFullTiledTexture(DAVA::BaseObject *object, void *userData, void *callerData)
{
    LandscapeNode *landscape = dynamic_cast<LandscapeNode*> (currentSceneNode);
    String texPathname = landscape->SaveFullTiledTexture();
    
    propertyList->SetFilepathPropertyValue(String("property.landscape.texture.tiledtexture"), texPathname);
    landscape->SetTexture(LandscapeNode::TEXTURE_TILE_FULL, texPathname);
}
Esempio n. 4
0
void LandscapePropertyControl::OnColorPropertyChanged(PropertyList *forList, const String &forKey, const Color& newColor)
{
    if("property.material.fogcolor" == forKey)
    {
        LandscapeNode *landscape = dynamic_cast<LandscapeNode*> (currentSceneNode);
        landscape->SetFogColor(newColor);
    }
    
    PropertyListDelegate::OnColorPropertyChanged(forList, forKey, newColor);
}
Esempio n. 5
0
void LandscapePropertyControl::OnComboIndexChanged(
                                PropertyList *forList, const String &forKey, int32 newItemIndex, const String &newItemKey)
{
    if("property.landscape.tilemode" == forKey)
    {
        LandscapeNode *landscape = dynamic_cast<LandscapeNode*> (currentSceneNode);
        landscape->SetTiledShaderMode((LandscapeNode::eTiledShaderMode)newItemIndex);
    }
        
    NodesPropertyControl::OnComboIndexChanged(forList, forKey, newItemIndex, newItemKey);
}
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);
}
Esempio n. 7
0
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::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();   
    }
}
Esempio n. 10
0
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);
}
Esempio n. 11
0
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(""));
    }
}
Esempio n. 12
0
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 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::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);
}
Esempio n. 15
0
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);
    }
}
void MaterialEditor::SetupFog(bool enabled, float32 dencity, const DAVA::Color &newColor)
{
    for(int32 i = 0; i < (int32)materials.size(); ++i)
    {
        materials[i]->SetFog(enabled);
        materials[i]->SetFogDensity(dencity);
        materials[i]->SetFogColor(newColor);
    }
    
    if(workingScene)
    {
        EditorScene *editorScene = dynamic_cast<EditorScene *>(workingScene);
        if(editorScene)
        {
            LandscapeNode *landscape = editorScene->GetLandscape(editorScene);
            if (landscape)
            {
                landscape->SetFog(enabled);
                landscape->SetFogDensity(dencity);
                landscape->SetFogColor(newColor);
            }
        }
    }
}
Esempio n. 17
0
void LandscapePropertyControl::OnBoolPropertyChanged(PropertyList *forList, const String &forKey, bool newValue)
{
    if("property.landscape.showgrid" == forKey)
    {
        LandscapeNode *landscape = dynamic_cast<LandscapeNode*> (currentSceneNode);
        
        if(newValue)
        {
            landscape->SetDebugFlags(landscape->GetDebugFlags() | SceneNode::DEBUG_DRAW_GRID);
        }
        else 
        {
            landscape->SetDebugFlags(landscape->GetDebugFlags() & ~SceneNode::DEBUG_DRAW_GRID);
        }
    }
    else if (String("property.material.fogenabled") == forKey)
    {
        LandscapeNode *landscape = dynamic_cast<LandscapeNode*> (currentSceneNode);
        landscape->SetFog(newValue);
    }

    NodesPropertyControl::OnBoolPropertyChanged(forList, forKey, newValue);
}
Esempio n. 18
0
void LandscapePropertyControl::ReadFrom(SceneNode * sceneNode)
{
	NodesPropertyControl::ReadFrom(sceneNode);

    LandscapeNode *landscape = dynamic_cast<LandscapeNode*> (sceneNode);
	DVASSERT(landscape);

    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->GetWorldTransform(), 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"), String(".png;.pvr"), LandscapeNode::TEXTURE_COLOR);
    AddFilepathProperty(String("property.landscape.texture.tile0"), String(".png;.pvr"), LandscapeNode::TEXTURE_TILE0);
    AddFilepathProperty(String("property.landscape.texture.tile1"), String(".png;.pvr"), LandscapeNode::TEXTURE_TILE1);
    AddFilepathProperty(String("property.landscape.texture.tile2"), String(".png;.pvr"), LandscapeNode::TEXTURE_TILE2);
    AddFilepathProperty(String("property.landscape.texture.tile3"), String(".png;.pvr"), LandscapeNode::TEXTURE_TILE3);
    AddFilepathProperty(String("property.landscape.texture.tilemask"), String(".png;.pvr"), LandscapeNode::TEXTURE_TILE_MASK);
    AddFilepathProperty(String("property.landscape.texture.tiledtexture"), String(".png;.pvr"), LandscapeNode::TEXTURE_TILE_FULL);
    propertyList->AddMessageProperty(String("property.landscape.generatefulltiled"), 
                                     Message(this, &LandscapePropertyControl::GenerateFullTiledTexture));

    propertyList->AddSubsection("property.landscape.subsection.build_mask");
    propertyList->AddFilepathProperty("property.landscape.lightmap", String(".png;.pvr"), true, PropertyList::PROPERTY_IS_EDITABLE);
    propertyList->AddFilepathProperty("property.landscape.alphamask", String(".png;.pvr"), true, PropertyList::PROPERTY_IS_EDITABLE);
    propertyList->SetFilepathPropertyValue("property.landscape.lightmap", String(""));
    propertyList->SetFilepathPropertyValue("property.landscape.alphamask", String(""));

    
    propertyList->AddBoolProperty("property.landscape.showgrid", PropertyList::PROPERTY_IS_EDITABLE);
    bool showGrid =  (0 != (landscape->GetDebugFlags() & SceneNode::DEBUG_DRAW_GRID));
    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::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());
}
Esempio n. 20
0
void LandscapePropertyControl::OnFloatPropertyChanged(PropertyList *forList, const String &forKey, float newValue)
{
    if("property.landscape.size" == forKey || "property.landscape.height" == forKey)
    {
        LandscapeNode *landscape = dynamic_cast<LandscapeNode*> (currentSceneNode);
        
        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));
        
        
        String heightMap = propertyList->GetFilepathPropertyValue("property.landscape.heightmap");
        if(EditorSettings::IsValidPath(heightMap) && heightMap.length())
        {
            landscape->BuildLandscapeFromHeightmapImage(heightMap, bbox);
        }
    }
    if ("property.landscape.texture0.tilex" == forKey || "property.landscape.texture0.tiley" == forKey)
    {
        LandscapeNode *landscape = dynamic_cast<LandscapeNode*> (currentSceneNode);
        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 = dynamic_cast<LandscapeNode*> (currentSceneNode);
        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 = dynamic_cast<LandscapeNode*> (currentSceneNode);
		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 = dynamic_cast<LandscapeNode*> (currentSceneNode);
		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 = dynamic_cast<LandscapeNode*> (currentSceneNode);
        landscape->SetFogDensity(newValue);
    }

    NodesPropertyControl::OnFloatPropertyChanged(forList, forKey, newValue);
}
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 LandscapeTestScreen::LoadResources()
{
#if 0
//    RenderManager::Instance()->EnableOutputDebugStatsEveryNFrame(30);
    RenderManager::Instance()->SetFPS(30.0);
	scene = new Scene();
    
	scene3dView = 0;
    scene3dView = new UI3DView(Rect(0, 0, 480, 320));
    //scene3dView->SetDebugDraw(true);
    scene3dView->SetScene(scene);
    scene3dView->SetInputEnabled(false);
    AddControl(scene3dView);
    
    camera = new Camera();
    scene->AddCamera(camera);
    camera->Setup(70.0f, 480.0f / 320.0f, 1.0f, 5000.0f); 
    scene->SetCurrentCamera(camera);
    camera->SetDebugFlags(SceneNode::DEBUG_DRAW_ALL);
    camera->SetUp(Vector3(0.0f, 0.0f, 1.0f));
    camera->SetPosition(Vector3(0.0f, 0.0f, 10.0f));
    scene->SetCurrentCamera(camera);
    scene->SetDebugFlags(SceneNode::DEBUG_DRAW_ALL);
 
    LandscapeNode * node = new LandscapeNode();
    AABBox3 box(Vector3(445.0f / 2.0f, 445.0f / 2.0f, 0), Vector3(-445.0f / 2.0f, -445.0f / 2.0f, 50.0f));
    
    //node->SetDebugFlags(LandscapeNode::DEBUG_DRAW_ALL);
#if 0
	node->BuildLandscapeFromHeightmapImage(LandscapeNode::RENDERING_MODE_DETAIL_SHADER, "~res:/Landscape/hmp2_1.png", box);
    
    Texture::EnableMipmapGeneration();
    node->SetTexture(LandscapeNode::TEXTURE_COLOR, "~res:/Landscape/diffuse_l2.png");
    node->SetTexture(LandscapeNode::TEXTURE_DETAIL, "~res:/Landscape/detail_gravel.png");
    Texture::DisableMipmapGeneration();

	
//     node->BuildLandscapeFromHeightmapImage(LandscapeNode::RENDERING_MODE_DETAIL_SHADER, "~res:/Landscape/hmp2_1.png", box);
//     
//     Texture::EnableMipmapGeneration();
//     node->SetTexture(LandscapeNode::TEXTURE_TEXTURE0, "~res:/Landscape/tex3.png");
//     node->SetTexture(LandscapeNode::TEXTURE_DETAIL, "~res:/Landscape/detail_gravel.png");
//     Texture::DisableMipmapGeneration();
#else
    node->BuildLandscapeFromHeightmapImage("~res:/Landscape/hmp2_1.png", box);
    
    Texture::EnableMipmapGeneration();
    node->SetTexture(LandscapeNode::TEXTURE_COLOR, "~res:/Landscape/diffuse.png");
    node->SetTexture(LandscapeNode::TEXTURE_TILE0, "~res:/Landscape/blend/d.png");
    node->SetTexture(LandscapeNode::TEXTURE_TILE1, "~res:/Landscape/blend/s.png");
    node->SetTexture(LandscapeNode::TEXTURE_TILE2, "~res:/Landscape/blend/d.png");
    node->SetTexture(LandscapeNode::TEXTURE_TILE3, "~res:/Landscape/blend/s.png");
    node->SetTexture(LandscapeNode::TEXTURE_TILE_MASK, "~res:/Landscape/blend/mask.png");
    Texture::DisableMipmapGeneration();
#endif
    
    node->SetName("landscapeNode");
    scene->AddNode(node);
    SafeRelease(node);
    
//    Sprite * sprite = Sprite::Create("~res:/Gfx/Billboards/billboards");
//    //sprite->SetPivotPoint(sprite->GetWidth() / 2.0f, sprite->GetHeight() / 2.0f);
//    SpriteNode * spriteNode = new SpriteNode(scene, sprite, 0, Vector2(0.1f, 0.1f), Vector2(sprite->GetWidth() / 2.0f, sprite->GetHeight() / 2.0f));
//    spriteNode->SetName("testSpriteNode");
//    spriteNode->SetLocalTransform(Matrix4::MakeTranslation(Vector3(0.f, 10.0f, 0.0f)));
//    spriteNode->SetDebugFlags(SceneNode::DEBUG_DRAW_ALL);
//    spriteNode->SetType(SpriteNode::TYPE_BILLBOARD);
//    scene->AddNode(spriteNode);

    
    SceneFile * file = new SceneFile();
    file->SetDebugLog(true);
    file->LoadScene("~res:/Scenes/level2/level2_445.sce", scene);
    scene->AddNode(scene->GetRootNode("~res:/Scenes/level2/level2_445.sce"));
    SafeRelease(file);

	inTouch = false;
    
	scene3dView = 0;
    scene3dView = new UI3DView(Rect(0, 0, 480, 320));
    scene3dView->SetInputEnabled(false);
    scene3dView->SetScene(scene);
    
    AddControl(scene3dView);
    
    viewXAngle = 0;
    viewYAngle = 0; 
    
	positionJoypad = new UIJoypad(Rect(0, 320 - 80, 80, 80));
    positionJoypad->GetBackground()->SetSprite("~res:/Gfx/Joypad/joypad", 0);
    positionJoypad->SetStickSprite("~res:/Gfx/Joypad/joypad", 1);
	AddControl(positionJoypad);

    angleJoypad = new UIJoypad(Rect(480 - 80, 320 - 80, 80, 80));
    angleJoypad->GetBackground()->SetSprite("~res:/Gfx/Joypad/joypad", 0);
    angleJoypad->SetStickSprite("~res:/Gfx/Joypad/joypad", 1);
	AddControl(angleJoypad);
#endif
}
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);
}