Beispiel #1
0
        public static void CreateSpiralSurface()
        {
            msgScene scene = msgScene.GetScene();

            scene.Clear();

            msgArcStruct   ArcGeo = new msgArcStruct();
            msgPointStruct ArP1   = new msgPointStruct(-1.0, -3.0, 0.0);
            msgPointStruct ArP2   = new msgPointStruct(-1.0, -2.0, 0.0);
            msgPointStruct ArP3   = new msgPointStruct(0.0, -3.5, 0.0);

            ArcGeo.FromThreePoints(ArP1, ArP2, ArP3, false);
            msg2DObject ar = msgArc.Create(ArcGeo);

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

            msgPointStruct axeP1 = new msgPointStruct(2.0, -3.0, 0.0);
            msgPointStruct axeP2 = new msgPointStruct(2.0, 3.0, 0.0);

            msg3DObject spirO = (msg3DObject)msgKinematic.Spiral(ar, null, axeP1, axeP2, 4, 10, 15, false);

            scene.AttachObject(spirO);
            spirO.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 85);

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

            spirO.InitTempMatrix().Translate(transV1);
            spirO.ApplyTempMatrix();
            spirO.DestroyTempMatrix();
        }
Beispiel #2
0
        public static void CreateSpheres()
        {
            msgScene scene = msgScene.GetScene();

            scene.Clear();

            Utils.AddFloorInScene(20.0, 10.0, 0.0, 1.0, -2.0);

            for (ushort i = 3; i < 5; i++)
            {
                msgSphere sp1 = msgSphere.Create(i, 24, 24);

                msgVectorStruct transV1 = new msgVectorStruct(5 * (i - 3), 2, 0);
                sp1.InitTempMatrix().Translate(transV1);
                sp1.ApplyTempMatrix();
                sp1.DestroyTempMatrix();

                scene.AttachObject(sp1);
                sp1.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, i);
                if (i % 2 > 0)
                {
                    sp1.SetAttribute(msgObjectAttrEnum.SG_OA_DRAW_STATE, (ushort)SG_OA_DRAW_STATEValuesEnum.SGDS_FRAME);
                }
            }
        }
Beispiel #3
0
        public static void CreateBoxes()
        {
            msgScene scene = msgScene.GetScene();

            scene.Clear();

            Utils.AddFloorInScene(7.0, 7.0, 1.0, 1.0, -0.3);

            msgBox bx1 = msgBox.Create(1, 2, 2.1);

            scene.AttachObject(bx1);
            bx1.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 8);

            msgBox bx2 = msgBox.Create(1, 1, 1);

            msgVectorStruct transV = new msgVectorStruct();

            transV.x = 1.5;
            transV.y = 0.0;
            transV.z = 0.0;
            bx2.InitTempMatrix().Translate(transV);
            bx2.ApplyTempMatrix();
            bx2.DestroyTempMatrix();

            bx2.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 0);
            bx2.SetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS, 1);
            bx2.SetAttribute(msgObjectAttrEnum.SG_OA_LINE_TYPE, 1);

            scene.AttachObject(bx2);
        }
Beispiel #4
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();
		}
Beispiel #5
0
        public Camera()
        {
            x_axe = new msgVectorStruct();
            x_axe.x = 1.0;
            x_axe.y = 0.0;
            x_axe.z = 0.0;

            y_axe = new msgVectorStruct();
            y_axe.x = 0.0;
            y_axe.y = 1.0;
            y_axe.z = 0.0;

            z_axe = new msgVectorStruct();
            z_axe.x = 0.0;
            z_axe.y = 0.0;
            z_axe.z = 1.0;

            zero_p = new msgVectorStruct();
            zero_p.x = 0.0;
            zero_p.y = 0.0;
            zero_p.z = 0.0;

            m_fEyePos = new msgPointStruct();
            m_fLookAtPos = new msgPointStruct();
            m_fUpVector = new msgVectorStruct();
            m_iViewport = new int[4];

            ReInit();
        }
Beispiel #6
0
		public static void CreateUnion()
		{
			msgScene scene = msgScene.GetScene();
			scene.Clear();

			msgTorus tor1 = msgTorus.Create(2,1 ,24,24);
			msgTorus tor2 = msgTorus.Create(2,0.5 ,24,24);

			msgVectorStruct transV1 = new msgVectorStruct(1, 3.5, 0);
			tor2.InitTempMatrix().Translate(transV1);
			tor2.ApplyTempMatrix();
			tor2.DestroyTempMatrix();
			scene.AttachObject(tor1);
			tor1.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 5);
			scene.AttachObject(tor2);
			tor2.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 45);

			msgVectorStruct transV2 = new msgVectorStruct(-6.5,0,0);

			msgGroup bool1 = msgBoolean.Union(tor1, tor2);

			bool1.InitTempMatrix().Translate(transV2);
			bool1.ApplyTempMatrix();
			bool1.DestroyTempMatrix();
			scene.AttachObject(bool1);
			bool1.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 3);
			bool1.SetAttribute(msgObjectAttrEnum.SG_OA_DRAW_STATE, (ushort)SG_OA_DRAW_STATEValuesEnum.SGDS_FRAME);
		}
Beispiel #7
0
		public static void CreateBoxes()
		{
			msgScene scene = msgScene.GetScene();
			scene.Clear();

			Utils.AddFloorInScene(7.0, 7.0, 1.0, 1.0, -0.3);

			msgBox bx1 = msgBox.Create(1, 2, 2.1);

			scene.AttachObject(bx1);
			bx1.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 8);

			msgBox bx2 = msgBox.Create(1, 1, 1);

			msgVectorStruct transV = new msgVectorStruct();
			transV.x = 1.5;
			transV.y = 0.0;
			transV.z = 0.0;
			bx2.InitTempMatrix().Translate(transV);
			bx2.ApplyTempMatrix();
			bx2.DestroyTempMatrix();

			bx2.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 0);
			bx2.SetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS, 1);
			bx2.SetAttribute(msgObjectAttrEnum.SG_OA_LINE_TYPE, 1);

			scene.AttachObject(bx2);
		}
Beispiel #8
0
        public static void CreateCylinders()
        {
            msgScene scene = msgScene.GetScene();

            scene.Clear();

            Utils.AddFloorInScene(80.0, 50.0, 20.0, 10.0, 5.0);

            for (ushort i = 2; i < 8; i++)
            {
                msgCylinder     cy1     = msgCylinder.Create(i, 2 * i, 24);
                msgVectorStruct transV1 = new msgVectorStruct(5 * i, 10, 10);
                cy1.InitTempMatrix().Translate(transV1);
                cy1.ApplyTempMatrix();
                cy1.DestroyTempMatrix();

                scene.AttachObject(cy1);
                cy1.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, i);

                if (i % 2 > 0)
                {
                    cy1.SetAttribute(msgObjectAttrEnum.SG_OA_DRAW_STATE, (ushort)SG_OA_DRAW_STATEValuesEnum.SGDS_FRAME);
                }
            }
        }
Beispiel #9
0
        public void SetRotationAboutEye(double x, double y, double z)
        {
            msgMatrix       matx      = new msgMatrix();
            msgVectorStruct LookAtPos = new msgVectorStruct();

            matx.Rotate(zero_p, x_axe, x / 180.0 * Math.PI);
            matx.Rotate(zero_p, z_axe, -z / 180.0 * Math.PI);

            LookAtPos.x = 0.0;
            LookAtPos.y = m_fFocalLength;
            LookAtPos.z = 0.0;
            matx.ApplyMatrixToVector(zero_p, LookAtPos);

            m_fLookAtPos.x = m_fEyePos.x + LookAtPos.x;
            m_fLookAtPos.y = m_fEyePos.y + LookAtPos.y;
            m_fLookAtPos.z = m_fEyePos.z + LookAtPos.z;

            // Calculate our camera's UpVector using ONLY the 'X' (Pitch) and 'Z' (Yaw)
            // parameters
            m_fUpVector = z_axe;
            matx.ApplyMatrixToVector(zero_p, m_fUpVector);

            // Just save the 'y' value for later use when calculating the camera's 'Up' vector
            // prior to calling gluLookAt()
            m_fRoll = y;
        }
Beispiel #10
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();
        }
Beispiel #11
0
        public Camera()
        {
            x_axe   = new msgVectorStruct();
            x_axe.x = 1.0;
            x_axe.y = 0.0;
            x_axe.z = 0.0;

            y_axe   = new msgVectorStruct();
            y_axe.x = 0.0;
            y_axe.y = 1.0;
            y_axe.z = 0.0;

            z_axe   = new msgVectorStruct();
            z_axe.x = 0.0;
            z_axe.y = 0.0;
            z_axe.z = 1.0;

            zero_p   = new msgVectorStruct();
            zero_p.x = 0.0;
            zero_p.y = 0.0;
            zero_p.z = 0.0;

            m_fEyePos    = new msgPointStruct();
            m_fLookAtPos = new msgPointStruct();
            m_fUpVector  = new msgVectorStruct();
            m_iViewport  = new int[4];

            ReInit();
        }
Beispiel #12
0
        public static void CreateUnion()
        {
            msgScene scene = msgScene.GetScene();

            scene.Clear();

            msgTorus tor1 = msgTorus.Create(2, 1, 24, 24);
            msgTorus tor2 = msgTorus.Create(2, 0.5, 24, 24);

            msgVectorStruct transV1 = new msgVectorStruct(1, 3.5, 0);

            tor2.InitTempMatrix().Translate(transV1);
            tor2.ApplyTempMatrix();
            tor2.DestroyTempMatrix();
            scene.AttachObject(tor1);
            tor1.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 5);
            scene.AttachObject(tor2);
            tor2.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 45);

            msgVectorStruct transV2 = new msgVectorStruct(-6.5, 0, 0);

            msgGroup bool1 = msgBoolean.Union(tor1, tor2);

            bool1.InitTempMatrix().Translate(transV2);
            bool1.ApplyTempMatrix();
            bool1.DestroyTempMatrix();
            scene.AttachObject(bool1);
            bool1.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 3);
            bool1.SetAttribute(msgObjectAttrEnum.SG_OA_DRAW_STATE, (ushort)SG_OA_DRAW_STATEValuesEnum.SGDS_FRAME);
        }
Beispiel #13
0
        private void PrepareMatrix(double Ox, double Oy, double Oz,
                                   double Rx, double Ry, double Rz,
                                   double Tx, double Ty, double Tz,
                                   ref msgMatrix XForm)
        {
            XForm.Identity();

            msgVectorStruct TransV = new msgVectorStruct();

            TransV.x = Tx;
            TransV.y = Ty;
            TransV.z = Tz;
            XForm.Translate(TransV);

            XForm.Rotate(zero_p, x_axe, Rx);
            XForm.Rotate(zero_p, y_axe, Ry);
            XForm.Rotate(zero_p, z_axe, Rz);

            msgVectorStruct oV = new msgVectorStruct();

            oV.x = Ox;
            oV.y = Oy;
            oV.z = Oz;
            XForm.Translate(oV);
        }
