Exemple #1
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();
        }
Exemple #2
0
        private static void DrawLine(msgLine objL, RenderingMode mode, bool selSubObjects, bool asHot)
        {
            msgLineStruct ln = objL.GetGeometry();

            double[] pnts1 = new double[3];
            pnts1[0] = ln.P1.x;
            pnts1[1] = ln.P1.y;
            pnts1[2] = ln.P1.z;
            double[] pnts2 = new double[3];
            pnts2[0] = ln.P2.x;
            pnts2[1] = ln.P2.y;
            pnts2[2] = ln.P2.z;

            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)(objL.GetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS) + 1));

                /*GLushort pattern = GetLineTypeByIndex(objL->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 (objL.IsSelect())
                {
                    OpenGLControl.glColor3f(1.0f, 0.0f, 0.0f);
                }
                else
                {
                    OpenGLControl.glColor3fv(GetColorByIndex(objL.GetAttribute(msgObjectAttrEnum.SG_OA_COLOR)));
                }
                OpenGLControl.glEnable(OpenGLControl.GL_LINE_SMOOTH);
                OpenGLControl.glPushMatrix();
                if (objL.GetTempMatrix() != null)
                {
                    double[] transData = GetDoubles(objL.GetTempMatrix().GetTransparentData().values);
                    unsafe
                    {
                        fixed(double *matrixPtr = transData)
                        {
                            OpenGLControl.glMultMatrixd(matrixPtr);
                        }
                    }
                }
                OpenGLControl.glBegin(OpenGLControl.GL_LINES);
                OpenGLControl.glVertex3dv(pnts1);
                OpenGLControl.glVertex3dv(pnts2);
                OpenGLControl.glEnd();

                OpenGLControl.glPopMatrix();
                OpenGLControl.glPopAttrib();
            }
        }