How do I determine which Shading Group is associated with a Material?

Pymel solution: def getSGFromMaterial(mat): mat = PyNode(mat) return mat.shadingGroups() The following is the original article and mel codes by Bryan Ewert. To determine which Material is associated to a Shading Group, get a list of all connection from the Material’s “.outColor” attribute. Iterate this array to find all Shading Groups. The 『nodeType』 command will identify a Shading Group with the string “shadingEngine”. // //////////////////////////////////////////////////////////////////// // getSGFromMaterial // // Description: Returns the Shading Group set whose '.surfaceShader' // attribute is being fed by the specified Material. // // Returns an array for all Shading Groups using the Material. global proc string[] getSGFromMaterial( string $material ) { string $SG[]; // First, assert that $material is a Material. // (Returns a string array, unfortunately, so requires variable.) string $class[] = getClassification( `nodeType $material` ); if ( $class[0] == "shader/surface" ) { // Assert that there is a connection from the Material's .outColor if ( `connectionInfo -is ( $material + ".outColor" )` ) { // There may be more than one connection... string $dests[] = `connectionInfo -dfs ( $material + ".outColor" )`; for ( $dest in $dests ) { // Iterate through connections and identify ShadingGroup sets. if ( "shadingEngine" == `nodeType $dest` ) { $SG[`size $SG`] = rootNode( $dest ); break; } } } } return $SG; } Note: The following 『rootNode()』 procedure is required by the procedures above. // ////////////////////////////////////////////////////////////// // rootNode // // Description: Strips the dot-suffix of the specified string. // e.g. "object.attribute" is returned as "object" proc string rootNode( string $object ) { string $buffer[]; tokenize $object "." $buffer; return $buffer[0]; }

November 11, 2008 · 2 分鐘 · Drake Guan

大腕特效座談會後…

拖同事 LuLu 的福,今晚跑去大腕影像 參加一個「電影【海角七號】導演與視覺特效的對談」,據說是要預約報名的,只有五十個名額。而且,被「記者會或座談會」嚇到了的魏導,熱情站台。到了會場,才發覺數位內容學院的人好多呀……然後也發現,原來還來了資策會副執行長許清琦!!! 我記得他在台大資工時,我還修過他的「必修課」…… ...

November 3, 2008 · 2 分鐘 · Drake Guan

Bruno 的 Utah Teapot 文章

Bruno 最近寫了一篇關於他在 SIGGRAPH 2008,自 Pixar 那排隊拿到的 Walking Teapot 的文章 ,建議去瞧瞧。 重點是,他拍得照片挺漂亮的 :) PS. 今年我好像沒有拿到 Pixar 會場發的 walking teapot,雖然有那麼點兒小遺憾,不過這種東西,有就是運氣好,沒有其實也不會怎麼樣,就只好期待下次囉~~ ...

November 2, 2008 · 1 分鐘 · Drake Guan

鹿橋山莊之「與大師有約」

原來預計這個週六要參加鎧尹發起的讀書會,突如其來的 CG Professor Retreat,把行程整個打亂了。由陳炳宇教授與 Phoebe 主辦,以休閒聚會為名,邀請了台灣的圖學教授們,一同聚集在鹿橋山莊 ,由太極的黃董來作客。我們這一匹國防役(八位)也被抓過去參加。 ...

September 28, 2008 · 3 分鐘 · Drake Guan

Convert Maya camera into RenderMan

The following is from Dan Maas: I just query the camera attributes using the normal Maya MEL commands. For example “getAttr cam.worldInverseMatrix” gives you the camera transform and “getAttr cam.focalLength” the focal length. You can call these from the code that generates your procedural. Maya->RenderMan conversions are as follows: 1. invert the 3rd column of the worldInverseMatrix to convert from right-handed to left-handed coordinates (i.e. multiply m[2] m[6] m[10] and m[14] by -1) 2. RenderMan’s “perspective” camera FOV = rad_to_deg(2_atan((xres/yres)_12.7/cam.focalLength))

August 2, 2008 · 1 分鐘 · Drake Guan

Maya camera 轉換到 RenderMan 相對應的參數

如果因為一些原因,你需要自行在 RIB 裏頭產生一段 camera 相關的參數來(像是使用 prman 的 multi-camera 這個 13.5 才有的新功能),那這篇文章就是在提示你,怎麼搞懂 RIB 裏頭,camera 會用到的 transformation, perspective 參數乃至於 screenwindow。 ...

July 28, 2008 · 1 分鐘 · Drake Guan

大家來去看 Wall-E

一封來自公司福委會的信: 各位同仁大家好: 瓦力(WALL•E)是皮克斯(Pixar)的第九部動畫長片,由海底總動員(Finding Nemo)的導演Andrew Stanton所執導,是一部描述一台打掃機器人「瓦力」的動畫。 ...

July 20, 2008 · 1 分鐘 · Drake Guan

How can I check if an objects attributes are connected?

Quick Answer: from pymel import * # Is the object.attr a source of a connection? len(object.tx.inputs()) > 0 # Is the object.attr the destination of a connection? len(object.tx.outputs()) > 0 # List an object.attr's source connection, meaning, list the input connection. # This will return a single object.attr. object.tx.inputs() # List an object.attr's destination connection, meaning, list the all output connections: # This could return multiple object.attrs. object.tx.outputs() # In other words, you can just use inputs() and outputs() to get if there is a connection # (source or destination), how many connections there are, and what they are! The following is the quotation of post from mel wiki . ...

July 6, 2008 · 1 分鐘 · Drake Guan