Пример #1
0
        public static void AddFloorInScene(double size1, double size2,
                                           double x_shift, double y_shift, double z_shift)
        {
            msgObject[] objects_buffer = new msgObject[4];
            objects_buffer[0] = msgLine.Create(size1 / 2.0, size2 / 2.0, 0.0,
                                               -size1 / 2.0, size2 / 2.0, 0.0);
            objects_buffer[1] = msgLine.Create(-size1 / 2.0, size2 / 2.0, 0.0,
                                               -size1 / 2.0, -size2 / 2.0, 0.0);
            objects_buffer[2] = msgLine.Create(-size1 / 2.0, -size2 / 2.0, 0.0,
                                               size1 / 2.0, -size2 / 2.0, 0.0);
            objects_buffer[3] = msgLine.Create(size1 / 2.0, -size2 / 2.0, 0.0,
                                               size1 / 2.0, size2 / 2.0, 0.0);

            msgContour cnt   = msgContour.CreateContour(objects_buffer);
            msgObject  floor = msgSurfaces.Face(cnt, null);

            msgObject.DeleteObject(cnt);

            msgScene.GetScene().AttachObject(floor);
            floor.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 25);

            msgVectorStruct transV = new msgVectorStruct(x_shift, y_shift, z_shift);

            floor.InitTempMatrix().Translate(transV);
            floor.ApplyTempMatrix();
            floor.DestroyTempMatrix();
        }
Пример #2
0
        public static void CreateBodyFromClips()
        {
            msgScene scene = msgScene.GetScene();

            scene.Clear();

            Utils.AddFloorInScene(20.0, 20.0, 5.0, 2.0, -4.0);

            msgPointStruct  tmpPnt = new msgPointStruct();
            msgSplineStruct spl1   = msgSplineStruct.Create();
            int             fl     = 0;

            for (double i = 0.0; i < 2.0 * 3.14159265; i += 0.4)
            {
                tmpPnt.x = ((double)(fl % 3 + 2)) * Math.Cos(i);
                tmpPnt.y = ((double)(fl % 3 + 2)) * Math.Sin(i);
                tmpPnt.z = 0.0;
                spl1.AddKnot(tmpPnt, fl);
                fl++;
            }
            spl1.Close();

            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 = 0.0; tmpPnt.y = -0.9; tmpPnt.z = 2.0;
            spl2.AddKnot(tmpPnt, 0);
            tmpPnt.x = 1.4; tmpPnt.y = 0.9; tmpPnt.z = 2.0;
            spl2.AddKnot(tmpPnt, 1);
            tmpPnt.x = -1.6; tmpPnt.y = 0.6; tmpPnt.z = 2.0;
            spl2.AddKnot(tmpPnt, 2);
            tmpPnt.x = -1.2; tmpPnt.y = -1.6; tmpPnt.z = 2.0;
            spl2.AddKnot(tmpPnt, 3);
            spl2.Close();

            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);

            scene.AttachObject(spl1_obj);
            scene.AttachObject(spl2_obj);

            msg2DObject[] ooo = new msg2DObject[3];
            ooo[1] = spl1_obj;
            ooo[0] = spl2_obj;
            ooo[2] = (msg2DObject)spl2_obj.Clone();

            scene.AttachObject(ooo[2]);

            msgPointStruct  axeP = new msgPointStruct(0.0, 0.0, 0.0);
            msgVectorStruct axeD = new msgVectorStruct(0.0, 0.0, 1.0);

            axeD.z = 0.0; axeD.x = 1.0;
            ooo[2].InitTempMatrix().Rotate(axeP, axeD, Math.PI / 4.0);
            msgVectorStruct trV = new msgVectorStruct(-1.0, 1.0, -3.0);

            ooo[2].GetTempMatrix().Translate(trV);
            ooo[2].ApplyTempMatrix();
            ooo[2].DestroyTempMatrix();

            double[] ppp = new double[3];
            ppp[0] = 0.1;
            ppp[1] = 0.0;
            ppp[2] = 0.2;


            msgObject lsf = msgSurfaces.SplineSurfaceFromSections(ooo, ppp, true);

            scene.AttachObject(lsf);
            lsf.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 23);

            msgVectorStruct transV1 = new msgVectorStruct(8, 0, 0);

            lsf.InitTempMatrix().Translate(transV1);
            lsf.ApplyTempMatrix();
            lsf.DestroyTempMatrix();
        }
Пример #3
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();
        }