Exemplo n.º 1
0
        public override SubRenderState CreateInstance(Scripting.Compiler.ScriptCompiler compiler,
                                                      Scripting.Compiler.AST.PropertyAbstractNode prop, Graphics.Pass pass,
                                                      SGScriptTranslator stranslator)
        {
            SubRenderState subRenderState = CreateInstance();

            return(subRenderState);
        }
        public virtual SubRenderState createOrRetrieveInstance(SGScriptTranslator translator)
        {
            global::System.IntPtr cPtr = RTShaderPINVOKE.SubRenderStateFactory_createOrRetrieveInstance(swigCPtr, SGScriptTranslator.getCPtr(translator));
            SubRenderState        ret  = (cPtr == global::System.IntPtr.Zero) ? null : new SubRenderState(cPtr, false);

            if (RTShaderPINVOKE.SWIGPendingException.Pending)
            {
                throw RTShaderPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Exemplo n.º 3
0
        private LayeredBlending CreateOrRetrieveSubRenderState(SGScriptTranslator translator)
        {
            LayeredBlending layeredBlendState = null;
            //check if we already create a blend srs
            SubRenderState subState = translator.GetGeneratedSubRenderState(Type);

            if (subState != null)
            {
                layeredBlendState = subState as LayeredBlending;
            }
            else
            {
                SubRenderState subRenderState = CreateOrRetrieveInstance(translator);
                layeredBlendState = (LayeredBlending)subRenderState;
            }

            return(layeredBlendState);
        }
		public override SubRenderState CreateInstance( Scripting.Compiler.ScriptCompiler compiler,
		                                               Scripting.Compiler.AST.PropertyAbstractNode prop,
		                                               Graphics.Pass pass, SGScriptTranslator stranslator )
		{
			if ( prop.Name == "lighting_stage" )
			{
				if ( prop.Values.Count == 1 )
				{
					string modelType;
					if ( SGScriptTranslator.GetString( prop.Values[ 0 ], out modelType ) == false )
					{
						//compiler.AddError(...)
						return null;
					}
					if ( modelType == "per_pixel" )
					{
						return CreateOrRetrieveInstance( stranslator );
					}
				}
			}

			return null;
		}
Exemplo n.º 5
0
        public override SubRenderState CreateInstance(Scripting.Compiler.ScriptCompiler compiler,
                                                      Scripting.Compiler.AST.PropertyAbstractNode prop,
                                                      Graphics.Pass pass, SGScriptTranslator stranslator)
        {
            if (prop.Name == "lighting_stage")
            {
                if (prop.Values.Count == 1)
                {
                    string modelType;
                    if (SGScriptTranslator.GetString(prop.Values[0], out modelType) == false)
                    {
                        //compiler.AddError(...)
                        return(null);
                    }
                    if (modelType == "per_pixel")
                    {
                        return(CreateOrRetrieveInstance(stranslator));
                    }
                }
            }

            return(null);
        }
Exemplo n.º 6
0
        public SubRenderState createInstance(ScriptCompiler compiler, PropertyAbstractNode prop, Pass pass, SGScriptTranslator translator)
        {
            global::System.IntPtr cPtr = RTShaderPINVOKE.IntegratedPSSM3Factory_createInstance(swigCPtr, ScriptCompiler.getCPtr(compiler), PropertyAbstractNode.getCPtr(prop), Pass.getCPtr(pass), SGScriptTranslator.getCPtr(translator));
            SubRenderState        ret  = (cPtr == global::System.IntPtr.Zero) ? null : new SubRenderState(cPtr, false);

            if (RTShaderPINVOKE.SWIGPendingException.Pending)
            {
                throw RTShaderPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Exemplo n.º 7
0
        public override SubRenderState CreateInstance(Scripting.Compiler.ScriptCompiler compiler,
                                                      Scripting.Compiler.AST.PropertyAbstractNode prop, Pass pass,
                                                      SGScriptTranslator stranslator)
        {
            if (prop.Name == "rtss_ext_reflection_map")
            {
                if (prop.Values.Count >= 2)
                {
                    string strValue;
                    int    it = 0;

                    //Read reflection map type
                    if (!SGScriptTranslator.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 (!SGScriptTranslator.GetString(prop.Values[it], out strValue))
                    {
                        //compiler.AddError(...)
                        return(null);
                    }
                    reflectionMapSubRenderState.MaskMapTextureName = strValue;
                    it++;

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

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

                    return(subRenderState);
                }
            }

            return(null);
        }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(SGScriptTranslator obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
Exemplo n.º 10
0
		public override SubRenderState CreateInstance( Scripting.Compiler.ScriptCompiler compiler,
		                                               Scripting.Compiler.AST.PropertyAbstractNode prop,
		                                               Graphics.TextureUnitState texState, SGScriptTranslator 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;
		}
Exemplo n.º 11
0
		private LayeredBlending CreateOrRetrieveSubRenderState( SGScriptTranslator translator )
		{
			LayeredBlending layeredBlendState = null;
			//check if we already create a blend srs
			SubRenderState subState = translator.GetGeneratedSubRenderState( Type );
			if ( subState != null )
			{
				layeredBlendState = subState as LayeredBlending;
			}
			else
			{
				SubRenderState subRenderState = CreateOrRetrieveInstance( translator );
				layeredBlendState = (LayeredBlending)subRenderState;
			}

			return layeredBlendState;
		}