示例#1
0
        private static void DrawArc(msgArc objA, RenderingMode mode, bool selSubObjects, bool asHot)
        {
            msgPointStruct[] pnts = objA.GetPoints();

            if (mode == RenderingMode.GL_RENDER)
            {
                OpenGLControl.glPushAttrib(OpenGLControl.GL_ENABLE_BIT |
                                           OpenGLControl.GL_LINE_BIT |
                                           OpenGLControl.GL_CURRENT_BIT |
                                           OpenGLControl.GL_LIGHTING_BIT);

                OpenGLControl.glDisable(OpenGLControl.GL_LIGHTING);
                OpenGLControl.glDisable(OpenGLControl.GL_TEXTURE_2D);
                OpenGLControl.glLineWidth((float)(objA.GetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS) + 1));


                /*GLushort pattern = GetLineTypeByIndex(objA->GetAttribute(SG_OA_LINE_TYPE));
                 * if (pattern > 0)
                 * {
                 *  glEnable(GL_LINE_STIPPLE);
                 *  glLineStipple(1, pattern);
                 * }*/

                if (asHot)
                {
                    OpenGLControl.glColor3f(1.0f, 0.0f, 0.0f);
                }
                else
                if (objA.IsSelect())
                {
                    OpenGLControl.glColor3f(1.0f, 0.0f, 0.0f);
                }
                else
                {
                    OpenGLControl.glColor3fv(GetColorByIndex(objA.GetAttribute(msgObjectAttrEnum.SG_OA_COLOR)));
                }
                OpenGLControl.glEnable(OpenGLControl.GL_LINE_SMOOTH);
                OpenGLControl.glPushMatrix();
                if (objA.GetTempMatrix() != null)
                {
                    double[] transData = GetDoubles(objA.GetTempMatrix().GetTransparentData().values);
                    unsafe
                    {
                        fixed(double *matrixPtr = transData)
                        {
                            OpenGLControl.glMultMatrixd(matrixPtr);
                        }
                    }
                }
                OpenGLControl.glBegin(OpenGLControl.GL_LINE_STRIP);
                for (int i = 0; i < pnts.Length; i++)
                {
                    OpenGLControl.glVertex3d(pnts[i].x, pnts[i].y, pnts[i].z);
                }
                OpenGLControl.glEnd();

                OpenGLControl.glPopMatrix();
                OpenGLControl.glPopAttrib();
            }
        }
示例#2
0
        public static void CreateFromClips()
        {
            msgScene scene = msgScene.GetScene();

            scene.Clear();

            msgPointStruct tmpPnt = new msgPointStruct();

            msgSplineStruct spl1 = msgSplineStruct.Create();

            tmpPnt.x = 98.0; tmpPnt.y = 0.0; tmpPnt.z = -13.0;
            spl1.AddKnot(tmpPnt, 0);
            tmpPnt.x = 85.0; tmpPnt.y = 0.0; tmpPnt.z = 19.0;
            spl1.AddKnot(tmpPnt, 1);
            tmpPnt.x = 43.0; tmpPnt.y = 0.0; tmpPnt.z = -31.0;
            spl1.AddKnot(tmpPnt, 2);
            tmpPnt.x = 5.0; tmpPnt.y = 0.0; tmpPnt.z = -3.0;
            spl1.AddKnot(tmpPnt, 3);
            tmpPnt.x = -11.0; tmpPnt.y = 0.0; tmpPnt.z = -39.0;
            spl1.AddKnot(tmpPnt, 4);
            tmpPnt.x = -48.0; tmpPnt.y = 0.0; tmpPnt.z = 23.0;
            spl1.AddKnot(tmpPnt, 5);
            tmpPnt.x = -125.0; tmpPnt.y = 0.0; tmpPnt.z = 23.0;
            spl1.AddKnot(tmpPnt, 6);

            msgSpline spl1_obj = msgSpline.Create(spl1);

            msgSplineStruct.Delete(spl1);
            scene.AttachObject(spl1_obj);
            spl1_obj.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 12);
            spl1_obj.SetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS, 2);

            msgSplineStruct spl2 = msgSplineStruct.Create();

            tmpPnt.x = 96.0; tmpPnt.y = 150.0; tmpPnt.z = 8.0;
            spl2.AddKnot(tmpPnt, 0);
            tmpPnt.x = 66.0; tmpPnt.y = 150.0; tmpPnt.z = -20.0;
            spl2.AddKnot(tmpPnt, 1);
            tmpPnt.x = 12.0; tmpPnt.y = 150.0; tmpPnt.z = 37.0;
            spl2.AddKnot(tmpPnt, 2);
            tmpPnt.x = -128.0; tmpPnt.y = 150.0; tmpPnt.z = -23.0;
            spl2.AddKnot(tmpPnt, 3);

            msgSpline spl2_obj = msgSpline.Create(spl2);

            msgSplineStruct.Delete(spl2);
            scene.AttachObject(spl2_obj);
            spl2_obj.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 12);
            spl2_obj.SetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS, 2);

            msgLine ln_obj = msgLine.Create(100.0, 100.0, 50.0, -121.0, 100.0, -50.0);

            scene.AttachObject(ln_obj);
            ln_obj.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 12);
            ln_obj.SetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS, 2);

            msgArcStruct   arcG   = new msgArcStruct();
            msgPointStruct arcBeg = new msgPointStruct(98.0, 50.0, -80.0);
            msgPointStruct arcEnd = new msgPointStruct(-117.0, 50.0, -80.0);
            msgPointStruct arcMid = new msgPointStruct(-55.0, 50.0, -50.0);

            arcG.FromThreePoints(arcBeg, arcEnd, arcMid, false);
            msgArc arc_obj = msgArc.Create(arcG);

            scene.AttachObject(arc_obj);
            arc_obj.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 12);
            arc_obj.SetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS, 2);

            msg2DObject[] objcts = new msg2DObject[4];
            objcts[0] = spl1_obj;
            objcts[1] = arc_obj;
            objcts[2] = ln_obj;
            objcts[3] = spl2_obj;

            double[] param = new double[4];
            param[0] = param[1] = param[2] = param[3] = 0.0;

            msgObject surf = msgSurfaces.SplineSurfaceFromSections(objcts, param, false);

            scene.AttachObject(surf);
            surf.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 24);

            msgVectorStruct transV1 = new msgVectorStruct(0, 0, -5);

            surf.InitTempMatrix().Translate(transV1);
            surf.ApplyTempMatrix();
            surf.DestroyTempMatrix();
        }
