示例#1
0
        public static void VisitNullable(this Pass p, ref Statement s)
        {
            if (s != null)
            {
                p.Begin(ref s);

                if (s is Expression)
                {
                    var e = s as Expression;
                    p.Begin(ref e, ExpressionUsage.Statement);
                    s = e;
                }

                s.Visit(p);

                if (s is Expression)
                {
                    var e = s as Expression;
                    p.End(ref e, ExpressionUsage.Statement);
                    s = e;
                }

                p.End(ref s);
            }
        }
示例#2
0
        public override void Visit(Pass p, ExpressionUsage u)
        {
            p.Begin(ref Array, ExpressionUsage.Object);
            Array.Visit(p, ExpressionUsage.Object);
            p.End(ref Array, ExpressionUsage.Object);

            p.Begin(ref Index);
            Index.Visit(p);
            p.End(ref Index);
        }
示例#3
0
文件: SequenceOp.cs 项目: mortend/uno
        public override void Visit(Pass p, ExpressionUsage u)
        {
            p.Begin(ref Left, ExpressionUsage.Statement);
            Left.Visit(p, ExpressionUsage.Statement);
            p.End(ref Left, ExpressionUsage.Statement);

            p.Begin(ref Right, u);
            Right.Visit(p, u);
            p.End(ref Right, u);
        }
示例#4
0
        public override void Visit(Pass p, ExpressionUsage u)
        {
            p.Begin(ref Left, ExpressionUsage.Operand);
            Left.Visit(p, ExpressionUsage.Operand);
            p.End(ref Left, ExpressionUsage.Operand);

            p.Begin(ref Right, ExpressionUsage.Operand);
            Right.Visit(p, ExpressionUsage.Operand);
            p.End(ref Right, ExpressionUsage.Operand);
        }
示例#5
0
        public override void Visit(Pass p, ExpressionUsage u)
        {
            p.Begin(ref Object, ExpressionUsage.Object);
            Object.Visit(p, ExpressionUsage.Object);
            p.End(ref Object, ExpressionUsage.Object);

            for (int i = 0; i < Arguments.Length; i++)
            {
                p.Begin(ref Arguments[i]);
                Arguments[i].Visit(p);
                p.End(ref Arguments[i]);
            }
        }
示例#6
0
        public override void Visit(Pass p, ExpressionUsage u)
        {
            if (Object != null)
            {
                p.Begin(ref Object, ExpressionUsage.Object);
                Object.Visit(p, ExpressionUsage.Object);
                p.End(ref Object, ExpressionUsage.Object);
            }

            p.Begin(ref Listener);
            Listener.Visit(p);
            p.End(ref Listener);
        }
示例#7
0
        public override void Visit(Pass p, ExpressionUsage u)
        {
            p.Begin(ref Condition, ExpressionUsage.Operand);
            Condition.Visit(p, ExpressionUsage.Operand);
            p.End(ref Condition, ExpressionUsage.Operand);

            p.Begin(ref True, ExpressionUsage.Operand);
            True.Visit(p, ExpressionUsage.Operand);
            p.End(ref True, ExpressionUsage.Operand);

            p.Begin(ref False, ExpressionUsage.Operand);
            False.Visit(p, ExpressionUsage.Operand);
            p.End(ref False, ExpressionUsage.Operand);
        }
