コード例 #1
0
uint32 TextureHelper::EnumerateSceneTextures(DAVA::Scene* scene)
{
	Map<String, Texture *> textureMap;
	EnumerateTextures(scene, textureMap);

	uint32 sceneTextureMemory = 0;
	for(Map<String, Texture *>::const_iterator it = textureMap.begin(); it != textureMap.end(); ++it)
	{
		Texture *t = it->second;
		//We need real info about textures size. In Editor on desktop pvr textures are decompressed to RGBA8888, so they have not real size.
        TextureDescriptor *descriptor = TextureDescriptor::CreateFromFile(t->GetPathname());
        if(descriptor)
        {
            FilePath imageFileName = GPUFamilyDescriptor::CreatePathnameForGPU(descriptor, (eGPUFamily)descriptor->exportedAsGpuFamily);
            if(imageFileName.IsEqualToExtension(".pvr"))
            {
                sceneTextureMemory += LibPVRHelper::GetDataSize(imageFileName);
            }
            else if(imageFileName.IsEqualToExtension(".dds"))
            {
                sceneTextureMemory += LibDxtHelper::GetDataSize(imageFileName);
            }
            else
            {
                sceneTextureMemory += t->GetDataSize();
            }
            
            delete descriptor;
        }
	}

	return sceneTextureMemory;
}
コード例 #2
0
void ImageLoader::Save(DAVA::Image *image, const FilePath &pathname)
{
    DVASSERT(pathname.IsEqualToExtension(".png"));
    
    DVASSERT((FORMAT_RGBA8888 == image->format) || (FORMAT_A8 == image->format) || (FORMAT_A16 == image->format));
    LibPngWrapper::WritePngFile(pathname, image->width, image->height, image->data, image->format);
}
コード例 #3
0
void SceneValidator::ValidateCustomColorsTexture(Entity *landscapeEntity, Set<String> &errorsLog)
{
	KeyedArchive* customProps = landscapeEntity->GetCustomProperties();
	if(customProps->IsKeyExists(ResourceEditor::CUSTOM_COLOR_TEXTURE_PROP))
	{
		String currentSaveName = customProps->GetString(ResourceEditor::CUSTOM_COLOR_TEXTURE_PROP);
		FilePath path = "/" + currentSaveName;
		if(!path.IsEqualToExtension(".png"))
		{
			errorsLog.insert("Custom colors texture has to have .png extension.");
		}
        
        String::size_type foundPos = currentSaveName.find("DataSource/3d/");
        if(String::npos == foundPos)
        {
			errorsLog.insert("Custom colors texture has to begin from DataSource/3d/.");
        }
	}
}
コード例 #4
0
bool SceneValidator::IsTextureDescriptorPath(const FilePath &path)
{
	return path.IsEqualToExtension(TextureDescriptor::GetDescriptorExtension());
}
コード例 #5
0
int32 ScenePreviewControl::OpenScene(const FilePath &pathToFile)
{
    ReleaseScene();
    RecreateScene();
    
    int32 retError = SceneFileV2::ERROR_NO_ERROR;
    if(pathToFile.IsEqualToExtension(".sce"))
    {
        SceneFile *file = new SceneFile();
        file->SetDebugLog(true);
        if(!file->LoadScene(pathToFile, editorScene))
        {
            retError = ERROR_CANNOT_OPEN_FILE;
        }
        
        SafeRelease(file);
    }
    else if(pathToFile.IsEqualToExtension(".sc2"))
    {
        SceneFileV2 *file = new SceneFileV2();
        file->EnableDebugLog(true);
        retError = file->LoadScene(pathToFile, editorScene);
        SafeRelease(file);
    }
    else
    {
        retError = ERROR_WRONG_EXTENSION;
    }
    
    if(SceneFileV2::ERROR_NO_ERROR == retError)
    {
        rootNode = editorScene->GetRootNode(pathToFile);
        if(rootNode)
        {
            currentScenePath = pathToFile;
            editorScene->AddNode(rootNode);
            
            needSetCamera = true;
            Camera *cam = editorScene->GetCamera(0);
            if(!cam)
            {
                Camera * cam = new Camera();
                //cam->SetDebugFlags(Entity::DEBUG_DRAW_ALL);
                cam->SetUp(Vector3(0.0f, 0.0f, 1.0f));
                cam->SetPosition(Vector3(0.0f, 0.0f, 0.0f));
                cam->SetTarget(Vector3(0.0f, 1.0f, 0.0f));
                
                cam->SetupPerspective(70.0f, 320.0f / 480.0f, 1.0f, 5000.0f); 
                

                
                ScopedPtr<Entity> node(new Entity());
                node->SetName("preview-camera");
                node->AddComponent(new CameraComponent(cam));
                editorScene->AddNode(node);
                editorScene->AddCamera(cam);
                editorScene->SetCurrentCamera(cam);
                cameraController->SetScene(editorScene);
                
                SafeRelease(cam);
                
                sceCamera = false;
            }
            else
            {
                sceCamera = true;
            }
        }
    }
    
    SceneValidator::Instance()->ValidateSceneAndShowErrors(editorScene);
    
    return retError;
}
コード例 #6
0
void TextureConverterCell::SetTexture(const FilePath &texturePath)
{
    textureFormat->SetText(L"");
    textureSize->SetText(L"");
    textureName->SetText(StringToWString(texturePath.GetFilename()));
    
    Texture *texture = Texture::CreateFromFile(texturePath);
    Sprite *s = Sprite::CreateFromTexture(texture, 0, 0, (float32)texture->width, (float32)texture->height);
    preview->SetSprite(s, 0);
    
    if(texturePath.IsEqualToExtension(".png"))
    {
        String pngFormat = Texture::GetPixelFormatString(texture->format);
        
        FilePath pvrPath = FilePath::CreateWithNewExtension(texturePath, ".pvr");
        Texture *pvrTex = Texture::CreateFromFile(pvrPath);
        if(pvrTex)
        {
            PixelFormat format = LibPVRHelper::GetPixelFormat(pvrPath);
            uint32 pvrDataSize = LibPVRHelper::GetDataSize(pvrPath);

            String pvrFormat = Texture::GetPixelFormatString(format);
            textureFormat->SetText(StringToWString(pngFormat + "/" + pvrFormat));
            
            textureSize->SetText(SizeInBytesToWideString(pvrDataSize));
            
            SafeRelease(pvrTex);
        }
        else 
        {
            textureFormat->SetText(StringToWString(pngFormat));
        }
    }
    else if(texturePath.IsEqualToExtension(".pvr"))
    {
        PixelFormat format = LibPVRHelper::GetPixelFormat(texturePath);
        uint32 pvrDataSize = LibPVRHelper::GetDataSize(texturePath);

        String pvrFormat = Texture::GetPixelFormatString(format);
        textureSize->SetText(SizeInBytesToWideString(pvrDataSize));

        FilePath pngPath = FilePath::CreateWithNewExtension(texturePath, ".png");
        Texture *pngTex = Texture::CreateFromFile(pngPath);
        if(pngTex)
        {
            String pngFormat = Texture::GetPixelFormatString(pngTex->format);
            textureFormat->SetText(StringToWString(pngFormat + "/" + pvrFormat));
            
            SafeRelease(pngTex);
        }
        else 
        {
            textureFormat->SetText(StringToWString(pvrFormat));
        }
    }

    textureDimensions->SetText(Format(L"%d x %d", texture->width, texture->height));
    
    SafeRelease(texture);
    SafeRelease(s);
}
コード例 #7
0
bool TextureDescriptorUtils::IsDescriptorPathname( const FilePath &pathname )
{
	return pathname.IsEqualToExtension(TextureDescriptor::GetDescriptorExtension());
}