protected SmartTerrainTrackableImpl(string name, int id, SmartTerrainTrackable parent) : base(name, id) { this.mMeshRevision = 0; this.Parent = parent; this.mLocalPose = new VuforiaManagerImpl.PoseData { orientation = Quaternion.identity, position = Vector3.zero }; }
private void PositionCamera(Vector3 localRefPosition, Quaternion localRefRotation, Transform cameraTransform, VuforiaManagerImpl.PoseData camToTargetPose) { Quaternion localRotation = localRefRotation * camToTargetPose.orientation; Vector3 localPosition = localRefPosition + localRefRotation * camToTargetPose.position; cameraTransform.localPosition = localPosition; cameraTransform.localRotation = localRotation; }
internal void SetLocalPose(VuforiaManagerImpl.PoseData localPose) { this.mLocalPose = localPose; }
public static void PositionTrackable(TrackableBehaviour trackableBehaviour, Transform arCameraTransform, VuforiaManagerImpl.PoseData camToTargetPose, double timeStamp) { TrackableBehaviour.CoordinateSystem coordinateSystem = camToTargetPose.coordinateSystem; if (coordinateSystem == TrackableBehaviour.CoordinateSystem.CAMERA) { trackableBehaviour.transform.position = arCameraTransform.TransformPoint(camToTargetPose.position); trackableBehaviour.transform.rotation = arCameraTransform.rotation * camToTargetPose.orientation * Quaternion.AngleAxis(270f, Vector3.left); trackableBehaviour.TimeStamp = timeStamp; return; } if (coordinateSystem != TrackableBehaviour.CoordinateSystem.WORLD) { Debug.LogError("Internal error: Unknown coordinate system for Trackable pose."); return; } trackableBehaviour.transform.position = camToTargetPose.position; trackableBehaviour.transform.rotation = camToTargetPose.orientation * Quaternion.AngleAxis(90f, Vector3.left); trackableBehaviour.TimeStamp = timeStamp; }
private void PositionCameraToTrackable(TrackableBehaviour trackable, Transform cameraTransform, Transform parentTransformToUpdate, VuforiaManagerImpl.PoseData camToTargetPose) { Quaternion quaternion = Quaternion.Inverse(camToTargetPose.orientation); Vector3 position = trackable.transform.rotation * Quaternion.AngleAxis(90f, Vector3.left) * quaternion * -camToTargetPose.position + trackable.transform.position; Quaternion rotation = trackable.transform.rotation * Quaternion.AngleAxis(90f, Vector3.left) * quaternion; if (parentTransformToUpdate == cameraTransform) { cameraTransform.position = position; cameraTransform.rotation = rotation; return; } if (this.mCameraPositioningHelper == null) { this.mCameraPositioningHelper = new GameObject("CamPosHelper"); } this.mCameraPositioningHelper.transform.position = cameraTransform.position; this.mCameraPositioningHelper.transform.rotation = cameraTransform.rotation; Transform parent = parentTransformToUpdate.parent; parentTransformToUpdate.parent = this.mCameraPositioningHelper.transform; this.mCameraPositioningHelper.transform.position = position; this.mCameraPositioningHelper.transform.rotation = rotation; parentTransformToUpdate.parent = parent; }
internal void UpdateCameraPoseWRTTrackable(Transform cameraTransform, Transform parentTransformToUpdate, VuforiaManager.TrackableIdPair trackableId, VuforiaManagerImpl.PoseData trackablePose) { TrackableBehaviour trackableBehaviour; if (this.TryGetBehaviour(trackableId, out trackableBehaviour) && trackableBehaviour.enabled) { this.PositionCameraToTrackable(trackableBehaviour, cameraTransform, parentTransformToUpdate, trackablePose); } }