Beispiel #14
0
        public static void CreateSections()
        {
            msgScene scene = msgScene.GetScene();

            scene.Clear();

            msgTorus tor1 = msgTorus.Create(2, 1, 36, 36);

            scene.AttachObject(tor1);

            msgVectorStruct transV2 = new msgVectorStruct(-6, 0, 0);

            for (int i = -30; i < 30; i += 4)
            {
                msgVectorStruct plN = new msgVectorStruct();
                plN.x = 0.0; plN.y = 1.0; plN.z = 1.0;

                msgGroup bool1 = msgBoolean.Section(tor1, plN, 0.1 * i);

                if (bool1 != null)
                {
                    bool1.InitTempMatrix().Translate(transV2);
                    bool1.ApplyTempMatrix();
                    bool1.DestroyTempMatrix();
                    scene.AttachObject(bool1);
                    bool1.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, (ushort)(i + 50));
                    bool1.SetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS, 2);
                }
            }
        }
Beispiel #15
0
        public static void CreateIntersectionContours()
        {
            msgScene scene = msgScene.GetScene();

            scene.Clear();

            msgTorus        tor1    = msgTorus.Create(2, 1, 36, 36);
            msgTorus        tor2    = msgTorus.Create(2, 0.6, 36, 36);
            msgVectorStruct transV1 = new msgVectorStruct(1, 1, 0);

            tor2.InitTempMatrix().Translate(transV1);
            tor2.ApplyTempMatrix();
            tor2.DestroyTempMatrix();
            scene.AttachObject(tor1);
            tor1.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 65);
            scene.AttachObject(tor2);
            tor2.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 105);

            msgVectorStruct transV2 = new msgVectorStruct(5, 0, 0.0);

            msgGroup bool1 = msgBoolean.IntersectionContour(tor1, tor2);

            bool1.InitTempMatrix().Translate(transV2);
            bool1.ApplyTempMatrix();
            bool1.DestroyTempMatrix();
            scene.AttachObject(bool1);
            bool1.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 0);
            bool1.SetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS, 2);
        }
Beispiel #16
0
        public static void CreateSub()
        {
            msgScene scene = msgScene.GetScene();

            scene.Clear();

            Utils.AddFloorInScene(15.0, 14.0, -2.0, 2.0, -1.0);

            msgTorus        tor1    = msgTorus.Create(2, 1, 24, 24);
            msgTorus        tor2    = msgTorus.Create(2, 0.8, 24, 24);
            msgVectorStruct transV1 = new msgVectorStruct(1, 1, 0);

            tor2.InitTempMatrix().Translate(transV1);
            tor2.ApplyTempMatrix();
            tor2.DestroyTempMatrix();
            scene.AttachObject(tor1);
            tor1.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 5);
            scene.AttachObject(tor2);
            tor2.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 25);

            msgVectorStruct transV2 = new msgVectorStruct(-6.0, 0, 0);

            msgGroup bool1 = msgBoolean.Sub(tor1, tor2);

            bool1.InitTempMatrix().Translate(transV2);
            bool1.ApplyTempMatrix();
            bool1.DestroyTempMatrix();
            scene.AttachObject(bool1);
            bool1.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 3);
        }
Beispiel #17
0
        public static void CreateExtrudeBody()
        {
            msgScene scene = msgScene.GetScene();

            scene.Clear();

            Utils.AddFloorInScene(30.0, 25.0, -2.0, 0.0, -2.0);

            msgPointStruct tmpPnt = new msgPointStruct();

            msgSplineStruct spl2 = msgSplineStruct.Create();
            int             fl   = 0;

            for (double i = 0.0; i < 2.0 * 3.14159265; i += 0.13)
            {
                tmpPnt.x = ((double)(fl % 3 + 2)) * Math.Cos(i);
                tmpPnt.y = ((double)(fl % 3 + 2)) * Math.Sin(i);
                tmpPnt.z = 0.0;
                spl2.AddKnot(tmpPnt, fl);
                fl++;
            }
            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);

            msgCircleStruct cirGeo = new msgCircleStruct();
            msgPointStruct  cirC   = new msgPointStruct(0.0, 0.0, 0.0);
            msgVectorStruct cirNor = new msgVectorStruct(0.0, 0.0, 1.0);

            cirGeo.FromCenterRadiusNormal(cirC, 1.6, cirNor);
            msg2DObject cir = msgCircle.Create(cirGeo);

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

            msgVectorStruct extVec = new msgVectorStruct(1, -2, 5);

            msg3DObject exO = (msg3DObject)msgKinematic.Extrude(spl2_obj, new msg2DObject[] { cir }, extVec, true);

            scene.AttachObject(exO);
            exO.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 30);

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

            exO.InitTempMatrix().Translate(transV1);
            exO.ApplyTempMatrix();
            exO.DestroyTempMatrix();
        }
Beispiel #18
0
        public void GetWorldCoord(int ix, int iy, double fz, ref msgVectorStruct coord)
        {
            double x, y, z, winX, winY, winZ;

            // Fix the yPos value.  MS Windows origin 0,0 is upper left
            // while OpenGL windows origin 0,0 is lower left...
            winX = ix;
            winY = m_iViewport[3] - iy;

            // Add the camera's focal length, or distance from 'LookAt' to 'Eye' position
            // to the given 'z' coordinate.
            fz += GetFocalLength();

            // Calculate the winZ coordinate:
            if (m_bPerspective)
            {
                // Compensate for perspective view
                winZ = 0.5 + (((m_fFar + m_fNear) - (2 * m_fFar * m_fNear) / fz)) / (2 * (m_fFar - m_fNear));
            }
            else
            {
                // winZ is linearly interpolated between the Near_Far clipping plane
                winZ = (fz - m_fNear) / (m_fFar - m_fNear);
            }

            // Unproject the point
            unsafe
            {
                fixed(double *m_dModelViewMatrixPtr = m_dModelViewMatrix)
                {
                    fixed(double *m_dProjectionMatrixPtr = m_dProjectionMatrix)
                    {
                        fixed(int *m_iViewportPtr = m_iViewport)
                        {
                            OpenGLControl.gluUnProject(winX, winY, winZ,
                                                       m_dModelViewMatrixPtr,
                                                       m_dProjectionMatrixPtr,
                                                       m_iViewportPtr,
                                                       &x, &y, &z);
                        }
                    }
                }
            }

            coord.x = x;
            coord.y = y;
            coord.z = z;
        }
Beispiel #19
0
        public static void CreateExtrudeBody()
        {
            msgScene scene = msgScene.GetScene();
            scene.Clear();

            Utils.AddFloorInScene(30.0, 25.0, -2.0, 0.0, -2.0);

            msgPointStruct tmpPnt = new msgPointStruct();

            msgSplineStruct spl2 = msgSplineStruct.Create();
            int fl=0;
            for (double i=0.0;i<2.0*3.14159265;i+=0.13)
            {
                tmpPnt.x = ((double)(fl%3+2))*Math.Cos(i);
                tmpPnt.y = ((double)(fl%3+2))*Math.Sin(i);
                tmpPnt.z = 0.0;
                spl2.AddKnot(tmpPnt,fl);
                fl++;
            }
            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);

            msgCircleStruct cirGeo = new msgCircleStruct();
            msgPointStruct cirC = new msgPointStruct(0.0, 0.0, 0.0);
            msgVectorStruct cirNor = new msgVectorStruct(0.0, 0.0, 1.0);
            cirGeo.FromCenterRadiusNormal(cirC,1.6, cirNor);
            msg2DObject cir = msgCircle.Create(cirGeo);
            scene.AttachObject(cir);
            cir.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 12);
            cir.SetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS, 2);

            msgVectorStruct extVec = new msgVectorStruct(1,-2,5);

            msg3DObject exO = (msg3DObject)msgKinematic.Extrude(spl2_obj, new msg2DObject[] { cir }, extVec,true);

            scene.AttachObject(exO);
            exO.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 30);

            msgVectorStruct transV1 = new msgVectorStruct( -7, 0, 0 );
            exO.InitTempMatrix().Translate(transV1);
            exO.ApplyTempMatrix();
            exO.DestroyTempMatrix();
        }
Beispiel #20
0
        public static void CreateRotationSurface()
        {
            msgScene scene = msgScene.GetScene();

            scene.Clear();

            Utils.AddFloorInScene(15.0, 14.0, -2.0, 2.0, -3.0);

            msgPointStruct tmpPnt = new msgPointStruct();

            msgSplineStruct spl2 = msgSplineStruct.Create();

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

            msgSpline spl2_obj = msgSpline.Create(spl2);

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

            msgSplineStruct.Delete(spl2);

            msgPointStruct p1 = new msgPointStruct(0, -2, 0);
            msgPointStruct p2 = new msgPointStruct(0, 0, 0);

            msg3DObject rO = (msg3DObject)msgKinematic.Rotation(spl2_obj, p1, p2, 250, false);

            scene.AttachObject(rO);
            rO.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 3);

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

            rO.InitTempMatrix().Translate(transV1);
            rO.ApplyTempMatrix();
            rO.DestroyTempMatrix();
        }
Beispiel #21
0
		public static void CreateRotationSurface()
		{
			msgScene scene = msgScene.GetScene();
			scene.Clear();

			Utils.AddFloorInScene(15.0, 14.0, -2.0, 2.0, -3.0);

			msgPointStruct tmpPnt = new msgPointStruct();

			msgSplineStruct spl2 = msgSplineStruct.Create();

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

			msgSpline spl2_obj = msgSpline.Create(spl2);
			scene.AttachObject(spl2_obj);
			spl2_obj.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR,12);
			spl2_obj.SetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS, 2);

			msgSplineStruct.Delete(spl2);

			msgPointStruct p1 = new msgPointStruct(0,-2,0);
			msgPointStruct p2 = new msgPointStruct(0,0,0);

			msg3DObject rO = (msg3DObject)msgKinematic.Rotation(spl2_obj, p1, p2, 250, false);

			scene.AttachObject(rO);
			rO.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 3);

			msgVectorStruct transV1 = new msgVectorStruct(-1, 0, 0);
			rO.InitTempMatrix().Translate(transV1);
			rO.ApplyTempMatrix();
			rO.DestroyTempMatrix();
		}
