PhysX Cameras
The PhysX Cameras extension programmatically moves cameras around the stage to follow and look at subjects that can be animated traditionally or with physics. There are currently three camera behaviors: a camera that follows behind and looks along the forward direction of a subject, a camera that follows behind and looks along the direction the subject is moving in, and a camera that behaves like a drone and follows the subject from above and simply tracks it.
Getting Started
The PhysX Cameras extension (omni.physx.camera
) must first be enabled. Open the Extension Manager using the Window > Extensions menu item. Enter “camera” into the search box to find the extension. Click on the PhysX Camera box and then check the Autoload check box if it should be active every time Kit is launched or slide the enabled switch to On to only use it temporarily.
Adding a Camera
The PhysX cameras can only follow Xform prims that have Transform properties. To have a PhysX camera track a prim, first select the prim by clicking on it in the Stage window. Then right click to open the context menu, move the cursor over the Add menu item, then move the cursor over the Cameras menu item and click on the desired camera. The Cameras menu item will not appear if the selected prim cannot be tracked.
Many cameras can be added to the same prim. More than one of the same type as well. Since the cameras are added automatically, names will be created by appending the name of the camera type with a number to the end of the prim name. For example, adding Follow Look cameras to a prim named “Car” will be named, “CarLookFollowCamera0”, then “CarLookFollowCamera1”, etc. Adding a Chase camera to the same prim will then be named, “CarDroneCamera0”, and so on. Feel free to rename the cameras after they have been created.
Selecting a Camera
Once a camera is added, it will appear in the list of available cameras in the Viewport. To select the new camera, click on the viewport camera button, then select the Cameras menu item and finally, select the new camera through which to view the scene.
The following two videos demonstrate the behaviors of the three cameras. The first video uses a vehicle that drives and slides around on a surface to illustrate the differences between the Follow Look and Follow Velocity cameras. The second video follows a simple rigid body as it moves through a conveyer belt system to illustrate that these cameras can be used to track and object animated by physics or animation.
Camera Properties
Each of the cameras have properties that can be tuned in order to greatly affect the behavior of the camera. To edit these properties, select the camera to edit in the list of prims and then click on the Property tab. Scroll down the list of properties until you find the Physics box and the list of cameras.
Follow Look Camera
Property 
Description 

Always Update Enabled 
When enabled, always update this camera whether it is the active camera or not. This prevents cameras from slewing into position when switching to a new active camera. When disabled, only the active camera is updated, saving time.

Subject 
Reference to the subject this camera is to track.

Yaw Angle 
The yaw angle of the follow vector around the subject. Zero is directly behind the subject.

Pitch Angle 
The pitch angle of the follow vector around the subject. Zero is directly behind the subject.

Pitch Angle Time Constant 
Time constant to filter the pitch angle, in seconds. Used to pitch the camera up and down when driving up or down hills.

Slow Speed Pitch Angle Scale 
Scale of the camera pitch angle at slow speed. This lowers the camera behind the subject at slow speeds.

Slow Pitch Angle Speed 
Scale of the camera pitch angle at slow speed. This lowers the camera behind the subject at slow speeds.

Velocity Normal Min Speed 
The minimum speed, below which, the subject look vector must be used because the normalized velocity vector is too erratic.

Follow Min Speed 
The minimum speed used for a linear interpolation to compute the follow distance of the camera.

Follow Min Distance 
The minimum distance used for a linear interpolation to compute the follow distance of the camera.

Follow Max Speed 
The maximum speed used for a linear interpolation to compute the follow distance of the camera.

Follow Max Distance 
The maximum distance used for a linear interpolation to compute the follow distance of the camera.

Yaw Rate Time Constant 
Time constant to filter the subject yaw rate, in seconds. Use to look into turns.

Follow Turn Rate Gain 
A scale factor that multiplies the filtered yaw rate to yaw the camera position behind the subject. Can be any positive or negative number.

Camera Position Time Constant 
Filter time constant for the position of the camera for each axis, in seconds.

Position Offset 
Position offset from the subject center of mass from which the camera follow vector and look vector are computed.

Look Ahead Min Speed 
The minimum speed used for a linear interpolation to compute the look ahead distance of the camera look point.

Look Ahead Min Distance 
The minimum distance used for a linear interpolation to compute the look ahead distance of the camera look point.

Look Ahead Max Speed 
The maximum speed used for a linear interpolation to compute the look ahead distance of the camera look point.

Look Ahead Max Distance 
The maximum distance used for a linear interpolation to compute the look ahead distance of the camera look point.

Look Ahead Turn Rate Gain 
A scale factor that multiplies the filtered yaw rate to yaw the camera look point left or right. Can be any positive or negative number.

Look Position Height 
Distance to elevate the camera look point.

Look Position Time Constant 
Filter time constant for the camera look point, in seconds.

Downhill Ground Angle 
The minimum pitch angle of the terrain used for a linear interpolation to adjust the pitch of the camera.

