Exemplo n.º 1
0
        void Awake()
        {
            ScapeLogging.Log(message: "OGeoAnchor::Awake " + this.gameObject.name);

            // this.gameObject.SetActive(false);

            GeoWorldRoot.GetInstance().RegisterGeoEvent(this.OriginEvent);

            WorldCoordinates = new Coordinates {
                longitude = Longitude, latitude = Latitude
            };
            WorldPos = GeoConversions.VectorFromCoordinates(WorldCoordinates);
        }
        void SynchronizeARCamera(ScapeMeasurements scapeMeasurements)
        {
            Coordinates LocalCoordinates  = GeoConversions.CoordinatesFromVector(new Vector2(PositionAtScapeMeasurements.x, PositionAtScapeMeasurements.z));
            Coordinates OriginCoordinates = new Coordinates()
            {
                longitude = scapeMeasurements.coordinates.longitude - LocalCoordinates.longitude,
                latitude  = scapeMeasurements.coordinates.latitude - LocalCoordinates.latitude
            };

            ScapeLogging.Log(message: "SynchronizeARCamera() scapecoords = " + GeoConversions.CoordinatesToString(scapeMeasurements.coordinates));
            ScapeLogging.Log(message: "SynchronizeARCamera() localcoords = " + GeoConversions.CoordinatesToString(LocalCoordinates));
            ScapeLogging.Log(message: "SynchronizeARCamera() origincoords = " + GeoConversions.CoordinatesToString(OriginCoordinates));

            GeoWorldRoot.GetInstance().SetWorldOrigin(OriginCoordinates);

            Quaternion worldEulerRotation = new Quaternion((float)scapeMeasurements.orientation.x,
                                                           (float)scapeMeasurements.orientation.y,
                                                           (float)scapeMeasurements.orientation.z,
                                                           (float)scapeMeasurements.orientation.w);

            ScapeDirectionFix = worldEulerRotation * Quaternion.Inverse(RotationAtScapeMeasurements);
            ScapeLogging.Log(message: "SynchronizeARCamera() ScapeDirectionFix = " + ScapeDirectionFix);
        }
Exemplo n.º 3
0
        void OriginEvent(Coordinates SceneOriginCoordinates)
        {
            Vector2 SceneOrigin = GeoConversions.VectorFromCoordinates(SceneOriginCoordinates);

            ScenePos = WorldPos - SceneOrigin;

            string name = this.gameObject.name;

            ScapeLogging.Log(message: "OriginEvent() " + name + " ScenePos = " + ScenePos.ToString());
            ScapeLogging.Log(message: "OriginEvent() " + name + " WorldCoords = " + GeoConversions.CoordinatesToString(WorldCoordinates));

            if (ScenePos.magnitude < MaxDistance)
            {
                needsUpdate = true;

                this.gameObject.SetActive(true);
            }
            else
            {
                ScapeLogging.Log(message: "OriginEvent() " + name + " beyond max distance (" + ScenePos.magnitude + ")");

                this.gameObject.SetActive(false);
            }
        }