Beispiel #22
0
        public static void CreateRotationBody()
        {
            msgScene scene = msgScene.GetScene();

            scene.Clear();

            msgPointStruct tmpPnt = new msgPointStruct();

            msgSplineStruct spl2 = msgSplineStruct.Create();
            int             fl   = 0;

            for (double i = 0.0; i < 2.0 * Math.PI; 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;
                spl2.AddKnot(tmpPnt, fl);
                fl++;
            }

            spl2.Close();

            msgSpline spl2_obj = msgSpline.Create(spl2);

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

            msgSplineStruct.Delete(spl2);

            msgPointStruct p1 = new msgPointStruct(10, 10, 0);
            msgPointStruct p2 = new msgPointStruct(20, 15, 0);

            msg3DObject rO = (msg3DObject)msgKinematic.Rotation(spl2_obj, p1, p2, 290, true);

            scene.AttachObject(rO);
            rO.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 8);

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

            rO.InitTempMatrix().Translate(transV1);
            rO.ApplyTempMatrix();
            rO.DestroyTempMatrix();
        }
Beispiel #23
0
        public static void CreateCones()
        {
            msgScene scene = msgScene.GetScene();
            scene.Clear();

            Utils.AddFloorInScene(200.0, 100.0, 50.0, 10.0, 5.0);

            for (ushort i = 2; i < 10; i++)
            {
                msgCone co1 = msgCone.Create(i, i / 3, 10 * i, 36);
                msgVectorStruct transV1 = new msgVectorStruct(10 * i, 10, 10);
                co1.InitTempMatrix().Translate(transV1);
                co1.ApplyTempMatrix();
                co1.DestroyTempMatrix();

                scene.AttachObject(co1);
                co1.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, i);
            }
        }
Beispiel #24
0
        public static void CreateBands()
        {
            msgScene scene = msgScene.GetScene();
            scene.Clear();

            Utils.AddFloorInScene(40.0, 40.0, 15.0, 10.0, 0.0);

            for (ushort i = 2; i < 5; i++)
            {
                msgSphericBand sb1 = msgSphericBand.Create(i, -0.4, 0.5, 24);
                msgVectorStruct transV1 = new msgVectorStruct(5 * i, 10, 10);
                sb1.InitTempMatrix().Translate(transV1);
                sb1.ApplyTempMatrix();
                sb1.DestroyTempMatrix();

                scene.AttachObject(sb1);
                sb1.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, i);
            }
        }
Beispiel #25
0
        public static void CreateExtrudeSurfaces()
        {
            msgScene scene = msgScene.GetScene();

            scene.Clear();

            msgPointStruct tmpPnt = new msgPointStruct();

            msgSplineStruct spl2 = msgSplineStruct.Create();

            int fl = 0;

            for (double i = 0.0; i < 10.0; i += 1.0)
            {
                tmpPnt.x = i;
                tmpPnt.y = (fl % 2 > 0)?-i / 2.0:i / 2.0;
                tmpPnt.z = 0.0;
                spl2.AddKnot(tmpPnt, fl);
                fl++;
            }

            msgSpline spl2_obj = msgSpline.Create(spl2);

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

            msgSplineStruct.Delete(spl2);

            msgVectorStruct extVec = new msgVectorStruct(1, -2, 3);

            msg3DObject exO = (msg3DObject)msgKinematic.Extrude(spl2_obj, null, extVec, false);

            scene.AttachObject(exO);
            exO.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 20);

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

            exO.InitTempMatrix().Translate(transV1);
            exO.ApplyTempMatrix();
            exO.DestroyTempMatrix();
        }
Beispiel #26
0
        public static void CreateSpiralBody()
        {
            msgScene scene = msgScene.GetScene();

            scene.Clear();

            msgCircleStruct cirGeo1 = new msgCircleStruct();
            msgPointStruct  cirC1   = new msgPointStruct(2.0, -2.0, 0.0);
            msgVectorStruct cirNor1 = new msgVectorStruct(0.0, 0.0, 1.0);

            cirGeo1.FromCenterRadiusNormal(cirC1, 3.0, cirNor1);
            msg2DObject cir1 = msgCircle.Create(cirGeo1);

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

            msgCircleStruct cirGeo2 = new msgCircleStruct();
            msgPointStruct  cirC2   = new msgPointStruct(2.0, -2.3, 0.0);
            msgVectorStruct cirNor2 = new msgVectorStruct(0.0, 0.0, 1.0);

            cirGeo2.FromCenterRadiusNormal(cirC2, 1.5, cirNor2);
            msg2DObject cir2 = msgCircle.Create(cirGeo2);

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

            msgPointStruct axeP1 = new msgPointStruct(6.0, -3.0, 0.0);
            msgPointStruct axeP2 = new msgPointStruct(6.0, 3.0, 0.0);

            msg3DObject spirO = (msg3DObject)msgKinematic.Spiral(cir1, new msg2DObject[] { cir2 }, axeP1, axeP2, 12, 30, 16, true);

            scene.AttachObject(spirO);
            spirO.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 56);

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

            spirO.InitTempMatrix().Translate(transV1);
            spirO.ApplyTempMatrix();
            spirO.DestroyTempMatrix();
        }
Beispiel #27
0
        public static void CreateBands()
        {
            msgScene scene = msgScene.GetScene();

            scene.Clear();

            Utils.AddFloorInScene(40.0, 40.0, 15.0, 10.0, 0.0);

            for (ushort i = 2; i < 5; i++)
            {
                msgSphericBand  sb1     = msgSphericBand.Create(i, -0.4, 0.5, 24);
                msgVectorStruct transV1 = new msgVectorStruct(5 * i, 10, 10);
                sb1.InitTempMatrix().Translate(transV1);
                sb1.ApplyTempMatrix();
                sb1.DestroyTempMatrix();

                scene.AttachObject(sb1);
                sb1.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, i);
            }
        }
Beispiel #28
0
        public static void CreateCones()
        {
            msgScene scene = msgScene.GetScene();

            scene.Clear();

            Utils.AddFloorInScene(200.0, 100.0, 50.0, 10.0, 5.0);

            for (ushort i = 2; i < 10; i++)
            {
                msgCone         co1     = msgCone.Create(i, i / 3, 10 * i, 36);
                msgVectorStruct transV1 = new msgVectorStruct(10 * i, 10, 10);
                co1.InitTempMatrix().Translate(transV1);
                co1.ApplyTempMatrix();
                co1.DestroyTempMatrix();

                scene.AttachObject(co1);
                co1.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, i);
            }
        }
Beispiel #29
0
        public void GetVectorsForRayTracingCamera(msgVectorStruct eye_loc,
                                                  msgVectorStruct eye_look_at,
                                                  msgVectorStruct eye_y,
                                                  msgVectorStruct eye_x)
        {
            double xval = eye_loc.x;
            double yval = eye_loc.y;
            double zval = eye_loc.z;

            GetEyePos(ref xval, ref yval, ref zval);
            eye_loc.x = xval;
            eye_loc.y = yval;
            eye_loc.z = zval;

            double xval2 = eye_look_at.x;
            double yval2 = eye_look_at.y;
            double zval2 = eye_look_at.z;

            GetLookAtPos(ref xval2, ref yval2, ref zval2);
            eye_look_at.x = xval2;
            eye_look_at.y = yval2;
            eye_look_at.z = zval2;

            msgVectorStruct p1 = new msgVectorStruct();
            msgVectorStruct p2 = new msgVectorStruct();

            GetWorldCoord(m_iScreenWidth / 2, m_iScreenHeight / 2, 0.0, ref p1);
            GetWorldCoord(m_iScreenWidth / 2, 0, 0.0, ref p2);

            eye_y = msgSpaceMath.VectorsSub(p2, p1);

            msgSpaceMath.NormalVector(eye_y);

            GetWorldCoord(m_iScreenWidth, m_iScreenHeight / 2, 0.0, ref p2);

            eye_x = msgSpaceMath.VectorsSub(p2, p1);
            msgSpaceMath.NormalVector(eye_x);
        }
Beispiel #30
0
		public static void CreateCylinders()
		{
			msgScene scene = msgScene.GetScene();
			scene.Clear();

			Utils.AddFloorInScene(80.0, 50.0, 20.0, 10.0, 5.0);

			for (ushort i = 2; i < 8; i++)
			{
				msgCylinder cy1 = msgCylinder.Create(i, 2 * i, 24);
				msgVectorStruct transV1 = new msgVectorStruct(5 * i, 10, 10);
				cy1.InitTempMatrix().Translate(transV1);
				cy1.ApplyTempMatrix();
				cy1.DestroyTempMatrix();

				scene.AttachObject(cy1);
				cy1.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, i);

				if (i % 2 > 0)
				{
					cy1.SetAttribute(msgObjectAttrEnum.SG_OA_DRAW_STATE, (ushort)SG_OA_DRAW_STATEValuesEnum.SGDS_FRAME);
				}
			}
		}
Beispiel #31
0
        public static void CreateEllipsoids()
        {
            msgScene scene = msgScene.GetScene();

            scene.Clear();

            Utils.AddFloorInScene(100.0, 50.0, 50.0, 10.0, 2.0);
            Random rand = new Random();

            for (ushort i = 3; i < 10; i++)
            {
                msgEllipsoid    ell1   = msgEllipsoid.Create(i, i / 6 + 2, 2 * i, 24, 24);
                msgPointStruct  rotCen = new msgPointStruct(0.0, 0.0, 0.0);
                msgVectorStruct rotDir = new msgVectorStruct(rand.Next(), rand.Next(), rand.Next());
                ell1.InitTempMatrix().Rotate(rotCen, rotDir, rand.Next() * 360);
                msgVectorStruct transV1 = new msgVectorStruct(10 * i, 10, 10);
                ell1.GetTempMatrix().Translate(transV1);
                ell1.ApplyTempMatrix();
                ell1.DestroyTempMatrix();

                scene.AttachObject(ell1);
                ell1.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, i);
            }
        }
Beispiel #32
0
		public static void CreateSpheres()
		{
			msgScene scene = msgScene.GetScene();
			scene.Clear();

			Utils.AddFloorInScene(20.0, 10.0, 0.0, 1.0, -2.0);

			for (ushort i = 3; i < 5; i++)
			{
				msgSphere sp1 = msgSphere.Create(i, 24, 24);

				msgVectorStruct transV1 = new msgVectorStruct(5 * (i - 3), 2, 0);
				sp1.InitTempMatrix().Translate(transV1);
				sp1.ApplyTempMatrix();
				sp1.DestroyTempMatrix();

				scene.AttachObject(sp1);
				sp1.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, i);
				if (i % 2 > 0)
				{
					sp1.SetAttribute(msgObjectAttrEnum.SG_OA_DRAW_STATE, (ushort)SG_OA_DRAW_STATEValuesEnum.SGDS_FRAME);
				}
			}
		}
Beispiel #33
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();
        }
