Example #1
0
        /// <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> >();
        }
Example #2
0
        /// <summary>
        ///     Draws a wire cylinder with an origin, rotation and size using the specified color.
        /// </summary>
        /// <param name="origin">The position of the cylinder.</param>
        /// <param name="rotation">A rotation matrix to set the orientation of the cylinder. The cylinder is by default XZ aligned.</param>
        /// <param name="size">The size of the cylinder.</param>
        /// <param name="color">The color of the cylinder.</param>
        public void DrawCylinder(Vector3 origin, Matrix rotation, Vector3 size, Color color)
        {
            var world = CylinderGizmoGeometry.CalculateWorld(origin, rotation, size);

            AddDrawInstance(Cylinder, color, world);
        }