// TODO: Add more advanced texture rectangles // Like texture region and texture rotation public static void AddRectangle(this DynamicPrimitive dynamicPrimitive, Vector2 min, Vector2 max, Color color, Matrix4x4?world = null, float lineWidth = 1) { dynamicPrimitive.BeginPrimitive(PrimitiveType.Lines, null, world, lineWidth); { dynamicPrimitive.AddVertex(new Vector3(min.X, min.Y, 0), color); dynamicPrimitive.AddVertex(new Vector3(min.X, max.Y, 0), color); dynamicPrimitive.AddVertex(new Vector3(max.X, max.Y, 0), color); dynamicPrimitive.AddVertex(new Vector3(max.X, min.Y, 0), color); dynamicPrimitive.AddIndex(0); dynamicPrimitive.AddIndex(1); dynamicPrimitive.AddIndex(1); dynamicPrimitive.AddIndex(2); dynamicPrimitive.AddIndex(2); dynamicPrimitive.AddIndex(3); dynamicPrimitive.AddIndex(3); dynamicPrimitive.AddIndex(0); } dynamicPrimitive.EndPrimitive(); }
public static void AddRectangle(this DynamicPrimitive dynamicPrimitive, Vector2 min, Vector2 max, Vector3 up, Color color, Matrix4x4?world = null, float lineWidth = 1) { var transform = MathHelper.CreateRotation(new Vector3(0, 1, 0), up); dynamicPrimitive.BeginPrimitive(PrimitiveType.Lines, null, world, lineWidth); { dynamicPrimitive.AddVertex(Vector3.TransformNormal(new Vector3(min.X, min.Y, 0), transform), color); dynamicPrimitive.AddVertex(Vector3.TransformNormal(new Vector3(min.X, max.Y, 0), transform), color); dynamicPrimitive.AddVertex(Vector3.TransformNormal(new Vector3(max.X, max.Y, 0), transform), color); dynamicPrimitive.AddVertex(Vector3.TransformNormal(new Vector3(max.X, min.Y, 0), transform), color); dynamicPrimitive.AddIndex(0); dynamicPrimitive.AddIndex(1); dynamicPrimitive.AddIndex(1); dynamicPrimitive.AddIndex(2); dynamicPrimitive.AddIndex(2); dynamicPrimitive.AddIndex(3); dynamicPrimitive.AddIndex(3); dynamicPrimitive.AddIndex(0); } dynamicPrimitive.EndPrimitive(); }
public static void AddSolidRectangle(this DynamicPrimitive dynamicPrimitive, Vector2 min, Vector2 max, Color color, TextureId?texture = null, Matrix4x4?world = null) { dynamicPrimitive.BeginPrimitive(PrimitiveType.Triangles, texture, world); { dynamicPrimitive.AddVertex(new Vector3(min.X, min.Y, 0), color, new Vector2(0, 0)); dynamicPrimitive.AddVertex(new Vector3(min.X, max.Y, 0), color, new Vector2(0, 1)); dynamicPrimitive.AddVertex(new Vector3(max.X, max.Y, 0), color, new Vector2(1, 1)); dynamicPrimitive.AddVertex(new Vector3(max.X, min.Y, 0), color, new Vector2(1, 0)); dynamicPrimitive.AddIndex(0); dynamicPrimitive.AddIndex(1); dynamicPrimitive.AddIndex(2); dynamicPrimitive.AddIndex(2); dynamicPrimitive.AddIndex(3); dynamicPrimitive.AddIndex(0); } dynamicPrimitive.EndPrimitive(); }