コード例 #1
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);
        }
コード例 #2
0
            /// <see cref="Translator.Translate"/>
            public override void Translate(ScriptCompiler compiler, AbstractNode node)
            {
                throw new NotImplementedException();
#if UNREACHABLE_CODE
                ObjectAbstractNode obj = (ObjectAbstractNode)node;

                // It has to have one value identifying the texture source name
                if (obj.Values.Count == 0)
                {
                    compiler.AddError(CompileErrorCode.StringExpected, node.File, node.Line,
                                      "texture_source requires a type value");
                    return;
                }

                // Set the value of the source
                //TODO: ExternalTextureSourceManager::getSingleton().setCurrentPlugIn(obj->values.front()->getValue());

                // Set up the technique, pass, and texunit levels
                if (true /*TODO: ExternalTextureSourceManager::getSingleton().getCurrentPlugIn() != 0*/)
                {
                    TextureUnitState texunit   = (TextureUnitState)obj.Parent.Context;
                    Pass             pass      = texunit.Parent;
                    Technique        technique = pass.Parent;
                    Material         material  = technique.Parent;

                    ushort techniqueIndex = 0, passIndex = 0, texUnitIndex = 0;
                    for (ushort i = 0; i < material.TechniqueCount; i++)
                    {
                        if (material.GetTechnique(i) == technique)
                        {
                            techniqueIndex = i;
                            break;
                        }
                    }
                    for (ushort i = 0; i < technique.PassCount; i++)
                    {
                        if (technique.GetPass(i) == pass)
                        {
                            passIndex = i;
                            break;
                        }
                    }
                    for (ushort i = 0; i < pass.TextureUnitStageCount; i++)
                    {
                        if (pass.GetTextureUnitState(i) == texunit)
                        {
                            texUnitIndex = i;
                            break;
                        }
                    }

                    string tps = string.Format("{0} {1} {2}", techniqueIndex, passIndex, texUnitIndex);

                    //TODO: ExternalTextureSourceManager::getSingleton().getCurrentPlugIn()->setParameter( "set_T_P_S", tps );

                    foreach (AbstractNode i in obj.Children)
                    {
                        if (i is PropertyAbstractNode)
                        {
                            PropertyAbstractNode prop = (PropertyAbstractNode)i;
                            // Glob the property values all together
                            string str = string.Empty;

                            foreach (AbstractNode j in prop.Values)
                            {
                                if (j != prop.Values[0])
                                {
                                    str += " ";
                                }

                                str = str + j.Value;
                            }
                            //TODO: ExternalTextureSourceManager::getSingleton().getCurrentPlugIn()->setParameter(prop->name, str);
                        }
                        else if (i is ObjectAbstractNode)
                        {
                            _processNode(compiler, i);
                        }
                    }

                    //TODO: ExternalTextureSourceManager::getSingleton().getCurrentPlugIn()->createDefinedTexture(material->getName(), material->getGroup());
                }
#endif
            }
