Esempio n. 1
0
        /// <summary>
        /// Draws a border around a sphere of the given dimensions
        /// </summary>
        /// <param name="height"></param>
        /// <param name="radius"></param>
        /// <param name="segs"></param>
        /// <param name="thickness"></param>
        public static void DrawCylinderBorder(float height, float radius, int segs, float thickness)
        {
            OpenTK.Math.Vector4 innerCol =  new OpenTK.Math.Vector4(0.3f, 0.3f, 0.3f, 0.6f);
            OpenTK.Math.Vector4 outerCol =  new OpenTK.Math.Vector4(0.3f, 0.3f, 0.3f, 0.0f);

            GL.Disable(EnableCap.CullFace);

              //  GLDrawHelper.DrawShadedDisk(radius,radius * 1.05f,segs,innerCol,outerCol);

            GL.PushMatrix();
                GL.Translate(0.0f, 0.0f, height/2);
                GLDrawHelper.DrawShadedDisk(radius, radius + thickness, segs, innerCol, outerCol);

            GL.PopMatrix();

            GL.Begin(BeginMode.Quads);

                //left line
                GL.Color4(innerCol);
                GL.Vertex3(-radius, 0, 0);
                GL.Vertex3(-radius, 0, height);

                GL.Color4(outerCol);
                GL.Vertex3(-radius - thickness, 0, height);
                GL.Vertex3(-radius - thickness, 0, 0);

                //right line
                GL.Color4(innerCol);
                GL.Vertex3(radius, 0, 0);
                GL.Vertex3(radius, 0, height);

                GL.Color4(outerCol);
                GL.Vertex3(radius + thickness, 0, height);
                GL.Vertex3(radius + thickness, 0, 0);

                //top line
                GL.Color4(innerCol);
                GL.Vertex3(-radius, 0, height);
                GL.Vertex3(radius, 0, height);

                GL.Color4(outerCol);
                GL.Vertex3(radius, 0, height + thickness);
                GL.Vertex3(-radius, 0, height + thickness);

                //Bottom line
                GL.Color4(innerCol);
                GL.Vertex3(-radius, 0, 0);
                GL.Vertex3(radius, 0, 0);

                GL.Color4(outerCol);
                GL.Vertex3(radius, 0, - thickness);
                GL.Vertex3(-radius, 0, - thickness);

            GL.End();

            //corner pieces
            GL.Begin(BeginMode.Triangles);
                //left top
                GL.Color4(innerCol);
                GL.Vertex3(-radius, 0, height);
                GL.Color4(outerCol);
                GL.Vertex3(-radius - thickness, 0, height);
                GL.Vertex3(-radius, 0, height + thickness);

                //right top
                GL.Color4(innerCol);
                GL.Vertex3(radius, 0, height);
                GL.Color4(outerCol);
                GL.Vertex3(radius + thickness, 0, height);
                GL.Vertex3(radius, 0, height + thickness);

                //left bottom
                GL.Color4(innerCol);
                GL.Vertex3(-radius, 0, 0);
                GL.Color4(outerCol);
                GL.Vertex3(-radius - thickness, 0, 0);
                GL.Vertex3(-radius, 0, - thickness);

                //right bottom
                GL.Color4(innerCol);
                GL.Vertex3(radius, 0, 0);
                GL.Color4(outerCol);
                GL.Vertex3(radius + thickness, 0, 0);
                GL.Vertex3(radius, 0, - thickness);

            GL.End();

            GL.Enable(EnableCap.CullFace);
        }
Esempio n. 2
0
        /// <summary>
        /// Draws a border around a sphere of the given dimensions
        /// </summary>
        /// <param name="radius"></param>
        /// <param name="segs"></param>
        /// <param name="thickness"></param>
        public static void DrawSphereBorder(float radius, int segs, float thickness)
        {
            OpenTK.Math.Vector4 innerCol = new OpenTK.Math.Vector4(0.3f, 0.3f, 0.3f, 0.6f);
            OpenTK.Math.Vector4 outerCol = new OpenTK.Math.Vector4(0.3f, 0.3f, 0.3f, 0.0f);

            GL.Disable(EnableCap.CullFace);

            GLDrawHelper.DrawShadedDisk(radius, radius + thickness, segs, innerCol, outerCol);

            GL.PushMatrix();
                GL.Rotate(90.0f, 1.0f, 0.0f, 0.0f);
                GLDrawHelper.DrawShadedDisk(radius, radius + thickness, segs, innerCol, outerCol);
            GL.PopMatrix();

            GL.Enable(EnableCap.CullFace);
        }
