コード例 #1
0
 void GetPosition(TerrainView.Position p)
 {
     p.x0       = m_view.GetPos().x0;
     p.y0       = m_view.GetPos().y0;
     p.theta    = m_view.GetPos().theta;
     p.phi      = m_view.GetPos().phi;
     p.distance = m_view.GetPos().distance;
 }
コード例 #2
0
        // Use this for initialization
        void Start()
        {
            m_view = GetComponent <TerrainView>();

            m_target           = new TerrainView.Position();
            m_start            = new TerrainView.Position();
            m_end              = new TerrainView.Position();
            m_previousMousePos = new Vector3d2(Input.mousePosition);
        }
コード例 #3
0
 void SetPosition(TerrainView.Position p)
 {
     m_view.GetPos().x0       = p.x0;
     m_view.GetPos().y0       = p.y0;
     m_view.GetPos().theta    = p.theta;
     m_view.GetPos().phi      = p.phi;
     m_view.GetPos().distance = p.distance;
     m_animation = -1.0;
 }
コード例 #4
0
        void UpdateController(double dt)
        {
            double dzFactor = Math.Pow(1.02, Math.Min(dt, 1.0));

            if (m_near)
            {
                m_target.distance = m_target.distance / (dzFactor * m_zoomSpeed);
            }
            else if (m_far)
            {
                m_target.distance = m_target.distance * dzFactor * m_zoomSpeed;
            }

            TerrainView.Position p = new TerrainView.Position();
            GetPosition(p);
            SetPosition(m_target);

            if (m_forward)
            {
                double speed = Math.Max(m_view.GetHeight(), 1.0);
                m_view.MoveForward(speed * dt * m_moveSpeed);
            }
            else if (m_backward)
            {
                double speed = Math.Max(m_view.GetHeight(), 1.0);
                m_view.MoveForward(-speed * dt * m_moveSpeed);
            }

            if (m_left)
            {
                m_view.Turn(dt * m_turnSpeed);
            }
            else if (m_right)
            {
                m_view.Turn(-dt * m_turnSpeed);
            }

            GetPosition(m_target);

            if (m_smooth)
            {
                double lerp = 1.0 - Math.Exp(-dt * 2.301e-3);
                double x0   = 0.0;
                double y0   = 0.0;
                m_view.InterpolatePos(p.x0, p.y0, m_target.x0, m_target.y0, lerp, ref x0, ref y0);
                p.x0       = x0;
                p.y0       = y0;
                p.theta    = Mix2(p.theta, m_target.theta, lerp);
                p.phi      = Mix2(p.phi, m_target.phi, lerp);
                p.distance = Mix2(p.distance, m_target.distance, lerp);
                SetPosition(p);
            }
            else
            {
                SetPosition(m_target);
            }
        }
コード例 #5
0
        void MouseMotion()
        {
            if (Input.GetMouseButton(0) && Input.GetKey(KeyCode.LeftControl))
            {
                m_target.phi   -= Input.GetAxis("Mouse X") * m_rotateSpeed;
                m_target.theta += Input.GetAxis("Mouse Y") * m_rotateSpeed;
            }
            else if (Input.GetMouseButton(0))
            {
                Vector3d2 mousePos = new Vector3d2();
                mousePos.x = Input.mousePosition.x;
                mousePos.y = Input.mousePosition.y;
                mousePos.z = 0.0;

                Vector3d2 preMousePos = new Vector3d2();
                preMousePos.x = m_previousMousePos.x;
                preMousePos.y = m_previousMousePos.y;
                preMousePos.z = 0.0;

                Vector3d2 oldp = m_view.GetCameraToWorld() * preMousePos;
                Vector3d2 p    = m_view.GetCameraToWorld() * mousePos;

                if (!(double.IsNaN(oldp.x) || double.IsNaN(oldp.y) || double.IsNaN(oldp.z) || double.IsNaN(p.x) || double.IsNaN(p.y) || double.IsNaN(p.z)))
                {
                    TerrainView.Position current = new TerrainView.Position();
                    GetPosition(current);
                    SetPosition(m_target);

                    m_view.Move(new Vector3d2(oldp), new Vector3d2(p), m_dragSpeed);
                    GetPosition(m_target);
                    SetPosition(current);
                }
            }

            m_previousMousePos = new Vector3d2(Input.mousePosition);
        }
