void Update() { if (needsUpdate) { this.gameObject.transform.position = new Vector3(ScenePos.x, 0.0f, ScenePos.y); ScapeLogging.Log(message: "OriginEvent() set position = " + this.gameObject.transform.localPosition); needsUpdate = false; } }
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); }
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); } }