Downhill Ground Pitch 
The minimum pitch angle of the camera used for a linear interpolation to adjust the pitch of the camera.

Uphill Ground Angle 
The maximum pitch angle of the terrain used for a linear interpolation to adjust the pitch of the camera.

Uphill Ground Pitch 
The maximum pitch angle of the camera used for a linear interpolation to adjust the pitch of the camera.

Velocity Blend Time Constant 
Filter time constant to blend between the look and velocity vectors, in seconds.

Follow Reverse Speed 
The positive, maximum speed, when driving in reverse, used for a linear interpolation to compute the follow distance of the camera.

Follow Reverse Distance 
The maximum distance, when driving in reverse, used for a linear interpolation to compute the follow distance of the camera.

Follow Velocity Camera
Property 
Description 

Always Update Enabled 
When enabled, always update this camera whether it is the active camera or not. This prevents cameras from slewing into position when switching to a new active camera. When disabled, only the active camera is updated, saving time.

Subject 
Reference to the subject this camera is to track.

Yaw Angle 
The yaw angle of the follow vector around the subject. Zero is directly behind the subject.

Pitch Angle 
The pitch angle of the follow vector around the subject. Zero is directly behind the subject.

Pitch Angle Time Constant 
Time constant to filter the pitch angle, in seconds. Used to pitch the camera up and down when driving up or down hills.

Slow Speed Pitch Angle Scale 
Scale of the camera pitch angle at slow speed. This lowers the camera behind the subject at slow speeds.

Slow Pitch Angle Speed 
Scale of the camera pitch angle at slow speed. This lowers the camera behind the subject at slow speeds.

Velocity Normal Min Speed 
The minimum speed, below which, the subject look vector must be used because the normalized velocity vector is too erratic.

Follow Min Speed 
The minimum speed used for a linear interpolation to compute the follow distance of the camera.

Follow Min Distance 
The minimum distance used for a linear interpolation to compute the follow distance of the camera.

Follow Max Speed 
The maximum speed used for a linear interpolation to compute the follow distance of the camera.

Follow Max Distance 
The maximum distance used for a linear interpolation to compute the follow distance of the camera.

Yaw Rate Time Constant 
Time constant to filter the subject yaw rate, in seconds. Use to look into turns.

Follow Turn Rate Gain 
A scale factor that multiplies the filtered yaw rate to yaw the camera position behind the subject. Can be any positive or negative number.

Camera Position Time Constant 
Filter time constant for the position of the camera for each axis, in seconds.

Position Offset 
Position offset from the subject center of mass from which the camera follow vector and look vector are computed.

Look Ahead Min Speed 
The minimum speed used for a linear interpolation to compute the look ahead distance of the camera look point.

Look Ahead Min Distance 
The minimum distance used for a linear interpolation to compute the look ahead distance of the camera look point.

Look Ahead Max Speed 
The maximum speed used for a linear interpolation to compute the look ahead distance of the camera look point.

Look Ahead Max Distance 
The maximum distance used for a linear interpolation to compute the look ahead distance of the camera look point.

Look Ahead Turn Rate Gain 
A scale factor that multiplies the filtered yaw rate to yaw the camera look point left or right. Can be any positive or negative number.

Look Position Height 
Distance to elevate the camera look point.

Look Position Time Constant 
Filter time constant for the camera look point, in seconds.

Chase Camera
Property 
Description 

Always Update Enabled 
When enabled, always update this camera whether it is the active camera or not. This prevents cameras from slewing into position when switching to a new active camera. When disabled, only the active camera is updated, saving time.

Subject 
Reference to the subject this camera is to track.

Follow Height 
The height above the subject that the drone attempts to maintain.

Follow Distance 
The distance from the subject that the drone attempts to maintain.

Max Distance 
The maximum distance allowed from the subject before the drone resets to the target position.

Max Speed 
The maximum speed the drone is allowed to move.

Horizontal Velocity Gain 
The higher the gain, the faster the drone will accelerate towards the target position.

Vertical Velocity Gain 
The higher the gain, the higher the climb or descent rate of the drone to get to the target altitude.

Feed Forward Velocity Gain 
The higher the gain, the more closely the drone will match the velocity of the subject and the more connected it will appear.

Velocity Filter Time Constant 
The velocity of the drone is filtered to make it appear as if it is accelerating.

Rotation Filter Time Constant 
The angular velocity of the drone is filtered to make it appear as if it is accelerating.

Position Offset 
An offset vector from the subject origin at which the drone looks.

