add keypress for recentering (doesnt work)

This commit is contained in:
Philipp Kramer 2020-01-13 10:17:47 +01:00
parent 113ea1b349
commit fb2c379ccf

View file

@ -224,6 +224,10 @@ public class ZEDManager : MonoBehaviour
[HideInInspector]
public bool estimateInitialPosition = true;
//public bool headfree = false;
public bool zLockZED = false;
public bool ZLockCam = false;
/////////////////////////////////////////////////////////////////////////
@ -1856,6 +1860,7 @@ public class ZEDManager : MonoBehaviour
if (UnityEngine.XR.XRDevice.isPresent && isStereoRig) //AR pass-through mode.
{
if (calibrationHasChanged) //If the HMD offset calibration file changed during runtime.
{
AdjustZEDRigCameraPosition(); //Re-apply the ZED's offset from the VR headset.
@ -1877,10 +1882,9 @@ public class ZEDManager : MonoBehaviour
//Rotate Image plane with zed rotation
r = zedOrientation;
zedRigDisplayer.transform.localRotation = r; //(Mod) zedRigDisplayer should move/rotate the image plane
//zedRigDisplayer.transform.localEulerAngles = new Vector3(r.x,r.y,0);
//TODO: rotation von hmd soll zedRigDisplayer weiterhin beeinflussen (r.z nicht übernehmen evtl?)
@ -1940,17 +1944,24 @@ public class ZEDManager : MonoBehaviour
//rotationTransformhelper.transform.rotation = zedRigDisplayer.transform.localRotation;
//rotationTransformhelper.transform.localEulerAngles = new Vector3(-zedRigDisplayer.transform.eulerAngles.x, -zedRigDisplayer.transform.eulerAngles.y, 0);
bool enableZLockZED = true;
bool enableZLockCam = false;
camRigDisplayer.transform.localRotation = Quaternion.identity;
if (enableZLockZED)
if (Input.GetKeyDown("space"))
{ //Restoring position does currently not work
Debug.Log("fix");
//camRigDisplayer.transform.localRotation = zedRigDisplayer.transform.rotation; //moves camera image to origin (not view point)
camRigDisplayer.transform.localRotation = zedRigDisplayer.transform.rotation;
camRigDisplayer.transform.Rotate(-camLeft.transform.rotation.eulerAngles);
}
if (zLockZED)
{
Vector3 zedDirection = new Vector3(0, 0, 1); //Create Vector towars Z+
zedDirection = zedRigDisplayer.transform.rotation * zedDirection; //rotate vector by zedRigRotation (vector should point towards +Z of zedRigDisplayer)
camRigDisplayer.transform.localRotation = Quaternion.AngleAxis(zedRigDisplayer.transform.localEulerAngles.z, zedDirection); //rotate only around zedDirection.z with respect to original coordinate system
}
if (enableZLockCam)
if (ZLockCam)
{
//same for camera Z rotation compensation
Vector3 hmdDirection = new Vector3(0, 0, 1); //Create Vector towars Z+
@ -1993,7 +2004,7 @@ public class ZEDManager : MonoBehaviour
arRig.CollectPose(); //Save headset pose with current timestamp.
}
Vector3 rotatePointAroundAxis(Vector3 point, float angle, Vector3 axis)
Vector3 RotatePointAroundAxis(Vector3 point, float angle, Vector3 axis)
{
Quaternion q = Quaternion.AngleAxis(angle, axis);
return q * point; //Note: q must be first (point * q wouldn't compile)