Beispiel #34
0
        public static void CreatePipeBody()
        {
            msgScene scene = msgScene.GetScene();

            scene.Clear();

            msgObject[] objcts = new msgObject[5];

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

            ArP1.x = 0.0; ArP1.y = -2.0; ArP1.z = 0.0;
            ArP2.x = 1.0; ArP2.y = -1.0; ArP2.z = 0.0;
            ArP3.x = 0.4; ArP3.y = -1.2; ArP3.z = 0.0;
            ArcGeo.FromThreePoints(ArP1, ArP2, ArP3, false);
            objcts[0] = msgArc.Create(ArcGeo);

            ArP1.x = 1.0; ArP1.y = -1.0; ArP1.z = 0.0;
            ArP2.x = 2.0; ArP2.y = 0.0; ArP2.z = 0.0;
            ArP3.x = 1.9; ArP3.y = -0.5; ArP3.z = 0.0;
            ArcGeo.FromThreePoints(ArP1, ArP2, ArP3, false);
            objcts[1] = msgArc.Create(ArcGeo);

            ArP1.x = 2.0; ArP1.y = 0.0; ArP1.z = 0.0;
            ArP2.x = 1.0; ArP2.y = 1.0; ArP2.z = 0.0;
            ArP3.x = 1.6; ArP3.y = 0.8; ArP3.z = 0.0;
            ArcGeo.FromThreePoints(ArP1, ArP2, ArP3, false);
            objcts[2] = msgArc.Create(ArcGeo);

            objcts[3] = msgLine.Create(1.0, 1.0, 0.0, -1.0, 1.0, 0.0);

            ArP1.x = -1.0; ArP1.y = 1.0; ArP1.z = 0.0;
            ArP2.x = -1.0; ArP2.y = 0.0; ArP2.z = 1.0;
            ArP3.x = -1.1; ArP3.y = 1.0; ArP3.z = 0.0;
            ArcGeo.FromThreePoints(ArP1, ArP2, ArP3, false);
            objcts[4] = msgArc.Create(ArcGeo);

            msgContour cnt1 = msgContour.CreateContour(objcts);

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

            ArP1.x = -0.2; ArP1.y = -0.2; ArP1.z = 0.0;
            ArP2.x = -0.1; ArP2.y = 0.2; ArP2.z = 0.0;
            ArP3.x = -0.3; ArP3.y = 0.1; ArP3.z = 0.0;
            ArcGeo.FromThreePoints(ArP1, ArP2, ArP3, false);
            objcts[0] = msgArc.Create(ArcGeo);


            ArP1.x = -0.1; ArP1.y = 0.2; ArP1.z = 0.0;
            ArP2.x = 0.3; ArP2.y = 0.5; ArP2.z = 0.0;
            ArP3.x = 0.2; ArP3.y = 0.6; ArP3.z = 0.0;
            ArcGeo.FromThreePoints(ArP1, ArP2, ArP3, false);
            objcts[1] = msgArc.Create(ArcGeo);

            ArP1.x = 0.3; ArP1.y = 0.5; ArP1.z = 0.0;
            ArP2.x = -0.2; ArP2.y = -0.2; ArP2.z = 0.0;
            ArP3.x = 0.6; ArP3.y = -0.4; ArP3.z = 0.0;
            ArcGeo.FromThreePoints(ArP1, ArP2, ArP3, false);
            objcts[2] = msgArc.Create(ArcGeo);

            msgObject[] objcts2 = null;
            Array.Copy(objcts, objcts2, 3);
            msgContour cnt2 = msgContour.CreateContour(objcts2);

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

            msgCircleStruct cirGeo = new msgCircleStruct();
            msgPointStruct  cirC   = new msgPointStruct(0.3, -0.1, 0.0);
            msgVectorStruct cirNor = new msgVectorStruct(0.0, 0.0, 1.0);

            cirGeo.FromCenterRadiusNormal(cirC, 0.31, cirNor);
            msg2DObject cir = msgCircle.Create(cirGeo);

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

            msgPointStruct point_in_plane = new msgPointStruct(0.0, 0.0, 0.0);

            bool        close = true;
            msg3DObject pipO  = (msg3DObject)msgKinematic.Pipe(cnt2, new msg2DObject[] { cir }, cnt1, point_in_plane, 0.0, ref close);

            scene.AttachObject(pipO);
            pipO.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 25);

            msgVectorStruct transV1 = new msgVectorStruct(3.0, 1.0, 0);

            pipO.InitTempMatrix().Translate(transV1);
            pipO.ApplyTempMatrix();
            pipO.DestroyTempMatrix();
        }
Beispiel #35
0
		public static void CreateIntersectionContours()
		{
			msgScene scene = msgScene.GetScene();
			scene.Clear();
 
			msgTorus tor1 = msgTorus.Create(2,1 ,36,36);
			msgTorus tor2 = msgTorus.Create(2,0.6 ,36,36);
			msgVectorStruct transV1 = new msgVectorStruct(1,1,0);
			tor2.InitTempMatrix().Translate(transV1);
			tor2.ApplyTempMatrix();
			tor2.DestroyTempMatrix();
			scene.AttachObject(tor1);
			tor1.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR,65);
			scene.AttachObject(tor2);
			tor2.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR,105);

			msgVectorStruct transV2 = new msgVectorStruct(5,0,0.0);
			
			msgGroup bool1 = msgBoolean.IntersectionContour(tor1, tor2);

			bool1.InitTempMatrix().Translate(transV2);
			bool1.ApplyTempMatrix();
			bool1.DestroyTempMatrix();
			scene.AttachObject(bool1);
			bool1.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 0);
			bool1.SetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS, 2);
		}
Beispiel #36
0
        public static void CreateFace()
        {
            msgScene scene = msgScene.GetScene();

            scene.Clear();

            msgPointStruct tmpPnt = new msgPointStruct();

            msgSplineStruct spl2 = msgSplineStruct.Create();

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

            msgSpline spl2_obj = msgSpline.Create(spl2);

            msgSplineStruct.Delete(spl2);
            scene.AttachObject(spl2_obj);
            spl2_obj.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 0);
            spl2_obj.SetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS, 1);

            msg2DObject[] holes = new msg2DObject[3];

            msgCircleStruct cirGeo = new msgCircleStruct();
            msgPointStruct  cirC   = new msgPointStruct(0.8, 1.0, 0.0);
            msgVectorStruct cirNor = new msgVectorStruct(0.0, 0.0, 1.0);

            cirGeo.FromCenterRadiusNormal(cirC, 0.8, cirNor);
            holes[0] = msgCircle.Create(cirGeo);
            scene.AttachObject(holes[0]);
            holes[0].SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 0);
            holes[0].SetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS, 1);

            cirC.x = 1.6; cirC.y = -1.0;
            cirGeo.FromCenterRadiusNormal(cirC, 0.2, cirNor);
            holes[1] = msgCircle.Create(cirGeo);
            scene.AttachObject(holes[1]);
            holes[1].SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 0);
            holes[1].SetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS, 1);


            cirC.x = 0.0; cirC.y = -1.0;
            cirGeo.FromCenterRadiusNormal(cirC, 0.4, cirNor);
            holes[2] = msgCircle.Create(cirGeo);
            scene.AttachObject(holes[2]);
            holes[2].SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 0);
            holes[2].SetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS, 1);

            msg3DObject fcO = (msg3DObject)msgSurfaces.Face(spl2_obj, holes);

            scene.AttachObject(fcO);
            fcO.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 50);

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

            fcO.InitTempMatrix().Translate(transV1);
            fcO.ApplyTempMatrix();
            fcO.DestroyTempMatrix();
        }
Beispiel #37
0
		public static void CreateIntersection()
		{
			msgScene scene = msgScene.GetScene();
			scene.Clear();

			msgTorus tor1 = msgTorus.Create(2,1 ,24,24);
			msgTorus tor2 = msgTorus.Create(2,0.3 ,24,24);
			msgVectorStruct transV1 = new msgVectorStruct(1, 1, 0);
			tor2.InitTempMatrix().Translate(transV1);
			tor2.ApplyTempMatrix();
			tor2.DestroyTempMatrix();
			scene.AttachObject(tor1);
			tor1.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 5);
			scene.AttachObject(tor2);
			tor2.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 45);

			msgVectorStruct transV2 = new msgVectorStruct(0, 0, 1.5);

			msgGroup bool1 = msgBoolean.Intersection(tor1, tor2);

			int ChCnt = bool1.GetChildrenList().GetCount();

			msgObject[] allChilds = null;
			bool1.BreakGroup(ref allChilds);
			
			msgObject.DeleteObject(bool1);
			for (ushort i=0; i < ChCnt;i++)
			{
				allChilds[i].InitTempMatrix().Translate(transV2);
				allChilds[i].ApplyTempMatrix();
				allChilds[i].DestroyTempMatrix();
				scene.AttachObject(allChilds[i]);
				allChilds[i].SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, (ushort)(10+i));
			}

			msgBox bx1 = msgBox.Create(2, 2, 1);
			msgSphere sp1 = msgSphere.Create(1, 24, 24);
			msgVectorStruct transV4 = new msgVectorStruct(3, 3, 0);
			bx1.InitTempMatrix().Translate(transV4);
			bx1.ApplyTempMatrix();
			bx1.DestroyTempMatrix();
			scene.AttachObject(bx1);
			bx1.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 55);
			msgVectorStruct transV5 = new msgVectorStruct(3, 4, 0);
			sp1.InitTempMatrix().Translate(transV5);
			sp1.ApplyTempMatrix();
			sp1.DestroyTempMatrix();
			scene.AttachObject(sp1);
			sp1.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 75);

			msgGroup bool2 = msgBoolean.Intersection(sp1, bx1);

			ChCnt = bool2.GetChildrenList().GetCount();
			bool2.BreakGroup(ref allChilds);
						
			msgObject.DeleteObject(bool2);
			for (ushort i = 0; i < ChCnt; i++)
			{
				allChilds[i].InitTempMatrix().Translate(transV2);
				allChilds[i].ApplyTempMatrix();
				allChilds[i].DestroyTempMatrix();
				scene.AttachObject(allChilds[i]);
				allChilds[i].SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, (ushort)(10 + i));
			}
		}
Beispiel #38
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();
        }