コード例 #3
0
        public override SubRenderState CreateInstance(Scripting.Compiler.ScriptCompiler compiler,
                                                      PropertyAbstractNode prop, Graphics.Pass pass,
                                                      SGScriptTranslator stranslator)
        {
            if (prop.Name == "lighting_stage")
            {
                if (prop.Values.Count >= 2)
                {
                    string strValue;
                    int    it = 0;

                    //Read light model type.
                    if (!SGScriptTranslator.GetString(prop.Values[it], out strValue))
                    {
                        //compiler.AddError(...)
                        return(null);
                    }

                    //Case light model type is normal map
                    if (strValue == "normal_map")
                    {
                        it++;
                        if (!SGScriptTranslator.GetString(prop.Values[it], out strValue))
                        {
                            //compiler.AddError(...)
                            return(null);
                        }

                        SubRenderState subRenderState          = CreateOrRetrieveInstance(stranslator);
                        var            normalMapSubRenderState = subRenderState as NormalMapLighting;

                        normalMapSubRenderState.NormalMapTextureName = strValue;

                        //Read normal map space type.
                        if (prop.Values.Count >= 3)
                        {
                            it++;
                            if (!SGScriptTranslator.GetString(prop.Values[it], out strValue))
                            {
                                //compiler.AddError(...)
                                return(null);
                            }

                            //Normal map defines normals in tangent space.
                            if (strValue == "tangent_space")
                            {
                                normalMapSubRenderState.NormalMapSpace = NormalMapSpace.Tangent;
                            }

                            //Normal map defines normals in object space
                            if (strValue == "object_space")
                            {
                                normalMapSubRenderState.NormalMapSpace = NormalMapSpace.Object;
                            }
                        }

                        //Read texture coordinate index.
                        if (prop.Values.Count >= 4)
                        {
                            int textureCoordinatesIndex = 0;
                            it++;
                            if (!SGScriptTranslator.GetInt(prop.Values[it], out textureCoordinatesIndex))
                            {
                                normalMapSubRenderState.TexCoordIndex = textureCoordinatesIndex;
                            }
                        }

                        //Read texture filtering format
                        if (prop.Values.Count >= 5)
                        {
                            it++;
                            if (!SGScriptTranslator.GetString(prop.Values[it], out strValue))
                            {
                                //compiler.AddError(...)
                                return(null);
                            }

                            if (strValue == "none")
                            {
                                normalMapSubRenderState.SetNormalMapFiltering(Graphics.FilterOptions.Point, Graphics.FilterOptions.Point,
                                                                              Graphics.FilterOptions.None);
                            }
                            else if (strValue == "bilinear")
                            {
                                normalMapSubRenderState.SetNormalMapFiltering(Graphics.FilterOptions.Linear, Graphics.FilterOptions.Linear,
                                                                              Graphics.FilterOptions.Point);
                            }
                            else if (strValue == "trilinear")
                            {
                                normalMapSubRenderState.SetNormalMapFiltering(Graphics.FilterOptions.Linear, Graphics.FilterOptions.Linear,
                                                                              Graphics.FilterOptions.Linear);
                            }
                            else if (strValue == "anisotropic")
                            {
                                normalMapSubRenderState.SetNormalMapFiltering(Graphics.FilterOptions.Anisotropic,
                                                                              Graphics.FilterOptions.Anisotropic, Graphics.FilterOptions.Linear);
                            }
                        }

                        //Read max anisotropy value
                        if (prop.Values.Count >= 6)
                        {
                            int maxAnisotropy = 0;
                            it++;
                            if (SGScriptTranslator.GetInt(prop.Values[it], out maxAnisotropy))
                            {
                                normalMapSubRenderState.NormalMapAnisotropy = maxAnisotropy;
                            }
                        }
                        //Read mip bias value.
                        if (prop.Values.Count >= 7)
                        {
                            Real mipBias = 0;
                            it++;
                            if (SGScriptTranslator.GetReal(prop.Values[it], out mipBias))
                            {
                                normalMapSubRenderState.NormalMapMipBias = mipBias;
                            }
                        }
                        return(subRenderState);
                    }
                }
            }
            return(null);
        }
