Example #1
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();
            }
        }
Example #2
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);
        }