示例#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;
            }
        }
示例#2
0
        private void RenderCrosshair(Graphics.Graphics graphics)
        {
            // render cross if captured the mouse
            if (CapturedMouse)
            {
                graphics.BeginDraw(MathExtensions.CreateOrthographicLH(mWidth, mHeight, 0, 1.0f));

                graphics.DrawSolidRectangle(Vector3.UnitX * -CROSS_SIZE + -Vector3.UnitY, Vector3.UnitX * CROSS_SIZE + -Vector3.UnitY,
                                            Vector3.UnitX * CROSS_SIZE + Vector3.UnitY, Vector3.UnitX * -CROSS_SIZE + Vector3.UnitY, Color.White);
                graphics.DrawSolidRectangle(Vector3.UnitY * -CROSS_SIZE + -Vector3.UnitX, Vector3.UnitY * -CROSS_SIZE + Vector3.UnitX,
                                            Vector3.UnitY * CROSS_SIZE + Vector3.UnitX, Vector3.UnitY * CROSS_SIZE + -Vector3.UnitX, Color.White);

                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);
            }
        }
示例#4
0
        private void RenderAllVertexHandles(Graphics.Graphics graphics, BaseViewport viewport)
        {
            int nearDepth = 1;
            int farDepth  = 0;

            //TODO check why this is neccessary
            if (viewport.ViewportType == BaseViewport.ViewportTypes.PERSPECTIVE)
            {
                nearDepth = 0;
                farDepth  = 1;
            }

            // handle vertices are already in NDC space when send to the graphicscard
            GL.Clear(ClearBufferMask.DepthBufferBit);
            GL.DepthRange(nearDepth, farDepth);
            GL.Enable(EnableCap.DepthTest);

            graphics.BeginDraw(Matrix4.Identity);

            Vector3       handleDimensions = new Vector3((float)HandleSize / viewport.Width, (float)HandleSize / viewport.Height, 0.0f);
            Matrix4       vpMatrix         = viewport.Camera.GetViewMatrix() * viewport.Camera.GetProjMatrix();
            Handle        handle           = new Handle();
            List <Handle> selectedHandles  = new List <Handle>();

            // create handles and draw non selected handles
            DoSolidAction(controller.Selection, (solid) =>
            {
                int index = 0;
                foreach (Vector3 position in solid.VertexPositions)
                {
                    Vector4 vec4Pos = new Vector4(position, 1.0f) * vpMatrix;
                    Vector3 pos     = vec4Pos.Xyz / vec4Pos.W;

                    handle.BottomLeft  = pos + (-Vector3.UnitX - Vector3.UnitY) * handleDimensions;
                    handle.BottomRight = pos + (Vector3.UnitX - Vector3.UnitY) * handleDimensions;
                    handle.TopRight    = pos + (Vector3.UnitX + Vector3.UnitY) * handleDimensions;
                    handle.TopLeft     = pos + (-Vector3.UnitX + Vector3.UnitY) * handleDimensions;

                    if (solid.SelectedVertices.Contains(index))
                    {
                        selectedHandles.Add(handle);
                        index++;
                        continue;
                    }
                    index++;

                    graphics.DrawSolidRectangle(handle.BottomLeft, handle.BottomRight,
                                                handle.TopRight, handle.TopLeft, Color.White);

                    graphics.DrawRectangle(handle.BottomLeft, handle.BottomRight,
                                           handle.TopRight, handle.TopLeft, Graphics.Graphics.LineType.LineNormal, Color.Black);
                }
            });

            graphics.EndDraw();

            GL.Clear(ClearBufferMask.DepthBufferBit);
            graphics.BeginDraw(Matrix4.Identity);

            //draw selected handles
            foreach (Handle selectedHandle in selectedHandles)
            {
                graphics.DrawSolidRectangle(selectedHandle.BottomLeft, selectedHandle.BottomRight,
                                            selectedHandle.TopRight, selectedHandle.TopLeft, Color.Red);

                graphics.DrawRectangle(selectedHandle.BottomLeft, selectedHandle.BottomRight,
                                       selectedHandle.TopRight, selectedHandle.TopLeft, Graphics.Graphics.LineType.LineNormal, Color.Black);
            }
            graphics.EndDraw();

            GL.Disable(EnableCap.DepthTest);
            GL.DepthRange(farDepth, nearDepth);
        }