コード例 #6
0
ファイル: Controller.cs プロジェクト: Climberfx/Scatterer
        void UpdateController(double dt)
        {
            double dzFactor = Math.Pow(1.02, Math.Min(dt, 1.0));

            if(m_near) {
                m_target.distance = m_target.distance / (dzFactor * m_zoomSpeed);
            }
            else if(m_far) {
                m_target.distance = m_target.distance * dzFactor * m_zoomSpeed;
            }

            TerrainView.Position p = new TerrainView.Position();
            GetPosition(p);
            SetPosition(m_target);

            if(m_forward)
            {
                double speed = Math.Max(m_view.GetHeight(), 1.0);
                m_view.MoveForward(speed * dt * m_moveSpeed);
            }
            else if(m_backward)
            {
                double speed = Math.Max(m_view.GetHeight(), 1.0);
                m_view.MoveForward(-speed * dt * m_moveSpeed);
            }

            if(m_left) {
                m_view.Turn(dt * m_turnSpeed);
            }
            else if(m_right) {
                m_view.Turn(-dt * m_turnSpeed);
            }

            GetPosition(m_target);

            if(m_smooth)
            {
                double lerp = 1.0 - Math.Exp(-dt * 2.301e-3);
                double x0 = 0.0;
                double y0 = 0.0;
                m_view.InterpolatePos(p.x0, p.y0, m_target.x0, m_target.y0, lerp, ref x0, ref y0);
                p.x0 = x0;
                p.y0 = y0;
                p.theta = Mix2(p.theta, m_target.theta, lerp);
                p.phi = Mix2(p.phi, m_target.phi, lerp);
                p.distance = Mix2(p.distance, m_target.distance, lerp);
                SetPosition(p);
            }
            else {
                SetPosition(m_target);
            }
        }
コード例 #7
0
ファイル: Controller.cs プロジェクト: Climberfx/Scatterer
        // Use this for initialization
        void Start()
        {
            m_view = GetComponent<TerrainView>();

            m_target = new TerrainView.Position();
            m_start = new TerrainView.Position();
            m_end = new TerrainView.Position();
            m_previousMousePos = new Vector3d2(Input.mousePosition);
        }
コード例 #8
0
ファイル: Controller.cs プロジェクト: Climberfx/Scatterer
        void MouseMotion()
        {
            if(Input.GetMouseButton(0) && Input.GetKey(KeyCode.LeftControl))
            {
                m_target.phi -= Input.GetAxis("Mouse X") * m_rotateSpeed;
                m_target.theta += Input.GetAxis("Mouse Y") * m_rotateSpeed;
            }
            else if(Input.GetMouseButton(0))
            {

                Vector3d2 mousePos = new Vector3d2();
                mousePos.x = Input.mousePosition.x;
                mousePos.y = Input.mousePosition.y;
                mousePos.z = 0.0;

                Vector3d2 preMousePos = new Vector3d2();
                preMousePos.x = m_previousMousePos.x;
                preMousePos.y = m_previousMousePos.y;
                preMousePos.z = 0.0;

                Vector3d2 oldp = m_view.GetCameraToWorld() * preMousePos;
                Vector3d2 p = m_view.GetCameraToWorld() * mousePos;

                if (!(double.IsNaN(oldp.x) || double.IsNaN(oldp.y) || double.IsNaN(oldp.z) || double.IsNaN(p.x) || double.IsNaN(p.y) || double.IsNaN(p.z)))
                {
                    TerrainView.Position current = new TerrainView.Position();
                    GetPosition(current);
                    SetPosition(m_target);

                    m_view.Move(new Vector3d2(oldp), new Vector3d2(p), m_dragSpeed);
                    GetPosition(m_target);
                    SetPosition(current);
                }
            }

            m_previousMousePos = new Vector3d2(Input.mousePosition);
        }
コード例 #9
0
ファイル: Controller.cs プロジェクト: Climberfx/Scatterer
 void JumpToPosition(TerrainView.Position p)
 {
     SetPosition(p);
     m_target = p;
 }
コード例 #10
0
ファイル: Controller.cs プロジェクト: Climberfx/Scatterer
 void GoToPosition(TerrainView.Position p)
 {
     GetPosition(m_start);
     m_end = p;
     m_animation = 0.0;
 }
コード例 #11
0
 void JumpToPosition(TerrainView.Position p)
 {
     SetPosition(p);
     m_target = p;
 }
コード例 #12
0
 void GoToPosition(TerrainView.Position p)
 {
     GetPosition(m_start);
     m_end       = p;
     m_animation = 0.0;
 }