Using PhysX Cameras In Python
Copy and paste the appropriate Python script, below, to add a PhysX Camera to the stage. It may be beneficial to tune the camera properties in Create while the simulation is running and then set the final values in Python.
1 import omni.usd
2
3 from pxr import UsdGeom, Gf, UsdPhysics, PhysxSchema
4
5
6 usdContext = omni.usd.get_context()
7 stage = usdContext.get_stage()
8
9 # Place the subject prim path here:
10 subjectPath = "/World/SubjectPrimPath"
11
12 # create tha Follow Look camera
13 cameraPath = "/FollowLookCamera"
14 usdCamera = UsdGeom.Camera.Define(stage, cameraPath)
15 followCameraPrim = stage.GetPrimAtPath(cameraPath)
16
17 followCameraApi = PhysxSchema.PhysxCameraFollowLookAPI.Apply(followCameraPrim)
18 followCameraApi.GetPhysxCameraSubjectRel().ClearTargets(True)
19 followCameraApi.GetPhysxCameraSubjectRel().AddTarget(subjectPath)
20
21 positionOffset = Gf.Vec3f(0, 0, 0)
22 cameraPositionTC = Gf.Vec3f(0.5, 0.1, 0.5)
23 lookPositionTC = Gf.Vec3f(0.2, 0.5, 0.2)
24
25 followCameraApi.CreateYawAngleAttr().Set(20.0)
26 followCameraApi.CreatePitchAngleAttr().Set(15.0)
27 followCameraApi.CreatePitchAngleTimeConstantAttr().Set(0.2)
28 followCameraApi.CreateSlowSpeedPitchAngleScaleAttr().Set(0.5)
29 followCameraApi.CreateSlowPitchAngleSpeedAttr().Set(1000.0)
30 followCameraApi.CreateDownHillGroundAngleAttr().Set(45.0)
31 followCameraApi.CreateDownHillGroundPitchAttr().Set(10.0)
32 followCameraApi.CreateUpHillGroundAngleAttr().Set(45.0)
33 followCameraApi.CreateUpHillGroundPitchAttr().Set(10.0)
34 followCameraApi.CreateVelocityNormalMinSpeedAttr().Set(600.0)
35 followCameraApi.CreateVelocityBlendTimeConstantAttr().Set(0.1)
36 followCameraApi.CreateFollowMinSpeedAttr().Set(3.0)
37 followCameraApi.CreateFollowMinDistanceAttr().Set(15.0)
38 followCameraApi.CreateFollowMaxSpeedAttr().Set(30.0)
39 followCameraApi.CreateFollowMaxDistanceAttr().Set(10.0)
40 followCameraApi.CreateFollowReverseSpeedAttr().Set(15.0)
41 followCameraApi.CreateFollowReverseDistanceAttr().Set(30.0)
42 followCameraApi.CreateYawRateTimeConstantAttr().Set(0.2)
43 followCameraApi.CreateFollowTurnRateGainAttr().Set(0.2)
44 followCameraApi.CreateCameraPositionTimeConstantAttr().Set(cameraPositionTC)
45 followCameraApi.CreatePositionOffsetAttr().Set(positionOffset)
46 followCameraApi.CreateLookAheadMinSpeedAttr().Set(0.0)
47 followCameraApi.CreateLookAheadMinDistanceAttr().Set(0.0)
48 followCameraApi.CreateLookAheadMaxSpeedAttr().Set(20.0)
49 followCameraApi.CreateLookAheadMaxDistanceAttr().Set(5.0)
50 followCameraApi.CreateLookAheadTurnRateGainAttr().Set(0.2)
51 followCameraApi.CreateLookPositionHeightAttr().Set(0.5)
52 followCameraApi.CreateLookPositionTimeConstantAttr().Set(lookPositionTC)
1 import omni.usd
2
3 from pxr import UsdGeom, Gf, UsdPhysics, PhysxSchema
4
5
6 usdContext = omni.usd.get_context()
7 stage = usdContext.get_stage()
8
9 # Place the subject prim path here:
10 subjectPath = "/World/SubjectPrimPath"
11
12 cameraPath = "/DroneCamera"
13 usdCamera = UsdGeom.Camera.Define(stage, cameraPath)
14 droneCameraPrim = stage.GetPrimAtPath(cameraPath)
15
16 droneCameraApi = PhysxSchema.PhysxCameraDroneAPI.Apply(droneCameraPrim)
17 droneCameraApi.GetPhysxCameraSubjectRel().ClearTargets(True)
18 droneCameraApi.GetPhysxCameraSubjectRel().AddTarget(subjectPath)
19
20 positionOffset = Gf.Vec3f(0, 0, 0)
21
22 droneCameraApi.CreateFollowHeightAttr().Set(15.0)
23 droneCameraApi.CreateFollowDistanceAttr().Set(30.0)
24 droneCameraApi.CreateMaxDistanceAttr().Set(100.0)
25 droneCameraApi.CreateMaxSpeedAttr().Set(20.0)
26 droneCameraApi.CreateHorizontalVelocityGainAttr().Set(1.0)
27 droneCameraApi.CreateVerticalVelocityGainAttr().Set(1.0)
28 droneCameraApi.CreateFeedForwardVelocityGainAttr().Set(0.1)
29 droneCameraApi.CreateVelocityFilterTimeConstantAttr().Set(1.0)
30 droneCameraApi.CreateRotationFilterTimeConstantAttr().Set(0.2)
31 droneCameraApi.CreatePositionOffsetAttr().Set(positionOffset)