一半君的总结纸

听话只听一半君

#65 How do I use MEL to get and set the Render Globals?

Most of the settings are defined in the “defaultRenderGlobals” node in the scene. You can query this node for the settings used in the render. Of course, you’ll need to know the name of the attribute corresponding to the setting for which you need, and you’ll need to know what its value means.

As a start, use the listAttr command to get a quick summary of all the attributes on this node. The following MEL will give you a sorted list:

string $globals[] = `listAttr defaultRenderGlobals`;
$globals = `sort $globals`;
print $globals;

The correlation between this node and the Render Globals window are managed by the MEL script:

/AW/Maya3.0/scripts/others/renderGlobalsWindow.mel

You can activate the Script Editor’s “Echo All Commands” and then toggle settings in the Render Globals window to see which MEL procedures are called in response. Note that the “renderGlobalsWindow.mel” script uses the UI for obtaining the current settings, defeating the ability to simply call the functions within it to specify your own setting.

Once you figure out what all the settings mean you can use the MEL commands getAttr and setAttr – targeting the “defaultRenderGlobals” node – to change the render settings as you see fit.

Resolution

The Render Globals derives its resolution from the “resolution” node connected through its ‘.resolution’ attribute:

listConnections defaultRenderGlobals.resolution;
// Result: defaultResolution //

Knowing this, you can query the width and height from the connected “resolution” node:

getAttr defaultResolution.width;
// Result: 640 //

getAttr defaultResolution.height;
// Result: 480 //

To find other potential resolutions:

ls -type "resolution";
// Result: defaultResolution resolution1 //

getAttr resolution1.width;
// Result: 320 //
getAttr resolution1.height;
// Result: 240 //

The following tip was generously provided by both Mark Adams (Pixar Animation Studios) and John Cassella (Red Paw FX). Originally posted on the Highend3D Maya forum, I’ve paraphrased the content for these pages. Reproduced with permission from the authors.

Maya maintains its list of resolutions in the global variable $gImageFormatData, which is defined in, e.g.:

/AW/Maya3.0/scripts/others/imageFormats.mel

You could make a script that blanks this global variable and then add your own, each in the format:

"     "

Maya supports user-defined resolutions as stored in “userImageFormats.mel“. The use of this file is described in Maya’s documentation under “Rendering: Render Globals, Resolution Presets”.

Renderable Cameras

The renderable camera is not specified by the “defaultRenderGlobals” node, but rather by the ‘.renderable’ attribute for each Camera in the scene. You’ll need to query each Camera to find out which ones are flagged to be renderable; e.g.

int $isRenderable = `getAttr perspShape.renderable`;

MEL Tip

To get at the old Render Globals window (from pre Maya2.0 days):

string $globals[] = `ls -head 1 -renderGlobals`;
showEditor $globals[0];

Acknowledgements

Mark Adams, Pixar Animation Studios

John Cassella, Red Paw FX

Wednesday, August 29, 2001

Advertisements

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: