コード例 #1
0
        public void DrawOpenGlBoxes(SolidEdgeSDK.InteropServices.IGL gl)
        {
            if (ShowOpenGlBoxesDemo == false)
            {
                return;
            }

            float fSize = 0.025f;

            double[] matrix0 = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 };
            double[] matrix1 = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, fSize, 1 };
            double[] matrix2 = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, fSize, -fSize, 1 };
            double[] matrix3 = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, fSize, -fSize, 0, 1 };

            gl.glMatrixMode(SharpGL.OpenGL.GL_MODELVIEW);

            int  mode  = 0;
            int  depth = 0;
            uint error;

            error = gl.glGetError();

            gl.glGetIntegerv(SharpGL.OpenGL.GL_MATRIX_MODE, ref mode);
            gl.glGetIntegerv(SharpGL.OpenGL.GL_MODELVIEW_STACK_DEPTH, ref depth);
            gl.glPushMatrix();
            gl.glGetIntegerv(SharpGL.OpenGL.GL_MODELVIEW_STACK_DEPTH, ref depth);

            gl.glLoadMatrixd(matrix0);
            gl.glColor3f(1, 0, 0);

            DrawOpenGlCube(gl, fSize / 2.0f);

            gl.glPopMatrix();
            gl.glPushMatrix();

            {
                gl.glMultMatrixd(matrix1);
                gl.glColor3f(0, 1, 0);
                DrawOpenGlCube(gl, fSize / 2.0f);
            }

            {
                gl.glMultMatrixd(matrix2);
                gl.glColor3f(0, 0, 1);
                DrawOpenGlCube(gl, fSize / 2.0f);
            }

            {
                gl.glMultMatrixd(matrix3);
                gl.glColor4f(1, 1, 0, .25f);
                DrawOpenGlCube(gl, fSize / 2.0f);
            }

            gl.glPopMatrix();
        }
コード例 #2
0
        public void DrawOpenGlBoundingBox(SolidEdgeSDK.InteropServices.IGL gl)
        {
            if (ShowBoundingBox == false)
            {
                return;
            }

            if (gl == null)
            {
                return;
            }

            Vector3d min = new Vector3d();
            Vector3d max = new Vector3d();

            this.View.GetModelRange(out min.X, out min.Y, out min.Z, out max.X, out max.Y, out max.Z);

            gl.glColor3i(BoundingBoxInfo.LineColor.R, BoundingBoxInfo.LineColor.G, BoundingBoxInfo.LineColor.B);
            gl.glLineWidth(BoundingBoxInfo.LineWidth);
            gl.glHint(SharpGL.OpenGL.GL_LINE_SMOOTH_HINT, SharpGL.OpenGL.GL_NICEST);

            {
                gl.glBegin(SharpGL.OpenGL.GL_LINE_LOOP);

                gl.glVertex3d(min.X, min.Y, max.Z);
                gl.glVertex3d(max.X, min.Y, max.Z);
                gl.glVertex3d(max.X, max.Y, max.Z);
                gl.glVertex3d(min.X, max.Y, max.Z);

                gl.glEnd();
            }

            {
                gl.glBegin(SharpGL.OpenGL.GL_LINE_LOOP);

                gl.glVertex3d(min.X, min.Y, min.Z);
                gl.glVertex3d(max.X, min.Y, min.Z);
                gl.glVertex3d(max.X, max.Y, min.Z);
                gl.glVertex3d(min.X, max.Y, min.Z);

                gl.glEnd();
            }

            {
                gl.glBegin(SharpGL.OpenGL.GL_LINES);

                gl.glVertex3d(min.X, min.Y, min.Z);
                gl.glVertex3d(min.X, min.Y, max.Z);

                gl.glVertex3d(max.X, max.Y, min.Z);
                gl.glVertex3d(max.X, max.Y, max.Z);

                gl.glVertex3d(min.X, max.Y, min.Z);
                gl.glVertex3d(min.X, max.Y, max.Z);

                gl.glVertex3d(max.X, min.Y, min.Z);
                gl.glVertex3d(max.X, min.Y, max.Z);

                gl.glEnd();
            }

            {
                gl.glColor3f(1, 0, 0);
                gl.glBegin(SharpGL.OpenGL.GL_LINES);

                // Diagonal line between min & max points.
                gl.glVertex3d(min.X, min.Y, min.Z);
                gl.glVertex3d(max.X, max.Y, max.Z);

                gl.glEnd();
            }
        }