示例#8
0
        public void Visit(Pass p)
        {
            if (!p.Begin(this))
            {
                return;
            }

            var old = p.MetaProperty;

            p.MetaProperty = this;

            foreach (var def in Definitions)
            {
                if (def.Value is Expression)
                {
                    Expression e = def.Value as Expression;
                    p.VisitNullable(ref e);
                    def.Value = e;
                }
                else
                {
                    p.VisitNullable(ref def.Value);
                }
            }

            p.MetaProperty = old;
            p.End(this);
        }
        public override void Draw(GraphicsDevice device, ThreeDScene scene)
        {
            for (int i = 0; i < m_Effects.Count; i++)
            {
                for (int j = 0; j < m_CurrentSims.Count; j++)
                {
                    if (m_CurrentSims[j].HeadTexture != null)
                    {
                        m_Effects[i].World = m_Scene.SceneMgr.WorldMatrix *
                                             Matrix.CreateTranslation(new Vector3(m_CurrentSims[j].HeadXPos, m_CurrentSims[j].HeadYPos, 0.0f));
                        m_Effects[i].View       = Matrix.CreateLookAt(Vector3.Backward * 17, Vector3.Zero, Vector3.Right);
                        m_Effects[i].Projection = m_Scene.SceneMgr.ProjectionMatrix;

                        m_Effects[i].Texture        = m_CurrentSims[j].HeadTexture;
                        m_Effects[i].TextureEnabled = true;

                        m_Effects[i].EnableDefaultLighting();

                        m_Effects[i].CommitChanges();

                        // Draw
                        m_Effects[i].Begin();

                        for (int k = 0; k < m_Effects[i].Techniques.Count; k++)
                        {
                            foreach (EffectPass Pass in m_Effects[i].Techniques[k].Passes)
                            {
                                Pass.Begin();

                                foreach (Sim Character in m_CurrentSims)
                                {
                                    foreach (Face Fce in Character.HeadMesh.FaceData)
                                    {
                                        if (Character.HeadMesh.VertexTexNormalPositions != null)
                                        {
                                            VertexPositionNormalTexture[] Vertex = new VertexPositionNormalTexture[3];
                                            Vertex[0] = Character.HeadMesh.VertexTexNormalPositions[Fce.VertexA];
                                            Vertex[1] = Character.HeadMesh.VertexTexNormalPositions[Fce.VertexB];
                                            Vertex[2] = Character.HeadMesh.VertexTexNormalPositions[Fce.VertexC];

                                            Vertex[0].TextureCoordinate = Character.HeadMesh.VertexTexNormalPositions[Fce.VertexA].TextureCoordinate;
                                            Vertex[1].TextureCoordinate = Character.HeadMesh.VertexTexNormalPositions[Fce.VertexB].TextureCoordinate;
                                            Vertex[2].TextureCoordinate = Character.HeadMesh.VertexTexNormalPositions[Fce.VertexC].TextureCoordinate;

                                            m_Scene.SceneMgr.Device.DrawUserPrimitives <VertexPositionNormalTexture>(
                                                PrimitiveType.TriangleList, Vertex, 0, 1);
                                        }
                                    }
                                }

                                Pass.End();
                                m_Effects[i].End();
                            }
                        }
                    }
                }
            }
        }
示例#10
0
文件: Extensions.cs 项目: mortend/uno
 public static void VisitNullable(this Pass p, ref Expression e, ExpressionUsage u = ExpressionUsage.Argument)
 {
     if (e != null)
     {
         p.Begin(ref e, u);
         e.Visit(p, u);
         p.End(ref e, u);
     }
 }
示例#11
0
文件: NewObject.cs 项目: mortend/uno
 public override void Visit(Pass p, ExpressionUsage u = ExpressionUsage.Argument)
 {
     for (int i = 0; i < Arguments.Length; i++)
     {
         p.Begin(ref Arguments[i]);
         Arguments[i].Visit(p);
         p.End(ref Arguments[i]);
     }
 }
示例#12
0
        private void Draw()
        {
            // render cube into offscreen render targets
            var offScreenPassAction = default(PassAction);

            offScreenPassAction.Color().Action = PassAttachmentAction.Clear;
            offScreenPassAction.Color().Value  = new Rgba32F(0.25f, 0.0f, 0.0f, 1.0f);
            offScreenPassAction.Color(1).Action = PassAttachmentAction.Clear;
            offScreenPassAction.Color(1).Value  = new Rgba32F(0.0f, 0.25f, 0.0f, 1.0f);
            offScreenPassAction.Color(2).Action = PassAttachmentAction.Clear;
            offScreenPassAction.Color(2).Value  = new Rgba32F(0.0f, 0.0f, 0.25f, 1.0f);

            // describe the binding of the off screen cube
            var offScreenBindings = default(ResourceBindings);

            offScreenBindings.VertexBuffer() = _cubeVertexBuffer;
            offScreenBindings.IndexBuffer    = _cubeIndexBuffer;

            _offScreenPass.Begin(ref offScreenPassAction);
            _offScreenPass.ApplyPipeline(_offScreenPipeline);
            _offScreenPass.ApplyBindings(ref offScreenBindings);
            _offScreenPass.ApplyShaderUniforms(ShaderStageType.VertexStage, ref _modelViewProjectionMatrix);
            _offScreenPass.DrawElements(36);
            _offScreenPass.End();

            // describe the binding of the debug quads
            var debugBindings = default(ResourceBindings);

            debugBindings.VertexBuffer() = _quadVertexBuffer;

            // describe the binding of the full screen quad vertex buffer
            var fullScreenBindings = default(ResourceBindings);

            fullScreenBindings.VertexBuffer()        = _quadVertexBuffer;
            fullScreenBindings.FragmentStageImage()  = _offScreenRenderTargets[0];
            fullScreenBindings.FragmentStageImage(1) = _offScreenRenderTargets[1];
            fullScreenBindings.FragmentStageImage(2) = _offScreenRenderTargets[2];

            // render fullscreen quad with the 'composed image',
            // plus 3 small debug-views with the content of the offscreen render targets
            var pass = BeginDefaultPass();

            pass.ApplyPipeline(_fullScreenPipeline);
            pass.ApplyBindings(ref fullScreenBindings);
            pass.ApplyShaderUniforms(ShaderStageType.VertexStage, ref _offset);
            pass.DrawElements(4);
            pass.ApplyPipeline(_debugPipeline);
            for (var i = 0; i < 3; i++)
            {
                pass.ApplyViewport(i * 100, 0, 100, 100);
                debugBindings.FragmentStageImage() = _offScreenRenderTargets[i];
                pass.ApplyBindings(ref debugBindings);
                pass.DrawElements(4);
            }

            pass.End();
        }
