Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating Agent Metadata and ThirdPartyCamera Metadata #1239

Merged
merged 9 commits into from
Sep 20, 2024

Conversation

winthos
Copy link
Collaborator

@winthos winthos commented Sep 6, 2024

This updates agent main camera and third party camera returned metadata to be more descriptive and have parity with each other in terms of naming convention and what values are returned. The idea is any camera, main or third party, will always return their position and rotation coordinates in world space and relative to the agent. Third party cameras additionally return position and rotation relative to any parent they might have as third party cameras may be attached to specific segments of articulated agents at some point.

This also fixes a silent bug where third party camera values may have not been correctly being calculated relative to the agent in some circumstances.

metadata now has

  • worldRelativeCameraPosition - New metadata added. same as AgentMetadata.cameraPosition which returns the position of the camera in world coordinates.
  • worldRelativeCameraRotation - New metadata added. same as AgentMetadata.cameraRotation which returns the rotation of the camera in world coordinates
  • agentPositionRelativeCameraPosition - this already existed, returns position of the camera relative to the AgentMetadata.position
  • agentPositionRelativeCameraRotation - this already existed, returns rotation of the camera relative to the AgentMetadata.position

ThirdPartyCameraMetadata has been updated as well

  • worldRelativeThirdPartyCameraPosition - newly added. the same as ThirdPartyCameraMetadata.position but with more descriptive name
  • worldRelativeThirdPartyCameraRotation - newly added. the same as ThirdPartyCameraMetadata.rotation but with a more descriptive name
  • agentPositionRelativeThirdPartyCameraPosition - newly added. If this third party camera is attached to an agent, returns the position of this camera relative to that agent. Null otherwise.
  • agentPositionRelativeThirdPartyCameraRotation - newly added. If this third party camera is attached to an agent, returns the rotation of this camera relative to that agent, null otherwise
  • parentPositionRelativeThirdPartyCameraPosition - newly added, if this third party camera is the child of some other object, returns the position of this camera relative to that object. Null otherwise. This allows us to track which joint a camera may be attached to for agents with joints and the like.
  • parentPositionRelativeThirdPartyCameraRotation - newly added, if this third party camera is the child of some other object, returns the rotation of this camera relative to that object. Null otherwise. This allows us to track which joint a camera may be attached to for agents with joints and the like.
  • parentObjectName - newly added, if this third party camera has a parent object (which could also be the agent) returns the string name of that object.

Copy link
Collaborator

@elimvb elimvb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good logically! Just a few tweaks for efficiency and typography's sake

unity/Assets/Scripts/AgentManager.cs Outdated Show resolved Hide resolved
unity/Assets/Scripts/AgentManager.cs Outdated Show resolved Hide resolved
unity/Assets/Scripts/AgentManager.cs Outdated Show resolved Hide resolved
unity/Assets/Scripts/AgentManager.cs Outdated Show resolved Hide resolved
unity/Assets/Scripts/AgentManager.cs Outdated Show resolved Hide resolved
cleaning up some comments and spelling, changing the following nomenclature:

//for third party camera
agentPositionRelativeThirdPartyCameraRotation -> agentRotationRelativeThirdPartyCameraRotation

//for main camera
agentPositionRelativeCameraRotation -> agentRotationRelativeCameraRotation

as rotation relative to the agent position doesn't mean anything.
- removing extra inverse matrix operations
Copy link
Collaborator

@Lucaweihs Lucaweihs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor naming change suggestion, otherwise LGTM.

Comment on lines 1313 to 1318
cMetadata.parentPositionRelativeThirdPartyCameraPosition =
camera.transform.localPosition;

//get third party camera rotation as quaternion in parent space
cMetadata.parentPositionRelativeThirdPartyCameraRotation =
camera.transform.localEulerAngles;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than parentPositionRelative... can we change this to just parentRelative...? I.e.

parentPositionRelativeThirdPartyCameraPosition -> parentRelativeThirdPartyCameraPosition
parentPositionRelativeThirdPartyCameraRotation -> parentRelativeThirdPartyCameraRotation

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok! Just talked with rose about this to confirm that its still clear that the third party camera position is relative to the parent's position, and that the third party camera rotation is relative to the parent's rotation.

Note that there was a change previously to make parentPositionRelativeThirdPartyCameraRotation to parent RotationRelativeThirdPartyCameraRotation to make it explicit that the rotation can only be relative to rotation, and position can only be relative to position, but I think we can just do this in the description of the variables in the documentation rather than bloating the names.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose it's not clear to me what it would mean for a rotation to be relative a position?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated with 12d8e05

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose it's not clear to me what it would mean for a rotation to be relative a position?

Right, I think most people can intuit that position only makes sense relative to a position, and rotation to a rotation, so my original intent of being extremely explicit was probably overkill

unity/Assets/Scripts/AgentManager.cs Outdated Show resolved Hide resolved
shortening the following:
- agentPositionRelativeThirdPartyCameraPosition -> agentRelativeThirdPartyCameraPosition
- agentRotationRelativeThirdPartyCameraRotation -> agentRelativeThirdPartyCameraRotation
- parentPositionRelativeThirdPartyCameraPosition -> parentRelativeThirdPartyCameraPosition
- parentRotationRelativeThirdPartyCameraRotation -> parentRelativeThirdPartyCameraRotation
…world coords if null parent

rather than returning null if no parent object, the parentRelativeThirdPartyCameraPosition and parentRelativeThirdPartyCameraRotation now default to world coordinates since za warudo is the parent now
@winthos winthos merged commit 4a067f1 into main Sep 20, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants