Exemplo n.º 1
0
        public void Set(MapCoord coord)
        {
            altitude = coord.altitude;

            latitude = coord.latitude;

            longitude = coord.longitude;
        }
Exemplo n.º 2
0
        //************************************************************************************************
        //
        //************************************************************************************************

        public void Update()
        {
            m_valid = false;

            if (m_enabled == false)
            {
                return;
            }

            if (m_camera == null)
            {
                return;
            }

            if ((m_plane == null) && (m_sphere == null))
            {
                return;
            }


            Vector3 cursorPos = Input.mousePosition;

            if ((cursorPos.x < 0.0f) || (cursorPos.x > Screen.width))
            {
                return;
            }

            if ((cursorPos.y < 0.0f) || (cursorPos.y > Screen.height))
            {
                return;
            }

            Ray ray = m_camera.ScreenPointToRay(cursorPos);


            if (m_plane != null)
            {
                float t = float.MinValue;

                float r = 1.0e3f;

                m_valid = CORE.RayCast.Intersect(ray, 1.0e3f, m_plane, ref t);

                if (m_valid)
                {
                    m_point = ray.origin + (ray.direction * r * t);

                    m_latitude = m_latFrom3DCoord(m_point);

                    m_longitude = m_lngFrom3DCoord(m_point);
                }
            }
            else
            {
                float t1 = float.MaxValue;

                float t2 = float.MaxValue;

                m_valid = CORE.RayCast.Intersect(ray, m_sphere, ref t1, ref t2);

                if (m_valid)
                {
                    m_point = ray.origin + (ray.direction * t1);

                    m_latitude = m_latFrom3DCoord((m_point - m_sphere.center).normalized);

                    m_longitude = m_lngFrom3DCoord((new Vector3(m_point.x, 0.0f, m_point.z) - m_sphere.center).normalized);
                }
            }
        }