/// <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 wire disk (a circle) with an origin and normal direction using the specified color. /// </summary> /// <param name="origin">The position of the disk.</param> /// <param name="normal">The normal direction of the disk, assumed normalized. It will face this vector.</param> /// <param name="radius">The radius of the disk in units.</param> /// <param name="color">The color of the disk.</param> public void DrawDisk(Vector3 origin, Vector3 normal, float radius, Color color) { var world = DiskGizmoGeometry.CalculateWorld(origin, normal, radius); AddDrawInstance(Disk, color, world); }