public static void RenderPlane(this WorldView world, Vector3 position, Vector3 normal, MatterHackers.Agg.Color color, bool doDepthTest, double rectSize, double lineWidth) { var clipping = world.GetClippingFrustum(); // get any perpendicular to the normal (we call it x to make it clear where to apply it) var perpendicularX = normal.GetPerpendicular().GetNormal() * rectSize; // get a second perpendicular that is perpendicular to both var perpendicularY = Vector3.GetPerpendicular(normal, perpendicularX).GetNormal() * rectSize; // the top line world.Render3DLine(clipping, position - perpendicularX + perpendicularY, position + perpendicularX + perpendicularY, color, doDepthTest, lineWidth); // the bottom line world.Render3DLine(clipping, position - perpendicularX - perpendicularY, position + perpendicularX - perpendicularY, color, doDepthTest, lineWidth); // the left line world.Render3DLine(clipping, position - perpendicularX - perpendicularY, position - perpendicularX + perpendicularY, color, doDepthTest, lineWidth); // the right line world.Render3DLine(clipping, position + perpendicularX - perpendicularY, position + perpendicularX + perpendicularY, color, doDepthTest, lineWidth); }
/// <summary> /// Draw a line in the scene in 3D but scale it such that it appears as a 2D line in the view. /// If drawing lots of lines call with a pre-calculated clipping frustum. /// </summary> /// <param name="world"></param> /// <param name="start"></param> /// <param name="end"></param> /// <param name="color"></param> /// <param name="doDepthTest"></param> /// <param name="width"></param> public static void Render3DLine(this WorldView world, Vector3 start, Vector3 end, Color color, bool doDepthTest = true, double width = 1) { world.Render3DLine(GetClippingFrustum(world), start, end, color, doDepthTest, width); }
/// <summary> /// Draw a line in the scene in 3D but scale it such that it appears as a 2D line in the view. /// If drawing lots of lines call with a pre-calculated clipping frustum. /// </summary> /// <param name="world"></param> /// <param name="start"></param> /// <param name="end"></param> /// <param name="color"></param> /// <param name="doDepthTest"></param> /// <param name="width"></param> public static void Render3DLine(this WorldView world, Vector3 start, Vector3 end, Color color, bool doDepthTest = true, double width = 1, bool startArrow = false, bool endArrow = false) { world.Render3DLine(world.GetClippingFrustum(), start, end, color, doDepthTest, width, startArrow, endArrow); }