This question comes up occasionally, so I thought I'd post up an example. Houdini Engine doesn't have support for inputting cameras (yet?). However, since all the Maya camera information is available as attributes, it's not difficult to create an asset that takes in the Maya camera information as asset parameters, and use these parameters to set the Houdini camera.
I've made an example asset that demonstrate this. The asset simple takes in a Maya geometry and the camera parameters, and cull the geometry based on the camera frustum.
The following MEL can be used to connect the Maya camera to the Houdini Engine asset.
proc connect_camera(string $camera, string $engine_asset)
{
string $children = `listRelatives -shapes -type camera $camera`;
string $camera_shape = $children;
connectAttr -f ($camera + “.translate”) ($engine_asset + “.houdiniAssetParm_camera_translate”);
connectAttr -f ($camera + “.rotate”) ($engine_asset + “.houdiniAssetParm_camera_rotate”);
connectAttr -f ($camera_shape + “.focalLength”) ($engine_asset + “.houdiniAssetParm_focal_length”);
connectAttr -f ($camera_shape + “.cameraAperture”) ($engine_asset + “.houdiniAssetParm_camera_aperture”);
connectAttr -f ($camera_shape + “.nearClipPlane”) ($engine_asset + “.houdiniAssetParm_near_plane”);
connectAttr -f ($camera_shape + “.farClipPlane”) ($engine_asset + “.houdiniAssetParm_far_plane”);
}
connect_camera(“camera1”, “camera_culling1”);
Hope this helps some of you out there.
Getting Maya camera information into Houdini Engine
5127 3 2- awong
- Member
- 818 posts
- Joined: 9月 2013
- Offline
- chistof
- Member
- 52 posts
- Joined: 6月 2012
- Offline
- Haki
- Member
- 14 posts
- Joined: 1月 2016
- Offline
It seems listRelatives returns a string. So the script ends with this error:
// Error: line 3: Cannot convert data of type string to type string. //
This worked for me with Maya 2020.1
:
// Error: line 3: Cannot convert data of type string to type string. //
This worked for me with Maya 2020.1
:
proc connect_camera(string $camera, string $engine_asset) { string $children[] = `listRelatives -shapes -type camera $camera`; string $camera_shape = $children[0]; connectAttr -f ($camera+".translate") ($engine_asset+".houdiniAssetParm_camera_translate"); connectAttr -f ($camera+".rotate") ($engine_asset+".houdiniAssetParm_camera_rotate"); connectAttr -f ($camera_shape+".focalLength") ($engine_asset+".houdiniAssetParm_focal_length"); connectAttr -f ($camera_shape+".cameraAperture") ($engine_asset+".houdiniAssetParm_camera_aperture"); connectAttr -f ($camera_shape+".nearClipPlane") ($engine_asset+".houdiniAssetParm_near_plane"); connectAttr -f ($camera_shape+".farClipPlane") ($engine_asset+".houdiniAssetParm_far_plane"); } connect_camera("camera1","asset1");
Edited by Haki - 2020年5月29日 05:35:41
3D Generalist
https://hristo.one [hristo.one]
https://hristo.one [hristo.one]
- johnmather
- スタッフ
- 525 posts
- Joined: 8月 2019
- Offline
-
- Quick Links