Esempio n. 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> >();
        }
Esempio n. 2
0
        /// <summary>
        ///     Draws a wire frustum -ViewProjection matrix- using the specified color.
        /// </summary>
        /// <param name="viewProjection">The ViewProjection matrix of a virtual camera to draw its frustum.</param>
        /// <param name="color">The color of the frustum.</param>
        public void DrawFrustum(Matrix viewProjection, Color color)
        {
            var world = CubeGizmoGeometry.CalculateFrustumWorld(viewProjection);

            AddDrawInstance(Cube, color, world);
        }
Esempio n. 3
0
        /// <summary>
        ///     Draws a wire cube with an origin and size using the specified color.
        /// </summary>
        /// <param name="origin">The position of the cube.</param>
        /// <param name="size">The size of the cube.</param>
        /// <param name="color">The color of the cube.</param>
        public void DrawCube(Vector3 origin, Vector3 size, Color color)
        {
            var world = CubeGizmoGeometry.CalculateWorld(origin, size);

            AddDrawInstance(Cube, color, world);
        }