Beispiel #39
0
        public static void CreateLinear()
        {
            msgScene scene = msgScene.GetScene();

            scene.Clear();

            Utils.AddFloorInScene(30.0, 30.0, 2.0, 5.0, -2.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);

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

            msgSplineStruct.Delete(spl1);

            msgCircleStruct cirGeo = new msgCircleStruct();

            cirGeo.center.x = 2.0; cirGeo.center.y = -2.0; cirGeo.center.z = 8.0;
            cirGeo.normal.x = 0.0; cirGeo.normal.y = 0.0; cirGeo.normal.z = 1.0;
            cirGeo.radius   = 1.5;
            msgCircle cir = msgCircle.Create(cirGeo);

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

            msg3DObject linO1 = (msg3DObject)msgSurfaces.LinearSurfaceFromSections(spl1_obj,
                                                                                   cir, 0.5f, false);

            scene.AttachObject(linO1);
            linO1.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 90);

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

            linO1.InitTempMatrix().Translate(transV1);
            linO1.ApplyTempMatrix();
            linO1.DestroyTempMatrix();


            msg3DObject linO2 = (msg3DObject)msgSurfaces.LinearSurfaceFromSections(spl1_obj,
                                                                                   cir, 0.7f, true);

            scene.AttachObject(linO2);
            linO2.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 150);

            transV1.x = 8.0; transV1.y = 0.0;
            linO2.InitTempMatrix().Translate(transV1);
            linO2.ApplyTempMatrix();
            linO2.DestroyTempMatrix();


            msg3DObject linO3 = (msg3DObject)msgSurfaces.LinearSurfaceFromSections(spl1_obj,
                                                                                   cir, 0.3f, false);

            scene.AttachObject(linO3);
            linO3.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 30);

            transV1.x = -8.0; transV1.y = 0.0;
            linO3.InitTempMatrix().Translate(transV1);
            linO3.ApplyTempMatrix();
            linO3.DestroyTempMatrix();
        }
Beispiel #40
0
        public void FitBounds(double minX, double minY, double minZ,
				double maxX, double maxY, double maxZ)
        {
            BoundingPlane boundsRight = new BoundingPlane();
            BoundingPlane boundsLeft = new BoundingPlane();
            BoundingPlane boundsTop = new BoundingPlane();
            BoundingPlane boundsBottom = new BoundingPlane();
            BoundingPlane boundsNear = new BoundingPlane();
            BoundingPlane boundsFar = new BoundingPlane();
            msgVectorStruct boundsMax = new msgVectorStruct();
            msgVectorStruct boundsMin = new msgVectorStruct();
            msgVectorStruct vecCenter = new msgVectorStruct();
            msgVectorStruct[] vertices = new msgVectorStruct[8];
            for (int i = 0; i < vertices.Length; i++)
            {
                vertices[i] = new msgVectorStruct();
            }

            msgVectorStruct vecOffset = new msgVectorStruct();
            msgMatrix matrix = new msgMatrix();
            double focalLength = 0;
            double fDepthWidth = 0;
            double fDepthHeight = 0;
            double rx = 0;
            double ry = 0;
            double rz = 0;
            double fTan = 0;
            double fx = 0;
            double fz = 0;

            fTan = (double)Math.Tan((float)Utils.Radiansf(m_fFovY/2));

            // Get the cameras rotatiom about the LookAt position, as we
            // will use this to restore the rotation values after we move
            // the camera and it's focal length.
            GetRotationAboutLookAt(ref rx, ref ry, ref rz);

            // Copy the bounds to our local variable
            boundsMin.x = minX;	boundsMin.y = minY;	boundsMin.z = minZ;
            boundsMax.x = maxX;	boundsMax.y = maxY;	boundsMax.z = maxZ;

            double spanX, spanY, spanZ;

            spanX = Utils.Diff(boundsMax.x, boundsMin.x);
            spanY = Utils.Diff(boundsMax.y, boundsMin.y);
            spanZ = Utils.Diff(boundsMax.z, boundsMin.z);

            vecCenter.x = boundsMax.x - Math.Abs(spanX)/2;
            vecCenter.y = boundsMax.y - Math.Abs(spanY)/2;
            vecCenter.z = boundsMax.z - Math.Abs(spanZ)/2;

            boundsMax.x = spanX/2;
            boundsMax.y = spanY/2;
            boundsMax.z = spanZ/2;

            boundsMin.x = -spanX/2;
            boundsMin.y = -spanY/2;
            boundsMin.z = -spanZ/2;

            // Given the bounding box, fill in the missing vertices to complete our
            // cube
            vertices[0] = boundsMax;	// Left
            vertices[1].x = boundsMax.x; vertices[1].y = boundsMax.y; vertices[1].z = boundsMin.x;
            vertices[2].x = boundsMax.x; vertices[2].y = boundsMin.y; vertices[2].z = boundsMin.x;
            vertices[3].x = boundsMax.x; vertices[3].y = boundsMin.y; vertices[3].z = boundsMax.x;

            vertices[4] = boundsMin;
            vertices[5].x = boundsMin.x; vertices[5].y = boundsMin.y; vertices[5].z = boundsMax.x;
            vertices[6].x = boundsMin.x; vertices[6].y = boundsMax.y; vertices[6].z = boundsMax.x;
            vertices[7].x = boundsMin.x; vertices[7].y = boundsMax.y; vertices[7].z = boundsMin.x;

            // Get the cameras rotation matrix
            GetRotationMatrix(ref matrix);

            for(int i=0; i<8; i++)
            {
                // Transform the vertice by the camera rotation matrix.  Since we define the
                // default 'Up' camera position as Z-axis Up, the coordinates map as follows:
                //		X maps to Width,
                //		Y maps to Depth
                //		Z mpas to Height
                zero_p.x  = zero_p.y  =zero_p.z  =0.0;
                matrix.ApplyMatrixToVector(zero_p, vertices[i]);

                // Calculate the focal length needed to fit the near bounding plane
                fDepthWidth  = (Math.Abs(vertices[i].x)/fTan/m_fAspect)-vertices[i].y;
                fDepthHeight = (Math.Abs(vertices[i].z) / fTan) - vertices[i].y;

                // Calculate the Near clipping bounds.  This will be used to fit Isometric views and
                // for calculating the Near/Far clipping m_fFrustum.
                if(vertices[i].y<0)
                {
                    if (Math.Abs(vertices[i].x) > Math.Abs(boundsNear.vec.x) ||
                       (Math.Abs(vertices[i].x) == boundsNear.vec.x && Math.Abs(vertices[i].y) > Math.Abs(boundsNear.vec.z)))
                    {
                        boundsNear.vec.x = Math.Abs(vertices[i].x);
                        boundsNear.vec.z = Math.Abs(vertices[i].y);
                    }

                    if (Math.Abs(vertices[i].z) > Math.Abs(boundsNear.vec.y) ||
                       (Math.Abs(vertices[i].z) == boundsNear.vec.y))
                    {
                        boundsNear.vec.y = Math.Abs(vertices[i].z);
                        //boundsNear.vec[W] = fabs(vertices[i].y);
                    }

                    // Get the bounding depth closest to the viewer
                    if(fDepthWidth < boundsNear.fDepth || boundsNear.fDepth == 0)
                        boundsNear.fDepth = fDepthWidth;
                    if(fDepthHeight < boundsNear.fDepth || boundsNear.fDepth == 0)
                        boundsNear.fDepth = fDepthHeight;
                }
                else
                {
                    if( Math.Abs(vertices[i].x) > Math.Abs(boundsFar.vec.x) ||
                       (Math.Abs(vertices[i].x) == boundsFar.vec.x && Math.Abs(vertices[i].y) < Math.Abs(boundsFar.vec.z)) )
                    {
                        boundsFar.vec.x = vertices[i].x;
                        boundsFar.vec.z = vertices[i].y;
                    }

                    if( Math.Abs(vertices[i].z) > Math.Abs(boundsFar.vec.y) ||
                       (Math.Abs(vertices[i].z) == Math.Abs(boundsFar.vec.y)) )
                    {
                        boundsFar.vec.y = vertices[i].z;
                        //boundsFar.vec[W] = vertices[i].y;
                    }

                    // Get the bounding depth furtherest from the viewer
                    if(fDepthWidth > boundsFar.fDepth)
                        boundsFar.fDepth = fDepthWidth;
                    if(fDepthHeight > boundsFar.fDepth)
                        boundsFar.fDepth = fDepthHeight;
                }

                // Calculate the Right, Left, Top and Bottom clipping bounds.  This will be used to fit
                // Perspective views.
                if(vertices[i].x > 0)
                {
                    if(fDepthWidth > boundsRight.fDepth)
                    {
                        boundsRight.fDepth = fDepthWidth;
                        boundsRight.vec.x = vertices[i].x;
                        //boundsRight.vec[W] = vertices[i].y;
                    }
                }
                if(vertices[i].x <= 0)
                {
                    if(fDepthWidth > boundsLeft.fDepth)
                    {
                        boundsLeft.fDepth = fDepthWidth;
                        boundsLeft.vec.x = vertices[i].x;
                        //boundsLeft.vec[W] = vertices[i].y;
                    }
                }
                if(vertices[i].z > 0)
                {
                    if(fDepthHeight > boundsTop.fDepth)
                    {
                        boundsTop.fDepth = fDepthHeight;
                        boundsTop.vec.x = vertices[i].x;
                        //boundsTop.vec[W] = vertices[i].y;
                    }
                }
                if(vertices[i].z <= 0)
                {
                    if(fDepthHeight > boundsBottom.fDepth)
                    {
                        boundsBottom.fDepth = fDepthHeight;
                        boundsBottom.vec.x = vertices[i].x;
                        //boundsBottom.vec[W] = vertices[i].y;
                    }
                }
            }

            // Now that we have the view clipping bounds, we can calculate the focal depth
            // required to fit the volumn and the offset necessary to center the volumn.
            if (m_bPerspective)
            {
                msgMatrix invMatrix = new msgMatrix();

                if (boundsRight.fDepth == boundsLeft.fDepth &&
                   boundsTop.fDepth == boundsBottom.fDepth)
                {
                    // Front, Side or Top view

                    //  Since the bounds are symetric, just use the Right and Top focal depth.
                    fx = boundsRight.fDepth;
                    fz = boundsTop.fDepth;

                    // No offset necessary
                    vecOffset.x = vecOffset.y = vecOffset.z = 0.0;
                }
                else
                {
                    // Calculate the average focal length needed to fit the bounding box
                    fx = (boundsRight.fDepth + boundsLeft.fDepth) / 2;
                    fz = (boundsTop.fDepth + boundsBottom.fDepth) / 2;

                    // Calculate the offset necessary to center the bounding box.  Note that we
                    // use a scaling factor for centering the non-limiting bounds to achieve a
                    // more visually appealing center.
                    if (fx > fz)
                    {
                        double fScale = Math.Sqrt(boundsTop.fDepth / boundsBottom.fDepth);
                        double fTop = fTan * fx - fTan * boundsTop.fDepth;
                        double fBottom = fTan * fx - fTan * boundsBottom.fDepth;

                        vecOffset.x = (fTan * m_fAspect * boundsRight.fDepth - fTan * m_fAspect * fx);
                        vecOffset.z = (fBottom - fTop * fScale) / 2;
                    }
                    else
                    {
                        double fScale = Math.Sqrt(boundsLeft.fDepth / boundsRight.fDepth);
                        double fRight = fTan * m_fAspect * fz - fTan * m_fAspect * boundsRight.fDepth;
                        double fLeft = fTan * m_fAspect * fz - fTan * m_fAspect * boundsLeft.fDepth;

                        vecOffset.z = (fTan * boundsTop.fDepth - fTan * fz);
                        vecOffset.x = (fLeft - fRight * fScale) / 2;
                    }
                }

                // Now that we have the offsets necessary to center the bounds, we must rotate
                // the vertices (camera coordinates) by the cameras inverse rotation matrix to
                // convert the offsets to world coordinates.
                GetInvRotationMatrix(ref invMatrix);
                zero_p.x = zero_p.y = zero_p.z = 0.0;

                invMatrix.ApplyMatrixToVector(zero_p, vecOffset);
            }
            else
            {
                // Isometric View
                // Calculate the focal length needed to fit the near bounding plane
                if (m_iScreenWidth <= m_iScreenHeight)
                {
                    fx = boundsNear.vec.x / Math.Tan((float)Utils.Radiansf(m_fFovY / 2));
                    fz = boundsNear.vec.y / Math.Tan((float)Utils.Radiansf(m_fFovY / 2)) / ((double)m_iScreenHeight / (double)m_iScreenWidth);
                }
                else
                {
                    fx = boundsNear.vec.x / Math.Tan((float)Utils.Radiansf(m_fFovY / 2)) / m_fAspect;
                    fz = boundsNear.vec.y / Math.Tan((float)Utils.Radiansf(m_fFovY / 2));
                }
            }

            // Set the focal length equal to the largest length required to fit either the
            // Width (Horizontal) or Height (Vertical)
            focalLength = (fx > fz ? fx : fz);

            // Set the camera's new LookAt position to focus on the center
            // of the bounding box.
            SetLookAtPos(vecCenter.x + vecOffset.x, vecCenter.y + vecOffset.y, vecCenter.z + vecOffset.z);

            // Set the camera focal Length
            if (focalLength > m_fNear)
                SetFocalLength(focalLength, true);

            // Adjust the Near clipping plane if necessary
            //	if((boundsNear.fDepth/2) > 0.5f)
            //		m_fNear = boundsNear.fDepth/2;

            // Adjust the Far clipping plane if necessary
            if (focalLength + boundsFar.fDepth > m_fFar)
                m_fFar = focalLength + boundsFar.fDepth;

            // Recalculate the camera view m_fFrustum;
            ResetView(0, 0);

            // Restore the cameras rotation about the LookAt position
            SetRotationAboutLookAt(rx, ry, rz);
        }
