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); }
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.ToXna4x4(); _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); } }
public override void Render(Batcher batcher, Camera camera) { if (_points.Length < 2) { return; } batcher.FlushBatch(); _basicEffect.Projection = camera.ProjectionMatrix; _basicEffect.View = camera.TransformMatrix; _basicEffect.CurrentTechnique.Passes[0].Apply(); if (!UseWorldSpace) { _basicEffect.World = Transform.LocalToWorldTransform; } var primitiveCount = _indices.Length / 3; Core.GraphicsDevice.SamplerStates[0] = Core.DefaultWrappedSamplerState; Core.GraphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, _vertices.Buffer, 0, _vertices.Length, _indices.Buffer, 0, primitiveCount); }