Ejemplo n.º 1
0
        public override void OnMouseUp(int int_0, int int_1, int int_2, int int_3)
        {
            ISceneGraph sceneGraph = this._plugin.SceneGraph;
            IPoint      point;
            object      obj;
            object      obj2;

            sceneGraph.Locate(sceneGraph.ActiveViewer, int_2, int_3, esriScenePickMode.esriScenePickAll, true, out point, out obj, out obj2);
            if (point != null)
            {
                ICamera camera = this._plugin.Camera;
                if (camera.ProjectionType == esri3DProjectionType.esriOrthoProjection)
                {
                    camera.Target = point;
                    sceneGraph.ActiveViewer.Redraw(true);
                }
                else
                {
                    IPoint target   = camera.Target;
                    IPoint observer = camera.Observer;
                    camera.Target = point;
                    camera.PolarUpdate(1.0, 0.0, 0.0, true);
                    IPoint observer2 = camera.Observer;
                    double num;
                    double num2;
                    sceneGraph.GetDrawingTimeInfo(out num, out num2);
                    if (num < 0.01)
                    {
                        num = 0.01;
                    }
                    int num3 = (int)(2.0 / num);
                    if (num3 < 1)
                    {
                        num3 = 1;
                    }
                    if (num3 > 60)
                    {
                        num3 = 60;
                    }
                    double num4 = (observer2.X - observer.X) / (double)num3;
                    double num5 = (observer2.Y - observer.Y) / (double)num3;
                    double num6 = (observer2.Z - observer.Z) / (double)num3;
                    double num7 = (point.X - target.X) / (double)num3;
                    double num8 = (point.Y - target.Y) / (double)num3;
                    double num9 = (point.Z - target.Z) / (double)num3;
                    for (int i = 0; i < num3; i++)
                    {
                        observer2.X     = observer.X + (double)i * num4;
                        observer2.Y     = observer.Y + (double)i * num5;
                        observer2.Z     = observer.Z + (double)i * num6;
                        point.X         = target.X + (double)i * num7;
                        point.Y         = target.Y + (double)i * num8;
                        point.Z         = target.Z + (double)i * num9;
                        camera.Observer = observer2;
                        camera.Target   = point;
                        sceneGraph.ActiveViewer.Redraw(true);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public override void OnMouseUp(int int_0, int int_1, int int_2, int int_3)
        {
            ISceneGraph sceneGraph = this._plugin.SceneGraph;
            IPoint      point;
            object      obj;
            object      obj2;

            sceneGraph.Locate(sceneGraph.ActiveViewer, int_2, int_3, esriScenePickMode.esriScenePickAll, true, out point, out obj, out obj2);
            if (point != null)
            {
                ICamera camera   = this._plugin.Camera;
                IPoint  observer = camera.Observer;
                double  num;
                double  num2;
                sceneGraph.GetDrawingTimeInfo(out num, out num2);
                if (num < 0.01)
                {
                    num = 0.01;
                }
                int num3 = (int)(2.0 / num);
                if (num3 < 1)
                {
                    num3 = 1;
                }
                if (num3 > 60)
                {
                    num3 = 60;
                }
                double num4 = (point.X - observer.X) / (double)num3;
                double num5 = (point.Y - observer.Y) / (double)num3;
                double num6 = (point.Z - observer.Z) / (double)num3;
                for (int i = 0; i <= num3; i++)
                {
                    point.X         = observer.X + (double)i * num4;
                    point.Y         = observer.Y + (double)i * num5;
                    point.Z         = observer.Z + (double)i * num6;
                    camera.Observer = point;
                    sceneGraph.ActiveViewer.Redraw(true);
                }
            }
        }
Ejemplo n.º 3
0
        public override void OnMouseUp(int Button, int Shift, int X, int Y)
        {
            //Get the scene graph
            ISceneGraph pSceneGraph = (ISceneGraph)m_pSceneHookHelper.SceneGraph;

            IPoint pNewObs;
            object pOwner, pObject;

            //Translate screen coordinates into a 3D point
            pSceneGraph.Locate(pSceneGraph.ActiveViewer, X, Y, esriScenePickMode.esriScenePickAll, true,
                               out pNewObs, out pOwner, out pObject);

            if (pNewObs == null)
            {
                return;
            }

            //Get the scene viewer's camera
            ICamera pCamera = (ICamera)m_pSceneHookHelper.Camera;

            //Get the camera's old observer
            IPoint pOldObs = (IPoint)pCamera.Observer;

            //Get the duration in seconds of last redraw
            //and the average number of frames per second
            double dlastFrameDuration, dMeanFrameRate;

            pSceneGraph.GetDrawingTimeInfo(out dlastFrameDuration, out dMeanFrameRate);

            if (dlastFrameDuration < 0.01)
            {
                dlastFrameDuration = 0.01;
            }

            int iSteps;

            iSteps = (int)(2 / dlastFrameDuration);
            if (iSteps < 1)
            {
                iSteps = 1;
            }

            if (iSteps > 60)
            {
                iSteps = 60;
            }

            double dxObs, dyObs, dzObs;

            dxObs = (pNewObs.X - pOldObs.X) / iSteps;
            dyObs = (pNewObs.Y - pOldObs.Y) / iSteps;
            dzObs = (pNewObs.Z - pOldObs.Z) / iSteps;

            //Loop through each step moving the camera's observer from the old
            //position to the new position, refreshing the scene viewer each time
            for (int i = 0; i <= iSteps; i++)
            {
                pNewObs.X        = pOldObs.X + (i * dxObs);
                pNewObs.Y        = pOldObs.Y + (i * dyObs);
                pNewObs.Z        = pOldObs.Z + (i * dzObs);
                pCamera.Observer = pNewObs;
                pSceneGraph.ActiveViewer.Redraw(true);
            }
        }
Ejemplo n.º 4
0
        public override void OnMouseUp(int Button, int Shift, int X, int Y)
        {
            //Get the scene graph
            ISceneGraph pSceneGraph = (ISceneGraph)m_pSceneHookHelper.SceneGraph;

            IPoint pNewTgt;
            object pOwner, pObject;

            //Translate screen coordinates into a 3D point
            pSceneGraph.Locate(pSceneGraph.ActiveViewer, X, Y, esriScenePickMode.esriScenePickAll, true,
                               out pNewTgt, out pOwner, out pObject);

            if (pNewTgt == null)
            {
                return;
            }

            //Get the scene viewer's camera
            ICamera pCamera = (ICamera)m_pSceneHookHelper.Camera;

            //If orthographic (2D) view
            if (pCamera.ProjectionType == esri3DProjectionType.esriOrthoProjection)
            {
                //Set the camera's new target
                pCamera.Target = pNewTgt;

                //Redraw the scene viewer
                pSceneGraph.ActiveViewer.Redraw(true);
            }
            else
            {
                //Get the camera's old target and observer
                IPoint pOldTgt, pOldObs;
                pOldTgt = pCamera.Target;
                pOldObs = pCamera.Observer;

                //Set the camera's new target and get the new observer
                pCamera.Target = pNewTgt;
                pCamera.PolarUpdate(1, 0, 0, true);

                IPoint pNewObs = (IPoint)pCamera.Observer;

                //Get the duration in seconds of last redraw
                //and the average number of frames per second
                double dlastFrameDuration, dMeanFrameRate;
                pSceneGraph.GetDrawingTimeInfo(out dlastFrameDuration, out dMeanFrameRate);

                if (dlastFrameDuration < 0.01)
                {
                    dlastFrameDuration = 0.01;
                }

                int iSteps;
                iSteps = (int)(2 / dlastFrameDuration);
                if (iSteps < 1)
                {
                    iSteps = 1;
                }

                if (iSteps > 60)
                {
                    iSteps = 60;
                }

                double dxObs, dyObs, dzObs;
                double dxTgt, dyTgt, dzTgt;

                dxObs = (pNewObs.X - pOldObs.X) / iSteps;
                dyObs = (pNewObs.Y - pOldObs.Y) / iSteps;
                dzObs = (pNewObs.Z - pOldObs.Z) / iSteps;

                dxTgt = (pNewTgt.X - pOldTgt.X) / iSteps;
                dyTgt = (pNewTgt.Y - pOldTgt.Y) / iSteps;
                dzTgt = (pNewTgt.Z - pOldTgt.Z) / iSteps;

                //Loop through each step moving the camera's observer and target from the
                //old positions to the new positions, refreshing the scene viewer each time
                for (int i = 0; i < iSteps; i++)
                {
                    pNewObs.X = pOldObs.X + (i * dxObs);
                    pNewObs.Y = pOldObs.Y + (i * dyObs);
                    pNewObs.Z = pOldObs.Z + (i * dzObs);

                    pNewTgt.X = pOldTgt.X + (i * dxTgt);
                    pNewTgt.Y = pOldTgt.Y + (i * dyTgt);
                    pNewTgt.Z = pOldTgt.Z + (i * dzTgt);

                    pCamera.Observer = pNewObs;
                    pCamera.Target   = pNewTgt;
                    pSceneGraph.ActiveViewer.Redraw(true);
                }
            }
        }
Ejemplo n.º 5
0
        public void Flight()
        {
            //Get IMessageDispatcher interface
            IMessageDispatcher pMessageDispatcher;

            pMessageDispatcher = new MessageDispatcherClass();

            //Set the ESC key to be seen as a cancel action
            pMessageDispatcher.CancelOnClick    = false;
            pMessageDispatcher.CancelOnEscPress = true;

            //Get the scene graph
            ISceneGraph pSceneGraph = (ISceneGraph)m_pSceneHookHelper.SceneGraph;

            //Get the scene viewer
            ISceneViewer pSceneViewer = (ISceneViewer)m_pSceneHookHelper.ActiveViewer;

            //Get the camera
            ICamera pCamera = (ICamera)m_pSceneHookHelper.Camera;

            bCancel = false;

            do
            {
                //Get the elapsed time
                double dlastFrameDuration, dMeanFrameRate;

                pSceneGraph.GetDrawingTimeInfo(out dlastFrameDuration, out dMeanFrameRate);

                if (dlastFrameDuration < 0.01)
                {
                    dlastFrameDuration = 0.01;
                }

                if (dlastFrameDuration > 1)
                {
                    dlastFrameDuration = 1;
                }

                //Windows API call to get windows client coordinates
                Rectangle rect = new Rectangle();
                if (GetClientRect(m_pSceneHookHelper.ActiveViewer.hWnd, ref rect) == 0)
                {
                    return;
                }

                //Get normal vectors
                double dXMouseNormal, dYMouseNormal;

                dXMouseNormal = 2 * ((double)m_lMouseX / (double)rect.Right) - 1;
                dYMouseNormal = 2 * ((double)m_lMouseY / (double)rect.Bottom) - 1;

                //Set elevation and azimuth in radians for normal rotation
                m_dElevation = m_dElevation - (dlastFrameDuration * dYMouseNormal * Math.Abs(dYMouseNormal));
                m_dAzimut    = m_dAzimut - (dlastFrameDuration * dXMouseNormal * Math.Abs(dXMouseNormal));
                if (m_dElevation > 0.45 * 3.141592)
                {
                    m_dElevation = 0.45 * 3.141592;
                }

                if (m_dElevation < -0.45 * 3.141592)
                {
                    m_dElevation = -0.45 * 3.141592;
                }

                if (m_dAzimut < 0)
                {
                    m_dAzimut = m_dAzimut + (2 * 3.141592);
                }

                if (m_dAzimut > 2 * 3.141592)
                {
                    m_dAzimut = m_dAzimut - (2 * 3.141592);
                }

                double dx, dy, dz;

                dx = Math.Cos(m_dElevation) * Math.Cos(m_dAzimut);
                dy = Math.Cos(m_dElevation) * Math.Sin(m_dAzimut);
                dz = Math.Sin(m_dElevation);

                //Change the viewing directions (target)
                m_pPointTgt.X = m_pPointObs.X + (m_dDistance * dx);
                m_pPointTgt.Y = m_pPointObs.Y + (m_dDistance * dy);
                m_pPointTgt.Z = m_pPointObs.Z + (m_dDistance * dz);

                //Move the camera in the viewing directions
                m_pPointObs.X = m_pPointObs.X + (dlastFrameDuration * (2 ^ m_iSpeed) * m_dMotion * dx);
                m_pPointObs.Y = m_pPointObs.Y + (dlastFrameDuration * (2 ^ m_iSpeed) * m_dMotion * dy);
                m_pPointTgt.X = m_pPointTgt.X + (dlastFrameDuration * (2 ^ m_iSpeed) * m_dMotion * dx);
                m_pPointTgt.Y = m_pPointTgt.Y + (dlastFrameDuration * (2 ^ m_iSpeed) * m_dMotion * dy);
                m_pPointObs.Z = m_pPointObs.Z + (dlastFrameDuration * (2 ^ m_iSpeed) * m_dMotion * dz);
                m_pPointTgt.Z = m_pPointTgt.Z + (dlastFrameDuration * (2 ^ m_iSpeed) * m_dMotion * dz);

                pCamera.Observer = m_pPointObs;
                pCamera.Target   = m_pPointTgt;

                //Set the angle of the camera about the line of sight between the observer and target
                pCamera.RollAngle = 10 * dXMouseNormal * Math.Abs(dXMouseNormal);

                //Redraw the scene viewer
                pSceneViewer.Redraw(true);

                object objCancel;

                //Dispatch any waiting messages: OnMouseMove / OnMouseUp / OnKeyUp events
                //object objCancel = bCancel as object;
                pMessageDispatcher.Dispatch(m_pSceneHookHelper.ActiveViewer.hWnd, false, out objCancel);

                //End flight if ESC key pressed
                if (bCancel == true)
                {
                    EndFlight();
                }
            }while(m_bInUse == true && bCancel == false);

            bCancel = false;
        }
Ejemplo n.º 6
0
        public void Flight()
        {
            IMessageDispatcher messageDispatcher = new MessageDispatcher();

            messageDispatcher.CancelOnClick    = false;
            messageDispatcher.CancelOnEscPress = true;
            ISceneGraph  sceneGraph   = this._plugin.SceneGraph;
            ISceneViewer activeViewer = this._plugin.ActiveViewer;
            ICamera      camera       = this._plugin.Camera;

            this.bool_1 = false;
            do
            {
                double num;
                double num2;
                sceneGraph.GetDrawingTimeInfo(out num, out num2);
                if (num < 0.01)
                {
                    num = 0.01;
                }
                if (num > 1.0)
                {
                    num = 1.0;
                }
                System.Drawing.Rectangle rectangle = default(System.Drawing.Rectangle);
                if (ToolSceneFly.GetClientRect(this._plugin.ActiveViewer.hWnd, ref rectangle) == 0)
                {
                    return;
                }
                double num3 = 2.0 * ((double)this.long_0 / (double)rectangle.Right) - 1.0;
                double num4 = 2.0 * ((double)this.long_1 / (double)rectangle.Bottom) - 1.0;
                this.double_2 -= num * num4 * Math.Abs(num4);
                this.double_3 -= num * num3 * Math.Abs(num3);
                if (this.double_2 > 1.4137164000000002)
                {
                    this.double_2 = 1.4137164000000002;
                }
                if (this.double_2 < -1.4137164000000002)
                {
                    this.double_2 = -1.4137164000000002;
                }
                if (this.double_3 < 0.0)
                {
                    this.double_3 += 6.283184;
                }
                if (this.double_3 > 6.283184)
                {
                    this.double_3 -= 6.283184;
                }
                double num5 = Math.Cos(this.double_2) * Math.Cos(this.double_3);
                double num6 = Math.Cos(this.double_2) * Math.Sin(this.double_3);
                double num7 = Math.Sin(this.double_2);
                this.ipoint_1.X  = this.ipoint_0.X + this.double_1 * num5;
                this.ipoint_1.Y  = this.ipoint_0.Y + this.double_1 * num6;
                this.ipoint_1.Z  = this.ipoint_0.Z + this.double_1 * num7;
                this.ipoint_0.X  = this.ipoint_0.X + num * (double)(2 ^ this.int_0) * this.double_0 * num5;
                this.ipoint_0.Y  = this.ipoint_0.Y + num * (double)(2 ^ this.int_0) * this.double_0 * num6;
                this.ipoint_1.X  = this.ipoint_1.X + num * (double)(2 ^ this.int_0) * this.double_0 * num5;
                this.ipoint_1.Y  = this.ipoint_1.Y + num * (double)(2 ^ this.int_0) * this.double_0 * num6;
                this.ipoint_0.Z  = this.ipoint_0.Z + num * (double)(2 ^ this.int_0) * this.double_0 * num7;
                this.ipoint_1.Z  = this.ipoint_1.Z + num * (double)(2 ^ this.int_0) * this.double_0 * num7;
                camera.Observer  = this.ipoint_0;
                camera.Target    = this.ipoint_1;
                camera.RollAngle = 10.0 * num3 * Math.Abs(num3);
                activeViewer.Redraw(true);
                object obj;
                messageDispatcher.Dispatch(this._plugin.ActiveViewer.hWnd, false, out obj);
                if (this.bool_1)
                {
                    this.EndFlight();
                }
            }while (this.bool_0 && !this.bool_1);
            this.bool_1 = false;
        }