Beispiel #41
0
        public static void CreateLinear()
        {
            msgScene scene = msgScene.GetScene();
            scene.Clear();

            Utils.AddFloorInScene(30.0, 30.0, 2.0, 5.0, -2.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);
            scene.AttachObject(spl1_obj);
            spl1_obj.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 12);
            spl1_obj.SetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS, 2);

            msgSplineStruct.Delete(spl1);

            msgCircleStruct cirGeo = new msgCircleStruct();
            cirGeo.center.x = 2.0; cirGeo.center.y = -2.0; cirGeo.center.z = 8.0;
            cirGeo.normal.x = 0.0; cirGeo.normal.y = 0.0; cirGeo.normal.z = 1.0;
            cirGeo.radius = 1.5;
            cirGeo.FromCenterRadiusNormal(cirGeo.center, cirGeo.radius, cirGeo.normal);
            msgCircle cir = msgCircle.Create(cirGeo);
            scene.AttachObject(cir);
            cir.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 12);
            cir.SetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS, 2);

            msg3DObject linO1 = (msg3DObject)msgSurfaces.LinearSurfaceFromSections(spl1_obj,
                cir, 0.5f ,false);

            scene.AttachObject(linO1);
            linO1.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 90);

            msgVectorStruct transV1 = new msgVectorStruct(0,7,0);
            linO1.InitTempMatrix().Translate(transV1);
            linO1.ApplyTempMatrix();
            linO1.DestroyTempMatrix();

            msg3DObject linO2 = (msg3DObject)msgSurfaces.LinearSurfaceFromSections(spl1_obj,
                cir, 0.7f, true);

            scene.AttachObject(linO2);
            linO2.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 150);

            transV1.x = 8.0; transV1.y = 0.0;
            linO2.InitTempMatrix().Translate(transV1);
            linO2.ApplyTempMatrix();
            linO2.DestroyTempMatrix();

            msg3DObject linO3 = (msg3DObject)msgSurfaces.LinearSurfaceFromSections(spl1_obj,
                cir, 0.3f, false);

            scene.AttachObject(linO3);
            linO3.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 30);

            transV1.x = -8.0; transV1.y = 0.0;
            linO3.InitTempMatrix().Translate(transV1);
            linO3.ApplyTempMatrix();
            linO3.DestroyTempMatrix();
        }
Beispiel #42
0
        private void PrepareMatrix(double Ox, double Oy, double Oz,
				   double Rx, double Ry, double Rz,
				   double Tx, double Ty, double Tz,
				   ref msgMatrix XForm)
        {
            XForm.Identity();

            msgVectorStruct TransV = new msgVectorStruct();
            TransV.x = Tx;
            TransV.y = Ty;
            TransV.z = Tz;
            XForm.Translate(TransV);

            XForm.Rotate(zero_p, x_axe, Rx);
            XForm.Rotate(zero_p, y_axe, Ry);
            XForm.Rotate(zero_p, z_axe, Rz);

            msgVectorStruct oV = new msgVectorStruct();
            oV.x = Ox;
            oV.y = Oy;
            oV.z = Oz;
            XForm.Translate(oV);
        }
Beispiel #43
0
		public static void CreateExtrudeSurfaces()
		{
			msgScene scene = msgScene.GetScene();
			scene.Clear();

			msgPointStruct tmpPnt = new msgPointStruct();

			msgSplineStruct spl2 = msgSplineStruct.Create();

			int fl=0;
			for (double i=0.0;i<10.0;i+=1.0)
			{
				tmpPnt.x = i;
				tmpPnt.y = (fl%2 > 0)?-i/2.0:i/2.0;
				tmpPnt.z = 0.0;
				spl2.AddKnot(tmpPnt,fl);
				fl++;
			}
			
			msgSpline spl2_obj = msgSpline.Create(spl2);
			scene.AttachObject(spl2_obj);
			spl2_obj.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 12);
			spl2_obj.SetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS, 2);

			msgSplineStruct.Delete(spl2);

			msgVectorStruct extVec = new msgVectorStruct(1,-2,3);

			msg3DObject exO = (msg3DObject)msgKinematic.Extrude(spl2_obj, null, extVec,false);

			scene.AttachObject(exO);
			exO.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 20);

			msgVectorStruct transV1 = new msgVectorStruct(8, 0, 0);
			exO.InitTempMatrix().Translate(transV1);
			exO.ApplyTempMatrix();
			exO.DestroyTempMatrix();
		}
Beispiel #44
0
		public static void CreateRotationBody()
		{
			msgScene scene = msgScene.GetScene();
			scene.Clear();

			msgPointStruct tmpPnt = new msgPointStruct();

			msgSplineStruct spl2 = msgSplineStruct.Create();
			int fl=0;
			for (double i=0.0;i<2.0*Math.PI;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;
				spl2.AddKnot(tmpPnt,fl);
				fl++;
			}
			
			spl2.Close();

			msgSpline spl2_obj = msgSpline.Create(spl2);
			scene.AttachObject(spl2_obj);
			spl2_obj.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR,12);
			spl2_obj.SetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS,2);

			msgSplineStruct.Delete(spl2);

			msgPointStruct p1 = new msgPointStruct(10,10,0);
			msgPointStruct p2 = new msgPointStruct(20,15,0);

			msg3DObject rO = (msg3DObject)msgKinematic.Rotation(spl2_obj,p1,p2,290,true);

			scene.AttachObject(rO);
			rO.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 8);

			msgVectorStruct transV1 = new msgVectorStruct( -6, 0, 0 );
			rO.InitTempMatrix().Translate(transV1);
			rO.ApplyTempMatrix();
			rO.DestroyTempMatrix();
		}
Beispiel #45
0
		public static void CreatePipeBody()
		{
			msgScene scene = msgScene.GetScene();
			scene.Clear();

			msgObject[] objcts = new msgObject[5];

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

			ArP1.x = 0.0; ArP1.y = -2.0; ArP1.z = 0.0;
			ArP2.x = 1.0; ArP2.y = -1.0; ArP2.z = 0.0;
			ArP3.x = 0.4; ArP3.y = -1.2; ArP3.z = 0.0;
			ArcGeo.FromThreePoints(ArP1,ArP2,ArP3,false);
			objcts[0] = msgArc.Create(ArcGeo);

			ArP1.x = 1.0; ArP1.y = -1.0; ArP1.z = 0.0;
			ArP2.x = 2.0; ArP2.y = 0.0; ArP2.z = 0.0;
			ArP3.x = 1.9; ArP3.y = -0.5; ArP3.z = 0.0;
			ArcGeo.FromThreePoints(ArP1,ArP2,ArP3,false);
			objcts[1] = msgArc.Create(ArcGeo);

			ArP1.x = 2.0; ArP1.y = 0.0; ArP1.z = 0.0;
			ArP2.x = 1.0; ArP2.y = 1.0; ArP2.z = 0.0;
			ArP3.x = 1.6; ArP3.y = 0.8; ArP3.z = 0.0;
			ArcGeo.FromThreePoints(ArP1,ArP2,ArP3,false);
			objcts[2] = msgArc.Create(ArcGeo);

			objcts[3] = msgLine.Create(1.0, 1.0, 0.0, -1.0, 1.0, 0.0);

			ArP1.x = -1.0; ArP1.y = 1.0; ArP1.z = 0.0;
			ArP2.x = -1.0; ArP2.y = 0.0; ArP2.z = 1.0;
			ArP3.x = -1.1; ArP3.y = 1.0; ArP3.z = 0.0;
			ArcGeo.FromThreePoints(ArP1,ArP2,ArP3,false);
			objcts[4] = msgArc.Create(ArcGeo);

			msgContour cnt1 = msgContour.CreateContour(objcts);
			scene.AttachObject(cnt1);
			cnt1.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 12);
			cnt1.SetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS, 2);

			ArP1.x = -0.2; ArP1.y = -0.2; ArP1.z = 0.0;
			ArP2.x = -0.1; ArP2.y = 0.2; ArP2.z = 0.0;
			ArP3.x = -0.3; ArP3.y = 0.1; ArP3.z = 0.0;
			ArcGeo.FromThreePoints(ArP1,ArP2,ArP3,false);
			objcts[0] = msgArc.Create(ArcGeo);


			ArP1.x = -0.1; ArP1.y = 0.2; ArP1.z = 0.0;
			ArP2.x = 0.3; ArP2.y = 0.5; ArP2.z = 0.0;
			ArP3.x = 0.2; ArP3.y = 0.6; ArP3.z = 0.0;
			ArcGeo.FromThreePoints(ArP1,ArP2,ArP3,false);
			objcts[1] = msgArc.Create(ArcGeo);

			ArP1.x = 0.3; ArP1.y = 0.5; ArP1.z = 0.0;
			ArP2.x = -0.2; ArP2.y = -0.2; ArP2.z = 0.0;
			ArP3.x = 0.6; ArP3.y = -0.4; ArP3.z = 0.0;
			ArcGeo.FromThreePoints(ArP1,ArP2,ArP3,false);
			objcts[2] = msgArc.Create(ArcGeo);

			msgObject[] objcts2 = null;
			Array.Copy(objcts, objcts2, 3);
			msgContour cnt2 = msgContour.CreateContour(objcts2);
			scene.AttachObject(cnt2);
			cnt2.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 12);
			cnt2.SetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS, 2);

			msgCircleStruct cirGeo = new msgCircleStruct();
			msgPointStruct cirC = new msgPointStruct(0.3, -0.1, 0.0);
			msgVectorStruct cirNor = new msgVectorStruct(0.0, 0.0, 1.0);
			cirGeo.FromCenterRadiusNormal(cirC,0.31, cirNor);
			msg2DObject cir = msgCircle.Create(cirGeo);
			scene.AttachObject(cir);
			cir.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 12);
			cir.SetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS, 2);

			msgPointStruct point_in_plane = new msgPointStruct(0.0,0.0,0.0);

			bool  close = true;
			msg3DObject pipO = (msg3DObject)msgKinematic.Pipe(cnt2, new msg2DObject[] { cir }, cnt1, point_in_plane, 0.0, ref close);

			scene.AttachObject(pipO);
			pipO.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 25);

			msgVectorStruct transV1 = new msgVectorStruct(3.0, 1.0, 0);
			pipO.InitTempMatrix().Translate(transV1);
			pipO.ApplyTempMatrix();
			pipO.DestroyTempMatrix();
		}