示例#13
0
        public override void Visit(Pass p, ExpressionUsage u)
        {
            if (Size != null)
            {
                p.Begin(ref Size);
                Size.Visit(p);
                p.End(ref Size);
            }

            if (Initializers != null)
            {
                for (int i = 0; i < Initializers.Length; i++)
                {
                    p.Begin(ref Initializers[i]);
                    Initializers[i].Visit(p);
                    p.End(ref Initializers[i]);
                }
            }
        }
示例#14
0
        public void Visit(Pass p)
        {
            if (!p.Begin(this))
            {
                return;
            }

            var old = p.Block;

            p.Block = this;

            var db = this as DrawBlock;

            if (db?.Drawables != null)
            {
                foreach (var dp in db.Drawables)
                {
                    dp.DrawState.VertexShader.Visit(p);
                    dp.DrawState.PixelShader.Visit(p);
                }
            }

            for (int i = 0; i < Members.Count; i++)
            {
                var m = Members[i];

                switch (m.Type)
                {
                case BlockMemberType.Apply:
                {
                    var apply = m as Apply;
                    p.OnApply(apply);
                    break;
                }

                case BlockMemberType.MetaProperty:
                {
                    var mp = m as MetaProperty;
                    mp.Visit(p);
                    break;
                }

                case BlockMemberType.Node:
                {
                    var node = m as Node;
                    node.Block.Visit(p);
                    break;
                }
                }
            }

            p.Block = old;
            p.End(this);
        }
示例#15
0
        private void Draw()
        {
            // begin the offscreen render pass
            var offscreenPassAction = PassAction.Clear(Rgba32F.Black);

            _offscreenRenderPass.Begin(ref offscreenPassAction);

            // describe the bindings for rendering a non-textured cube into the render target
            var offscreenResourceBindings = default(ResourceBindings);

            offscreenResourceBindings.VertexBuffer() = _vertexBuffer;
            offscreenResourceBindings.IndexBuffer    = _indexBuffer;

            // apply the render pipeline and bindings for the offscreen render pass
            _offscreenRenderPass.ApplyPipeline(_offscreenPipeline);
            _offscreenRenderPass.ApplyBindings(ref offscreenResourceBindings);

            // apply the mvp matrix to the offscreen vertex shader
            _offscreenRenderPass.ApplyShaderUniforms(ShaderStageType.VertexStage, ref _modelViewProjectionMatrix);

            // draw the non-textured cube into the target of the offscreen render pass
            _offscreenRenderPass.DrawElements(36);

            // end the offscreen render pass
            _offscreenRenderPass.End();

            // begin a frame buffer render pass
            Rgba32F clearColor      = 0x0040FFFF;
            var     frameBufferPass = BeginDefaultPass(clearColor);

            // describe the bindings for using the offscreen render target as the sampled texture
            var frameBufferResourceBindings = default(ResourceBindings);

            frameBufferResourceBindings.VertexBuffer()       = _vertexBuffer;
            frameBufferResourceBindings.IndexBuffer          = _indexBuffer;
            frameBufferResourceBindings.FragmentStageImage() = _renderTarget;

            // apply the render pipeline and bindings for the frame buffer render pass
            frameBufferPass.ApplyPipeline(_frameBufferPipeline);
            frameBufferPass.ApplyBindings(ref frameBufferResourceBindings);

            // apply the mvp matrix to the frame buffer vertex shader
            frameBufferPass.ApplyShaderUniforms(ShaderStageType.VertexStage, ref _modelViewProjectionMatrix);

            // draw the textured cube into the target of the frame buffer render pass
            frameBufferPass.DrawElements(36);

            // end the frame buffer render pass
            frameBufferPass.End();
        }
