コード例 #1
0
void LandscapeEditorDrawSystem::SaveTileMaskTexture()
{
	if (!baseLandscape)
	{
		return;
	}

	if (!GetLandscapeProxy()->IsTilemaskChanged())
	{
		return;
	}

	Texture* texture = baseLandscape->GetTexture(Landscape::TEXTURE_TILE_MASK);

	if (texture)
	{
		FilePath texturePathname = baseLandscape->GetTextureName(Landscape::TEXTURE_TILE_MASK);

		if (texturePathname.IsEmpty())
		{
			return;
		}

		texturePathname.ReplaceExtension(".png");

		eBlendMode srcBlend = RenderManager::Instance()->GetSrcBlend();
		eBlendMode dstBlend = RenderManager::Instance()->GetDestBlend();
		RenderManager::Instance()->SetBlendMode(BLEND_ONE, BLEND_ZERO);
		Image *image = texture->CreateImageFromMemory();
		RenderManager::Instance()->SetBlendMode(srcBlend, dstBlend);

		if(image)
		{
			ImageLoader::Save(image, texturePathname);
			SafeRelease(image);
		}

		FilePath descriptorPathname = TextureDescriptor::GetDescriptorPathname(texturePathname);
		TextureDescriptor *descriptor = TextureDescriptor::CreateFromFile(descriptorPathname);
		if(!descriptor)
		{
			descriptor = new TextureDescriptor();
			descriptor->pathname = descriptorPathname;
			descriptor->Save();
		}

		SafeRelease(descriptor);

		GetLandscapeProxy()->ResetTilemaskChanged();
	}
}
コード例 #2
0
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);
}
コード例 #3
0
void CommandConvertScene::Execute()
{
    DVASSERT(CheckExtension(String(".dae")) && "Wrong extension");
//    TextureDescriptorUtils::CreateDescriptorsForFolder(EditorSettings::Instance()->GetDataSourcePath());
    DVASSERT(false)
    
    eColladaErrorCodes code = ConvertDaeToSce(filePathname);
    if(code == COLLADA_OK)
    {
        // load sce to scene object
        FilePath path = FilePath::CreateWithNewExtension(filePathname, ".sce");

        Scene * scene = new Scene();
        
        Entity *rootNode = scene->GetRootNode(path);
		if(rootNode)
		{
			rootNode = rootNode->Clone();
			scene->AddNode(rootNode);
			rootNode->Release();
		}
        
        scene->BakeTransforms();
        
        // Export to *.sc2
        path.ReplaceExtension(".sc2");
        scene->Save(path);
        SafeRelease(scene);
    }
    else if(code == COLLADA_ERROR_OF_ROOT_NODE)
    {
        ShowErrorDialog(String("Can't convert from DAE. Looks like one of materials has same name as root node."));
    }
    else
    {
        ShowErrorDialog(String("Can't convert from DAE."));
    }
}
コード例 #4
0
void SceneSaver::CopyEmitter( ParticleEmitter *emitter, Set<String> &errorLog )
{
	sceneUtils.CopyFile(emitter->GetConfigPath(), errorLog);

	const Vector<ParticleLayer*> &layers = emitter->GetLayers();

	uint32 count = (uint32)layers.size();
	for(uint32 i = 0; i < count; ++i)
	{
		if(layers[i]->type == ParticleLayer::TYPE_SUPEREMITTER_PARTICLES)
		{
			CopyEmitter(layers[i]->GetInnerEmitter(), errorLog);
		}
		else
		{
			Sprite *sprite = layers[i]->GetSprite();
			if(!sprite) continue;

			FilePath psdPath = ReplaceInString(sprite->GetRelativePathname().GetAbsolutePathname(), "/Data/", "/DataSource/");
			psdPath.ReplaceExtension(".psd");
			sceneUtils.CopyFile(psdPath, errorLog);
		}
	}
}
コード例 #5
0
void CubeMapTextureBrowser::OnDeleteSelectedItemsClicked()
{
	int checkedItemCount = GetCheckedItemsCount();
	int answer = MB_FLAG_NO;
	if(checkedItemCount > 0)
	{
		QString text = QString("%1 item(s) will be deleted. Continue?").arg(QString().setNum(checkedItemCount));
		answer = ShowQuestion("Confirmation",
							  text.toStdString(),
							  MB_FLAG_YES | MB_FLAG_NO,
							  MB_FLAG_NO);
	}
	
	if(MB_FLAG_YES == answer)
	{
		DAVA::Vector<DAVA::String> failedToRemove;
		int itemCount = ui->listTextures->count();
		for(int i = 0; i < itemCount; ++i)
		{
			QListWidgetItem* item = ui->listTextures->item(i);
			bool checkedState = item->data(Qt::CheckStateRole).toBool();
			
			if(checkedState)
			{
				FilePath fp = item->data(CUBELIST_DELEGATE_ITEMFULLPATH).toString().toStdString();
				if(fp.Exists())
				{
					DAVA::Vector<DAVA::String> faceNames;
					CubemapUtils::GenerateFaceNames(fp.GetAbsolutePathname(), faceNames);
					for(size_t faceIndex = 0; faceIndex < faceNames.size(); ++faceIndex)
					{
						FilePath hackTex = faceNames[faceIndex];
						hackTex.ReplaceExtension(".tex");
						
						QFile::remove(hackTex.GetAbsolutePathname().c_str());
						bool removeResult = QFile::remove(faceNames[faceIndex].c_str());
						if(!removeResult)
						{
							failedToRemove.push_back(faceNames[faceIndex]);
						}
					}
					
					bool removeResult = QFile::remove(fp.GetAbsolutePathname().c_str());
					if(!removeResult)
					{
						failedToRemove.push_back(fp.GetAbsolutePathname().c_str());
					}
				}
			}
		}
		
		if(failedToRemove.size() > 0)
		{
			DAVA::String fileList;
			int count = failedToRemove.size();
			for(int i = 0; i < count; ++i)
			{
				fileList += failedToRemove[i];
				fileList += "\n";
			}
			
			DAVA::String message = "Failed to remove the following files. Please delete them manually.\n";
			message += fileList;
			
			ShowErrorDialog(message);
		}

		QString path = ui->textRootPath->text();
		ReloadTexturesFromUI(path);
		UpdateCheckedState();
	}
}