diff --git a/unity/Assets/Scripts/AgentManager.cs b/unity/Assets/Scripts/AgentManager.cs index fb9b815af5..79f7f69588 100644 --- a/unity/Assets/Scripts/AgentManager.cs +++ b/unity/Assets/Scripts/AgentManager.cs @@ -1295,7 +1295,7 @@ bool shouldRenderImageSynthesis Camera camera = thirdPartyCameras.ToArray()[i]; cMetadata.thirdPartyCameraId = i; - //to be depracated at some point, will be replaced by more descriptive worldRelativeThirdPartyCamera.... + //to be deprecated at some point, will be replaced by more descriptive worldRelativeThirdPartyCamera.... cMetadata.position = camera.transform.position; cMetadata.rotation = camera.transform.eulerAngles; //currently redundant data as it is the same as metadata.position/rotation, but more descriptive naming convention @@ -1313,7 +1313,7 @@ bool shouldRenderImageSynthesis cMetadata.parentPositionRelativeThirdPartyCameraPosition = camera.transform.parent.InverseTransformPoint(camera.transform.position); - //get third party camera rotation as quaternion in world space + //get third party camera rotation as quaternion in parent space var parentSpaceCameraRotationAsQuaternion = Quaternion.Inverse(camera.transform.parent.rotation) * worldSpaceCameraRotationAsQuaternion; @@ -1325,23 +1325,22 @@ bool shouldRenderImageSynthesis cMetadata.parentPositionRelativeThirdPartyCameraRotation = null; } - //if this camera is part of the agent's heirarchy at all, get agent relative info + //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 = agent.transform.InverseTransformPoint(camera.gameObject.transform.position); - //get third party camera rotation as quaternion in world space var agentSpaceCameraRotationAsQuaternion = Quaternion.Inverse(agent.transform.rotation) * worldSpaceCameraRotationAsQuaternion; - cMetadata.agentPositionRelativeThirdPartyCameraRotation = + cMetadata.agentRotationRelativeThirdPartyCameraRotation = 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.agentPositionRelativeThirdPartyCameraRotation = null; + cMetadata.agentRotationRelativeThirdPartyCameraRotation = null; } cMetadata.fieldOfView = camera.fieldOfView; @@ -1877,12 +1876,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? agentPositionRelativeThirdPartyCameraRotation; + public Vector3? agentRotationRelativeThirdPartyCameraRotation; //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 string parentObjectName; //if this third party camera is in a heirarchy, return the name of the parent object + public string parentObjectName; //if this third party camera is in a hierarchy, return the name of the parent object } [Serializable] @@ -2314,7 +2313,7 @@ public struct MetadataWrapper { public Vector3 worldRelativeCameraPosition; public Vector3 worldRelativeCameraRotation; public Vector3 agentPositionRelativeCameraPosition; - public Vector3 agentPositionRelativeCameraRotation; + public Vector3 agentRotationRelativeCameraRotation; public float cameraOrthSize; public ThirdPartyCameraMetadata[] thirdPartyCameras; public bool collided; diff --git a/unity/Assets/Scripts/BaseFPSAgentController.cs b/unity/Assets/Scripts/BaseFPSAgentController.cs index b04ff1f848..1ad6e89011 100644 --- a/unity/Assets/Scripts/BaseFPSAgentController.cs +++ b/unity/Assets/Scripts/BaseFPSAgentController.cs @@ -2627,8 +2627,8 @@ public virtual MetadataWrapper generateMetadataWrapper() { metaMessage.screenWidth = Screen.width; metaMessage.screenHeight = Screen.height; - metaMessage.cameraPosition = m_Camera.transform.position; - metaMessage.cameraRotation = m_Camera.transform.eulerAngles; + metaMessage.cameraPosition = m_Camera.transform.position; //to be deprecated + metaMessage.cameraRotation = m_Camera.transform.eulerAngles; //to be deprecated metaMessage.worldRelativeCameraPosition = m_Camera.transform.position; metaMessage.worldRelativeCameraRotation = m_Camera.transform.eulerAngles; @@ -2645,9 +2645,9 @@ public virtual MetadataWrapper generateMetadataWrapper() { var worldSpaceCameraRotationAsQuaternion = m_Camera.transform.rotation; var localSpaceCameraRotationAsQuaternion = Quaternion.Inverse(transform.rotation) * worldSpaceCameraRotationAsQuaternion; - metaMessage.agentPositionRelativeCameraRotation = + metaMessage.agentRotationRelativeCameraRotation = localSpaceCameraRotationAsQuaternion.eulerAngles; - //Debug.Log($"agentRelativeCameraRotation: {metaMessage.agentPositionRelativeCameraRotation}"); + //Debug.Log($"agentRelativeCameraRotation: {metaMessage.agentRotationRelativeCameraRotation}"); metaMessage.cameraOrthSize = cameraOrthSize; cameraOrthSize = -1f; diff --git a/unity/Assets/UnitTests/TestThirdPartyCameraAndMainCamera.cs b/unity/Assets/UnitTests/TestThirdPartyCameraAndMainCamera.cs index 7fd08f9c14..dc47ced39a 100644 --- a/unity/Assets/UnitTests/TestThirdPartyCameraAndMainCamera.cs +++ b/unity/Assets/UnitTests/TestThirdPartyCameraAndMainCamera.cs @@ -358,17 +358,17 @@ public IEnumerator TestMainCameraMetadataReturn() ); Assert.AreEqual(result, true); result = Mathf.Approximately( - metadata.agentPositionRelativeCameraRotation.x, + metadata.agentRotationRelativeCameraRotation.x, 0.0000000000f ); Assert.AreEqual(result, true); result = Mathf.Approximately( - metadata.agentPositionRelativeCameraRotation.y, + metadata.agentRotationRelativeCameraRotation.y, 0.0000000000f ); Assert.AreEqual(result, true); result = Mathf.Approximately( - metadata.agentPositionRelativeCameraRotation.z, + metadata.agentRotationRelativeCameraRotation.z, 0.0000000000f ); Assert.AreEqual(result, true); @@ -409,17 +409,17 @@ public IEnumerator TestMainCameraMetadataReturn() ); Assert.AreEqual(result, true); result = Mathf.Approximately( - metadata.agentPositionRelativeCameraRotation.x, + metadata.agentRotationRelativeCameraRotation.x, 30.0000000000f ); Assert.AreEqual(result, true); result = Mathf.Approximately( - metadata.agentPositionRelativeCameraRotation.y, + metadata.agentRotationRelativeCameraRotation.y, 10.0000000000f ); Assert.AreEqual(result, true); result = Mathf.Approximately( - metadata.agentPositionRelativeCameraRotation.z, + metadata.agentRotationRelativeCameraRotation.z, 12.0000000000f ); Assert.AreEqual(result, true); @@ -483,7 +483,7 @@ public IEnumerator TestThirdPartyCameraMetadataReturn() null ); Assert.AreEqual( - metadata.thirdPartyCameras[0].agentPositionRelativeThirdPartyCameraRotation, + metadata.thirdPartyCameras[0].agentRotationRelativeThirdPartyCameraRotation, null ); Assert.AreEqual( @@ -514,7 +514,7 @@ public IEnumerator TestThirdPartyCameraMetadataReturn() // 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].agentPositionRelativeThirdPartyCameraRotation:F10}"); + // Debug.Log($"agent relative camera rot: {metadata.thirdPartyCameras[0].agentRotationRelativeThirdPartyCameraRotation: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}"); @@ -566,17 +566,17 @@ public IEnumerator TestThirdPartyCameraMetadataReturn() ); Assert.AreEqual(result, true); result = Mathf.Approximately( - metadata.thirdPartyCameras[0].agentPositionRelativeThirdPartyCameraRotation.Value.x, + metadata.thirdPartyCameras[0].agentRotationRelativeThirdPartyCameraRotation.Value.x, 20.0000000000f ); Assert.AreEqual(result, true); result = Mathf.Approximately( - metadata.thirdPartyCameras[0].agentPositionRelativeThirdPartyCameraRotation.Value.y, + metadata.thirdPartyCameras[0].agentRotationRelativeThirdPartyCameraRotation.Value.y, 20.0000000000f ); Assert.AreEqual(result, true); result = Mathf.Approximately( - metadata.thirdPartyCameras[0].agentPositionRelativeThirdPartyCameraRotation.Value.z, + metadata.thirdPartyCameras[0].agentRotationRelativeThirdPartyCameraRotation.Value.z, 20.0000000000f ); Assert.AreEqual(result, true);