コード例 #4
0
            private void visit(ConcreteNode node)
            {
                AbstractNode asn = null;

                // Import = "import" >> 2 children, _current == null
                if (node.Type == ConcreteNodeType.Import && this._current == null)
                {
                    if (node.Children.Count > 2)
                    {
                        this._compiler.AddError(CompileErrorCode.FewerParametersExpected, node.File, node.Line);
                        return;
                    }
                    if (node.Children.Count < 2)
                    {
                        this._compiler.AddError(CompileErrorCode.StringExpected, node.File, node.Line);
                        return;
                    }

                    var impl = new ImportAbstractNode();
                    impl.Line   = node.Line;
                    impl.File   = node.File;
                    impl.Target = node.Children[0].Token;
                    impl.Source = node.Children[1].Token;

                    asn = impl;
                }
                // variable set = "set" >> 2 children, children[0] == variable
                else if (node.Type == ConcreteNodeType.VariableAssignment)
                {
                    if (node.Children.Count > 2)
                    {
                        this._compiler.AddError(CompileErrorCode.FewerParametersExpected, node.File, node.Line);
                        return;
                    }
                    if (node.Children.Count < 2)
                    {
                        this._compiler.AddError(CompileErrorCode.StringExpected, node.File, node.Line);
                        return;
                    }
                    if (node.Children[0].Type != ConcreteNodeType.Variable)
                    {
                        this._compiler.AddError(CompileErrorCode.VariableExpected, node.Children[0].File, node.Children[0].Line);
                        return;
                    }

                    var name  = node.Children[0].Token;
                    var value = node.Children[1].Token;

                    if (this._current != null && this._current is ObjectAbstractNode)
                    {
                        var ptr = (ObjectAbstractNode)this._current;
                        ptr.SetVariable(name, value);
                    }
                    else
                    {
                        this._compiler.Environment.Add(name, value);
                    }
                }
                // variable = $*, no children
                else if (node.Type == ConcreteNodeType.Variable)
                {
                    if (node.Children.Count != 0)
                    {
                        this._compiler.AddError(CompileErrorCode.FewerParametersExpected, node.File, node.Line);
                        return;
                    }

                    var impl = new VariableGetAbstractNode(this._current);
                    impl.Line = node.Line;
                    impl.File = node.File;
                    impl.Name = node.Token;

                    asn = impl;
                }
                // Handle properties and objects here
                else if (node.Children.Count != 0)
                {
                    // Grab the last two nodes
                    ConcreteNode temp1 = null, temp2 = null;

                    if (node.Children.Count >= 1)
                    {
                        temp1 = node.Children[node.Children.Count - 1];
                    }
                    if (node.Children.Count >= 2)
                    {
                        temp2 = node.Children[node.Children.Count - 2];
                    }

                    // object = last 2 children == { and }
                    if (temp1 != null && temp2 != null && temp1.Type == ConcreteNodeType.RightBrace &&
                        temp2.Type == ConcreteNodeType.LeftBrace)
                    {
                        if (node.Children.Count < 2)
                        {
                            this._compiler.AddError(CompileErrorCode.StringExpected, node.File, node.Line);
                            return;
                        }

                        var impl = new ObjectAbstractNode(this._current);
                        impl.Line       = node.Line;
                        impl.File       = node.File;
                        impl.IsAbstract = false;

                        // Create a temporary detail list
                        var temp = new List <ConcreteNode>();
                        if (node.Token == "abstract")
                        {
                            impl.IsAbstract = true;
                        }
                        else
                        {
                            temp.Add(node);
                        }
                        temp.AddRange(node.Children);

                        // Get the type of object
                        IEnumerator <ConcreteNode> iter = temp.GetEnumerator();
                        iter.MoveNext();
                        impl.Cls = iter.Current.Token;
                        var validNode = iter.MoveNext();

                        // Get the name
                        // Unless the type is in the exclusion list
                        if (validNode && (iter.Current.Type == ConcreteNodeType.Word || iter.Current.Type == ConcreteNodeType.Quote) &&
                            !this._compiler._isNameExcluded(impl.Cls, this._current))
                        {
                            impl.Name = iter.Current.Token;
                            validNode = iter.MoveNext();
                        }

                        // Everything up until the colon is a "value" of this object
                        while (validNode && iter.Current.Type != ConcreteNodeType.Colon &&
                               iter.Current.Type != ConcreteNodeType.LeftBrace)
                        {
                            if (iter.Current.Type == ConcreteNodeType.Variable)
                            {
                                var var = new VariableGetAbstractNode(impl);
                                var.File = iter.Current.File;
                                var.Line = iter.Current.Line;
                                var.Name = iter.Current.Token;
                                impl.Values.Add(var);
                            }
                            else
                            {
                                var atom = new AtomAbstractNode(impl);
                                atom.File  = iter.Current.File;
                                atom.Line  = iter.Current.Line;
                                atom.Value = iter.Current.Token;
                                impl.Values.Add(atom);
                            }
                            validNode = iter.MoveNext();
                        }

                        // Find the base
                        if (validNode && iter.Current.Type == ConcreteNodeType.Colon)
                        {
                            // Children of the ':' are bases
                            foreach (var j in iter.Current.Children)
                            {
                                impl.Bases.Add(j.Token);
                            }

                            validNode = iter.MoveNext();
                        }

                        // Finally try to map the cls to an id
                        if (this._compiler.KeywordMap.ContainsKey(impl.Cls))
                        {
                            impl.Id = this._compiler.KeywordMap[impl.Cls];
                        }

                        asn           = (AbstractNode)impl;
                        this._current = impl;

                        // Visit the children of the {
                        AbstractTreeBuilder.Visit(this, temp2.Children);

                        // Go back up the stack
                        this._current = impl.Parent;
                    }
                    // Otherwise, it is a property
                    else
                    {
                        var impl = new PropertyAbstractNode(this._current);
                        impl.Line = node.Line;
                        impl.File = node.File;
                        impl.Name = node.Token;

                        if (this._compiler.KeywordMap.ContainsKey(impl.Name))
                        {
                            impl.Id = this._compiler.KeywordMap[impl.Name];
                        }

                        asn           = (AbstractNode)impl;
                        this._current = impl;

                        // Visit the children of the {
                        AbstractTreeBuilder.Visit(this, node.Children);

                        // Go back up the stack
                        this._current = impl.Parent;
                    }
                }
                // Otherwise, it is a standard atom
                else
                {
                    var impl = new AtomAbstractNode(this._current);
                    impl.Line  = node.Line;
                    impl.File  = node.File;
                    impl.Value = node.Token;

                    if (this._compiler.KeywordMap.ContainsKey(impl.Value))
                    {
                        impl.Id = this._compiler.KeywordMap[impl.Value];
                    }

                    asn = impl;
                }

                if (asn != null)
                {
                    if (this._current != null)
                    {
                        if (this._current is PropertyAbstractNode)
                        {
                            var impl = (PropertyAbstractNode)this._current;
                            impl.Values.Add(asn);
                        }
                        else
                        {
                            var impl = (ObjectAbstractNode)this._current;
                            impl.Children.Add(asn);
                        }
                    }
                    else
                    {
                        this._nodes.Add(asn);
                    }
                }
            }
コード例 #5
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PropertyAbstractNode obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
コード例 #6
0
 public virtual SubRenderState CreateInstance(ScriptCompiler compiler, PropertyAbstractNode prop, Pass pass,
                                              ScriptTranslator stranslator)
 {
     return(null);
 }
コード例 #7
0
 public virtual SubRenderState CreateInstance(ScriptCompiler compiler, PropertyAbstractNode prop,
                                              TextureUnitState texState, ScriptTranslator translator)
 {
     return(null);
 }