Esempio n. 3
0
        /// <summary>
        /// Draws a border around a cuboid of the given dimensions
        /// </summary>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="depth"></param>
        /// <param name="thickness"></param>
        public static void DrawCuboidBorder(float width, float height, float depth, float thickness)
        {
            width /= 2;
            height /= 2;
            depth /= 2;

            OpenTK.Math.Vector4 innerCol = new OpenTK.Math.Vector4(0.3f, 0.3f, 0.3f, 0.6f);
            OpenTK.Math.Vector4 outerCol = new OpenTK.Math.Vector4(0.3f, 0.3f, 0.3f, 0.0f);

            GL.Disable(EnableCap.CullFace);
            GL.Begin(BeginMode.Quads);

                //left line
                GL.Color4(innerCol);
                GL.Vertex3(-width, -height, 0);
                GL.Vertex3(-width, height, 0);

                GL.Color4(outerCol);
                GL.Vertex3(-width-thickness, height, 0);
                GL.Vertex3(-width-thickness, -height, 0);

                //top line
                GL.Color4(innerCol);
                GL.Vertex3(-width, -height, 0);
                GL.Vertex3(width, -height, 0);

                GL.Color4(outerCol);
                GL.Vertex3(width, -height-thickness, 0);
                GL.Vertex3(-width, -height - thickness, 0);

                //Right line
                GL.Color4(innerCol);
                GL.Vertex3(width, -height, 0);
                GL.Vertex3(width, height, 0);

                GL.Color4(outerCol);
                GL.Vertex3(width+thickness, height, 0);
                GL.Vertex3(width+thickness, -height, 0);

                //bottom line
                GL.Color4(innerCol);
                GL.Vertex3(width, height, 0);
                GL.Vertex3(-width, height, 0);

                GL.Color4(outerCol);
                GL.Vertex3(-width, height+thickness, 0);
                GL.Vertex3(width, height + thickness, 0);

                //left side line
                GL.Color4(innerCol);
                GL.Vertex3(-width, 0, -depth);
                GL.Vertex3(-width, 0, depth);

                GL.Color4(outerCol);
                GL.Vertex3(-width - thickness, 0, depth);
                GL.Vertex3(-width - thickness, 0, -depth);

                //back line
                GL.Color4(innerCol);
                GL.Vertex3(-width, 0, -depth);
                GL.Vertex3(width, 0, -depth);

                GL.Color4(outerCol);
                GL.Vertex3(width, 0, -depth - thickness);
                GL.Vertex3(-width, 0 , -depth - thickness);

                //right side line
                GL.Color4(innerCol);
                GL.Vertex3(width, 0, -depth);
                GL.Vertex3(width, 0, depth);

                GL.Color4(outerCol);
                GL.Vertex3(width + thickness, 0, depth);
                GL.Vertex3(width + thickness, 0, -depth);

                //front line
                GL.Color4(innerCol);
                GL.Vertex3(width, 0, depth);
                GL.Vertex3(-width, 0, depth);

                GL.Color4(outerCol);
                GL.Vertex3(-width,0, depth + thickness);
                GL.Vertex3(width,0, depth + thickness);

            GL.End();

            GL.Begin(BeginMode.Triangles);

            //top left
            GL.Color4(innerCol);
            GL.Vertex3(-width, -height, 0);
            GL.Color4(outerCol);
            GL.Vertex3(-width - thickness, -height, 0);
            GL.Vertex3(-width, -height - thickness, 0);

            //top right
            GL.Color4(innerCol);
            GL.Vertex3(width, -height, 0);
            GL.Color4(outerCol);
            GL.Vertex3(width + thickness, -height, 0);
            GL.Vertex3(width, -height - thickness, 0);

            //bottom left
            GL.Color4(innerCol);
            GL.Vertex3(-width, height, 0);
            GL.Color4(outerCol);
            GL.Vertex3(-width - thickness, height, 0);
            GL.Vertex3(-width, height + thickness, 0);

            //bottom right
            GL.Color4(innerCol);
            GL.Vertex3(width, height, 0);
            GL.Color4(outerCol);
            GL.Vertex3(width, height + thickness, 0);
            GL.Vertex3(width + thickness, height, 0);

            //back left
            GL.Color4(innerCol);
            GL.Vertex3(-width, 0, -depth);
            GL.Color4(outerCol);
            GL.Vertex3(-width, 0, -depth - thickness);
            GL.Vertex3(-width - thickness, 0, -depth);

            //back right
            GL.Color4(innerCol);
            GL.Vertex3(width, 0, -depth);
            GL.Color4(outerCol);
            GL.Vertex3(width, 0, -depth - thickness);
            GL.Vertex3(width + thickness, 0, -depth);

            //front right
            GL.Color4(innerCol);
            GL.Vertex3(width, 0, depth);
            GL.Color4(outerCol);
            GL.Vertex3(width, 0, depth + thickness);
            GL.Vertex3(width + thickness, 0, depth);

            //front left
            GL.Color4(innerCol);
            GL.Vertex3(-width, 0, depth);
            GL.Color4(outerCol);
            GL.Vertex3(-width, 0, depth + thickness);
            GL.Vertex3(-width - thickness, 0, depth);

            GL.Vertex3(-width, 0, depth);

            GL.End();
            GL.Enable(EnableCap.CullFace);
        }