示例#16
0
文件: Shader.cs 项目: mortend/uno
        public void VisitTerminals(Statement parent, Pass p)
        {
            var keys = new string[Terminals.Count];

            Terminals.Keys.CopyTo(keys, 0);

            foreach (var key in keys)
            {
                var s = Terminals[key];
                p.Next(parent);
                p.Begin(ref s);
                s.Visit(p);
                p.End(ref s);
                Terminals[key] = s;
            }
        }
示例#17
0
文件: DrawState.cs 项目: mortend/uno
        public void VisitVaryings(Statement parent, Pass p)
        {
            for (int i = 0; i < Varyings.Count; i++)
            {
                var u = Varyings[i];
                var s = u.Value;

                p.Next(parent);
                p.Begin(ref s);
                s.Visit(p);
                p.End(ref s);

                u.Value     = s;
                Varyings[i] = u;
            }
        }
示例#18
0
文件: Shader.cs 项目: mortend/uno
        public void Visit(Pass p)
        {
            if (!p.Begin(this))
            {
                return;
            }

            var ps = p.Shader;

            p.Shader = this;

            foreach (var f in Functions)
            {
                f.Visit(p);
            }

            Entrypoint.Visit(p);
            p.Shader = ps;
            p.End(this);
        }
示例#19
0
文件: CastOp.cs 项目: mortend/uno
 public override void Visit(Pass p, ExpressionUsage u)
 {
     p.Begin(ref Operand, ExpressionUsage.Operand);
     Operand.Visit(p, ExpressionUsage.Operand);
     p.End(ref Operand, ExpressionUsage.Operand);
 }
示例#20
0
 public override void Visit(Pass p, ExpressionUsage u)
 {
     p.Begin(ref Value);
     Value.Visit(p);
     p.End(ref Value);
 }
示例#21
0
 public override void Visit(Pass p, ExpressionUsage u)
 {
     p.Begin(ref _body);
     Body.Visit(p);
     p.End(ref _body);
 }
示例#22
0
文件: Swizzle.cs 项目: mortend/uno
 public override void Visit(Pass p, ExpressionUsage u)
 {
     p.Begin(ref Object, ExpressionUsage.Object);
     Object.Visit(p, ExpressionUsage.Object);
     p.End(ref Object, ExpressionUsage.Object);
 }
示例#23
0
文件: DrawState.cs 项目: mortend/uno
        public void Visit(Statement parent, Pass p)
        {
            foreach (var key in Terminals.Keys.ToArray())
            {
                var s = Terminals[key];

                p.Next(parent);
                p.Begin(ref s);
                s.Visit(p);
                p.End(ref s);

                Terminals[key] = s;
            }

            if (OptionalIndices != null)
            {
                p.Next(parent);
                p.Begin(ref OptionalIndices.Buffer);
                OptionalIndices.Buffer.Visit(p);
                p.End(ref OptionalIndices.Buffer);

                p.Next(parent);
                p.Begin(ref OptionalIndices.IndexType);
                OptionalIndices.IndexType.Visit(p);
                p.End(ref OptionalIndices.IndexType);
            }

            for (int i = 0; i < VertexAttributes.Count; i++)
            {
                var e = VertexAttributes[i];

                p.Next(parent);
                p.Begin(ref e.AttribType);
                e.AttribType.Visit(p);
                p.End(ref e.AttribType);

                p.Next(parent);
                p.Begin(ref e.Buffer);
                e.Buffer.Visit(p);
                p.End(ref e.Buffer);

                p.Next(parent);
                p.Begin(ref e.Offset);
                e.Offset.Visit(p);
                p.End(ref e.Offset);

                p.Next(parent);
                p.Begin(ref e.Stride);
                e.Stride.Visit(p);
                p.End(ref e.Stride);
            }

            for (int i = 0; i < RuntimeConstants.Count; i++)
            {
                var e = RuntimeConstants[i];

                p.Next(parent);
                p.Begin(ref e.Value);
                e.Value.Visit(p);
                p.End(ref e.Value);
            }

            for (int i = 0; i < Uniforms.Count; i++)
            {
                var e = Uniforms[i];

                p.Next(parent);
                p.Begin(ref e.Value);
                e.Value.Visit(p);
                p.End(ref e.Value);
            }

            for (int i = 0; i < PixelSamplers.Count; i++)
            {
                var e = PixelSamplers[i];

                p.Next(parent);
                p.Begin(ref e.Texture);
                e.Texture.Visit(p);
                p.End(ref e.Texture);

                if (e.OptionalState != null)
                {
                    p.Next(parent);
                    p.Begin(ref e.OptionalState);
                    e.OptionalState.Visit(p);
                    p.End(ref e.OptionalState);
                }
            }
        }