Ooops!  Let out my dark secret.  Umph!.....must....recover.............quic-


Create a custom property in a central location where it's easily accessible, such as the scene root. Create an integer parameter called "Camera_Index" with range [0...N] where N is at least the number of cameras in the scene, but I'd opt for a fixed value like 9999 to allow for expansion without fuss.

Create a null called 'n_CameraData' and apply an ICE Tree to it. In the ICE Tree, get a 'select case' node and plug all the cameras into it's 'case' ports. Connect the camera data type to the case node (eg; if needing global kinematics, connect the camera's global kinematics port to the 'case' port). Insert a GetData node which reads the Camera_Index parameter of the custom property and applies it's value to the 'condition' port of the select case node. Take the output of the select case node and feed it into a SetData node which records the selected camera's data as a custom ICE attribute on n_CameraData. If you need multiple types of data from the camera, then create a select case node for each unique data. Just make sure you connect cameras in the same order on each select case node. For example, if your render camera is connected to case 3 of your main select case node, then make sure it's connected to case 3 of all other select case nodes. The output of the GetData node reading the Camera_Index parameter can be reused and applied to the condition port of all the select case nodes.

Each object in the scene requiring the camera data should have it's own ICE Tree which reads the custom ICE Attributes applied to n_CameraData. When you want to switch cameras, simply adjust the Camera_Index parameter in the custom property and the change will propagate to all the ICE Trees in the scene reading the data. I would advise plugging the default scene camera into case 0 for consistency. This will also be the camera used when the value of Camera_Index is out of range.

This setup effectively replaces any need for expressions in the scene.


I guess the important question is what you're doing that requires an expression to switch (refer to arbitrary) cameras? If it's for rendering to switch cameras on a given pass, for example, I'd suggest using a event script than expressions or ICE.


Matt

Reply via email to