Beispiel #46
0
		public static void CreatePipeSurface()
		{
			msgScene scene = msgScene.GetScene();
			scene.Clear();

			msgArcStruct ArcGeo = new msgArcStruct();
			msgPointStruct ArP1 = new msgPointStruct(1.0, -4.0, 0.0);
			msgPointStruct ArP2 = new msgPointStruct(1.0, -3.6, 0.0);
			msgPointStruct ArP3 = new msgPointStruct(1.2, -3.5, 0.0);
			ArcGeo.FromThreePoints(ArP1,ArP2,ArP3,false);
			msg2DObject ar = msgArc.Create(ArcGeo);
			scene.AttachObject(ar);
			ar.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 12);
			ar.SetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS, 2);

			msgObject[] objcts = new msgObject[6];

			objcts[0] = msgLine.Create(0.0, -4.0, 0.0, 0.0, -2.0, 0.0);

			ArP1.x = 0.0; ArP1.y = -2.0; ArP1.z = 0.0;
			ArP2.x = 1.0; ArP2.y = -1.0; ArP2.z = 0.0;
			ArP3.x = 0.4; ArP3.y = -1.2; ArP3.z = 0.0;
			ArcGeo.FromThreePoints(ArP1,ArP2,ArP3,false);
			objcts[1] = msgArc.Create(ArcGeo);

			ArP1.x = 1.0; ArP1.y = -1.0; ArP1.z = 0.0;
			ArP2.x = 2.0; ArP2.y = 0.0; ArP2.z = 0.0;
			ArP3.x = 1.9; ArP3.y = -0.5; ArP3.z = 0.0;
			ArcGeo.FromThreePoints(ArP1,ArP2,ArP3,false);
			objcts[2] = msgArc.Create(ArcGeo);

			ArP1.x = 2.0; ArP1.y = 0.0; ArP1.z = 0.0;
			ArP2.x = 1.0; ArP2.y = 1.0; ArP2.z = 0.0;
			ArP3.x = 1.6; ArP3.y = 0.8; ArP3.z = 0.0;
			ArcGeo.FromThreePoints(ArP1,ArP2,ArP3,false);
			objcts[3] = msgArc.Create(ArcGeo);

			objcts[4] = msgLine.Create(1.0, 1.0, 0.0, -1.0, 1.0, 0.0);

			ArP1.x = -1.0; ArP1.y = 1.0; ArP1.z = 0.0;
			ArP2.x = -1.0; ArP2.y = 0.0; ArP2.z = 1.0;
			ArP3.x = -1.1; ArP3.y = 1.0; ArP3.z = 0.0;
			ArcGeo.FromThreePoints(ArP1,ArP2,ArP3,false);
			objcts[5] = msgArc.Create(ArcGeo);

			msgContour cnt1 = msgContour.CreateContour(objcts);
			scene.AttachObject(cnt1);
			cnt1.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 12);
			cnt1.SetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS, 2);

			msgPointStruct point_in_plane = new msgPointStruct(1.0, -4.0, 0.0);

			bool close = false;
			msg3DObject pipO = (msg3DObject)msgKinematic.Pipe(ar,null, cnt1, point_in_plane, 0.0, ref close);

			scene.AttachObject(pipO);
			pipO.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 25);

			msgVectorStruct transV1 = new msgVectorStruct(2.5, 1, 0);
			pipO.InitTempMatrix().Translate(transV1);
			pipO.ApplyTempMatrix();
			pipO.DestroyTempMatrix();
		}
Beispiel #47
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();
        }
Beispiel #48
0
        public void GetVectorsForRayTracingCamera(msgVectorStruct eye_loc,
				msgVectorStruct eye_look_at,
				msgVectorStruct eye_y,
				msgVectorStruct eye_x)
        {
            double xval = eye_loc.x;
            double yval = eye_loc.y;
            double zval = eye_loc.z;
            GetEyePos(ref xval, ref yval, ref zval);
            eye_loc.x = xval;
            eye_loc.y = yval;
            eye_loc.z = zval;

            double xval2 = eye_look_at.x;
            double yval2 = eye_look_at.y;
            double zval2 = eye_look_at.z;
            GetLookAtPos(ref xval2, ref yval2, ref zval2);
            eye_look_at.x = xval2;
            eye_look_at.y = yval2;
            eye_look_at.z = zval2;

            msgVectorStruct p1 = new msgVectorStruct();
            msgVectorStruct p2 = new msgVectorStruct();
            GetWorldCoord(m_iScreenWidth/2,m_iScreenHeight/2,0.0,ref p1);
            GetWorldCoord(m_iScreenWidth/2,0,0.0, ref p2);

            eye_y = msgSpaceMath.VectorsSub(p2,p1);

            msgSpaceMath.NormalVector(eye_y);

            GetWorldCoord(m_iScreenWidth, m_iScreenHeight/2,0.0, ref p2);

            eye_x = msgSpaceMath.VectorsSub(p2,p1);
            msgSpaceMath.NormalVector(eye_x);
        }
Beispiel #49
0
        public static void CreateCoonsFrom4Curves()
        {
            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 = -2.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 = -5.0; tmpPnt.y = 4.0; tmpPnt.z = 2.0;
            spl2.AddKnot(tmpPnt, 0);
            tmpPnt.x = -3.0; tmpPnt.y = 4.0; tmpPnt.z = 1.0;
            spl2.AddKnot(tmpPnt, 1);
            tmpPnt.x = -2.0; tmpPnt.y = 4.0; tmpPnt.z = 2.0;
            spl2.AddKnot(tmpPnt, 2);
            tmpPnt.x = -1.0; tmpPnt.y = 4.0; tmpPnt.z = -1.0;
            spl2.AddKnot(tmpPnt, 3);
            tmpPnt.x = 4.0; tmpPnt.y = 4.0; tmpPnt.z = 0.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, 10);
            spl2_obj.SetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS, 2);

            msgSplineStruct spl3 = msgSplineStruct.Create();

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

            msgSpline spl3_obj = msgSpline.Create(spl3);

            msgSplineStruct.Delete(spl3);
            scene.AttachObject(spl3_obj);
            spl3_obj.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 50);
            spl3_obj.SetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS, 3);

            msgSplineStruct spl4 = msgSplineStruct.Create();

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

            msgSpline spl4_obj = msgSpline.Create(spl4);

            msgSplineStruct.Delete(spl4);
            scene.AttachObject(spl4_obj);
            spl4_obj.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 100);
            spl4_obj.SetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS, 4);

            msg3DObject coons = (msg3DObject)msgSurfaces.Coons(spl1_obj,
                                                               spl2_obj,
                                                               spl3_obj,
                                                               spl4_obj, 36, 36, 4, 4);

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

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

            coons.InitTempMatrix().Translate(transV1);
            coons.ApplyTempMatrix();
            coons.DestroyTempMatrix();
        }
Beispiel #50
0
        public void GetWorldCoord(int ix, int iy, double fz, ref msgVectorStruct coord)
        {
            double x, y, z, winX, winY, winZ;

            // Fix the yPos value.  MS Windows origin 0,0 is upper left
            // while OpenGL windows origin 0,0 is lower left...
            winX = ix;
            winY = m_iViewport[3] - iy;

            // Add the camera's focal length, or distance from 'LookAt' to 'Eye' position
            // to the given 'z' coordinate.
            fz += GetFocalLength();

            // Calculate the winZ coordinate:
            if (m_bPerspective)
                // Compensate for perspective view
                winZ = 0.5 + (((m_fFar + m_fNear) - (2 * m_fFar * m_fNear) / fz)) / (2 * (m_fFar - m_fNear));
            else
                // winZ is linearly interpolated between the Near_Far clipping plane
                winZ = (fz - m_fNear) / (m_fFar - m_fNear);

            // Unproject the point
            unsafe
            {
                fixed (double* m_dModelViewMatrixPtr = m_dModelViewMatrix)
                {
                    fixed (double* m_dProjectionMatrixPtr = m_dProjectionMatrix)
                    {
                        fixed (int* m_iViewportPtr = m_iViewport)
                        {
                            OpenGLControl.gluUnProject(winX, winY, winZ,
                                 m_dModelViewMatrixPtr,
                                 m_dProjectionMatrixPtr,
                                 m_iViewportPtr,
                                 &x, &y, &z);
                        }
                    }
                }
            }

            coord.x = x;
            coord.y = y;
            coord.z = z;
        }
Beispiel #51
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();
        }
