public void DrawLines(Vector3[] lineData, Color color) { // drawing in 3D requires you to define vertices of a certain type // VertexPositionColor simply means a vertex with a position and color MyVertexFormatPositionColor[] line = new MyVertexFormatPositionColor[lineData.Length]; for (int i = 0; i < lineData.Length; i++) { line[i] = new MyVertexFormatPositionColor(lineData[i], color.ToVector4()); } var effect = (MyEffectModelsDiffuse)MyRender.GetEffect(MyEffects.ModelDiffuse); // you have to set these parameters for the basic effect to be able to draw // on the screen effect.SetProjectionMatrix(MyCamera.ProjectionMatrix); effect.SetViewMatrix(MyCamera.ViewMatrix); // graphics card should use basic effect shader effect.Begin(); // you have to tell the graphics card what kind of vertices it will be receiving MinerWars.AppCode.App.MyMinerGame.Static.GraphicsDevice.VertexDeclaration = MyVertexFormatPositionColor.VertexDeclaration; MinerWars.AppCode.App.MyMinerGame.Static.GraphicsDevice.DrawUserPrimitives(PrimitiveType.LineList, 0, lineData.Length, line); effect.End(); }
public static void Draw() { for (int i = 0; i < m_moints.Count / 3; i++) { MyVertexFormatPositionColor v1 = m_moints[i * 3 + 0]; MyVertexFormatPositionColor v2 = m_moints[i * 3 + 1]; MyVertexFormatPositionColor v3 = m_moints[i * 3 + 2]; DrawTriangle(v1.Position, v2.Position, v3.Position, v1.Color, v2.Color, v3.Color); } for (int i = 0; i < m_spheres.Count; i++) { DrawSphereWireframe(m_spheres[i].Center, m_spheres[i].Radius, Color.Red.ToVector3(), 1.0f); } ClearAll(); }
internal unsafe void Update(MyRenderMessageDebugDrawMesh message) { edges = !message.Shaded; depth = message.DepthRead; if (vbuffer.ElementCount < message.VertexCount) { MyManagers.Buffers.Resize(vbuffer, message.VertexCount); } var mapping = MyMapping.MapDiscard(MyPrimitivesRenderer.RC, vbuffer); for (int i = 0; i < message.VertexCount; i++) { MyVertexFormatPositionColor vert = new MyVertexFormatPositionColor(Vector3.Transform(message.Vertices[i].Position, message.WorldMatrix), message.Vertices[i].Color); mapping.WriteAndPosition(ref vert); } mapping.Unmap(); message.Vertices.Clear(); }
public static void LoadContent() { MyMwcLog.WriteLine("MyDebugDraw.LoadContent() - START"); MyMwcLog.IncreaseIndent(); // Line m_verticesLine = new MyVertexFormatPositionColor[2]; m_verticesLine[0] = new MyVertexFormatPositionColor(); m_verticesLine[1] = new MyVertexFormatPositionColor(); // Triangle m_triangleVertices = new MyVertexFormatPositionColor[3]; m_triangleVertices[0] = new MyVertexFormatPositionColor(); m_triangleVertices[1] = new MyVertexFormatPositionColor(); m_triangleVertices[2] = new MyVertexFormatPositionColor(); m_moints = new List<MyVertexFormatPositionColor>(); m_spheres = new List<BoundingSphere>(); /* m_modelSphere = MyMinerGame.Static.Content.Load<Model>("Models2\\Debug\\Sphere"); m_modelSphereLowRes = MyMinerGame.Static.Content.Load<Model>("Models2\\Debug\\Sphere_low"); m_modelHemisphere = MyMinerGame.Static.Content.Load<Model>("Models2\\Debug\\Hemisphere"); m_modelBoxHiRes = MyMinerGame.Static.Content.Load<Model>("Models2\\Debug\\BoxHiRes"); m_modelBoxLowRes = MyMinerGame.Static.Content.Load<Model>("Models2\\Debug\\BoxLowRes"); m_modelCapsule = MyMinerGame.Static.Content.Load<Model>("Models2\\Debug\\Capsule"); m_lowResBoxEffect = (BasicEffect)m_modelBoxLowRes.Meshes[0].Effects[0]; */ m_lineBatch = new MyLineBatch(Matrix.Identity, Matrix.Identity, 128); m_frustumCorners = new Vector3[8]; m_coneVertex = new List<Vector3>(32); MyDebugDrawCoordSystem.LoadContent(); MyMwcLog.DecreaseIndent(); MyMwcLog.WriteLine("MyDebugDraw.LoadContent() - END"); }
public static void LoadContent() { MyMwcLog.WriteLine("MyDebugDraw.LoadContent() - START"); MyMwcLog.IncreaseIndent(); // Line m_verticesLine = new MyVertexFormatPositionColor[2]; m_verticesLine[0] = new MyVertexFormatPositionColor(); m_verticesLine[1] = new MyVertexFormatPositionColor(); // Triangle m_triangleVertices = new MyVertexFormatPositionColor[3]; m_triangleVertices[0] = new MyVertexFormatPositionColor(); m_triangleVertices[1] = new MyVertexFormatPositionColor(); m_triangleVertices[2] = new MyVertexFormatPositionColor(); m_moints = new List <MyVertexFormatPositionColor>(); m_spheres = new List <BoundingSphere>(); /* * m_modelSphere = MyMinerGame.Static.Content.Load<Model>("Models2\\Debug\\Sphere"); * m_modelSphereLowRes = MyMinerGame.Static.Content.Load<Model>("Models2\\Debug\\Sphere_low"); * m_modelHemisphere = MyMinerGame.Static.Content.Load<Model>("Models2\\Debug\\Hemisphere"); * m_modelBoxHiRes = MyMinerGame.Static.Content.Load<Model>("Models2\\Debug\\BoxHiRes"); * m_modelBoxLowRes = MyMinerGame.Static.Content.Load<Model>("Models2\\Debug\\BoxLowRes"); * m_modelCapsule = MyMinerGame.Static.Content.Load<Model>("Models2\\Debug\\Capsule"); * * m_lowResBoxEffect = (BasicEffect)m_modelBoxLowRes.Meshes[0].Effects[0]; */ m_lineBatch = new MyLineBatch(Matrix.Identity, Matrix.Identity, 128); m_frustumCorners = new Vector3[8]; m_coneVertex = new List <Vector3>(32); MyDebugDrawCoordSystem.LoadContent(); MyMwcLog.DecreaseIndent(); MyMwcLog.WriteLine("MyDebugDraw.LoadContent() - END"); }
public static void DrawTriangle(Vector3 vertex1, Vector3 vertex2, Vector3 vertex3, Vector4 color1, Vector4 color2, Vector4 color3) { Device graphicsDevice = MyMinerGame.Static.GraphicsDevice; // Create triangleVertexes vertices m_triangleVertices[0] = new MyVertexFormatPositionColor(vertex1, color1); m_triangleVertices[1] = new MyVertexFormatPositionColor(vertex2, color2); m_triangleVertices[2] = new MyVertexFormatPositionColor(vertex3, color3); var effect = (MyEffectModelsDiffuse)MyRender.GetEffect(MyEffects.ModelDiffuse); // Initialise the effect effect.SetProjectionMatrix(MyCamera.ProjectionMatrix); effect.SetViewMatrix(MyCamera.ViewMatrix); effect.SetTechnique(MyEffectModelsDiffuse.Technique.PositionColor); graphicsDevice.VertexDeclaration = MyVertexFormatPositionColor.VertexDeclaration; // Draw the line effect.Begin(); graphicsDevice.VertexDeclaration = MyVertexFormatPositionColor.VertexDeclaration; graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleStrip, 0, 1, m_triangleVertices); effect.End(); }
internal void Add(MyVertexFormatPositionColor from, MyVertexFormatPositionColor to) { List.Add(from); List.Add(to); }
internal void Add(MyVertexFormatPositionColor v) { List.Add(v); }
internal void Add(MyVertexFormatPositionColor from, MyVertexFormatPositionColor to) { MyLinesRenderer.m_lineVertexList.Add(from); MyLinesRenderer.m_lineVertexList.Add(to); }
internal void Add(MyVertexFormatPositionColor v) { MyLinesRenderer.m_lineVertexList.Add(v); }