Пример #1
0
 public void setSourceModifier(ushort index, LayeredBlending.SourceModifier modType, int customNum)
 {
     RTShaderPINVOKE.LayeredBlending_setSourceModifier(swigCPtr, index, (int)modType, customNum);
     if (RTShaderPINVOKE.SWIGPendingException.Pending)
     {
         throw RTShaderPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Пример #2
0
        public string SourceModifierToString(LayeredBlending.SourceModifier modifier)
        {
            for (int i = 0; i < LayeredBlending.sourceModifiers.Length; i++)
            {
                if (LayeredBlending.sourceModifiers[i].Type == modifier)
                {
                    return(LayeredBlending.sourceModifiers[i].Name);
                }
            }

            return(string.Empty);
        }
Пример #3
0
        public override SubRenderState CreateInstance(Scripting.Compiler.ScriptCompiler compiler,
                                                      Scripting.Compiler.AST.PropertyAbstractNode prop,
                                                      Graphics.TextureUnitState texState, ScriptTranslator translator)
        {
            if (prop.Name == "layered_blend")
            {
                string blendType;
                if (!SGScriptTranslator.GetString(prop.Values[0], out blendType))
                {
                    // compiler.AddError(...);
                    return(null);
                }

                LayeredBlending.BlendMode blendMode = StringToBlendMode(blendType);
                if (blendMode == LayeredBlending.BlendMode.Invalid)
                {
                    //  compiler.AddError(...);
                    return(null);
                }

                //get the layer blend sub-render state to work on
                var layeredBlendState = (LayeredBlending)CreateOrRetrieveInstance(translator);

                int texIndex = -1;
                //TODO: check impl. Ogre use: texIndex = texState.Parent.GetTextureUnitStateIndex(texState);
                for (int i = 0; i < texState.Parent.TextureUnitStatesCount; i++)
                {
                    if (texState.Parent.GetTextureUnitState(i) == texState)
                    {
                        texIndex = i;
                        break;
                    }
                }
                layeredBlendState.SetBlendMode(texIndex, blendMode);

                return(layeredBlendState);
            }
            if (prop.Name == "source_modifier")
            {
                if (prop.Values.Count < 3)
                {
                    //compiler.AddError(..);
                    return(null);
                }

                //Read light model type
                bool   isParseSuccess;
                string modifierString;
                string paramType;
                int    customNum;

                int itValue = 0;
                isParseSuccess = SGScriptTranslator.GetString(prop.Values[itValue], out modifierString);
                LayeredBlending.SourceModifier modType = StringToSourceModifier(modifierString);
                isParseSuccess &= modType != LayeredBlending.SourceModifier.Invalid;
                if (isParseSuccess == false)
                {
                    //compiler.AddError(...);
                    return(null);
                }
                itValue++;
                isParseSuccess  = SGScriptTranslator.GetString(prop.Values[itValue], out paramType);
                isParseSuccess &= (paramType == "custom");
                if (isParseSuccess == false)
                {
                    // compiler.AddError(...);

                    return(null);
                }

                itValue++;
                isParseSuccess = SGScriptTranslator.GetString(prop.Values[itValue], out paramType);
                if (isParseSuccess == false)
                {
                    //compiler.AddError(...);
                    return(null);
                }
                itValue++;
                isParseSuccess = SGScriptTranslator.GetInt(prop.Values[itValue], out customNum);
                if (isParseSuccess == false)
                {
                    //compiler.AddError(...);
                    return(null);
                }

                //get the layer blend sub render state to work on
                var layeredBlendState = (LayeredBlending)CreateOrRetrieveInstance(translator);

                int texIndex = 0;
                //update the layer sub render state
                for (int i = 0; i < texState.Parent.TextureUnitStatesCount; i++)
                {
                    if (texState.Parent.GetTextureUnitState(i) == texState)
                    {
                        texIndex = i;
                        break;
                    }
                }
                layeredBlendState.SetSourceModifier(texIndex, modType, customNum);

                return(layeredBlendState);
            }
            return(null);
        }