一半君的总结纸

听话只听一半君

#92 How do I determine which Material or File Texture is associated with a Shading Group?

Trace upstream from the Shading Group to the Material then to the File Texture. To get the name of the image file assigned to the File Texture, query the file node’s ‘.fileTextureName’ attribute.

<br />// ////////////////////////////////////////////////////////////////////<br />//  getMaterialFromSG<br />//<br />// Description: Returns the Material node feeing the '.surfaceShader'<br />//  attribute of the specified Shading Group node (shadingEngine).<br /><br />proc string getMaterialFromSG( string $SG )<br />{<br /><%%KEEPWHITESPACE%%>  string $material = "";<br /><br /><%%KEEPWHITESPACE%%>  if ( "shadingEngine" == `nodeType $SG` &amp;amp;&amp;amp;<br /><%%KEEPWHITESPACE%%>    `connectionInfo -id ( $SG + ".surfaceShader" )` )<br /><%%KEEPWHITESPACE%%>  {<br /><%%KEEPWHITESPACE%%>    $material = rootNode( `connectionInfo -sfd<br /><%%KEEPWHITESPACE%%>      ( $SG + ".surfaceShader" )` );<br /><%%KEEPWHITESPACE%%>  }<br /><br /><%%KEEPWHITESPACE%%>  return $material;<br />}<br /><br />// ////////////////////////////////////////////////////////<br />//   getTextureFromMaterial<br />//<br />// Description: Returns the File Texture node feeding the '.color'<br />//   attribute of the specified Material node<br /><br />proc string getTextureFromMaterial( string $material )<br />{<br /><%%KEEPWHITESPACE%%>  string $texture = "";<br /><br /><%%KEEPWHITESPACE%%>  string $class[] = getClassification( `nodeType $material` );<br /><br /><%%KEEPWHITESPACE%%>  if ( "shader/surface" == $class[0] &amp;amp;&amp;amp; `connectionInfo -id<br /><%%KEEPWHITESPACE%%>       ( $material + ".color" )` )<br /><%%KEEPWHITESPACE%%>  {<br /><%%KEEPWHITESPACE%%>    $texture = rootNode( `connectionInfo -sfd ( $material + ".color" )` );<br /><%%KEEPWHITESPACE%%>  }<br /><br /><%%KEEPWHITESPACE%%>  return $texture;<br />}<br />

 

Related How-To’s

Friday, September 14, 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 博主赞过: