コード例 #1
0
        public override void Render(Batcher batcher, Camera camera)
        {
            // flush the 2D batch so we render appropriately depth-wise
            batcher.FlushBatch();

            Core.GraphicsDevice.BlendState        = BlendState.Opaque;
            Core.GraphicsDevice.DepthStencilState = DepthStencilState.Default;

            // Set BasicEffect parameters.
            _basicEffect.World        = WorldMatrix;
            _basicEffect.View         = camera.ViewMatrix3D;
            _basicEffect.Projection   = camera.ProjectionMatrix3D;
            _basicEffect.DiffuseColor = Color.ToVector3();

            // Set our vertex declaration, vertex buffer, and index buffer.
            Core.GraphicsDevice.SetVertexBuffer(_vertexBuffer);
            Core.GraphicsDevice.Indices = _indexBuffer;

            _basicEffect.CurrentTechnique.Passes[0].Apply();
            var primitiveCount = _indices.Count / 3;

            Core.GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, primitiveCount);
        }
コード例 #2
0
ファイル: Mesh.cs プロジェクト: JonSnowbd/Ash
        public override void Render(Batcher batcher, Camera camera)
        {
            if (_verts == null)
            {
                return;
            }

            batcher.FlushBatch();

            _basicEffect.Projection = camera.ProjectionMatrix;
            _basicEffect.View       = camera.TransformMatrix;
            _basicEffect.World      = Entity.Transform.LocalToWorldTransform;
            _basicEffect.CurrentTechnique.Passes[0].Apply();

            if (_primitiveType == PrimitiveType.TriangleList)
            {
                Core.GraphicsDevice.DrawUserIndexedPrimitives(_primitiveType, _verts, 0, _verts.Length, _triangles, 0, _primitiveCount);
            }
            else if (_primitiveType == PrimitiveType.TriangleStrip)
            {
                Core.GraphicsDevice.DrawUserPrimitives(_primitiveType, _verts, 0, _verts.Length - 2);
            }
        }