/// <summary> /// Loads all the content necessary for drawing Gizmos. /// </summary> /// <param name="device">The GraphicsDevice to use when drawing. It is also used to bind buffers.</param> /// <param name="content">The ContentManager to manage Gizmos resources.</param> public void LoadContent(GraphicsDevice device) { GraphicsDevice = device; Content = TGCGame.Instance.Content; Effect = Content.Load <Effect>("Effects/Gizmos"); BackgroundPass = Effect.CurrentTechnique.Passes["Background"]; ForegroundPass = Effect.CurrentTechnique.Passes["Foreground"]; WorldViewProjectionParameter = Effect.Parameters["WorldViewProjection"]; ColorParameter = Effect.Parameters["Color"]; LineSegment = new LineSegmentGizmoGeometry(GraphicsDevice); Cube = new CubeGizmoGeometry(GraphicsDevice); Sphere = new SphereGizmoGeometry(GraphicsDevice, 20); PolyLine = new PolyLineGizmoGeometry(GraphicsDevice); Disk = new DiskGizmoGeometry(GraphicsDevice, 20); Cylinder = new CylinderGizmoGeometry(GraphicsDevice, 20); //AxisLines = new AxisLines(GraphicsDevice, Content.Load<Model>("3D/geometries/arrow")); DrawInstances[LineSegment] = new Dictionary <Color, List <Matrix> >(); DrawInstances[Sphere] = new Dictionary <Color, List <Matrix> >(); DrawInstances[Cube] = new Dictionary <Color, List <Matrix> >(); DrawInstances[Disk] = new Dictionary <Color, List <Matrix> >(); DrawInstances[Cylinder] = new Dictionary <Color, List <Matrix> >(); }
/// <summary> /// Draws a line between the points origin and destination using the specified color. /// </summary> /// <param name="origin">The origin of the line.</param> /// <param name="destination">The final point of the line.</param> /// <param name="color">The color of the line.</param> public void DrawLine(Vector3 origin, Vector3 destination, Color color) { var world = LineSegmentGizmoGeometry.CalculateWorld(origin, destination); AddDrawInstance(LineSegment, BaseColor, world); }