예제 #1
0
void BeastAction::Finish()
{
    PackLightmaps();

    Landscape *land = FindLandscape(workingScene);
    if(land)
    {
        FilePath textureName = land->GetTextureName(DAVA::Landscape::TEXTURE_COLOR);
        textureName.ReplaceFilename("temp_beast.png");

        FileSystem::Instance()->DeleteFile(textureName);
    }

    FileSystem::Instance()->DeleteDirectory(GetLightmapDirectoryPath());
    FileSystem::Instance()->DeleteDirectory(FileSystem::Instance()->GetCurrentWorkingDirectory() + "temp_beast/");
}
예제 #2
0
void CubemapEditorDialog::LoadCubemap(const QString& path)
{
	FilePath filePath(path.toStdString());
	TextureDescriptor* texDescriptor = TextureDescriptor::CreateFromFile(filePath);
	
	if(NULL != texDescriptor &&
	   texDescriptor->IsCubeMap())
	{
		String fileNameWithoutExtension = filePath.GetFilename();
		String extension = filePath.GetExtension();
		fileNameWithoutExtension.replace(fileNameWithoutExtension.find(extension), extension.size(), "");

		bool cubemapLoadResult = true;
		for(int i = 0; i < CubemapUtils::GetMaxFaces(); ++i)
		{
			if(texDescriptor->dataSettings.faceDescription & (1 << CubemapUtils::MapUIToFrameworkFace(i)))
			{
				FilePath faceFilePath = filePath;
				faceFilePath.ReplaceFilename(fileNameWithoutExtension +
											 CubemapUtils::GetFaceNameSuffix(CubemapUtils::MapUIToFrameworkFace(i)) + "." +
											 CubemapUtils::GetDefaultFaceExtension());

				bool faceLoadResult = LoadImageTo(faceFilePath.GetAbsolutePathname(), i, true);
				cubemapLoadResult = cubemapLoadResult && faceLoadResult;
			}
		}
		
		if(!cubemapLoadResult)
		{
			ShowErrorDialog("This cubemap texture seems to be damaged.\nPlease repair it by setting image(s) to empty face(s) and save to disk.");
		}
	}
	else
	{
		if(NULL == texDescriptor)
		{
			ShowErrorDialog("Failed to load cubemap texture " + path.toStdString());
		}
		else
		{
			ShowErrorDialog("Failed to load cubemap texture " + path.toStdString() + ". Seems this is not a cubemap texture.");
		}
	}

	SafeDelete(texDescriptor);
}
void CubeMapTextureBrowser::ReloadTextures(const DAVA::String& rootPath)
{	
	cubeListItemDelegate.ClearCache();
	ui->listTextures->clear();
	ui->listTextures->setVisible(false);
	ui->loadingWidget->setVisible(true);
	
	
	this->paintEvent(NULL);
	ui->loadingWidget->update();
	QApplication::processEvents();
	QApplication::flush();
	
	this->setUpdatesEnabled(false);

	QDir dir(rootPath.c_str());
	QStringList filesList = dir.entryList(QStringList("*.tex"));
	size_t cubemapTextures = 0;
	
	if(filesList.size() > 0)
	{
		DAVA::Vector<CubeListItemDelegate::ListItemInfo> cubemapList;
		FilePath fp = rootPath;
		for(int i = 0; i < filesList.size(); ++i)
		{
			QString str = filesList.at(i);
			fp.ReplaceFilename(str.toStdString());
			
			DAVA::TextureDescriptor* texDesc = DAVA::TextureDescriptor::CreateFromFile(fp);
			if(texDesc && texDesc->IsCubeMap())
			{
				CubeListItemDelegate::ListItemInfo itemInfo;
				itemInfo.path = fp;
				itemInfo.valid = ValidateTextureAndFillThumbnails(fp, itemInfo.icons, itemInfo.actualSize);
				
				if(itemInfo.valid)
				{
					cubemapList.push_back(itemInfo);
				}
				else
				{
					//non-valid items should be always at the beginning of the list
					cubemapList.insert(cubemapList.begin(), itemInfo);
				}
			}

			SafeDelete(texDesc);
		}
		
		cubeListItemDelegate.UpdateCache(cubemapList);
		
		for(size_t i = 0; i < cubemapList.size(); ++i)
		{
			CubeListItemDelegate::ListItemInfo& itemInfo = cubemapList[i];
			
			QListWidgetItem* listItem = new QListWidgetItem();
			listItem->setData(Qt::CheckStateRole, false);
			listItem->setData(CUBELIST_DELEGATE_ITEMFULLPATH, itemInfo.path.GetAbsolutePathname().c_str());
			listItem->setData(CUBELIST_DELEGATE_ITEMFILENAME, itemInfo.path.GetFilename().c_str());
			ui->listTextures->addItem(listItem);
		}
		
		cubemapTextures = cubemapList.size();
		ui->listTextures->setCurrentItem(ui->listTextures->item(0));
	}
	
	this->setUpdatesEnabled(true);
	
	ui->listTextures->setVisible(cubemapTextures > 0);
	ui->loadingWidget->setVisible(false);
	
	UpdateCheckedState();
}
예제 #4
0
void EditorBodyControl::Update(float32 timeElapsed)
{
	Entity * selection = scene->GetProxy();
	if (selection)
	{
		rotationCenter = selection->GetWorldTransform().GetTranslationVector();

		ArrowsNode* arrowsNode = GetArrowsNode(true);
		if (arrowsNode)
			UpdateArrowsNode(selection);
	}
	else
	{
		ArrowsNode* arrowsNode = GetArrowsNode(false);
		if (arrowsNode)
		{
			arrowsNode->SetVisible(false);
			SceneData *activeScene = SceneDataManager::Instance()->SceneGetActive();
			activeScene->RemoveSceneNode(arrowsNode);
		}
	}
	
    if(cameraController)
    {
        cameraController->Update(timeElapsed);
    }
    
    if(currentLandscapeEditor)
    {
        currentLandscapeEditor->Update(timeElapsed);
    }
    
    
    UIControl::Update(timeElapsed);

	BeastProxy::Instance()->Update(beastManager);
	if(BeastProxy::Instance()->IsJobDone(beastManager))
	{
		PackLightmaps();
		BeastProxy::Instance()->SafeDeleteManager(&beastManager);

		Landscape *land = scene->GetLandscape(scene);
		if(land)
		{
			FilePath textureName = land->GetTextureName(DAVA::Landscape::TEXTURE_COLOR);
			textureName.ReplaceFilename("temp_beast.png");

			FileSystem::Instance()->DeleteFile(textureName);
		}

#if defined (__DAVAENGINE_WIN32__)
		BeastCommandLineTool *beastTool = dynamic_cast<BeastCommandLineTool *>(CommandLineManager::Instance()->GetActiveCommandLineTool());
        if(beastTool)
        {
            QtMainWindowHandler::Instance()->SaveScene(scene, beastTool->GetScenePathname());

			bool forceClose =	CommandLineParser::CommandIsFound(String("-force"))
							||  CommandLineParser::CommandIsFound(String("-forceclose"));
			if(forceClose)
	            Core::Instance()->Quit();
        }
#endif //#if defined (__DAVAENGINE_WIN32__)

		QtMainWindowHandler::Instance()->ReloadSceneTextures();
	}
}
예제 #5
0
void CubemapEditorDialog::SaveCubemap(const QString& path)
{
	FilePath filePath(path.toStdString());
	DAVA::uint8 faceMask = GetFaceMask();
		
	//copy file to the location where .tex will be put. Add suffixes to file names to distinguish faces
	String fileNameWithoutExtension = filePath.GetFilename();
	String extension = filePath.GetExtension();
	fileNameWithoutExtension.replace(fileNameWithoutExtension.find(extension), extension.size(), "");
	for(int i = 0 ; i < CubemapUtils::GetMaxFaces(); ++i)
	{
		if(!facePath[i].isNull())
		{
			FilePath faceFilePath = filePath;
			faceFilePath.ReplaceFilename(fileNameWithoutExtension +
										 CubemapUtils::GetFaceNameSuffix(CubemapUtils::MapUIToFrameworkFace(i)) + "." +
										 CubemapUtils::GetDefaultFaceExtension());

			DAVA::String targetFullPath = faceFilePath.GetAbsolutePathname().c_str();
			if(facePath[i] != targetFullPath.c_str())
			{
				if(QFile::exists(targetFullPath.c_str()))
				{
					int answer = ShowQuestion("File overwrite",
											  "File " + targetFullPath + " already exist. Do you want to overwrite it with " + facePath[i].toStdString(),
											  MB_FLAG_YES | MB_FLAG_NO, MB_FLAG_NO);
					
					if(MB_FLAG_YES == answer)
					{
						bool removeResult = QFile::remove(targetFullPath.c_str());
						
						if(!removeResult)
						{
							ShowErrorDialog("Failed to copy texture " + facePath[i].toStdString() + " to " + targetFullPath.c_str());
							return;
						}

					}
					else
					{
						continue;
					}
				}
				
				bool copyResult = QFile::copy(facePath[i], targetFullPath.c_str());
				
				if(!copyResult)
				{
					ShowErrorDialog("Failed to copy texture " + facePath[i].toStdString() + " to " + targetFullPath);
					return;
				}
			}
			
			ClickableQLabel* faceLabel = GetLabelForFace(i);
			if(faceLabel->GetRotation() != 0)
			{
				QTransform transform;
				transform.rotate(faceLabel->GetRotation());
				QImage qimg(targetFullPath.c_str());
				QImage rotatedImage = qimg.transformed(transform);
				rotatedImage.save(targetFullPath.c_str());
                faceLabel->SetRotation(0);
			}
		}
	}
	
	TextureDescriptor* descriptor = new TextureDescriptor();
    bool descriptorReady = false;
    if(filePath.Exists())
    {
        descriptorReady = descriptor->Load(filePath);
    }
    
    if(!descriptorReady)
    {
        descriptor->SetDefaultValues();
        descriptor->drawSettings.wrapModeS = descriptor->drawSettings.wrapModeT = Texture::WRAP_CLAMP_TO_EDGE;
    }
    
	descriptor->dataSettings.faceDescription = faceMask;

    descriptor->Save(filePath);
	SafeDelete(descriptor);
	
	QMessageBox::information(this, "Cubemap texture save result", "Cubemap texture was saved successfully!");
}