// line 2d public void DrawLine(float x0, float y0, float x1, float y1, int dw, Color color) { TGCVector2[] V = new TGCVector2[4]; V[0].X = x0; V[0].Y = y0; V[1].X = x1; V[1].Y = y1; if (dw < 1) { dw = 1; } // direccion normnal TGCVector2 v = V[1] - V[0]; v.Normalize(); TGCVector2 n = new TGCVector2(-v.Y, v.X); V[2] = V[1] + n * dw; V[3] = V[0] + n * dw; VERTEX2D[] pt = new VERTEX2D[16]; // 1er triangulo pt[0].x = V[0].X; pt[0].y = V[0].Y; pt[1].x = V[1].X; pt[1].y = V[1].Y; pt[2].x = V[2].X; pt[2].y = V[2].Y; // segundo triangulo pt[3].x = V[0].X; pt[3].y = V[0].Y; pt[4].x = V[2].X; pt[4].y = V[2].Y; pt[5].x = V[3].X; pt[5].y = V[3].Y; for (int t = 0; t < 6; ++t) { pt[t].z = 0.5f; pt[t].rhw = 1; pt[t].color = color.ToArgb(); ++t; } // dibujo como lista de triangulos var device = D3DDevice.Instance.Device; device.VertexFormat = VertexFormats.Transformed | VertexFormats.Diffuse; device.DrawUserPrimitives(PrimitiveType.TriangleList, 2, pt); }
public void FillRect(float x0, float y0, float x1, float y1, Color color) { TGCVector2[] V = new TGCVector2[4]; V[0].X = x0; V[0].Y = y0; V[1].X = x0; V[1].Y = y1; V[2].X = x1; V[2].Y = y1; V[3].X = x1; V[3].Y = y0; VERTEX2D[] pt = new VERTEX2D[16]; // 1er triangulo pt[0].x = V[0].X; pt[0].y = V[0].Y; pt[1].x = V[1].X; pt[1].y = V[1].Y; pt[2].x = V[2].X; pt[2].y = V[2].Y; // segundo triangulo pt[3].x = V[0].X; pt[3].y = V[0].Y; pt[4].x = V[2].X; pt[4].y = V[2].Y; pt[5].x = V[3].X; pt[5].y = V[3].Y; for (int t = 0; t < 6; ++t) { pt[t].z = 0.5f; pt[t].rhw = 1; pt[t].color = color.ToArgb(); ++t; } // dibujo como lista de triangulos var device = D3DDevice.Instance.Device; device.VertexFormat = VertexFormats.Transformed | VertexFormats.Diffuse; device.DrawUserPrimitives(PrimitiveType.TriangleList, 2, pt); }