Beispiel #52
0
        public static void CreatePipeSurface()
        {
            msgScene scene = msgScene.GetScene();

            scene.Clear();

            msgArcStruct   ArcGeo = new msgArcStruct();
            msgPointStruct ArP1   = new msgPointStruct(1.0, -4.0, 0.0);
            msgPointStruct ArP2   = new msgPointStruct(1.0, -3.6, 0.0);
            msgPointStruct ArP3   = new msgPointStruct(1.2, -3.5, 0.0);

            ArcGeo.FromThreePoints(ArP1, ArP2, ArP3, false);
            msg2DObject ar = msgArc.Create(ArcGeo);

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

            msgObject[] objcts = new msgObject[6];

            objcts[0] = msgLine.Create(0.0, -4.0, 0.0, 0.0, -2.0, 0.0);

            ArP1.x = 0.0; ArP1.y = -2.0; ArP1.z = 0.0;
            ArP2.x = 1.0; ArP2.y = -1.0; ArP2.z = 0.0;
            ArP3.x = 0.4; ArP3.y = -1.2; ArP3.z = 0.0;
            ArcGeo.FromThreePoints(ArP1, ArP2, ArP3, false);
            objcts[1] = msgArc.Create(ArcGeo);

            ArP1.x = 1.0; ArP1.y = -1.0; ArP1.z = 0.0;
            ArP2.x = 2.0; ArP2.y = 0.0; ArP2.z = 0.0;
            ArP3.x = 1.9; ArP3.y = -0.5; ArP3.z = 0.0;
            ArcGeo.FromThreePoints(ArP1, ArP2, ArP3, false);
            objcts[2] = msgArc.Create(ArcGeo);

            ArP1.x = 2.0; ArP1.y = 0.0; ArP1.z = 0.0;
            ArP2.x = 1.0; ArP2.y = 1.0; ArP2.z = 0.0;
            ArP3.x = 1.6; ArP3.y = 0.8; ArP3.z = 0.0;
            ArcGeo.FromThreePoints(ArP1, ArP2, ArP3, false);
            objcts[3] = msgArc.Create(ArcGeo);

            objcts[4] = msgLine.Create(1.0, 1.0, 0.0, -1.0, 1.0, 0.0);

            ArP1.x = -1.0; ArP1.y = 1.0; ArP1.z = 0.0;
            ArP2.x = -1.0; ArP2.y = 0.0; ArP2.z = 1.0;
            ArP3.x = -1.1; ArP3.y = 1.0; ArP3.z = 0.0;
            ArcGeo.FromThreePoints(ArP1, ArP2, ArP3, false);
            objcts[5] = msgArc.Create(ArcGeo);

            msgContour cnt1 = msgContour.CreateContour(objcts);

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

            msgPointStruct point_in_plane = new msgPointStruct(1.0, -4.0, 0.0);

            bool        close = false;
            msg3DObject pipO  = (msg3DObject)msgKinematic.Pipe(ar, null, cnt1, point_in_plane, 0.0, ref close);

            scene.AttachObject(pipO);
            pipO.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 25);

            msgVectorStruct transV1 = new msgVectorStruct(2.5, 1, 0);

            pipO.InitTempMatrix().Translate(transV1);
            pipO.ApplyTempMatrix();
            pipO.DestroyTempMatrix();
        }
Beispiel #53
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();
        }
Beispiel #54
0
        public void SetRotationAboutLookAt(double x, double y, double z)
        {
            msgMatrix matx = new msgMatrix();
            msgVectorStruct EyePos = new msgVectorStruct();

            matx.Rotate(zero_p, x_axe, x / 180.0 * Math.PI);
            matx.Rotate(zero_p, z_axe, -z / 180.0 * Math.PI);

            EyePos.x = 0.0;
            EyePos.y = -m_fFocalLength;
            EyePos.z = 0.0;
            matx.ApplyMatrixToVector(zero_p, EyePos);

            m_fEyePos.x = EyePos.x + m_fLookAtPos.x;
            m_fEyePos.y = EyePos.y + m_fLookAtPos.y;
            m_fEyePos.z = EyePos.z + m_fLookAtPos.z;

            // Calculate our camera's UpVector using ONLY the 'X' (Pitch) and 'Z' (Yaw)
            // parameters
            m_fUpVector = z_axe;
            matx.ApplyMatrixToVector(zero_p, m_fUpVector);

            // Just save the 'y' value for later use when calculating the camera's 'Up' vector
            // prior to calling gluLookAt()
            m_fRoll = y;
        }
Beispiel #55
0
		public static void CreateSub()
		{
			msgScene scene = msgScene.GetScene();
			scene.Clear();

			Utils.AddFloorInScene(15.0, 14.0, -2.0, 2.0, -1.0);

			msgTorus tor1 = msgTorus.Create(2,1 ,24,24);
			msgTorus tor2 = msgTorus.Create(2,0.8 ,24,24);
			msgVectorStruct transV1 = new msgVectorStruct(1,1,0);
			tor2.InitTempMatrix().Translate(transV1);
			tor2.ApplyTempMatrix();
			tor2.DestroyTempMatrix();
			scene.AttachObject(tor1);
			tor1.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR,5);
			scene.AttachObject(tor2);
			tor2.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR,25);

			msgVectorStruct transV2 = new msgVectorStruct(-6.0,0,0);

			msgGroup bool1 = msgBoolean.Sub(tor1, tor2);

			bool1.InitTempMatrix().Translate(transV2);
			bool1.ApplyTempMatrix();
			bool1.DestroyTempMatrix();
			scene.AttachObject(bool1);
			bool1.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 3);
		}
Beispiel #56
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);
            msgSpline spl3_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] = spl3_obj;

            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();
        }
Beispiel #57
0
		public static void CreateSections()
		{
			msgScene scene = msgScene.GetScene();
			scene.Clear();

			msgTorus tor1 = msgTorus.Create(2,1 ,36,36);
			scene.AttachObject(tor1);

			msgVectorStruct transV2 = new msgVectorStruct(-6,0,0);

			for (int i=-30;i<30;i+=4)
			{
				msgVectorStruct plN = new msgVectorStruct();
				plN.x =0.0; plN.y = 1.0; plN.z = 1.0;

				msgGroup bool1 = msgBoolean.Section(tor1, plN, 0.1*i );

				if (bool1 != null)
				{
					bool1.InitTempMatrix().Translate(transV2);
					bool1.ApplyTempMatrix();
					bool1.DestroyTempMatrix();
					scene.AttachObject(bool1);
					bool1.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, (ushort)(i + 50));
					bool1.SetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS, 2);
				}
			}
		}
Beispiel #58
0
        public static void CreateCoonsFrom4Curves()
        {
            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 = -2.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 = -5.0; tmpPnt.y = 4.0; tmpPnt.z = 2.0;
            spl2.AddKnot(tmpPnt,0);
            tmpPnt.x = -3.0; tmpPnt.y = 4.0; tmpPnt.z = 1.0;
            spl2.AddKnot(tmpPnt,1);
            tmpPnt.x = -2.0; tmpPnt.y = 4.0; tmpPnt.z = 2.0;
            spl2.AddKnot(tmpPnt,2);
            tmpPnt.x = -1.0; tmpPnt.y = 4.0; tmpPnt.z = -1.0;
            spl2.AddKnot(tmpPnt,3);
            tmpPnt.x =4.0; tmpPnt.y = 4.0; tmpPnt.z = 0.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, 10);
            spl2_obj.SetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS, 2);

            msgSplineStruct spl3 = msgSplineStruct.Create();

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

            msgSpline spl3_obj = msgSpline.Create(spl3);
            msgSplineStruct.Delete(spl3);
            scene.AttachObject(spl3_obj);
            spl3_obj.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 50);
            spl3_obj.SetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS, 3);

            msgSplineStruct spl4 = msgSplineStruct.Create();

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

            msgSpline spl4_obj = msgSpline.Create(spl4);
            msgSplineStruct.Delete(spl4);
            scene.AttachObject(spl4_obj);
            spl4_obj.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 100);
            spl4_obj.SetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS, 4);

            msg3DObject coons = (msg3DObject)msgSurfaces.Coons(spl1_obj,
                                                                spl2_obj,
                                                                spl3_obj,
                                                                spl4_obj, 36, 36, 4, 4);

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

            msgVectorStruct transV1 = new msgVectorStruct(0,0,-0.3);
            coons.InitTempMatrix().Translate(transV1);
            coons.ApplyTempMatrix();
            coons.DestroyTempMatrix();
        }
Beispiel #59
0
        public void CalculateUpVector()
        {
            msgMatrix matx = new msgMatrix();

            matx.Rotate(zero_p, x_axe, m_fPitch / 180.0 * Math.PI);
            matx.Rotate(zero_p, z_axe, -m_fYaw / 180.0 * Math.PI);

            m_fUpVector = z_axe;
            matx.ApplyMatrixToVector(zero_p, m_fUpVector);
        }
Beispiel #60
0
        public static void CreateFace()
        {
            msgScene scene = msgScene.GetScene();
            scene.Clear();

            msgPointStruct tmpPnt = new msgPointStruct();

            msgSplineStruct spl2 = msgSplineStruct.Create();

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

            msgSpline spl2_obj = msgSpline.Create(spl2);
            msgSplineStruct.Delete(spl2);
            scene.AttachObject(spl2_obj);
            spl2_obj.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 0);
            spl2_obj.SetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS, 1);

            msg2DObject[] holes = new msg2DObject[3];

            msgCircleStruct cirGeo = new msgCircleStruct();
            msgPointStruct cirC = new msgPointStruct(0.8, 1.0, 0.0);
            msgVectorStruct cirNor = new msgVectorStruct(0.0, 0.0, 1.0);
            cirGeo.FromCenterRadiusNormal(cirC,0.8, cirNor);
            holes[0] = msgCircle.Create(cirGeo);
            scene.AttachObject(holes[0]);
            holes[0].SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 0);
            holes[0].SetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS, 1);

            cirC.x = 1.6; cirC.y = -1.0;
            cirGeo.FromCenterRadiusNormal(cirC,0.2, cirNor);
            holes[1] = msgCircle.Create(cirGeo);
            scene.AttachObject(holes[1]);
            holes[1].SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 0);
            holes[1].SetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS, 1);

            cirC.x = 0.0; cirC.y = -1.0;
            cirGeo.FromCenterRadiusNormal(cirC,0.4, cirNor);
            holes[2] = msgCircle.Create(cirGeo);
            scene.AttachObject(holes[2]);
            holes[2].SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 0);
            holes[2].SetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS, 1);

            msg3DObject fcO = (msg3DObject)msgSurfaces.Face(spl2_obj,holes);

            scene.AttachObject(fcO);
            fcO.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 50);

            msgVectorStruct transV1 = new msgVectorStruct(-5,0,0);
            fcO.InitTempMatrix().Translate(transV1);
            fcO.ApplyTempMatrix();
            fcO.DestroyTempMatrix();
        }