Пример #1
0
        public override SubRenderState CreateInstance(Scripting.Compiler.ScriptCompiler compiler,
                                                      Scripting.Compiler.AST.PropertyAbstractNode prop, Pass pass,
                                                      ScriptTranslator stranslator)
        {
            if (prop.Name == "rtss_ext_reflection_map")
            {
                if (prop.Values.Count >= 2)
                {
                    string strValue;
                    int    it = 0;

                    //Read reflection map type
                    if (!ScriptTranslator.GetString(prop.Values[it], out strValue))
                    {
                        //compiler.AddError(...)
                        return(null);
                    }
                    it++;

                    SubRenderState subRenderState = CreateInstance();
                    var            reflectionMapSubRenderState = subRenderState as ReflectionMap;

                    //Reflection map is cubic texture.
                    if (strValue == "cube_map")
                    {
                        reflectionMapSubRenderState.ReflectionMapType = TextureType.CubeMap;
                    }
                    else if (strValue == "2d_map")
                    {
                        reflectionMapSubRenderState.ReflectionMapType = TextureType.TwoD;
                    }

                    if (!ScriptTranslator.GetString(prop.Values[it], out strValue))
                    {
                        //compiler.AddError(...)
                        return(null);
                    }
                    reflectionMapSubRenderState.MaskMapTextureName = strValue;
                    it++;

                    //read reflection texture
                    if (!ScriptTranslator.GetString(prop.Values[it], out strValue))
                    {
                        //compiler.AddError(...);
                        return(null);
                    }
                    reflectionMapSubRenderState.ReflectionMapTextureName = strValue;
                    it++;

                    //Read reflection power value
                    Real reflectionPower = 0.5;
                    if (!ScriptTranslator.GetReal(prop.Values[it], out reflectionPower))
                    {
                        //compiler.AddError(...)
                        return(null);
                    }
                    reflectionMapSubRenderState.ReflectionPower = reflectionPower;

                    return(subRenderState);
                }
            }

            return(null);
        }