Esempio n. 1
0
File: Decal.cpp Progetto: vexe/r5ge
bool Decal::OnSerializeFrom (const TreeNode& node)
{
    IGraphics* graphics = mCore->GetGraphics();
    if (graphics == 0) return false;

    const String&	tag   = node.mTag;
    const Variable&	value = node.mValue;

    if (tag == "Shader")
    {
        SetShader( graphics->GetShader(value.AsString()) );
    }
    else if (tag == "Color")
    {
        if (value.IsColor4f())
        {
            SetColor(value.AsColor4f());
        }
        else if (value.IsColor4ub())
        {
            SetColor(value.AsColor4ub());
        }
    }
    else if (tag == "Textures")
    {
        mTextures.Clear();

        if (value.IsStringArray())
        {
            const Array<String>& list = value.AsStringArray();

            for (uint i = 0; i < list.GetSize(); ++i)
            {
                // Skip legacy functionality
                if (!list[i].BeginsWith("[Generated]"))
                {
                    const ITexture* tex = graphics->GetTexture(list[i]);
                    if (tex != 0) mTextures.Expand() = tex;
                }
            }
        }
    }
    else return false;
    return true;
}
Esempio n. 2
0
File: Decal.cpp Progetto: vexe/r5ge
void Decal::SetShader (const String& shader)
{
    IGraphics* graphics = GetGraphics();
    if (graphics != 0) SetShader( graphics->GetShader(shader) );
}