diff --git a/unity/Assets/Scripts/AgentManager.cs b/unity/Assets/Scripts/AgentManager.cs index 712c9497de..3f54a0749f 100644 --- a/unity/Assets/Scripts/AgentManager.cs +++ b/unity/Assets/Scripts/AgentManager.cs @@ -1310,34 +1310,34 @@ bool shouldRenderImageSynthesis if (camera.transform.parent != null) { cMetadata.parentObjectName = camera.transform.parent.name; - cMetadata.parentPositionRelativeThirdPartyCameraPosition = + cMetadata.parentRelativeThirdPartyCameraPosition = camera.transform.localPosition; //get third party camera rotation as quaternion in parent space - cMetadata.parentPositionRelativeThirdPartyCameraRotation = + cMetadata.parentRelativeThirdPartyCameraRotation = camera.transform.localEulerAngles; } else { cMetadata.parentObjectName = ""; - cMetadata.parentPositionRelativeThirdPartyCameraPosition = null; - cMetadata.parentPositionRelativeThirdPartyCameraRotation = null; + cMetadata.parentRelativeThirdPartyCameraPosition = null; + cMetadata.parentRelativeThirdPartyCameraRotation = null; } //if this camera is part of the agent's hierarchy at all, get agent relative info if (camera.GetComponentInParent() != null) { GameObject agent = camera.GetComponentInParent().gameObject; - cMetadata.agentPositionRelativeThirdPartyCameraPosition = + cMetadata.agentRelativeThirdPartyCameraPosition = agent.transform.InverseTransformPoint(camera.transform.position); var agentSpaceCameraRotationAsQuaternion = Quaternion.Inverse(agent.transform.rotation) * worldSpaceCameraRotationAsQuaternion; - cMetadata.agentRotationRelativeThirdPartyCameraRotation = + cMetadata.agentRelativeThirdPartyCameraRotation = agentSpaceCameraRotationAsQuaternion.eulerAngles; } else { //if this third party camera is not a child of the agent, we don't need agent-relative coordinates - cMetadata.agentPositionRelativeThirdPartyCameraPosition = null; - cMetadata.agentRotationRelativeThirdPartyCameraRotation = null; + cMetadata.agentRelativeThirdPartyCameraPosition = null; + cMetadata.agentRelativeThirdPartyCameraRotation = null; } cMetadata.fieldOfView = camera.fieldOfView; @@ -1872,12 +1872,12 @@ public class ThirdPartyCameraMetadata { //note these should only be returned with values //if the third party camera is a child of the agent - public Vector3? agentPositionRelativeThirdPartyCameraPosition; - public Vector3? agentRotationRelativeThirdPartyCameraRotation; + public Vector3? agentRelativeThirdPartyCameraPosition; + public Vector3? agentRelativeThirdPartyCameraRotation; //return the local space coordinates if this third party camera has a parent object, this may be the same as agentPositionRelative depending on how things are parented - public Vector3? parentPositionRelativeThirdPartyCameraPosition; - public Vector3? parentPositionRelativeThirdPartyCameraRotation; + public Vector3? parentRelativeThirdPartyCameraPosition; + public Vector3? parentRelativeThirdPartyCameraRotation; public string parentObjectName; //if this third party camera is in a hierarchy, return the name of the parent object } diff --git a/unity/Assets/UnitTests/TestThirdPartyCameraAndMainCamera.cs b/unity/Assets/UnitTests/TestThirdPartyCameraAndMainCamera.cs index dc47ced39a..f6f6b9522e 100644 --- a/unity/Assets/UnitTests/TestThirdPartyCameraAndMainCamera.cs +++ b/unity/Assets/UnitTests/TestThirdPartyCameraAndMainCamera.cs @@ -479,19 +479,19 @@ public IEnumerator TestThirdPartyCameraMetadataReturn() ); Assert.AreEqual(result, true); Assert.AreEqual( - metadata.thirdPartyCameras[0].agentPositionRelativeThirdPartyCameraPosition, + metadata.thirdPartyCameras[0].agentRelativeThirdPartyCameraPosition, null ); Assert.AreEqual( - metadata.thirdPartyCameras[0].agentRotationRelativeThirdPartyCameraRotation, + metadata.thirdPartyCameras[0].agentRelativeThirdPartyCameraRotation, null ); Assert.AreEqual( - metadata.thirdPartyCameras[0].parentPositionRelativeThirdPartyCameraPosition, + metadata.thirdPartyCameras[0].parentRelativeThirdPartyCameraPosition, null ); Assert.AreEqual( - metadata.thirdPartyCameras[0].parentPositionRelativeThirdPartyCameraRotation, + metadata.thirdPartyCameras[0].parentRelativeThirdPartyCameraRotation, null ); Assert.AreEqual(metadata.thirdPartyCameras[0].parentObjectName, ""); @@ -513,11 +513,11 @@ public IEnumerator TestThirdPartyCameraMetadataReturn() // Debug.Log($"world relative camera pos: {metadata.thirdPartyCameras[0].worldRelativeThirdPartyCameraPosition:F10}"); // Debug.Log($"world relative camera rot: {metadata.thirdPartyCameras[0].worldRelativeThirdPartyCameraRotation:F10}"); // //agent relative - // Debug.Log($"agent relative camera pos: {metadata.thirdPartyCameras[0].agentPositionRelativeThirdPartyCameraPosition:F10}"); - // Debug.Log($"agent relative camera rot: {metadata.thirdPartyCameras[0].agentRotationRelativeThirdPartyCameraRotation:F10}"); + // Debug.Log($"agent relative camera pos: {metadata.thirdPartyCameras[0].agentRelativeThirdPartyCameraPosition:F10}"); + // Debug.Log($"agent relative camera rot: {metadata.thirdPartyCameras[0].agentRelativeThirdPartyCameraRotation:F10}"); // //parent relative - // Debug.Log($"parent relative camera rot: {metadata.thirdPartyCameras[0].parentPositionRelativeThirdPartyCameraPosition:F10}"); - // Debug.Log($"parent relative camera rot: {metadata.thirdPartyCameras[0].parentPositionRelativeThirdPartyCameraRotation:F10}"); + // Debug.Log($"parent relative camera rot: {metadata.thirdPartyCameras[0].parentRelativeThirdPartyCameraPosition:F10}"); + // Debug.Log($"parent relative camera rot: {metadata.thirdPartyCameras[0].parentRelativeThirdPartyCameraRotation:F10}"); // Debug.Log($"parent object name: {metadata.thirdPartyCameras[0].parentObjectName}"); result = Mathf.Approximately( @@ -551,39 +551,39 @@ public IEnumerator TestThirdPartyCameraMetadataReturn() ); Assert.AreEqual(result, true); result = Mathf.Approximately( - metadata.thirdPartyCameras[0].agentPositionRelativeThirdPartyCameraPosition.Value.x, + metadata.thirdPartyCameras[0].agentRelativeThirdPartyCameraPosition.Value.x, 1.0000000000f ); Assert.AreEqual(result, true); result = Mathf.Approximately( - metadata.thirdPartyCameras[0].agentPositionRelativeThirdPartyCameraPosition.Value.y, + metadata.thirdPartyCameras[0].agentRelativeThirdPartyCameraPosition.Value.y, 2.0000000000f ); Assert.AreEqual(result, true); result = Mathf.Approximately( - metadata.thirdPartyCameras[0].agentPositionRelativeThirdPartyCameraPosition.Value.z, + metadata.thirdPartyCameras[0].agentRelativeThirdPartyCameraPosition.Value.z, 3.0000020000f ); Assert.AreEqual(result, true); result = Mathf.Approximately( - metadata.thirdPartyCameras[0].agentRotationRelativeThirdPartyCameraRotation.Value.x, + metadata.thirdPartyCameras[0].agentRelativeThirdPartyCameraRotation.Value.x, 20.0000000000f ); Assert.AreEqual(result, true); result = Mathf.Approximately( - metadata.thirdPartyCameras[0].agentRotationRelativeThirdPartyCameraRotation.Value.y, + metadata.thirdPartyCameras[0].agentRelativeThirdPartyCameraRotation.Value.y, 20.0000000000f ); Assert.AreEqual(result, true); result = Mathf.Approximately( - metadata.thirdPartyCameras[0].agentRotationRelativeThirdPartyCameraRotation.Value.z, + metadata.thirdPartyCameras[0].agentRelativeThirdPartyCameraRotation.Value.z, 20.0000000000f ); Assert.AreEqual(result, true); result = Mathf.Approximately( metadata .thirdPartyCameras[0] - .parentPositionRelativeThirdPartyCameraPosition + .parentRelativeThirdPartyCameraPosition .Value .x, 1.0000000000f @@ -592,7 +592,7 @@ public IEnumerator TestThirdPartyCameraMetadataReturn() result = Mathf.Approximately( metadata .thirdPartyCameras[0] - .parentPositionRelativeThirdPartyCameraPosition + .parentRelativeThirdPartyCameraPosition .Value .y, 2.0000000000f @@ -601,7 +601,7 @@ public IEnumerator TestThirdPartyCameraMetadataReturn() result = Mathf.Approximately( metadata .thirdPartyCameras[0] - .parentPositionRelativeThirdPartyCameraPosition + .parentRelativeThirdPartyCameraPosition .Value .z, 3.0000020000f @@ -610,7 +610,7 @@ public IEnumerator TestThirdPartyCameraMetadataReturn() result = Mathf.Approximately( metadata .thirdPartyCameras[0] - .parentPositionRelativeThirdPartyCameraRotation + .parentRelativeThirdPartyCameraRotation .Value .x, 20.0000000000f @@ -619,7 +619,7 @@ public IEnumerator TestThirdPartyCameraMetadataReturn() result = Mathf.Approximately( metadata .thirdPartyCameras[0] - .parentPositionRelativeThirdPartyCameraRotation + .parentRelativeThirdPartyCameraRotation .Value .y, 20.0000000000f @@ -628,7 +628,7 @@ public IEnumerator TestThirdPartyCameraMetadataReturn() result = Mathf.Approximately( metadata .thirdPartyCameras[0] - .parentPositionRelativeThirdPartyCameraRotation + .parentRelativeThirdPartyCameraRotation .Value .z, 20.0000000000f