void CubeMapTextureBrowser::OnCreateCubemapClicked()
{
	QString fileName = QtFileDialog::getSaveFileName(this,
													tr("Create Cubemap Texture"),
													ui->textRootPath->text(),
													tr("Tex File (*.tex)"));
	
	if(!fileName.isNull())
	{
		CubemapEditorDialog dlg(this);
		FilePath fp = fileName.toStdString();
		
		DAVA::FilePath rootPath = fp.GetDirectory();
		dlg.InitForCreating(fp, rootPath);
		dlg.exec();
		
		QString path = rootPath.GetAbsolutePathname().c_str();
		ui->textRootPath->setText(path);
		int currentRow = ui->listTextures->currentRow();
		ReloadTexturesFromUI(path);
		
		if(ui->listTextures->count() > 0 &&
		   currentRow < ui->listTextures->count())
		{
			RestoreListSelection(currentRow);
		}
	}	
}
Пример #2
0
void CubemapEditorDialog::InitForCreating(DAVA::FilePath& textureDescriptorPath, DAVA::FilePath& root)
{
	targetFile = textureDescriptorPath;
	editorMode = CubemapEditorDialog::eEditorModeCreating;
	rootPath = QString::fromStdString(root.GetAbsolutePathname());
	ui->legend->setVisible(true);
	
	faceChanged = false;
}
Пример #3
0
void SceneValidator::ValidateLandscapeTexture(Landscape *landscape, Landscape::eTextureLevel texLevel, Set<String> &errorsLog)
{
	DAVA::FilePath landTexName = landscape->GetTextureName(texLevel);
	if(!IsTextureDescriptorPath(landTexName) &&
	   landTexName.GetAbsolutePathname().size() > 0)
	{
		landscape->SetTextureName(texLevel, TextureDescriptor::GetDescriptorPathname(landTexName));
	}

	ValidateTexture(landscape->GetTexture(texLevel), landscape->GetTextureName(texLevel), Format("Landscape. TextureLevel %d", texLevel), errorsLog);
}
Пример #4
0
void CubemapEditorDialog::InitForEditing(DAVA::FilePath& textureDescriptorPath, DAVA::FilePath& root)
{
	targetFile = textureDescriptorPath;
	editorMode = CubemapEditorDialog::eEditorModeEditing;
	rootPath = QString::fromStdString(root.GetAbsolutePathname());
	
	LoadCubemap(targetFile.GetAbsolutePathname().c_str());
	
	ui->buttonSave->setEnabled(false);
	ui->legend->setVisible(false);
	
	faceChanged = false;
}
bool CubeMapTextureBrowser::ValidateTextureAndFillThumbnails(DAVA::FilePath& fp,
									  DAVA::Vector<QImage*>& icons,
									  DAVA::Vector<QSize>& actualSize)
{
	bool result = true;
	
	int width = 0;
	int height = 0;
	DAVA::Vector<DAVA::String> faceNames;
	CubemapUtils::GenerateFaceNames(fp.GetAbsolutePathname(), faceNames);
	for(size_t i = 0; i < faceNames.size(); ++i)
	{
		QImage faceImage;
		if(!faceImage.load(faceNames[i].c_str())) //file must be present
		{
			result = false;
		}
	
		if(faceImage.width() != faceImage.height() || //file must be square and be power of 2
		   !IsPowerOf2(faceImage.width()))
		{
			result = false;
		}
				
		if(0 == i)
		{
			width = faceImage.width();
			height = faceImage.height();
		}
		else if(faceImage.width() != width || //all files should be the same size
				faceImage.height() != height)
		{
			result = false;
		}
		
		//scale image and put scaled version to an array
		QImage scaledFaceTemp = faceImage.scaled(FACE_IMAGE_SIZE, FACE_IMAGE_SIZE);
		QImage* scaledFace = new QImage(scaledFaceTemp);
		
		icons.push_back(scaledFace);
		actualSize.push_back(QSize(faceImage.width(), faceImage.height()));
	}
	
	return result;
}
Пример #6
0
void TextureBrowser::updateInfoConverted()
{
	if(NULL != curTexture && NULL != curDescriptor)
	{
		char tmp[1024];
		const char *formatStr = "Unknown";

		int datasize = 0;
		int filesize = 0;
		QSize imgSize(0, 0);

		if(curDescriptor->compression[curTextureView].format != DAVA::FORMAT_INVALID)
		{
			DAVA::FilePath compressedTexturePath = DAVA::GPUFamilyDescriptor::CreatePathnameForGPU(curDescriptor, curTextureView);
			filesize = QFileInfo(compressedTexturePath.GetAbsolutePathname().c_str()).size();
			formatStr = GlobalEnumMap<DAVA::PixelFormat>::Instance()->ToString(curDescriptor->compression[curTextureView].format);
			
			int w = curDescriptor->compression[curTextureView].compressToWidth;
			int h = curDescriptor->compression[curTextureView].compressToHeight;

			if(0 != w && 0 != h)
			{
				imgSize = QSize(w, h);
			}
			else
			{
				imgSize = QSize(curTexture->width, curTexture->height);
			}

			// get data size
			datasize = ImageTools::GetTexturePhysicalSize(curDescriptor, curTextureView);
		}

		sprintf(tmp, "Format\t: %s\nSize\t: %dx%d\nData size\t: %s\nFile size\t: %s", formatStr, imgSize.width(), imgSize.height(),
			SizeInBytesToString(datasize).c_str(),
			SizeInBytesToString(filesize).c_str());

		ui->labelConvertedFormat->setText(tmp);
	}
	else
	{
		ui->labelConvertedFormat->setText("");
	}
}
Пример #7
0
void QtMainWindow::OpenLastProject()
{
    if(CommandLineManager::Instance() && !CommandLineManager::Instance()->IsCommandLineModeEnabled())
    {
        DAVA::FilePath projectPath = EditorSettings::Instance()->GetProjectPath();

        if(projectPath.IsEmpty())
        {
			projectPath = FilePath(ProjectManager::Instance()->ProjectOpenDialog().toStdString());
        }

        if(projectPath.IsEmpty())
		{
			QtLayer::Instance()->Quit();
		}
		else
		{
			ProjectManager::Instance()->ProjectOpen(QString(projectPath.GetAbsolutePathname().c_str()));
		}
    }
}
Пример #8
0
void SceneValidator::ValidateScene(Scene *scene, const DAVA::FilePath &scenePath, Set<String> &errorsLog)
{
    if(scene) 
    {
		DAVA::String tmp = scenePath.GetAbsolutePathname();
		size_t pos = tmp.find("/Data");
		if(pos != String::npos)
		{
			SetPathForChecking(tmp.substr(0, pos + 1));
		}

        ValidateSceneNode(scene, errorsLog);

        for (Set<Entity*>::iterator it = emptyNodesForDeletion.begin(); it != emptyNodesForDeletion.end(); ++it)
        {
            Entity * node = *it;
            if (node->GetParent())
            {
                node->GetParent()->RemoveNode(node);
            }
        }
        

		for (Set<Entity *>::iterator it = emptyNodesForDeletion.begin(); it != emptyNodesForDeletion.end(); ++it)
		{
			Entity *node = *it;
			SafeRelease(node);
		}

        emptyNodesForDeletion.clear();
    }
    else 
    {
        errorsLog.insert(String("Scene in NULL!"));
    }
}
Пример #9
0
void SceneHelper::CollectTextures(const DAVA::NMaterial *material, DAVA::TexturesMap &textures, TexturesEnumerateMode mode)
{
    DAVA::uint32 texCount = material->GetTextureCount();
    for(DAVA::uint32 t = 0; t < texCount; ++t)
    {
        DAVA::FilePath texturePath = material->GetTexturePath(material->GetTextureName(t));
        if(!texturePath.IsEmpty() && SceneValidator::Instance()->IsPathCorrectForProject(texturePath)&&!NMaterial::IsRuntimeTexture(material->GetTextureName(t)))
        {
            if(mode == EXCLUDE_NULL)
            {
                DAVA::Texture *texture = material->GetTexture(t);
                if(texture && !texture->isRenderTarget)
                {
                    const DAVA::FilePath & path = texture->texDescriptor->pathname;

                    if(path != texturePath)
                    {
                        DAVA::Logger::Error("texture path: \"%s\"\n material (%s) path: \"%s\"\n", path.GetAbsolutePathname().c_str(), material->GetMaterialName().c_str(), texturePath.GetAbsolutePathname().c_str());
                        DVASSERT(path == texturePath);
                    }

                    textures[FILEPATH_MAP_KEY(path)] = texture;
                }
            }
            else if(mode == INCLUDE_NULL)
            {
                textures[FILEPATH_MAP_KEY(texturePath)] = material->GetTexture(t);
            }
            else
            {
                DVASSERT(0 && "Unknown enumeration mode");
            }
        }
    }
}
Пример #10
0
void SelectPathWidgetBase::SetOpenDialogDefaultPath(const DAVA::FilePath& path)
{
    openDialogDefaultPath = path.GetAbsolutePathname();
}