Beispiel #1
0
void CommandCopyPasteHeightmap::UpdateLandscapeTilemap(DAVA::Image *image)
{
    Texture* texture = Texture::CreateFromData(image->GetPixelFormat(), image->GetData(), image->GetWidth(), image->GetHeight(), false);
    texture->relativePathname = tilemapSavedPathname;
    texture->GenerateMipmaps();
    texture->SetWrapMode(Texture::WRAP_REPEAT, Texture::WRAP_REPEAT);

    LandscapeEditorBase* editor = GetActiveEditor();
    if (editor)
    {
        editor->UpdateLandscapeTilemap(texture);
    }
    else
    {
        SceneEditorScreenMain *screen = dynamic_cast<SceneEditorScreenMain *>(UIScreenManager::Instance()->GetScreen());
        EditorScene* scene = screen->FindCurrentBody()->bodyControl->GetScene();
        Landscape* landscape = FindLandscape(scene);

        landscape->SetTexture(Landscape::TEXTURE_TILE_MASK, texture);
        landscape->UpdateFullTiledTexture();
        ImageLoader::Save(image, tilemapSavedPathname);
    }

    SafeRelease(texture);
}
void EditorBodyControl::RecreteFullTilingTexture()
{
    Landscape *landscape = FindLandscape(scene);
    if (landscape)
    {
        landscape->UpdateFullTiledTexture();
    }
}
bool LandscapeEditorCustomColors::SetScene(EditorScene *newScene)
{
    EditorLandscape *editorLandscape = dynamic_cast<EditorLandscape *>(FindLandscape(newScene));
    if(editorLandscape)
    {
        ShowErrorDialog(String("Cannot start color editor. Remove EditorLandscape from scene"));
        return false;
    }

    return LandscapeEditorBase::SetScene(newScene);
}
LandscapeSetHeightMapCommand::LandscapeSetHeightMapCommand( Entity* _landscapeEntity,
														   const FilePath& _heightMapPath,
														   const AABBox3& _newLandscapeBox)
								: Command2(CMDID_LANDSCAPE_SET_HEIGHTMAP, "Set Landscape heightmap")
{
	landscape = FindLandscape(_landscapeEntity);
	if(NULL == landscape)
	{
		return;
	}
	landscapeEntity = SafeRetain(_landscapeEntity);

	originalHeightMapPath = landscape->GetHeightmapPathname();
	originalLandscapeBox = landscape->GetBoundingBox();
	newHeightMapPath = _heightMapPath;
	newLandscapeBox = _newLandscapeBox;
}
Matrix4 EditorBodyControl::GetLandscapeOffset(const Matrix4& transform)
{
	Matrix4 resTransform;
	resTransform.Identity();

	Landscape* landscape = FindLandscape(scene);
	if(!landscape) return resTransform;

	Vector3 p = Vector3(0, 0, 0) * transform;

	Vector3 result;
	bool res = landscape->PlacePoint(p, result);
	if (res)
	{
		Vector3 offset = result - p;
		resTransform.CreateTranslation(offset);
	}

	return resTransform;
}