示例#3
0
        public static void CreateCoonsFrom3Curves()
        {
            msgScene scene = msgScene.GetScene();

            scene.Clear();

            msgPointStruct tmpPnt = new msgPointStruct();

            msgSplineStruct spl1 = msgSplineStruct.Create();

            tmpPnt.x = -6.0; tmpPnt.y = 0.0; tmpPnt.z = -1.0;
            spl1.AddKnot(tmpPnt, 0);
            tmpPnt.x = -5.0; tmpPnt.y = 0.0; tmpPnt.z = -2.0;
            spl1.AddKnot(tmpPnt, 1);
            tmpPnt.x = -3.0; tmpPnt.y = 0.0; tmpPnt.z = -1.0;
            spl1.AddKnot(tmpPnt, 2);
            tmpPnt.x = -2.0; tmpPnt.y = 0.0; tmpPnt.z = -2.0;
            spl1.AddKnot(tmpPnt, 3);
            tmpPnt.x = -1.0; tmpPnt.y = 0.0; tmpPnt.z = 1.0;
            spl1.AddKnot(tmpPnt, 4);
            tmpPnt.x = 2.0; tmpPnt.y = 0.0; tmpPnt.z = 1.0;
            spl1.AddKnot(tmpPnt, 5);
            tmpPnt.x = 2.0; tmpPnt.y = 0.0; tmpPnt.z = 0.0;
            spl1.AddKnot(tmpPnt, 6);
            tmpPnt.x = 4.0; tmpPnt.y = 0.0; tmpPnt.z = 1.0;
            spl1.AddKnot(tmpPnt, 7);

            msgSpline spl1_obj = msgSpline.Create(spl1);

            msgSplineStruct.Delete(spl1);
            scene.AttachObject(spl1_obj);
            spl1_obj.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 0);
            spl1_obj.SetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS, 1);

            msgSplineStruct spl2 = msgSplineStruct.Create();

            tmpPnt.x = -6.0; tmpPnt.y = 0.0; tmpPnt.z = -1.0;
            spl2.AddKnot(tmpPnt, 0);
            tmpPnt.x = -6.0; tmpPnt.y = 0.5; tmpPnt.z = 0.0;
            spl2.AddKnot(tmpPnt, 1);
            tmpPnt.x = -6.0; tmpPnt.y = 2.0; tmpPnt.z = -1.0;
            spl2.AddKnot(tmpPnt, 2);
            tmpPnt.x = -6.0; tmpPnt.y = 3.0; tmpPnt.z = 1.0;
            spl2.AddKnot(tmpPnt, 3);
            tmpPnt.x = -4.0; tmpPnt.y = 4.0; tmpPnt.z = 1.0;
            spl2.AddKnot(tmpPnt, 4);

            msgSpline spl2_obj = msgSpline.Create(spl2);

            msgSplineStruct.Delete(spl2);
            scene.AttachObject(spl2_obj);
            spl2_obj.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 50);
            spl2_obj.SetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS, 3);

            msgPointStruct ArP1   = new msgPointStruct();
            msgPointStruct ArP2   = new msgPointStruct();
            msgPointStruct ArP3   = new msgPointStruct();
            msgArcStruct   ArcGeo = new msgArcStruct();

            ArP1.x = -4.0; ArP1.y = 4.0; ArP1.z = 1.0;
            ArP2.x = 4.0; ArP2.y = 0.0; ArP2.z = 1.0;
            ArP3.x = 0.0; ArP3.y = 5.0; ArP3.z = -4.0;
            ArcGeo.FromThreePoints(ArP1, ArP2, ArP3, false);
            msgArc arcObj = msgArc.Create(ArcGeo);

            scene.AttachObject(arcObj);
            arcObj.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 20);
            arcObj.SetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS, 3);

            msg3DObject coons = (msg3DObject)msgSurfaces.Coons(spl1_obj, spl2_obj, arcObj, null, 36, 36, 4, 4);

            scene.AttachObject(coons);
            coons.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 4);

            msgVectorStruct transV1 = new msgVectorStruct(0, 0, -0.4);

            coons.InitTempMatrix().Translate(transV1);
            coons.ApplyTempMatrix();
            coons.DestroyTempMatrix();
        }