Beispiel #1
0
    DiTexturePtr DiShaderParameter::WriteTexture2D( const DiString& name, 
        const DiString& textureName )
    {
        DiString texfile = textureName;
#if DEMI_PLATFORM == DEMI_PLATFORM_IOS
        if(texfile.CheckFileExtension("dds"))
            texfile = texfile.ExtractBaseName() + ".pvr";
#endif
        
        //DI_LOG("Writing 2d texture name: %s, %s [%x]", name.c_str(), textureName.c_str(),this);
        
        DiAssetManager& assetMgr = DiAssetManager::GetInstance();
        DiTexturePtr textureAsset = assetMgr.GetAsset<DiTexture>(texfile);

        if (!textureAsset)
        {
            textureAsset = DiTexture::GetDefaultTexture();
            DI_WARNING("Cannot write the texture(%s), using default texture", texfile.c_str());
        }

        auto it = mShaderParams[VARIABLE_SAMPLER2D].find(name);
        if (it != mShaderParams[VARIABLE_SAMPLER2D].end())
        {
            DiTexture* tex = textureAsset.get();
            DiAny an(tex);
            it->second = an;
        }
        return textureAsset;
    }
Beispiel #2
0
    DiTexturePtr DiShaderParameter::WriteTextureCUBE( const DiString& name, 
        const DiString& textureName )
    {
        DiString texfile = textureName;
#if DEMI_PLATFORM == DEMI_PLATFORM_IOS
        if(texfile.CheckFileExtension("dds"))
            texfile = texfile.ExtractBaseName() + ".pvr";
#endif
        
        DiAssetManager& assetMgr = DiAssetManager::GetInstance();
        DiTexturePtr textureAsset = assetMgr.GetAsset<DiTexture>(texfile);

        if (!textureAsset)
        {
            DI_WARNING("Failed to load the textureCUBE resource : %s",texfile.c_str());
            return DiTexturePtr();
        }

        auto it = mShaderParams[VARIABLE_SAMPLERCUBE].find(name);
        if (it != mShaderParams[VARIABLE_SAMPLERCUBE].end())
        {
            DiTexture* tex = textureAsset.get();
            DiAny an(tex);
            it->second = an;
        }
        return textureAsset;
    }
Beispiel #3
0
void parseArgs(int numArgs, char **args)
{
	srcName = args[1];
	srcName.ToLower();
	if(srcName.CheckFileExtension("skeleton") ||
		srcName.CheckFileExtension("skeleton"))
	{
		isAnimation = true;
	}

	if(numArgs == 2)
	{
		destName = srcName.ExtractDirName();
		DiString temp = srcName.ExtractFileName().ExtractBaseName();
		destName.append(temp);
		destName.append(!isAnimation?".model":".motion");
	}
	else if(numArgs == 3)
	{
		destName = args[2];
	}
}
Beispiel #4
0
    void DiK2Configs::Init()
    {
#if DEMI_PLATFORM == DEMI_PLATFORM_WIN32
        LoadConfig("ConfigWin32.xml");
#elif DEMI_PLATFORM == DEMI_PLATFORM_OSX
        LoadConfig("ConfigOSX.xml");
#else
        LoadConfig("ConfigiOS.xml");
#endif

        DiString resPath;
        if (DiBase::CommandMgr->GetConsoleVar("k2_resource_path"))
        {
            resPath = DiBase::CommandMgr->GetConsoleVar("k2_resource_path")->GetString();
        }

        DiString texPath;
        if (DiBase::CommandMgr->GetConsoleVar("k2_texture_path"))
        {
            texPath = DiBase::CommandMgr->GetConsoleVar("k2_texture_path")->GetString();
        }

        // if zip
        if (resPath.CheckFileExtension("zip") || resPath.CheckFileExtension("s2z"))
            SetK2ResourcePack(resPath, texPath);

        // register the asset type
        DiAssetManager::GetInstance().RegisterAssetType(DiK2ModelAsset::TYPE, "", [](const DiString& name){
            return make_shared<DiK2ModelAsset>(name);
        });
        
        // register the manual loader
        DiAssetManager::GetInstance().RegisterManualLoader(DiTexture::TYPE, [&](const DiString& name){
            auto ret = DiK2Configs::GetTexture(name);
            return ret;
        });
    }