Exemple #1
0
        public void Render(Graphics.Graphics graphics)
        {
            switch (Mode)
            {
            case HandleMode.Resize:
                for (int i = 0; i < BRUSH_MANIPULATION_HANDLE_COUNT; i++)
                {
                    SolidGrabHandle handle = mHandles[i];
                    graphics.DrawSolidRectangle(handle.BottomLeft, handle.BottomRight,
                                                handle.TopRight, handle.TopLeft, Color.White);
                }
                break;

            case HandleMode.Rotate:
                for (int i = 0; i < 4; i++)
                {
                    SolidGrabHandle handle = mHandles[i];
                    graphics.DrawSolidCircle(handle.BottomLeft, handle.BottomRight,
                                             handle.TopRight, handle.TopLeft, Color.White);
                }
                break;

            case HandleMode.Skew:
                for (int i = 4; i < 8; i++)
                {
                    SolidGrabHandle handle = mHandles[i];
                    graphics.DrawSolidRectangle(handle.BottomLeft, handle.BottomRight,
                                                handle.TopRight, handle.TopLeft, Color.White);
                }
                break;
            }
        }
        /// <summary>
        /// Draw center
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="solid"></param>
        /// <param name="color"></param>
        private void DrawCenter(Graphics.Graphics graphics, MapObject solid, Color color)
        {
            // create this viewport base vectors
            float   halfIndicitorSize = 5f * Viewport.Zoom;
            Matrix4 viewportMatrix    = Viewport.Camera.GetWorldMatrix().ClearTranslation();
            Vector3 horizontalVector  = viewportMatrix.Row0.Xyz * halfIndicitorSize;
            Vector3 verticalVector    = viewportMatrix.Row1.Xyz * halfIndicitorSize;

            // draw center x
            Vector3 center      = solid.Bounds.Center;
            Vector3 diagonalOne = (-horizontalVector + verticalVector).Normalized() * halfIndicitorSize;
            Vector3 diagonalTwo = (-horizontalVector - verticalVector).Normalized() * halfIndicitorSize;

            graphics.DrawLine(center - diagonalOne, center + diagonalOne, RuneGear.Graphics.Graphics.LineType.LineNormal, color);
            graphics.DrawLine(center - diagonalTwo, center + diagonalTwo, RuneGear.Graphics.Graphics.LineType.LineNormal, color);
        }
Exemple #3
0
        /// <summary>
        /// Only draw for the current viewport that is doing the action
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="viewport"></param>
        private void RenderBlanket(Graphics.Graphics graphics, BaseViewport viewport)
        {
            if (viewport.ViewportType != BaseViewport.ViewportTypes.PERSPECTIVE &&
                coverBlanket.HasVolume2D && currentActionViewport == viewport.ViewportType)
            {
                Vector3 bottomLeft  = new Vector3(coverBlanket.Min.X, coverBlanket.Min.Y, 0);
                Vector3 bottomRight = new Vector3(coverBlanket.Max.X, coverBlanket.Min.Y, 0);
                Vector3 topRight    = new Vector3(coverBlanket.Max.X, coverBlanket.Max.Y, 0);
                Vector3 topLeft     = new Vector3(coverBlanket.Min.X, coverBlanket.Max.Y, 0);

                graphics.BeginDraw(Matrix4.CreateOrthographicOffCenter(0, viewport.Width, viewport.Height, 0, 0, 1));

                //Color blanketColor = Color.FromArgb(64, Color.LightSkyBlue);
                //renderer.DrawSolidRectangle(topLeft, topRight, bottomRight, bottomLeft, blanketColor); // TODO FIX winding....??!?!?!?
                graphics.DrawRectangle(bottomLeft, bottomRight, topRight, topLeft, Graphics.Graphics.LineType.LineDashed, Color.DeepSkyBlue);
                graphics.EndDraw();
            }
        }
        /// <summary>
        /// Draw corner point indicators
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="solid"></param>
        /// <param name="color"></param>
        private void DrawCornerPoints(Graphics.Graphics graphics, Solid solid, Color color)
        {
            // create this viewport base vectors
            float   halfIndicitorSize = 1.8f * Viewport.Zoom;
            Matrix4 viewportMatrix    = Viewport.Camera.GetWorldMatrix().ClearTranslation();
            Vector3 horizontalVector  = viewportMatrix.Row0.Xyz * halfIndicitorSize;
            Vector3 verticalVector    = viewportMatrix.Row1.Xyz * halfIndicitorSize;

            foreach (Vector3 position in solid.VertexPositions)
            {
                // create 4 points for the rectangle
                Vector3 bottomLeft  = position - horizontalVector - verticalVector;
                Vector3 bottomRight = position + horizontalVector - verticalVector;
                Vector3 topRight    = position + horizontalVector + verticalVector;
                Vector3 topLeft     = position - horizontalVector + verticalVector;

                graphics.DrawSolidRectangle(bottomLeft, bottomRight, topRight, topLeft, color);
            }
        }
        public void DrawSolid(Graphics.Graphics graphics, Solid solid, Color color, bool textured = false)
        {
            // extract triangles from faces
            // trianglefan to trianglelist
            foreach (SolidFace face in solid.Faces)
            {
                if (face.Indices.Count < 3)
                {
                    continue;
                }

                SolidVertex[] vertices = solid.GetVerticesForFace(face);
                if (textured)
                {
                    graphics.DrawTexturedSolidPolygon(vertices, face.Normal, color, face.Texture);
                }
                else
                {
                    graphics.DrawSolidPolygon(vertices, face.Normal, color);
                }
            }
        }