Search - User list
Full Version: Getting Maya camera information into Houdini Engine
Root » Houdini Engine for Maya » Getting Maya camera information into Houdini Engine
awong
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.
chistof
Thx Andrew for posting this solution. So far I've been creating a camera in my otl and promote parameters to finally use some expression in Maya to apply the camera settings but I'm happy to see an other way.

Thanks again !
Chris
Haki
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
:
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");
johnmather
I think part of the error message above may have been eaten by the forum. The error is:

// Error: line 3: Cannot convert data of type string[] to type string. //

Thanks for posting. That is indeed the correct solution.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB