tag:blogger.com,1999:blog-87634791843024668452023-06-20T07:01:45.648-07:00Mel MagicSimple tips and tricks (somewhat daily?)Jacob Schieckhttp://www.blogger.com/profile/04562687762228940994noreply@blogger.comBlogger19125tag:blogger.com,1999:blog-8763479184302466845.post-36220480681754690072010-12-15T14:27:00.000-08:002010-12-15T14:36:49.501-08:00Simple HUD ButtonshudButton is a command that kind of flies under the radar mostly, but can be useful. For example making a HUD button that hides nurbs curves in the perspective view:<br /><br /><blockquote><pre><font color="#000000"><font color="#000099"><strong>global</strong></font> <font color="#000099"><strong>int</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>gCurvesHudActive</strong></font><font color="#000000"><strong>;</strong></font><br /><font color="#999999">//</font><font color="#999999"> </font><font color="#999999">this</font><font color="#999999"> </font><font color="#999999">procedure</font><font color="#999999"> </font><font color="#999999">could</font><font color="#999999"> </font><font color="#999999">be</font><font color="#999999"> </font><font color="#999999">combined</font><font color="#999999"> </font><font color="#999999">into</font><font color="#999999"> </font><font color="#999999">a</font><font color="#999999"> </font><font color="#999999">single</font><font color="#999999"> </font><font color="#999999">line</font><font color="#999999"> </font><font color="#999999">and</font><font color="#999999"> </font><font color="#999999">put</font><font color="#999999"> </font><font color="#999999">in</font><font color="#999999"> </font><font color="#999999">the</font><font color="#999999"> </font><font color="#999999">button</font><font color="#999999"> </font><font color="#999999">command</font><br /><font color="#999999">//</font><font color="#999999"> </font><font color="#999999">but</font><font color="#999999"> </font><font color="#999999">wouldnt</font><font color="#999999"> </font><font color="#999999">fit</font><font color="#999999"> </font><font color="#999999">in</font><font color="#999999"> </font><font color="#999999">the</font><font color="#999999"> </font><font color="#999999">blog</font><font color="#999999"> </font><font color="#999999">post</font><font color="#999999"> </font><font color="#999999">:D</font><br /><font color="#000099"><strong>global</strong></font> <font color="#000099"><strong>proc</strong></font> <font color="#000099"><strong>ToggleNurbsCurves</strong></font>() <font color="#000000"><strong>{</strong></font><br /> <font color="#000099"><strong>int</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>nurbsActive</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>modelEditor</strong></font> -<font color="#000000"><strong>q</strong></font> -<font color="#000000"><strong>nurbsCurves</strong></font> modelPanel4<font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#000099"><strong>if</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>nurbsActive</strong></font> <font color="#000000"><strong>=</strong></font><font color="#000000"><strong>=</strong></font> <font color="#ff0000">1</font>) <font color="#0000ff"><strong>hudButton</strong></font> -<font color="#000000"><strong>e</strong></font> -<font color="#000000"><strong>l</strong></font> <font color="#009900"><strong>"</strong></font><font color="#009900"><strong>Show</strong></font><font color="#009900"><strong> </strong></font><font color="#009900"><strong>Nurbs</strong></font><font color="#009900"><strong> </strong></font><font color="#009900"><strong>Curves</strong></font><font color="#009900"><strong>"</strong></font> HUDCurvesButton<font color="#000000"><strong>;</strong></font><br /> <font color="#000099"><strong>else</strong></font> <font color="#0000ff"><strong>hudButton</strong></font> -<font color="#000000"><strong>e</strong></font> -<font color="#000000"><strong>l</strong></font> <font color="#009900"><strong>"</strong></font><font color="#009900"><strong>Hide</strong></font><font color="#009900"><strong> </strong></font><font color="#009900"><strong>Nurbs</strong></font><font color="#009900"><strong> </strong></font><font color="#009900"><strong>Curves</strong></font><font color="#009900"><strong>"</strong></font> HUDCurvesButton<font color="#000000"><strong>;</strong></font><br /> <font color="#0000ff"><strong>modelEditor</strong></font> -<font color="#000000"><strong>e</strong></font> -<font color="#000000"><strong>nurbsCurves</strong></font> (<font color="#0000ff"><strong>abs</strong></font>((<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>nurbsActive</strong></font>)-<font color="#000000"><strong>1</strong></font>)) modelPanel4<font color="#000000"><strong>;</strong></font><br /><font color="#000000"><strong>}</strong></font><br /><br /><font color="#000099"><strong>if</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>gCurvesHudActive</strong></font> <font color="#000000"><strong>=</strong></font><font color="#000000"><strong>=</strong></font> <font color="#ff0000">0</font>) <font color="#000000"><strong>{</strong></font><br /> <font color="#0000ff"><strong>hudButton</strong></font> -<font color="#000000"><strong>s</strong></font> <font color="#ff0000">8</font> -<font color="#000000"><strong>b</strong></font> <font color="#ff0000">1</font><br /> -<font color="#000000"><strong>vis</strong></font> <font color="#ff0000">1</font><br /> -<font color="#000000"><strong>l</strong></font> <font color="#009900"><strong>"</strong></font><font color="#009900"><strong>Hide</strong></font><font color="#009900"><strong> </strong></font><font color="#009900"><strong>Nurbs</strong></font><font color="#009900"><strong> </strong></font><font color="#009900"><strong>Curves</strong></font><font color="#009900"><strong>"</strong></font><br /> -<font color="#000000"><strong>bw</strong></font> <font color="#ff0000">150</font><br /> -<font color="#000000"><strong>padding</strong></font> <font color="#ff0000">2</font><br /> -<font color="#000000"><strong>bsh</strong></font> <font color="#009900"><strong>"</strong></font><font color="#009900"><strong>roundRectangle</strong></font><font color="#009900"><strong>"</strong></font><br /> -<font color="#000000"><strong>rc</strong></font> <font color="#009900"><strong>"</strong></font><font color="#009900"><strong>ToggleNurbsCurves()</strong></font><font color="#009900"><strong>"</strong></font><br /> HUDCurvesButton<font color="#000000"><strong>;</strong></font><br /> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>gCurvesHudActive</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#ff0000">1</font><font color="#000000"><strong>;</strong></font> <br /><font color="#000000"><strong>}</strong></font><br /><font color="#000099"><strong>else</strong></font> <font color="#000000"><strong>{</strong></font><br /> <font color="#0000ff"><strong>headsUpDisplay</strong></font> -<font color="#000000"><strong>remove</strong></font> <font color="#009900"><strong>"</strong></font><font color="#009900"><strong>HUDCurvesButton</strong></font><font color="#009900"><strong>"</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>gCurvesHudActive</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#ff0000">0</font><font color="#000000"><strong>;</strong></font><br /><font color="#000000"><strong>}</strong></font><br /></font></pre></blockquote>Jacob Schieckhttp://www.blogger.com/profile/04562687762228940994noreply@blogger.com0tag:blogger.com,1999:blog-8763479184302466845.post-22727462546566843802010-10-20T10:03:00.000-07:002010-10-20T15:02:53.571-07:00Select UV Border EdgesSelecting border edges for the most part is relatively easy, but if you have a model where an internal edge shares the same vertices as two border vertices, it will also select those edges (ex. - a square polygon subdivided diagonally across the center into triangles). This fixes that problem (as long as the object is bigger than a square, which 99% of the time it is) <a href="http://forums.cgsociety.org/showthread.php?p=6735461">source</a><br /><br /><blockquote><pre><font color="#000000"><font color="#999999">//</font><font color="#999999"> </font><font color="#999999">select</font><font color="#999999"> </font><font color="#999999">UV</font><font color="#999999"> </font><font color="#999999">border</font><font color="#999999"> </font><font color="#999999">edges</font><font color="#999999"> </font><font color="#999999">and</font><font color="#999999"> </font><font color="#999999">remove</font><font color="#999999"> </font><font color="#999999">edges</font><font color="#999999"> </font><font color="#999999">that</font><font color="#999999"> </font><font color="#999999">share</font><font color="#999999"> </font><font color="#999999">uvs</font><font color="#999999"> </font><font color="#999999">with</font><font color="#999999"> </font><font color="#999999">the</font><font color="#999999"> </font><font color="#999999">borders</font><br /><font color="#999999">//</font><font color="#999999"> </font><font color="#999999">thus</font><font color="#999999"> </font><font color="#999999">eliminating</font><font color="#999999"> </font><font color="#999999">any</font><font color="#999999"> </font><font color="#999999">unwanted</font><font color="#999999"> </font><font color="#999999">internal</font><font color="#999999"> </font><font color="#999999">edges</font><br /><font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>currSelected</strong></font><font color="#000000"><strong>[</strong></font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>ls</strong></font> -<font color="#000000"><strong>sl</strong></font> -<font color="#000000"><strong>o</strong></font><font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /><font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>temp</strong></font><font color="#000000"><strong>[</strong></font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>ls</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>currSelected</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>+</strong></font><font color="#009900"><strong>"</strong></font><font color="#009900"><strong>.map[*]</strong></font><font color="#009900"><strong>"</strong></font>)<font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /><font color="#0000ff"><strong>select</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>temp</strong></font><font color="#000000"><strong>;</strong></font><br />polySelectBorderShell <font color="#ff0000">1</font><font color="#000000"><strong>;</strong></font><br />PolySelectConvert <font color="#ff0000">20</font><font color="#000000"><strong>;</strong></font><br /><font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>potentialEdges</strong></font><font color="#000000"><strong>[</strong></font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>=</strong></font><font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>filterExpand</strong></font> -<font color="#000000"><strong>ex</strong></font> <font color="#ff0000">1</font> -<font color="#000000"><strong>sm</strong></font> <font color="#ff0000">32</font><font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /><font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>removedEdges</strong></font><font color="#000000"><strong>[</strong></font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>;</strong></font><br /><font color="#000099"><strong>for</strong></font>(<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>eachEdge</strong></font> <font color="#000099"><strong>in</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>potentialEdges</strong></font>)<br /><font color="#000000"><strong>{</strong></font><br /> <font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>uvs</strong></font><font color="#000000"><strong>[</strong></font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font><font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>polyListComponentConversion</strong></font> -<font color="#000000"><strong>fe</strong></font> -<font color="#000000"><strong>tuv</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>eachEdge</strong></font><font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>uvs</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>ls</strong></font> -<font color="#000000"><strong>fl</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>uvs</strong></font><font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#000099"><strong>if</strong></font>(<font color="#0000ff"><strong>size</strong></font>(<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>uvs</strong></font>)<font color="#000000"><strong><=</strong></font><font color="#ff0000">2</font>)<br /> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>removedEdges</strong></font><font color="#000000"><strong>[</strong></font><font color="#0000ff"><strong>size</strong></font>(<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>removedEdges</strong></font>)<font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>eachEdge</strong></font><font color="#000000"><strong>;</strong></font><br /><font color="#000000"><strong>}</strong></font><br /><font color="#0000ff"><strong>select</strong></font> -<font color="#000000"><strong>d</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>removedEdges</strong></font><font color="#000000"><strong>;</strong></font><br /></font></pre></blockquote>Jacob Schieckhttp://www.blogger.com/profile/04562687762228940994noreply@blogger.com0tag:blogger.com,1999:blog-8763479184302466845.post-67031962192687881502010-10-11T09:43:00.000-07:002010-10-11T09:47:20.142-07:00Soft influence falloff for objectsThese two procedures will take an object, and influence surrounding objects based on their distance from the object, and a falloff distance specified. Similar to how the Soft Modification Tool works for meshes, but this is for objects.<br /><blockquote><pre><font color="#000000"><font color="#999999">//</font><br /><font color="#999999">//</font><font color="#999999"> </font><font color="#999999">TAKES</font><font color="#999999"> </font><font color="#999999">A</font><font color="#999999"> </font><font color="#999999">LOCATOR</font><font color="#999999"> </font><font color="#999999">THAT</font><font color="#999999"> </font><font color="#999999">INFLUENCES</font><font color="#999999"> </font><font color="#999999">SURROUNDING</font><font color="#999999"> </font><font color="#999999">OBJECTS</font><font color="#999999"> </font><font color="#999999">BASED</font><font color="#999999"> </font><font color="#999999">ON</font><font color="#999999"> </font><font color="#999999">THEIR</font><font color="#999999"> </font><font color="#999999">DISTANCE</font><font color="#999999"> </font><font color="#999999">FROM</font><font color="#999999"> </font><font color="#999999">IT</font><br /><font color="#999999">//</font><br /><br /><font color="#000099"><strong>global</strong></font> <font color="#000099"><strong>proc</strong></font> <font color="#000099"><strong>jsCreateSoftSelectLoc</strong></font>(<font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>locator</strong></font><font color="#000000"><strong>,</strong></font> <font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>objects</strong></font><font color="#000000"><strong>[</strong></font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>,</strong></font> <font color="#000099"><strong>float</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>falloffDistance</strong></font>) <font color="#000000"><strong>{</strong></font><br /> <br /> <font color="#000099"><strong>float</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>start</strong></font><font color="#000000"><strong>[</strong></font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>xform</strong></font> -<font color="#000000"><strong>q</strong></font> -<font color="#000000"><strong>ws</strong></font> -<font color="#000000"><strong>piv</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>locator</strong></font><font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /> <br /> <font color="#000099"><strong>for</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>i</strong></font><font color="#000000"><strong>=</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>;</strong></font><font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>i</strong></font><font color="#000000"><strong><</strong></font><font color="#0000ff"><strong>size</strong></font>(<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>objects</strong></font>)<font color="#000000"><strong>;</strong></font><font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>i</strong></font><font color="#000000"><strong>+</strong></font><font color="#000000"><strong>+</strong></font>) <font color="#000000"><strong>{</strong></font><br /> <font color="#000099"><strong>float</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>offsetVal</strong></font><font color="#000000"><strong>[</strong></font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>;</strong></font> <br /> <font color="#000099"><strong>float</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>curPos</strong></font><font color="#000000"><strong>[</strong></font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>xform</strong></font> -<font color="#000000"><strong>q</strong></font> -<font color="#000000"><strong>ws</strong></font> -<font color="#000000"><strong>piv</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>objects</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>i</strong></font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /> <br /> <font color="#999999">//</font><font color="#999999"> </font><font color="#999999">make</font><font color="#999999"> </font><font color="#999999">a</font><font color="#999999"> </font><font color="#999999">distance</font><font color="#999999"> </font><font color="#999999">dimension</font><font color="#999999"> </font><font color="#999999">node</font><font color="#999999"> </font><font color="#999999">to</font><font color="#999999"> </font><font color="#999999">find</font><font color="#999999"> </font><font color="#999999">the</font><font color="#999999"> </font><font color="#999999">distance,</font><font color="#999999"> </font><font color="#999999">then</font><font color="#999999"> </font><font color="#999999">find</font><font color="#999999"> </font><font color="#999999">the</font><font color="#999999"> </font><font color="#999999">ratio</font><font color="#999999"> </font><font color="#999999">based</font><font color="#999999"> </font><font color="#999999">of</font><font color="#999999"> </font><font color="#999999">the</font><font color="#999999"> </font><font color="#999999">input</font><br /> <font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>dis</strong></font><font color="#000000"><strong>[</strong></font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000099"><strong>jsCreateMeasureTool</strong></font>(<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>locator</strong></font><font color="#000000"><strong>,</strong></font><font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>objects</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>i</strong></font><font color="#000000"><strong>]</strong></font>)<font color="#000000"><strong>;</strong></font><br /> <font color="#000099"><strong>float</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>distance</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>getAttr</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>dis</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>+</strong></font><font color="#009900"><strong>"</strong></font><font color="#009900"><strong>.distance</strong></font><font color="#009900"><strong>"</strong></font>)<font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#000099"><strong>float</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>disRatio</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>distance</strong></font> <font color="#000000"><strong>/</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>falloffDistance</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#000099"><strong>if</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>disRatio</strong></font> <font color="#000000"><strong>></strong></font> <font color="#ff0000">1</font>) <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>disRatio</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#ff0000">1</font><font color="#000000"><strong>;</strong></font><br /> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>disRatio</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#ff0000">1</font> - <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>disRatio</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#000099"><strong>delete</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>dis</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>dis</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">1</font><font color="#000000"><strong>]</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>dis</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">2</font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>;</strong></font><br /> <br /> <font color="#999999">//</font><font color="#999999"> </font><font color="#999999">get</font><font color="#999999"> </font><font color="#999999">the</font><font color="#999999"> </font><font color="#999999">original</font><font color="#999999"> </font><font color="#999999">distance</font><font color="#999999"> </font><font color="#999999">between</font><font color="#999999"> </font><font color="#999999">them</font><br /> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>offsetVal</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>start</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font> - <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>curPos</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>offsetVal</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">1</font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>start</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">1</font><font color="#000000"><strong>]</strong></font> - <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>curPos</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">1</font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>offsetVal</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">2</font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>start</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">2</font><font color="#000000"><strong>]</strong></font> - <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>curPos</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">2</font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>;</strong></font><br /> <br /> <font color="#999999">//</font><font color="#999999"> </font><font color="#999999">make</font><font color="#999999"> </font><font color="#999999">it</font><font color="#999999"> </font><font color="#999999">so</font><font color="#999999"> </font><font color="#999999">we</font><font color="#999999"> </font><font color="#999999">can</font><font color="#999999"> </font><font color="#999999">just</font><font color="#999999"> </font><font color="#999999">add</font><font color="#999999"> </font><font color="#999999">a</font><font color="#999999"> </font><font color="#999999">value</font><font color="#999999"> </font><font color="#999999">to</font><font color="#999999"> </font><font color="#999999">them</font><font color="#999999"> </font><font color="#999999">by</font><font color="#999999"> </font><font color="#999999">finding</font><font color="#999999"> </font><font color="#999999">the</font><font color="#999999"> </font><font color="#999999">orig</font><font color="#999999"> </font><font color="#999999">pos</font><br /> <font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>plusNode</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>shadingNode</strong></font> -<font color="#000000"><strong>asUtility</strong></font> <font color="#0000ff"><strong>plusMinusAverage</strong></font><font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#0000ff"><strong>connectAttr</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>plusNode</strong></font><font color="#000000"><strong>+</strong></font><font color="#009900"><strong>"</strong></font><font color="#009900"><strong>.output3D</strong></font><font color="#009900"><strong>"</strong></font>) (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>objects</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>i</strong></font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>+</strong></font><font color="#009900"><strong>"</strong></font><font color="#009900"><strong>.t</strong></font><font color="#009900"><strong>"</strong></font>)<font color="#000000"><strong>;</strong></font><br /> <font color="#0000ff"><strong>setAttr</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>plusNode</strong></font><font color="#000000"><strong>+</strong></font><font color="#009900"><strong>"</strong></font><font color="#009900"><strong>.input3D[0]</strong></font><font color="#009900"><strong>"</strong></font>) <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>curPos</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>curPos</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">1</font><font color="#000000"><strong>]</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>curPos</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">2</font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>;</strong></font><br /> <br /> <font color="#999999">//</font><font color="#999999"> </font><font color="#999999">add</font><font color="#999999"> </font><font color="#999999">the</font><font color="#999999"> </font><font color="#999999">distance</font><font color="#999999"> </font><font color="#999999">minus</font><font color="#999999"> </font><font color="#999999">the</font><font color="#999999"> </font><font color="#999999">orignal</font><font color="#999999"> </font><font color="#999999">offset</font><br /> <font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>addNode</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>shadingNode</strong></font> -<font color="#000000"><strong>asUtility</strong></font> <font color="#0000ff"><strong>plusMinusAverage</strong></font><font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>multNode</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>shadingNode</strong></font> -<font color="#000000"><strong>asUtility</strong></font> <font color="#0000ff"><strong>multiplyDivide</strong></font><font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#0000ff"><strong>connectAttr</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>locator</strong></font><font color="#000000"><strong>+</strong></font><font color="#009900"><strong>"</strong></font><font color="#009900"><strong>.t</strong></font><font color="#009900"><strong>"</strong></font>) (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>addNode</strong></font><font color="#000000"><strong>+</strong></font><font color="#009900"><strong>"</strong></font><font color="#009900"><strong>.input3D[0]</strong></font><font color="#009900"><strong>"</strong></font>)<font color="#000000"><strong>;</strong></font><br /> <font color="#0000ff"><strong>setAttr</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>plusNode</strong></font><font color="#000000"><strong>+</strong></font><font color="#009900"><strong>"</strong></font><font color="#009900"><strong>.input3D[1]</strong></font><font color="#009900"><strong>"</strong></font>) <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>offsetVal</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>offsetVal</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">1</font><font color="#000000"><strong>]</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>offsetVal</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">2</font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#0000ff"><strong>setAttr</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>addNode</strong></font><font color="#000000"><strong>+</strong></font><font color="#009900"><strong>"</strong></font><font color="#009900"><strong>.operation</strong></font><font color="#009900"><strong>"</strong></font>) <font color="#ff0000">2</font><font color="#000000"><strong>;</strong></font><br /> <font color="#0000ff"><strong>connectAttr</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>addNode</strong></font><font color="#000000"><strong>+</strong></font><font color="#009900"><strong>"</strong></font><font color="#009900"><strong>.output3D</strong></font><font color="#009900"><strong>"</strong></font>) (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>multNode</strong></font><font color="#000000"><strong>+</strong></font><font color="#009900"><strong>"</strong></font><font color="#009900"><strong>.input1</strong></font><font color="#009900"><strong>"</strong></font>)<font color="#000000"><strong>;</strong></font><br /> <font color="#0000ff"><strong>setAttr</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>multNode</strong></font><font color="#000000"><strong>+</strong></font><font color="#009900"><strong>"</strong></font><font color="#009900"><strong>.input2</strong></font><font color="#009900"><strong>"</strong></font>) <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>disRatio</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>disRatio</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>disRatio</strong></font><font color="#000000"><strong>;</strong></font> <br /> <font color="#0000ff"><strong>connectAttr</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>multNode</strong></font><font color="#000000"><strong>+</strong></font><font color="#009900"><strong>"</strong></font><font color="#009900"><strong>.output</strong></font><font color="#009900"><strong>"</strong></font>) (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>plusNode</strong></font><font color="#000000"><strong>+</strong></font><font color="#009900"><strong>"</strong></font><font color="#009900"><strong>.input3D[1]</strong></font><font color="#009900"><strong>"</strong></font>)<font color="#000000"><strong>;</strong></font><br /> <font color="#000000"><strong>}</strong></font><br /><font color="#000000"><strong>}</strong></font><br /><br /><font color="#999999">//</font><br /><font color="#999999">//</font><font color="#999999"> </font><font color="#999999">CREATE</font><font color="#999999"> </font><font color="#999999">A</font><font color="#999999"> </font><font color="#999999">MEASUREMENT</font><font color="#999999"> </font><font color="#999999">TOOL</font><font color="#999999"> </font><font color="#999999">BETWEEN</font><font color="#999999"> </font><font color="#999999">TWO</font><font color="#999999"> </font><font color="#999999">OBJECTS</font><br /><font color="#999999">//</font><br /><br /><font color="#000099"><strong>global</strong></font> <font color="#000099"><strong>proc</strong></font> <font color="#000099"><strong>string</strong></font><font color="#000000"><strong>[</strong></font><font color="#000000"><strong>]</strong></font> <font color="#000099"><strong>jsCreateMeasureTool</strong></font>(<font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>start</strong></font><font color="#000000"><strong>,</strong></font> <font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>end</strong></font>) <font color="#000000"><strong>{</strong></font><br /> <font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>return</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#000099"><strong>float</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>startPos</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#000099"><strong>float</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>endPos</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>startPos</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>xform</strong></font> -<font color="#000000"><strong>q</strong></font> -<font color="#000000"><strong>ws</strong></font> -<font color="#000000"><strong>rp</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>start</strong></font><font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>endPos</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>xform</strong></font> -<font color="#000000"><strong>q</strong></font> -<font color="#000000"><strong>ws</strong></font> -<font color="#000000"><strong>rp</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>end</strong></font><font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>tmpLoc</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>spaceLocator</strong></font> -<font color="#000000"><strong>name</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>start</strong></font> <font color="#000000"><strong>+</strong></font> <font color="#009900"><strong>"</strong></font><font color="#009900"><strong>_distanceStart</strong></font><font color="#009900"><strong>"</strong></font>)<font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>tmpLoc2</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>spaceLocator</strong></font> -<font color="#000000"><strong>name</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>end</strong></font> <font color="#000000"><strong>+</strong></font> <font color="#009900"><strong>"</strong></font><font color="#009900"><strong>_distanceEnd</strong></font><font color="#009900"><strong>"</strong></font>)<font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#0000ff"><strong>move</strong></font> -<font color="#000000"><strong>a</strong></font> -<font color="#000000"><strong>ws</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>startPos</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>startPos</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">1</font><font color="#000000"><strong>]</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>startPos</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">2</font><font color="#000000"><strong>]</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>tmpLoc</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#0000ff"><strong>move</strong></font> -<font color="#000000"><strong>a</strong></font> -<font color="#000000"><strong>ws</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>endPos</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>endPos</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">1</font><font color="#000000"><strong>]</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>endPos</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">2</font><font color="#000000"><strong>]</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>tmpLoc2</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>;</strong></font> <br /> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>dimension</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>createNode</strong></font> <font color="#0000ff"><strong>distanceDimShape</strong></font> <font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#0000ff"><strong>connectAttr</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>tmpLoc</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>+</strong></font> <font color="#009900"><strong>"</strong></font><font color="#009900"><strong>.worldPosition[0]</strong></font><font color="#009900"><strong>"</strong></font>) (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>dimension</strong></font> <font color="#000000"><strong>+</strong></font> <font color="#009900"><strong>"</strong></font><font color="#009900"><strong>.startPoint</strong></font><font color="#009900"><strong>"</strong></font>)<font color="#000000"><strong>;</strong></font><br /> <font color="#0000ff"><strong>connectAttr</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>tmpLoc2</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>+</strong></font> <font color="#009900"><strong>"</strong></font><font color="#009900"><strong>.worldPosition[0]</strong></font><font color="#009900"><strong>"</strong></font>) (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>dimension</strong></font> <font color="#000000"><strong>+</strong></font> <font color="#009900"><strong>"</strong></font><font color="#009900"><strong>.endPoint</strong></font><font color="#009900"><strong>"</strong></font>)<font color="#000000"><strong>;</strong></font> <br /> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>parent</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>listRelatives</strong></font> -<font color="#000000"><strong>f</strong></font> -<font color="#000000"><strong>p</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>dimension</strong></font><font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>newName</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>rename</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>parent</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>start</strong></font> <font color="#000000"><strong>+</strong></font> <font color="#009900"><strong>"</strong></font><font color="#009900"><strong>_distance</strong></font><font color="#009900"><strong>"</strong></font>)<font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font> <br /> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>return</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>newName</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>return</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">1</font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>tmpLoc</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>return</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">2</font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>tmpLoc2</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#000099"><strong>return</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>return</strong></font><font color="#000000"><strong>;</strong></font><br /><font color="#000000"><strong>}</strong></font><br /></font></pre></blockquote>Jacob Schieckhttp://www.blogger.com/profile/04562687762228940994noreply@blogger.com0tag:blogger.com,1999:blog-8763479184302466845.post-3689161289488481072010-09-24T14:07:00.001-07:002010-09-24T14:12:38.658-07:00Finding the perfect pole vector postionSimple trick to finding the perfect pole vector position, so that when you create your constraint, your joint chain wont move at all! :)<br /><br /><blockquote><pre><font color="#000000"><font color="#999999">//</font><font color="#999999"> </font><font color="#999999">ik</font><font color="#999999"> </font><font color="#999999">chain</font><font color="#999999"> </font><font color="#999999">joint</font><font color="#999999"> </font><font color="#999999">list</font><br /><font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>ikJoints</strong></font><font color="#000000"><strong>[</strong></font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>{</strong></font><font color="#009900"><strong>"</strong></font><font color="#009900"><strong>joint1</strong></font><font color="#009900"><strong>"</strong></font><font color="#000000"><strong>,</strong></font><font color="#009900"><strong>"</strong></font><font color="#009900"><strong>joint2</strong></font><font color="#009900"><strong>"</strong></font><font color="#000000"><strong>,</strong></font><font color="#009900"><strong>"</strong></font><font color="#009900"><strong>joint3</strong></font><font color="#009900"><strong>"</strong></font><font color="#000000"><strong>}</strong></font><font color="#000000"><strong>;</strong></font><br /><font color="#999999">//</font><font color="#999999"> </font><font color="#999999">find</font><font color="#999999"> </font><font color="#999999">joint</font><font color="#999999"> </font><font color="#999999">positions</font><br /><font color="#000099"><strong>float</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>pos1</strong></font><font color="#000000"><strong>[</strong></font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>xform</strong></font> -<font color="#000000"><strong>q</strong></font> -<font color="#000000"><strong>ws</strong></font> -<font color="#000000"><strong>piv</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>ikJoints</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /><font color="#000099"><strong>float</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>pos2</strong></font><font color="#000000"><strong>[</strong></font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>xform</strong></font> -<font color="#000000"><strong>q</strong></font> -<font color="#000000"><strong>ws</strong></font> -<font color="#000000"><strong>piv</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>ikJoints</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">1</font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /><font color="#000099"><strong>float</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>pos3</strong></font><font color="#000000"><strong>[</strong></font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>xform</strong></font> -<font color="#000000"><strong>q</strong></font> -<font color="#000000"><strong>ws</strong></font> -<font color="#000000"><strong>piv</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>ikJoints</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">2</font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /><font color="#999999">//</font><font color="#999999"> </font><font color="#999999">create</font><font color="#999999"> </font><font color="#999999">a</font><font color="#999999"> </font><font color="#999999">3</font><font color="#999999"> </font><font color="#999999">vertex</font><font color="#999999"> </font><font color="#999999">plane</font><font color="#999999"> </font><font color="#999999">between</font><font color="#999999"> </font><font color="#999999">the</font><font color="#999999"> </font><font color="#999999">joints</font><font color="#999999"> </font><font color="#999999">and</font><font color="#999999"> </font><font color="#999999">add</font><font color="#999999"> </font><font color="#999999">a</font><font color="#999999"> </font><font color="#999999">move</font><font color="#999999"> </font><font color="#999999">vertex</font><font color="#999999"> </font><font color="#999999">node</font><br /><font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>rpPlane</strong></font><font color="#000000"><strong>[</strong></font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>polyCreateFacet</strong></font> -<font color="#000000"><strong>ch</strong></font> <font color="#000099"><strong>on</strong></font> -<font color="#000000"><strong>tx</strong></font> <font color="#ff0000">1</font> -<font color="#000000"><strong>s</strong></font> <font color="#ff0000">1</font> <br /> -<font color="#000000"><strong>p</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>pos1</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>pos1</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">1</font><font color="#000000"><strong>]</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>pos1</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">2</font><font color="#000000"><strong>]</strong></font> <br /> -<font color="#000000"><strong>p</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>pos3</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>pos3</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">1</font><font color="#000000"><strong>]</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>pos3</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">2</font><font color="#000000"><strong>]</strong></font> <br /> -<font color="#000000"><strong>p</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>pos2</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>pos2</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">1</font><font color="#000000"><strong>]</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>pos2</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">2</font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /><font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>polyMove</strong></font><font color="#000000"><strong>[</strong></font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>polyMoveVertex</strong></font> -<font color="#000000"><strong>constructionHistory</strong></font> <font color="#ff0000">1</font> -<font color="#000000"><strong>random</strong></font> <font color="#ff0000">0</font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>rpPlane</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>+</strong></font> <font color="#009900"><strong>"</strong></font><font color="#009900"><strong>.vtx[2]</strong></font><font color="#009900"><strong>"</strong></font>)<font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /><font color="#999999">//</font><font color="#999999"> </font><font color="#999999">now</font><font color="#999999"> </font><font color="#999999">move</font><font color="#999999"> </font><font color="#999999">that</font><font color="#999999"> </font><font color="#999999">vertex</font><font color="#999999"> </font><font color="#999999">back</font><font color="#999999"> </font><font color="#999999">or</font><font color="#999999"> </font><font color="#999999">forwards</font><font color="#999999"> </font><font color="#999999">or</font><font color="#999999"> </font><font color="#999999">whatever</font><font color="#999999"> </font><font color="#999999">direction</font><font color="#999999"> </font><font color="#999999">you</font><font color="#999999"> </font><font color="#999999">need</font><br /><font color="#0000ff"><strong>setAttr</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>polyMove</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>+</strong></font> <font color="#009900"><strong>"</strong></font><font color="#009900"><strong>.localTranslate</strong></font><font color="#009900"><strong>"</strong></font>) -<font color="#000000"><strong>type</strong></font> double3 <font color="#ff0000">0</font> -<font color="#000000"><strong>5</strong></font> <font color="#ff0000">0</font> <font color="#000000"><strong>;</strong></font><br /><font color="#999999">//</font><font color="#999999"> </font><font color="#999999">snap</font><font color="#999999"> </font><font color="#999999">your</font><font color="#999999"> </font><font color="#999999">controller</font><font color="#999999"> </font><font color="#999999">to</font><font color="#999999"> </font><font color="#999999">the</font><font color="#999999"> </font><font color="#999999">vertex</font><font color="#999999"> </font><font color="#999999">and</font><font color="#999999"> </font><font color="#999999">it'll</font><font color="#999999"> </font><font color="#999999">be</font><font color="#999999"> </font><font color="#999999">in</font><font color="#999999"> </font><font color="#999999">the</font><font color="#999999"> </font><font color="#999999">perfect</font><font color="#999999"> </font><font color="#999999">position!</font><br /></font></pre></blockquote>Jacob Schieckhttp://www.blogger.com/profile/04562687762228940994noreply@blogger.com0tag:blogger.com,1999:blog-8763479184302466845.post-80815347234041121922010-09-24T08:17:00.000-07:002010-09-24T14:20:29.981-07:00jEdit as a Mel IDEEveryone has opinions about what the best editor for MEL is, but for me it's jEdit. So I'm going to share my setup and how I use it.<br /><br /><span style="text-decoration: underline;"><strong>Step 1: Syntax Highlighting</strong></span><br />First off get jEdit (<a href="http://www.jedit.org">http://www.jedit.org</a>). You'll need syntax highlighter for Mel which you can get here. <a href="http://www.creativecrash.com/maya/downloads/applications/syntax-scripting/c/jedit-mel-syntax-highlighting-mode/description#tabs">http://www.creativecrash.com/maya/downloads/applications/syntax-scripting/c/jedit-mel-syntax-highlighting-mode/description#tabs</a><br /><br />Once you have them both extract the highlighter and put it in your installation directory here (<em>C:\Program Files\jEdit\modes<span style="font-style: normal;">)</span></em> but be sure not to overwrite the existing catalog file, simply open the mel on and copy the contents to the end of the existing one.<br /><br />That should do it for highlighting, you can adjust the colors in your <em>Utilities -> Global Options,</em> under <em>Syntax Highlighting</em>. Mine is setup like <a href="http://img185.imageshack.us/img185/609/syntaxcolors.jpg">this</a>.<br /><br /><span style="text-decoration: underline;"><strong>Step 2: Auto Completion </strong></span><br />A great plugin is <em>TextAutoComplete </em>which you can download under <em>Plugins -> Plugin Manager.</em> This will auto complete commands that you previously have typed in your buffer, standard in most editors.<br /><br /><span style="text-decoration: underline;"><strong>Step 3: Buffer Tabs </strong></span><br />Get this plugin in the <em>Plugin Manager</em> as well, makes tabs similar to your web browser for open files.<br /><br /><span style="text-decoration: underline;"><strong>Step 4: MEL Parsing</strong></span><br />Now this is by far the most complex and in some cases most useful tool. It will parse the current buffer and find procedures, variables, whatever u want basically. What it finds can be modified using regular expressions. It uses two plugins and some 3rd party software that pipes into jEdit. So in the plugin manager download <em>CtagsSideKick </em>and<em> SideKick</em>. You will also need to download Exuberant Ctags (<a href="http://ctags.sourceforge.net/">http://ctags.sourceforge.net/</a>) Get the source and binary zip file.<br /><br />Now extract those files into your .jedit folder under a new directory (<em>C:\Documents and Settings\USERNAME\.jedit\ctags\</em>) and copy that path to the ctags <em>Path Field</em> under the <em>CtagsSideKick Plugin Options</em> inside of jEdit, so it shoulder read: <em>C:/Documents and Settings/jacob.schieck/.jedit/ctags/ctags.exe</em> If you don't do this it wont work.<br /><br />Next you want to navigate to your user profile directory (<em>C:\Documents and Settings\USERNAME\</em>) or just %USERPROFILE% will take you there and make a new text document with the following contents:<br /><blockquote><font color="black">--langdef=mel<br />--langmap=mel:.mel<br /><br />--regex-mel=/\[ \t]*([$]+[a-zA-Z0-9_$]+)/\1/var string/<br />--regex-mel=/\[ \t]*([$]+[a-zA-Z0-9_$]+)/\1/var integer/<br />--regex-mel=/\[ \t]*([$]+[a-zA-Z0-9_$]+)/\1/var float/<br />--regex-mel=/\[ \t]*([$]+[a-zA-Z0-9_$]+)/\1/var matrix/<br />--regex-mel=/\[ \t]*([$]+[a-zA-Z0-9_$]+)/\1/var vector/<br /><br />--regex-mel=/^global proc([ \t]|string|int|float|matrix|vector|\[\])*([a-zA-Z0-9_]+)/\2/global procedure/<br />--regex-mel=/^proc([ \t]|string|int|float|matrix|vector|\[\])*([a-zA-Z0-9_]+)/\2/local procedure/<br /><br />--regex-C++=/[ \t]+\b(M[A-Za-z]+)[ \t]+([a-zA-Z0-9_]+)/\1 \2/maya api/</font></blockquote><br />Save it out as <em>ctags.cnf</em>. This will tell the ctags.exe how to parse apart you mel script into finding variables and procedures. Personally I don't use the variables and just use procedures so if you don't want them just delete those lines.<br /><br />Next you need to set up an environment variable pointing to that file. Technically, it's supposed to work without this step but it was the only way I got it work with jEdit. Right click on <em>My Computer</em> and click <em>Properties</em>. Go to the Advanced tab and at the bottom open up <em>Environment Variables</em>. Create a new <em>User Environment Variable</em> with the variable name "<strong>Files</strong>" without quotes and set the value to the path of your configuration file (<em>C:\Documents and Settings\jacob.schieck\ctags.cnf;</em>)<br /><br />Alright now that should be it! Open up jEdit, under your<em> SideKick Plugin Options </em>under the <em>Parser </em>sections find mel and set it to ctags. Now open a mel script, and under <em>Plugins -> SideKick,</em> click <em>SideKick </em>and a window should pop-up that lists all your procedures and variables. If it doesn't make sure the dropdown box at the top says ctags, if it doesn't change it and if it still doesn't work then something is wrong. Run through again and make sure you didn't miss any steps and if you still can't figure it out let me know and I'll try to help you out.<br /><br />And that's basically it! Those are all the plugins I use. I no longer use SendToMaya or whatever it was called, I just save and source my scripts manually now.Jacob Schieckhttp://www.blogger.com/profile/04562687762228940994noreply@blogger.com0tag:blogger.com,1999:blog-8763479184302466845.post-73111075604415026542010-09-17T08:51:00.000-07:002010-09-17T08:53:32.191-07:00Substep MatrixFinding middle points is easy, but what if you want to find a bunch of midpoints or evenly space out objects between two points. This little proc will generate a matrix of positions that are evenly spaced between two nodes.<br /><br /><blockquote><pre><font color="#000000"><font color="#000099"><strong>global</strong></font> <font color="#000099"><strong>proc</strong></font> <font color="#000099"><strong>matrix</strong></font> <font color="#000099"><strong>jsGenerateSubStepMatrix</strong></font>(<font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>obj1</strong></font><font color="#000000"><strong>,</strong></font> <font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>obj2</strong></font><font color="#000000"><strong>,</strong></font> <font color="#000099"><strong>int</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>divisions</strong></font>) <font color="#000000"><strong>{</strong></font><br /> <font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>objs</strong></font><font color="#000000"><strong>[</strong></font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>{</strong></font><font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>obj1</strong></font><font color="#000000"><strong>,</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>obj2</strong></font><font color="#000000"><strong>}</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#000099"><strong>matrix</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>subStepPos</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">20</font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">3</font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>;</strong></font><br /> <br /> <font color="#000099"><strong>float</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>position1</strong></font><font color="#000000"><strong>[</strong></font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>xform</strong></font> -<font color="#000000"><strong>q</strong></font> -<font color="#000000"><strong>ws</strong></font> -<font color="#000000"><strong>t</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>objs</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#000099"><strong>float</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>position2</strong></font><font color="#000000"><strong>[</strong></font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>xform</strong></font> -<font color="#000000"><strong>q</strong></font> -<font color="#000000"><strong>ws</strong></font> -<font color="#000000"><strong>t</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>objs</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">1</font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font> <br /> <font color="#000099"><strong>float</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>divideVec</strong></font><font color="#000000"><strong>[</strong></font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>divideVec</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>position2</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font> - <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>position1</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font>) <font color="#000000"><strong>/</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>divisions</strong></font> - <font color="#ff0000">1</font>)<font color="#000000"><strong>;</strong></font><br /> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>divideVec</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">1</font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>position2</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">1</font><font color="#000000"><strong>]</strong></font> - <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>position1</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">1</font><font color="#000000"><strong>]</strong></font>) <font color="#000000"><strong>/</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>divisions</strong></font> - <font color="#ff0000">1</font>)<font color="#000000"><strong>;</strong></font><br /> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>divideVec</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">2</font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>position2</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">2</font><font color="#000000"><strong>]</strong></font> - <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>position1</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">2</font><font color="#000000"><strong>]</strong></font>) <font color="#000000"><strong>/</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>divisions</strong></font> - <font color="#ff0000">1</font>)<font color="#000000"><strong>;</strong></font> <br /> <font color="#000099"><strong>for</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>i</strong></font><font color="#000000"><strong>=</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>;</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>i</strong></font><font color="#000000"><strong><</strong></font><font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>divisions</strong></font><font color="#000000"><strong>;</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>i</strong></font><font color="#000000"><strong>+</strong></font><font color="#000000"><strong>+</strong></font>) <font color="#000000"><strong>{</strong></font><br /> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>subStepPos</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>i</strong></font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>position1</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>+</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>divideVec</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>*</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>i</strong></font>)<font color="#000000"><strong>;</strong></font><br /> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>subStepPos</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>i</strong></font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">1</font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>position1</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">1</font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>+</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>divideVec</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">1</font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>*</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>i</strong></font>)<font color="#000000"><strong>;</strong></font><br /> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>subStepPos</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>i</strong></font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">2</font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>position1</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">2</font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>+</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>divideVec</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">2</font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>*</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>i</strong></font>)<font color="#000000"><strong>;</strong></font> <br /> <font color="#000000"><strong>}</strong></font><br /> <font color="#000099"><strong>return</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>subStepPos</strong></font><font color="#000000"><strong>;</strong></font><br /><font color="#000000"><strong>}</strong></font><br /></font></pre></blockquote>Jacob Schieckhttp://www.blogger.com/profile/04562687762228940994noreply@blogger.com0tag:blogger.com,1999:blog-8763479184302466845.post-10830937607163828112010-09-07T11:31:00.001-07:002010-09-07T11:34:53.192-07:00SMTP Email DeliveryHere is some basic code that allows you to send an email using python, which of course can then be called from MEL.<br /><br /><blockquote><pre><font color="#000000"><font color="#000099"><strong>def</strong></font> <font color="#000099"><strong>basicEmail</strong></font>(fromAddr,toAddr,subject,messageBody,debug<font color="#000000"><strong>=</strong></font><font color="#0000ff"><strong>False</strong></font>):<br /> <font color="#000099"><strong>import</strong></font> smtplib<br /> toList <font color="#000000"><strong>=</strong></font> toAddr<br /> <font color="#000099"><strong>if</strong></font> <font color="#0000ff"><strong>type</strong></font>(toAddr) <font color="#000000"><strong>=</strong></font><font color="#000000"><strong>=</strong></font> <font color="#0000ff"><strong>list</strong></font>:<br /> toList <font color="#000000"><strong>=</strong></font> <font color="#009900"><strong>'</strong></font><font color="#009900"><strong>,</strong></font><font color="#009900"><strong> </strong></font><font color="#009900"><strong>'</strong></font>.<font color="#000099"><strong>join</strong></font>(toAddr) <font color="#999999">#</font><font color="#999999"> </font><font color="#999999">this</font><font color="#999999"> </font><font color="#999999">is</font><font color="#999999"> </font><font color="#999999">a</font><font color="#999999"> </font><font color="#999999">single</font><font color="#999999"> </font><font color="#999999">string</font><font color="#999999"> </font><font color="#999999">,separated</font><font color="#999999"> </font><font color="#999999">list</font><font color="#999999"> </font><font color="#999999">of</font><font color="#999999"> </font><font color="#999999">the</font><font color="#999999"> </font><font color="#999999">to:</font><font color="#999999"> </font><font color="#999999">adresses</font><br /> mail <font color="#000000"><strong>=</strong></font> (<font color="#009900"><strong>'</strong></font><font color="#009900"><strong>From:</strong></font><font color="#009900"><strong> </strong></font><font color="#009900"><strong>'</strong></font><font color="#000000"><strong>+</strong></font>fromAddr<font color="#000000"><strong>+</strong></font><font color="#009900"><strong>'</strong></font><font color="#009900"><strong>\r\nTo:</strong></font><font color="#009900"><strong> </strong></font><font color="#009900"><strong>'</strong></font><font color="#000000"><strong>+</strong></font>toList<font color="#000000"><strong>+</strong></font><font color="#009900"><strong>'</strong></font><font color="#009900"><strong>\r\nSubject:</strong></font><font color="#009900"><strong> </strong></font><font color="#009900"><strong>'</strong></font><font color="#000000"><strong>+</strong></font>subject<font color="#000000"><strong>+</strong></font><font color="#009900"><strong>'</strong></font><font color="#009900"><strong>\r\n</strong></font><font color="#009900"><strong>'</strong></font><font color="#000000"><strong>+</strong></font>messageBody)<br /> server <font color="#000000"><strong>=</strong></font> smtplib.<font color="#000099"><strong>SMTP</strong></font>(<font color="#009900"><strong>'</strong></font><font color="#009900"><strong>mail.jacobschieck.com</strong></font><font color="#009900"><strong>'</strong></font>)<br /> server.<font color="#000099"><strong>set_debuglevel</strong></font>(debug)<br /> server.<font color="#000099"><strong>login</strong></font>(<font color="#009900"><strong>'</strong></font><font color="#009900"><strong>pym***@jacobschieck.com</strong></font><font color="#009900"><strong>'</strong></font>, <font color="#009900"><strong>'</strong></font><font color="#009900"><strong>pym***</strong></font><font color="#009900"><strong>'</strong></font>)<br /> server.<font color="#000099"><strong>sendmail</strong></font>(fromAddr,toAddr,mail) <br /> <font color="#0000ff"><strong>print</strong></font> <font color="#009900"><strong>"</strong></font><font color="#009900"><strong>Successfully</strong></font><font color="#009900"><strong> </strong></font><font color="#009900"><strong>sent</strong></font><font color="#009900"><strong> </strong></font><font color="#009900"><strong>email</strong></font><font color="#009900"><strong>"</strong></font><br /> server.<font color="#0000ff"><strong>quit</strong></font>()<br /><br /><font color="#000099"><strong>basicEmail</strong></font>(<font color="#009900"><strong>'</strong></font><font color="#009900"><strong>jschieck@gmail.com</strong></font><font color="#009900"><strong>'</strong></font>,<font color="#009900"><strong>'</strong></font><font color="#009900"><strong>jschieck@gmail.com</strong></font><font color="#009900"><strong>'</strong></font>,<font color="#009900"><strong>'</strong></font><font color="#009900"><strong> </strong></font><font color="#009900"><strong> </strong></font><font color="#009900"><strong>test</strong></font><font color="#009900"><strong>'</strong></font>,<font color="#009900"><strong>'</strong></font><font color="#009900"><strong>this</strong></font><font color="#009900"><strong> </strong></font><font color="#009900"><strong>is</strong></font><font color="#009900"><strong> </strong></font><font color="#009900"><strong>the</strong></font><font color="#009900"><strong> </strong></font><font color="#009900"><strong>msg</strong></font><font color="#009900"><strong> </strong></font><font color="#009900"><strong>body</strong></font><font color="#009900"><strong>'</strong></font>)<br /></font></pre></blockquote>Jacob Schieckhttp://www.blogger.com/profile/04562687762228940994noreply@blogger.com0tag:blogger.com,1999:blog-8763479184302466845.post-56752146534618884402010-08-12T08:26:00.000-07:002010-08-12T08:27:19.545-07:00Fix persp cameraSometimes your persp will begin to tumble on it's axis rather than rotate around the focused object. Quick fix is to just delete it and replace it, but you cannot delete it by default because it's set to be a startupCamera. This will change that attribute and replace it with a new one.<br /><br /><blockquote><pre><font color="#000000"><font color="#0000ff"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>camera</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000099"><strong>findStartUpCamera</strong></font>( <font color="#009900"><strong>"</strong></font><font color="#009900"><strong>persp</strong></font><font color="#009900"><strong>"</strong></font> )<font color="#000000"><strong>;</strong></font><br /><font color="#0000ff"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>camera2</strong></font><font color="#000000"><strong>[</strong></font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>camera</strong></font> -<font color="#000000"><strong>n</strong></font> persp -<font color="#000000"><strong>hc</strong></font> <font color="#009900"><strong>"</strong></font><font color="#009900"><strong>viewSet</strong></font><font color="#009900"><strong> </strong></font><font color="#009900"><strong>-p</strong></font><font color="#009900"><strong> </strong></font><font color="#009900"><strong>%camera</strong></font><font color="#009900"><strong>"</strong></font><font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /><font color="#0000ff"><strong>camera</strong></font> -<font color="#000000"><strong>e</strong></font> -<font color="#000000"><strong>sc</strong></font> <font color="#ff0000">0</font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>camera</strong></font><font color="#000000"><strong>;</strong></font><br /><font color="#0000ff"><strong>delete</strong></font> <font color="#009900"><strong>"</strong></font><font color="#009900"><strong>persp</strong></font><font color="#009900"><strong>"</strong></font><font color="#000000"><strong>;</strong></font><br /><font color="#0000ff"><strong>rename</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>camera2</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font> <font color="#009900"><strong>"</strong></font><font color="#009900"><strong>persp</strong></font><font color="#009900"><strong>"</strong></font><font color="#000000"><strong>;</strong></font><br /><font color="#0000ff"><strong>camera</strong></font> -<font color="#000000"><strong>e</strong></font> -<font color="#000000"><strong>sc</strong></font> <font color="#ff0000">1</font> <font color="#009900"><strong>"</strong></font><font color="#009900"><strong>persp</strong></font><font color="#009900"><strong>"</strong></font><font color="#000000"><strong>;</strong></font><br /></font></pre></blockquote>Jacob Schieckhttp://www.blogger.com/profile/04562687762228940994noreply@blogger.com0tag:blogger.com,1999:blog-8763479184302466845.post-81420504313237594802010-07-18T14:50:00.000-07:002010-07-18T14:59:56.453-07:00Code based on maya versionWith the implementation of 2011's fileDialog2 command (which by the way is amazing) you run into the problem of not being able to get it to work on older versions because the command doesn't exist in the version.<br /><br />Even writing a simple if statement won't work because the command will still get evaluated when you initially source the script. You can use the eval command to fix this though by putting your commands in a string, then evaluating that string.<br /><br />Mel Version:<br /><blockquote><pre><font color="#000000"><font color="#000099"><strong>float</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>v</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>about</strong></font> -<font color="#000000"><strong>version</strong></font><font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /><font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>eval</strong></font><font color="#000000"><strong>;</strong></font><br /><font color="#000099"><strong>if</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>v</strong></font> <font color="#000000"><strong><</strong></font> <font color="#ff0000">2011</font>) <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>eval</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#009933"><strong>"</strong></font><font color="#009933"><strong>fileDialog</strong></font><font color="#009933"><strong>"</strong></font><font color="#000000"><strong>;</strong></font><br /><font color="#000099"><strong>else</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>eval</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#009933"><strong>"</strong></font><font color="#009933"><strong>fileDialog2</strong></font><font color="#009933"><strong>"</strong></font><font color="#000000"><strong>;</strong></font><br /><font color="#0000ff"><strong>eval</strong></font>(<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>eval</strong></font>)<font color="#000000"><strong>;</strong></font><br /></font></pre></blockquote>Python Version:<br /><blockquote><pre><font color="#000000"><font color="#000099"><strong>import</strong></font> maya.cmds <font color="#000099"><strong>as</strong></font> cmds<br /><font color="#000099"><strong>import</strong></font> maya.mel <font color="#000099"><strong>as</strong></font> mel<br /><br />myVersion<font color="#000000"><strong>=</strong></font>cmds.<font color="#0000ff"><strong>about</strong></font>(v<font color="#000000"><strong>=</strong></font><font color="#0000ff"><strong>True</strong></font>)<br />myEval <font color="#000000"><strong>=</strong></font> <font color="#009933"><strong>"</strong></font><font color="#009933"><strong>"</strong></font><br /><font color="#000099"><strong>if</strong></font> myVersion <font color="#000000"><strong>!</strong></font><font color="#000000"><strong>=</strong></font> <font color="#ff0000">2011</font>:<br /> myEval<font color="#000000"><strong>=</strong></font>(<font color="#009933"><strong>"</strong></font><font color="#009933"><strong>fileDialog</strong></font><font color="#009933"><strong>"</strong></font>)<br /><font color="#000099"><strong>else</strong></font>:<br /> myEval<font color="#000000"><strong>=</strong></font>(<font color="#009933"><strong>"</strong></font><font color="#009933"><strong>fileDialog2</strong></font><font color="#009933"><strong>"</strong></font>)<br />fullPath<font color="#000000"><strong>=</strong></font>mel.<font color="#0000ff"><strong>eval</strong></font>(myEval)<br /></font></pre></blockquote>Jacob Schieckhttp://www.blogger.com/profile/04562687762228940994noreply@blogger.com0tag:blogger.com,1999:blog-8763479184302466845.post-87202392210362652862010-06-22T09:39:00.001-07:002010-06-22T10:00:01.438-07:00Make a perfect circle of objects in MELYou can use this to duplicate a perfect circle of objects, draw lines or all sorts of stuff.<br /><br /><blockquote><pre><font color="#000000"><font color="#000000"><strong>{</strong></font><br /><font color="#666666">//</font><font color="#666666"> </font><font color="#666666">Make</font><font color="#666666"> </font><font color="#666666">a</font><font color="#666666"> </font><font color="#666666">perfect</font><font color="#666666"> </font><font color="#666666">circle</font><font color="#666666"> </font><font color="#666666">of</font><font color="#666666"> </font><font color="#666666">objects!</font><br /><font color="#000099"><strong>proc</strong></font> <font color="#000099"><strong>float</strong></font> <font color="#9966ff">magicTrigFunctionX</font>(<font color="#000099"><strong>float</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>pointRatio</strong></font>)<font color="#000000"><strong>{</strong></font><br /> <font color="#000099"><strong>return</strong></font> <font color="#0000ff"><strong>cos</strong></font>(<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>pointRatio</strong></font><font color="#000000"><strong>*</strong></font><font color="#ff0000">2</font><font color="#000000"><strong>*</strong></font><font color="#ff0000">3</font>.<font color="#ff0000">14</font>)<font color="#000000"><strong>;</strong></font><br /><font color="#000000"><strong>}</strong></font><br /><font color="#000099"><strong>proc</strong></font> <font color="#000099"><strong>float</strong></font> <font color="#9966ff">magicTrigFunctionZ</font>(<font color="#000099"><strong>float</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>pointRatio</strong></font>)<font color="#000000"><strong>{</strong></font><br /> <font color="#000099"><strong>return</strong></font> <font color="#0000ff"><strong>sin</strong></font>(<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>pointRatio</strong></font><font color="#000000"><strong>*</strong></font><font color="#ff0000">2</font><font color="#000000"><strong>*</strong></font><font color="#ff0000">3</font>.<font color="#ff0000">14</font>)<font color="#000000"><strong>;</strong></font> <br /><font color="#000000"><strong>}</strong></font><br /><br /><font color="#000099"><strong>proc</strong></font> <font color="#9966ff">drawCircle</font>(<font color="#000099"><strong>float</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>centerX</strong></font><font color="#000000"><strong>,</strong></font> <font color="#000099"><strong>float</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>centerZ</strong></font><font color="#000000"><strong>,</strong></font> <font color="#000099"><strong>float</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>radius</strong></font><font color="#000000"><strong>,</strong></font> <font color="#000099"><strong>float</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>sides</strong></font>)<font color="#000000"><strong>{</strong></font><br /> <font color="#666666">//</font><font color="#666666"> </font><font color="#666666">Move</font><font color="#666666"> </font><font color="#666666">the</font><font color="#666666"> </font><font color="#666666">original</font><font color="#666666"> </font><font color="#666666">to</font><font color="#666666"> </font><font color="#666666">the</font><font color="#666666"> </font><font color="#666666">first</font><font color="#666666"> </font><font color="#666666">point</font><font color="#666666"> </font><font color="#666666">on</font><font color="#666666"> </font><font color="#666666">the</font><font color="#666666"> </font><font color="#666666">circle.</font><br /> <font color="#666666">//</font><font color="#666666"> </font><font color="#666666">Replace</font><font color="#666666"> </font><font color="#666666">newCube</font><font color="#666666"> </font><font color="#666666">with</font><font color="#666666"> </font><font color="#666666">your</font><font color="#666666"> </font><font color="#666666">object</font><font color="#666666"> </font><font color="#666666">below</font><br /> <font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>newCube</strong></font><font color="#000000"><strong>[</strong></font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#006600"><strong>polyCube</strong></font><font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>orig</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>newCube</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#0000ff"><strong>xform</strong></font> -<font color="#000000"><strong>t</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>centerX</strong></font> <font color="#000000"><strong>+</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>radius</strong></font>) <font color="#ff0000">0</font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>centerZ</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>newCube</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#666666">//</font><font color="#666666"> </font><font color="#666666">Run</font><font color="#666666"> </font><font color="#666666">the</font><font color="#666666"> </font><font color="#666666">loop</font><font color="#666666"> </font><font color="#666666">to</font><font color="#666666"> </font><font color="#666666">draw</font><font color="#666666"> </font><font color="#666666">the</font><font color="#666666"> </font><font color="#666666">circle</font><br /> <font color="#000099"><strong>for</strong></font>(<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>i</strong></font><font color="#000000"><strong>=</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>;</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>i</strong></font> <font color="#000000"><strong><</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>sides</strong></font> <font color="#000000"><strong>;</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>i</strong></font><font color="#000000"><strong>+</strong></font><font color="#000000"><strong>+</strong></font>)<font color="#000000"><strong>{</strong></font><br /> <font color="#000099"><strong>float</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>pointRatio</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>i</strong></font><font color="#000000"><strong>/</strong></font><font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>sides</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#000099"><strong>float</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>xSteps</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#9966ff">magicTrigFunctionX</font>(<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>pointRatio</strong></font>)<font color="#000000"><strong>;</strong></font><br /> <font color="#000099"><strong>float</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>zSteps</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#9966ff">magicTrigFunctionZ</font>(<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>pointRatio</strong></font>)<font color="#000000"><strong>;</strong></font><br /> <font color="#000099"><strong>float</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>pointX</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>centerX</strong></font> <font color="#000000"><strong>+</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>xSteps</strong></font> <font color="#000000"><strong>*</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>radius</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#000099"><strong>float</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>pointZ</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>centerZ</strong></font> <font color="#000000"><strong>+</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>zSteps</strong></font> <font color="#000000"><strong>*</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>radius</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>newCube</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>duplicate</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>newCube</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#0000ff"><strong>xform</strong></font> -<font color="#000000"><strong>t</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>pointX</strong></font> <font color="#ff0000">0</font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>pointZ</strong></font> -<font color="#000000"><strong>ro</strong></font> <font color="#ff0000">0</font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>pointRatio</strong></font><font color="#000000"><strong>*</strong></font>-<font color="#000000"><strong>360</strong></font>) <font color="#ff0000">0</font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>newCube</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#000000"><strong>}</strong></font><br /> <font color="#000099"><strong>delete</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>orig</strong></font><font color="#000000"><strong>;</strong></font><br /><font color="#000000"><strong>}</strong></font><br /><font color="#666666">//</font><font color="#666666"> </font><font color="#666666">Arguments</font><br /><font color="#666666">//</font><font color="#666666"> </font><font color="#666666">centerX,</font><font color="#666666"> </font><font color="#666666">centerZ,</font><font color="#666666"> </font><font color="#666666">radius,</font><font color="#666666"> </font><font color="#666666">number</font><font color="#666666"> </font><font color="#666666">of</font><font color="#666666"> </font><font color="#666666">objects</font><br /><font color="#9966ff">drawCircle</font>(<font color="#ff0000">0</font><font color="#000000"><strong>,</strong></font> <font color="#ff0000">0</font><font color="#000000"><strong>,</strong></font> <font color="#ff0000">200</font><font color="#000000"><strong>,</strong></font> <font color="#ff0000">100</font>)<font color="#000000"><strong>;</strong></font><br /><br /><font color="#000000"><strong>}</strong></font><br /></font></pre></blockquote>Jacob Schieckhttp://www.blogger.com/profile/04562687762228940994noreply@blogger.com0tag:blogger.com,1999:blog-8763479184302466845.post-14780709731661364862010-06-03T12:36:00.000-07:002010-06-03T12:41:09.851-07:00IK/FK Switch Ratio ExpressionsRather than using a constraint to two joints then changing the contraint values, sometimes I'll use and expression to drive the roll joints in arms/legs or whatever.<br /><blockquote><pre><font color="#000000"><font color="#666666">//</font><font color="#666666">roll</font><font color="#666666"> </font><font color="#666666">joint</font><font color="#666666"> </font><font color="#666666"> </font><font color="#666666">|wrist</font><font color="#666666"> </font><font color="#666666">IK</font><font color="#666666"> </font><font color="#666666">joint|ratio|switch</font><font color="#666666"> </font><font color="#666666">controller</font><font color="#666666"> </font><font color="#666666"> </font><font color="#666666"> </font><font color="#666666">|wrist</font><font color="#666666"> </font><font color="#666666">FK</font><font color="#666666"> </font><font color="#666666">joint|ratio|switch</font><font color="#666666"> </font><font color="#666666">controller</font><br />roll_jnt.rx <font color="#000000"><strong>=</strong></font> ((wristIK_jnt.rx <font color="#000000"><strong>*</strong></font> .<font color="#ff0000">3</font>)<font color="#000000"><strong>*</strong></font><font color="#000099"><strong>switch</strong></font>.IKFK) <font color="#000000"><strong>+</strong></font> ((wristFK_jnt.rx <font color="#000000"><strong>*</strong></font> .<font color="#ff0000">3</font>)<font color="#000000"><strong>*</strong></font><font color="#0000ff"><strong>abs</strong></font>(<font color="#000099"><strong>switch</strong></font>.IKFK - <font color="#ff0000">1</font>))<font color="#000000"><strong>;</strong></font><br /></font></pre></blockquote><br />In this expression I am multiplying the wrists rotation by a ratio (0.3) to get the amount of rotation I want on the roll joint. For the IK I am then multiplying it by the value of the switch which goes from 0-1. That way if I'm in FK mode it doesn't get any influence. For the FK you do the same thing but subtract 1 and take the absolute value to get 0-1 but reversed from the attribute.<br /><br />So:<br /><b>IK MODE</b><br /><i>x</i> = ((30 * 0.3) * 1) + ((60 * 0.3) * abs(1 - 1))<br /><i>x</i> = (9 * 1) + (18 * abs(0))<br /><i>x</i> = 9 + 0<br /><i>x</i> = 9<br /><br /><b>FK MODE</b><br /><i>x</i> = ((30 * 0.3) * 0) + ((60 * 0.3) * abs(0 - 1))<br /><i>x</i> = (9 * 0) + (18 * abs(-1))<br /><i>x</i> = 0 + 18<br /><i>x</i> = 18<br /><br />Not really MEL but still a handy trick.Jacob Schieckhttp://www.blogger.com/profile/04562687762228940994noreply@blogger.com0tag:blogger.com,1999:blog-8763479184302466845.post-15559652675929499652010-06-02T12:09:00.001-07:002010-06-02T12:12:26.588-07:00Delete unused materials OnlyThis spawned off of <a href="http://forums.cgsociety.org/showthread.php?f=89&t=885657&page=1"><b>this thread</b></a> about deteremining if a material is in use or not.<br /><br />"Delete Unused Nodes" in the hypershade is great, but what if you don't want to get rid of all those textures and only materials?<br /><br /><blockquote><pre><font color="#000000"><font color="#000099"><strong>for</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>c</strong></font> <font color="#000099"><strong>in</strong></font> <font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>ls</strong></font> -<font color="#000000"><strong>materials</strong></font><font color="#000000"><strong>`</strong></font>) <font color="#000000"><strong>{</strong></font><br /> <font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>outputs</strong></font><font color="#000000"><strong>[</strong></font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>SG</strong></font><font color="#000000"><strong>[</strong></font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>{</strong></font><font color="#000000"><strong>}</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>outputs</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#9966ff">stringArrayRemoveDuplicates</font>(<font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>listConnections</strong></font> -<font color="#000000"><strong>destination</strong></font> <font color="#ff0000">1</font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>c</strong></font><font color="#000000"><strong>`</strong></font>)<font color="#000000"><strong>;</strong></font><br /> <font color="#000099"><strong>for</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>c2</strong></font> <font color="#000099"><strong>in</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>outputs</strong></font>) <font color="#000000"><strong>{</strong></font><br /> <font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>type</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#0000ff"><strong>nodeType</strong></font>(<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>c2</strong></font>)<font color="#000000"><strong>;</strong></font><br /> <font color="#000099"><strong>if</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>type</strong></font> <font color="#000000"><strong>=</strong></font><font color="#000000"><strong>=</strong></font> <font color="#009933"><strong>"</strong></font><font color="#009933"><strong>shadingEngine</strong></font><font color="#009933"><strong>"</strong></font>) <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>SG</strong></font><font color="#000000"><strong>[</strong></font><font color="#0000ff"><strong>size</strong></font>(<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>SG</strong></font>)<font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>c2</strong></font><font color="#000000"><strong>;</strong></font> <br /> <font color="#000000"><strong>}</strong></font><br /> <font color="#000099"><strong>if</strong></font> (<font color="#0000ff"><strong>size</strong></font>(<font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>listConnections</strong></font> -<font color="#000000"><strong>source</strong></font> <font color="#ff0000">1</font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>SG</strong></font><font color="#000000"><strong>[</strong></font><font color="#0000ff"><strong>size</strong></font>(<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>SG</strong></font>)-<font color="#000000"><strong>1</strong></font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>+</strong></font> <font color="#009933"><strong>"</strong></font><font color="#009933"><strong>.dagSetMembers</strong></font><font color="#009933"><strong>"</strong></font>)<font color="#000000"><strong>`</strong></font>) <font color="#000000"><strong>=</strong></font><font color="#000000"><strong>=</strong></font> <font color="#ff0000">0</font>) <font color="#000099"><strong>delete</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>c</strong></font><font color="#000000"><strong>;</strong></font><br /><font color="#000000"><strong>}</strong></font><br /></font></pre></blockquote>Jacob Schieckhttp://www.blogger.com/profile/04562687762228940994noreply@blogger.com0tag:blogger.com,1999:blog-8763479184302466845.post-51829037576443848592010-06-01T07:11:00.000-07:002010-06-01T07:12:47.056-07:00MEL ScopeAn excellent post was made about MEL scripting and scope of variables, check it out: <a href="http://forums.cgsociety.org/showpost.php?p=6538895&postcount=17">HERE</a>Jacob Schieckhttp://www.blogger.com/profile/04562687762228940994noreply@blogger.com0tag:blogger.com,1999:blog-8763479184302466845.post-17042145672354077402010-05-24T14:46:00.000-07:002010-05-24T14:47:55.539-07:00Swap object namesOkay so I didn't make any handy scripts at work today so I'm sharing one that I have on my custom marking menu. It just simply swaps the name of two objects. Handy if you need to remake a joint chain and don't want to rename them all.<br /><br /><blockquote><pre><font color="#000000"><font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>s</strong></font><font color="#000000"><strong>[</strong></font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>ls</strong></font> -<font color="#000000"><strong>sl</strong></font><font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /><font color="#000099"><strong>if</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>s</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font><font color="#000000"><strong>=</strong></font> <font color="#009933"><strong>"</strong></font><font color="#009933"><strong>"</strong></font>) <font color="#0000ff"><strong>error</strong></font> <font color="#009933"><strong>"</strong></font><font color="#009933"><strong>Make</strong></font><font color="#009933"><strong> </strong></font><font color="#009933"><strong>a</strong></font><font color="#009933"><strong> </strong></font><font color="#009933"><strong>selection!</strong></font><font color="#009933"><strong>"</strong></font><font color="#000000"><strong>;</strong></font><br /><font color="#000099"><strong>else</strong></font> <font color="#000000"><strong>{</strong></font><br /> <font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>num1</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>s</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>num2</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>s</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">1</font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#0000ff"><strong>rename</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>num1</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>num1</strong></font> <font color="#000000"><strong>+</strong></font> <font color="#009933"><strong>"</strong></font><font color="#009933"><strong>TEMP</strong></font><font color="#009933"><strong>"</strong></font>)<font color="#000000"><strong>;</strong></font><br /> <font color="#0000ff"><strong>rename</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>num2</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>num1</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#0000ff"><strong>rename</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>num1</strong></font> <font color="#000000"><strong>+</strong></font> <font color="#009933"><strong>"</strong></font><font color="#009933"><strong>TEMP</strong></font><font color="#009933"><strong>"</strong></font>) <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>num2</strong></font><font color="#000000"><strong>;</strong></font><br /><font color="#000000"><strong>}</strong></font><br /></font></pre></blockquote>Jacob Schieckhttp://www.blogger.com/profile/04562687762228940994noreply@blogger.com0tag:blogger.com,1999:blog-8763479184302466845.post-82897951845873634012010-05-21T08:14:00.001-07:002010-05-21T08:15:38.867-07:00Substitute names "left" for "right"A quick script to replace something in an object name with something else, or simply just remove something by leaving it blank.<br /><br /><blockquote><pre><font color="#000000"><font color="#000099"><strong>global</strong></font> <font color="#000099"><strong>proc</strong></font> <font color="#9966ff">doNameReplace</font>() <font color="#000000"><strong>{</strong></font><br /> <font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>s</strong></font><font color="#000000"><strong>[</strong></font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>ls</strong></font> -<font color="#000000"><strong>sl</strong></font><font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>r</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>textField</strong></font> -<font color="#000000"><strong>q</strong></font> -<font color="#000000"><strong>text</strong></font> rField<font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>w</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>textField</strong></font> -<font color="#000000"><strong>q</strong></font> -<font color="#000000"><strong>text</strong></font> wField<font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#000099"><strong>for</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>c</strong></font> <font color="#000099"><strong>in</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>s</strong></font>) <font color="#000000"><strong>{</strong></font><br /> <font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>new</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#9966ff">substituteAllString</font>(<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>c</strong></font><font color="#000000"><strong>,</strong></font><font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>r</strong></font><font color="#000000"><strong>,</strong></font><font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>w</strong></font>)<font color="#000000"><strong>;</strong></font><br /> <font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>split</strong></font><font color="#000000"><strong>[</strong></font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#0000ff"><strong>tokenize</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>new</strong></font> <font color="#009933"><strong>"</strong></font><font color="#009933"><strong>|</strong></font><font color="#009933"><strong>"</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>split</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#0000ff"><strong>rename</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>c</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>split</strong></font><font color="#000000"><strong>[</strong></font><font color="#0000ff"><strong>size</strong></font>(<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>split</strong></font>) - <font color="#ff0000">1</font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#0000ff"><strong>deleteUI</strong></font> replaceNameWin<font color="#000000"><strong>;</strong></font><br /> <font color="#000000"><strong>}</strong></font><br /><font color="#000000"><strong>}</strong></font><br /><font color="#000099"><strong>if</strong></font> (<font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>window</strong></font> -<font color="#000000"><strong>ex</strong></font> replaceNameWin<font color="#000000"><strong>`</strong></font>) <font color="#0000ff"><strong>deleteUI</strong></font> replaceNameWin<font color="#000000"><strong>;</strong></font><br /><font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>win</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>window</strong></font> -<font color="#000000"><strong>mnb</strong></font> <font color="#ff0000">0</font> -<font color="#000000"><strong>mxb</strong></font> <font color="#ff0000">0</font> -<font color="#000000"><strong>t</strong></font> <font color="#009933"><strong>"</strong></font><font color="#009933"><strong>Name</strong></font><font color="#009933"><strong> </strong></font><font color="#009933"><strong>Replace</strong></font><font color="#009933"><strong>"</strong></font> replaceNameWin<font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /><font color="#0000ff"><strong>columnLayout</strong></font><font color="#000000"><strong>;</strong></font><br /><font color="#0000ff"><strong>rowColumnLayout</strong></font> -<font color="#000000"><strong>nc</strong></font> <font color="#ff0000">4</font> -<font color="#000000"><strong>cw</strong></font> <font color="#ff0000">1</font> <font color="#ff0000">50</font> -<font color="#000000"><strong>cw</strong></font> <font color="#ff0000">2</font> <font color="#ff0000">75</font> -<font color="#000000"><strong>cw</strong></font> <font color="#ff0000">3</font> <font color="#ff0000">50</font> -<font color="#000000"><strong>cw</strong></font> <font color="#ff0000">4</font> <font color="#ff0000">75</font> -<font color="#000000"><strong>cs</strong></font> <font color="#ff0000">1</font> <font color="#ff0000">10</font><font color="#000000"><strong>;</strong></font><br /><br /><font color="#0000ff"><strong>text</strong></font> -<font color="#000000"><strong>l</strong></font> <font color="#009933"><strong>"</strong></font><font color="#009933"><strong>Replace:</strong></font><font color="#009933"><strong>"</strong></font><font color="#000000"><strong>;</strong></font><br /><font color="#0000ff"><strong>textField</strong></font> rField<font color="#000000"><strong>;</strong></font><br /><font color="#0000ff"><strong>text</strong></font> -<font color="#000000"><strong>l</strong></font> <font color="#009933"><strong>"</strong></font><font color="#009933"><strong> </strong></font><font color="#009933"><strong> </strong></font><font color="#009933"><strong> </strong></font><font color="#009933"><strong> </strong></font><font color="#009933"><strong>with</strong></font><font color="#009933"><strong> </strong></font><font color="#009933"><strong>"</strong></font><font color="#000000"><strong>;</strong></font><br /><font color="#0000ff"><strong>textField</strong></font> wField<font color="#000000"><strong>;</strong></font><br /><font color="#0000ff"><strong>setParent</strong></font>..<font color="#000000"><strong>;</strong></font><br /><font color="#0000ff"><strong>rowColumnLayout</strong></font> -<font color="#000000"><strong>nc</strong></font> <font color="#ff0000">2</font> -<font color="#000000"><strong>cw</strong></font> <font color="#ff0000">1</font> <font color="#ff0000">125</font> -<font color="#000000"><strong>cw</strong></font> <font color="#ff0000">2</font> <font color="#ff0000">125</font> -<font color="#000000"><strong>cs</strong></font> <font color="#ff0000">1</font> <font color="#ff0000">10</font><font color="#000000"><strong>;</strong></font><br /><font color="#0000ff"><strong>button</strong></font> -<font color="#000000"><strong>l</strong></font> <font color="#009933"><strong>"</strong></font><font color="#009933"><strong>Apply</strong></font><font color="#009933"><strong>"</strong></font> -<font color="#000000"><strong>c</strong></font> <font color="#009933"><strong>"</strong></font><font color="#009933"><strong>doNameReplace</strong></font><font color="#009933"><strong>"</strong></font><font color="#000000"><strong>;</strong></font><br /><font color="#0000ff"><strong>button</strong></font> -<font color="#000000"><strong>l</strong></font> <font color="#009933"><strong>"</strong></font><font color="#009933"><strong>Cancel</strong></font><font color="#009933"><strong>"</strong></font> -<font color="#000000"><strong>c</strong></font> <font color="#009933"><strong>"</strong></font><font color="#009933"><strong>deleteUI</strong></font><font color="#009933"><strong> </strong></font><font color="#009933"><strong>$win</strong></font><font color="#009933"><strong>"</strong></font><font color="#000000"><strong>;</strong></font><br /><font color="#0000ff"><strong>showWindow</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>win</strong></font><font color="#000000"><strong>;</strong></font><br /><font color="#0000ff"><strong>window</strong></font> -<font color="#000000"><strong>e</strong></font> -<font color="#000000"><strong>w</strong></font> <font color="#ff0000">275</font> -<font color="#000000"><strong>h</strong></font> <font color="#ff0000">75</font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>win</strong></font><font color="#000000"><strong>;</strong></font><br /></font></pre></blockquote>Jacob Schieckhttp://www.blogger.com/profile/04562687762228940994noreply@blogger.com0tag:blogger.com,1999:blog-8763479184302466845.post-11360571843758910202010-05-21T07:44:00.000-07:002010-05-21T08:11:57.618-07:00Flood uncolored vertexes with whiteIf you working in games, baking occlusion, or just messing with vertex coloring in general a problem occurs when you try to combine two meshes when not all the vertexes have a color assigned to them. It will scramble all your colors so this little code snippet will change any of them that don't have color (or black ones I knooowww, it's a quick fix) with white, then allowing you to combine objects with no coloring with ones that have it.<br /><br /><blockquote><pre><font color="#000000">PolySelectConvert <font color="#ff0000">3</font><font color="#000000"><strong>;</strong></font><br /><font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>s</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>ls</strong></font> -<font color="#000000"><strong>fl</strong></font> -<font color="#000000"><strong>sl</strong></font><font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /><br /><font color="#000099"><strong>for</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>i</strong></font><font color="#000000"><strong>=</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>;</strong></font><font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>i</strong></font><font color="#000000"><strong><</strong></font><font color="#0000ff"><strong>size</strong></font>(<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>s</strong></font>)<font color="#000000"><strong>;</strong></font><font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>i</strong></font><font color="#000000"><strong>+</strong></font><font color="#000000"><strong>+</strong></font>) <font color="#000000"><strong>{</strong></font><br /> <font color="#000099"><strong>float</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>colorR</strong></font><font color="#000000"><strong>[</strong></font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#006600"><strong>polyColorPerVertex</strong></font> -<font color="#000000"><strong>q</strong></font> -<font color="#000000"><strong>colorR</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>s</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>i</strong></font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#000099"><strong>float</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>colorG</strong></font><font color="#000000"><strong>[</strong></font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#006600"><strong>polyColorPerVertex</strong></font> -<font color="#000000"><strong>q</strong></font> -<font color="#000000"><strong>colorG</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>s</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>i</strong></font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#000099"><strong>float</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>colorB</strong></font><font color="#000000"><strong>[</strong></font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#006600"><strong>polyColorPerVertex</strong></font> -<font color="#000000"><strong>q</strong></font> -<font color="#000000"><strong>colorB</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>s</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>i</strong></font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /><br /> <font color="#000099"><strong>if</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>colorR</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font><font color="#000000"><strong>=</strong></font> <font color="#ff0000">0</font> <font color="#000000"><strong>&</strong></font><font color="#000000"><strong>&</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>colorG</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font><font color="#000000"><strong>=</strong></font> <font color="#ff0000">0</font> <font color="#000000"><strong>&</strong></font><font color="#000000"><strong>&</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>colorB</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font><font color="#000000"><strong>=</strong></font> <font color="#ff0000">0</font>) <font color="#000000"><strong>{</strong></font><br /> <font color="#006600"><strong>polyColorPerVertex</strong></font> -<font color="#000000"><strong>colorR</strong></font> <font color="#ff0000">1</font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>s</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>i</strong></font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#006600"><strong>polyColorPerVertex</strong></font> -<font color="#000000"><strong>colorG</strong></font> <font color="#ff0000">1</font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>s</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>i</strong></font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#006600"><strong>polyColorPerVertex</strong></font> -<font color="#000000"><strong>colorB</strong></font> <font color="#ff0000">1</font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>s</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>i</strong></font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#000000"><strong>}</strong></font><br /> <font color="#000099"><strong>int</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>num</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#0000ff"><strong>size</strong></font>(<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>s</strong></font>) - <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>i</strong></font><font color="#000000"><strong>;</strong></font> <br /> <font color="#0000ff"><strong>print</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>num</strong></font><font color="#000000"><strong>+</strong></font><font color="#009933"><strong>"</strong></font><font color="#009933"><strong> </strong></font><font color="#009933"><strong>left\n</strong></font><font color="#009933"><strong>"</strong></font>)<font color="#000000"><strong>;</strong></font><br /><font color="#000000"><strong>}</strong></font><br /><font color="#0000ff"><strong>print</strong></font> <font color="#009933"><strong>"</strong></font><font color="#009933"><strong>DONE!</strong></font><font color="#009933"><strong>"</strong></font><font color="#000000"><strong>;</strong></font><br /></font></pre></blockquote>Jacob Schieckhttp://www.blogger.com/profile/04562687762228940994noreply@blogger.com0tag:blogger.com,1999:blog-8763479184302466845.post-8785764200317403422010-05-14T12:42:00.000-07:002010-05-24T14:50:27.450-07:00Using evalDeferred() to dynamically update window sizeOften times when making tools the GUI changes if you add new buttons/controls, change between tabs, or expand and collapse frameLayouts. Using evalDeferred and querying the size of a top layout in your window is a quick way to update the size of your window (or any other control for that matter) without hardcoding in values.<br /><br />The reason behind using evalDeferred rather than just calling the procedure is that if you are loading a complex GUI, or building it on the fly, it might execute the bit of code before Maya has updated it's values. This way you make sure that it's not querying the values of the layouts before they have updated.<br /><br /><blockquote><pre><font color="#000000"><font color="#666666">//</font><font color="#666666"> </font><font color="#666666">evalDeferred("command")</font><font color="#666666"> </font><font color="#666666">WILL</font><font color="#666666"> </font><font color="#666666">WAIT</font><font color="#666666"> </font><font color="#666666">TILL</font><font color="#666666"> </font><font color="#666666">MAYA</font><font color="#666666"> </font><font color="#666666">IS</font><font color="#666666"> </font><font color="#666666">IDLE</font><br /><br /><font color="#666666">//</font><font color="#666666"> </font><font color="#666666">QUERY</font><font color="#666666"> </font><font color="#666666">THE</font><font color="#666666"> </font><font color="#666666">HEIGHT</font><font color="#666666"> </font><font color="#666666">OF</font><font color="#666666"> </font><font color="#666666">THE</font><font color="#666666"> </font><font color="#666666">TOP</font><font color="#666666"> </font><font color="#666666">MOST</font><font color="#666666"> </font><font color="#666666">LAYOUT</font><font color="#666666"> </font><font color="#666666">AND</font><font color="#666666"> </font><font color="#666666">MAKE</font><font color="#666666"> </font><font color="#666666">THAT</font><font color="#666666"> </font><font color="#666666">THE</font><font color="#666666"> </font><font color="#666666">WINDOW</font><font color="#666666"> </font><font color="#666666">HEIGHT</font><br /><font color="#000099"><strong>global</strong></font> <font color="#000099"><strong>proc</strong></font> <font color="#9966ff">updateMyWinSize</font>() <font color="#000000"><strong>{</strong></font><br /> <font color="#000099"><strong>int</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>tabSize</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>rowColumnLayout</strong></font> -<font color="#000000"><strong>q</strong></font> -<font color="#000000"><strong>h</strong></font> myTopLayout<font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>tabSize</strong></font> <font color="#000000"><strong>+</strong></font><font color="#000000"><strong>=</strong></font> <font color="#ff0000">30</font><font color="#000000"><strong>;</strong></font><br /> <font color="#0000ff"><strong>window</strong></font> -<font color="#000000"><strong>e</strong></font> -<font color="#000000"><strong>w</strong></font> <font color="#ff0000">160</font> -<font color="#000000"><strong>h</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>tabSize</strong></font> autoUpdateWin<font color="#000000"><strong>;</strong></font><br /><font color="#000000"><strong>}</strong></font><br /><br /><font color="#666666">//</font><font color="#666666"> </font><font color="#666666">GET</font><font color="#666666"> </font><font color="#666666">ALL</font><font color="#666666"> </font><font color="#666666">THE</font><font color="#666666"> </font><font color="#666666">CHILDREN</font><font color="#666666"> </font><font color="#666666">IN</font><font color="#666666"> </font><font color="#666666">THE</font><font color="#666666"> </font><font color="#666666">LAYOUT</font><font color="#666666"> </font><font color="#666666">AND</font><font color="#666666"> </font><font color="#666666">DELETE</font><font color="#666666"> </font><font color="#666666">THEM</font><br /><font color="#666666">//</font><font color="#666666"> </font><font color="#666666">THEN</font><font color="#666666"> </font><font color="#666666">UPDATE</font><font color="#666666"> </font><font color="#666666">THE</font><font color="#666666"> </font><font color="#666666">WINDOW</font><font color="#666666"> </font><font color="#666666">SIZE</font><br /><font color="#000099"><strong>global</strong></font> <font color="#000099"><strong>proc</strong></font> <font color="#9966ff">clearButtons</font>() <font color="#000000"><strong>{</strong></font><br /> <font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>children</strong></font><font color="#000000"><strong>[</strong></font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>columnLayout</strong></font> -<font color="#000000"><strong>q</strong></font> -<font color="#000000"><strong>ca</strong></font> newButtonLayout<font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#000099"><strong>for</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>c</strong></font> <font color="#000099"><strong>in</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>children</strong></font>) <font color="#000000"><strong>{</strong></font><br /> <font color="#0000ff"><strong>deleteUI</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>c</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#000000"><strong>}</strong></font><br /> <font color="#0000ff"><strong>evalDeferred</strong></font>(<font color="#009933"><strong>"</strong></font><font color="#009933"><strong>updateMyWinSize</strong></font><font color="#009933"><strong>"</strong></font>)<font color="#000000"><strong>;</strong></font><br /><font color="#000000"><strong>}</strong></font><br /><br /><font color="#666666">//</font><font color="#666666"> </font><font color="#666666">ADDS</font><font color="#666666"> </font><font color="#666666">A</font><font color="#666666"> </font><font color="#666666">NEW</font><font color="#666666"> </font><font color="#666666">BUTTON</font><br /><font color="#000099"><strong>global</strong></font> <font color="#000099"><strong>proc</strong></font> <font color="#9966ff">addNewButton</font>() <font color="#000000"><strong>{</strong></font><br /> <font color="#0000ff"><strong>setParent</strong></font> newButtonLayout<font color="#000000"><strong>;</strong></font><br /> <font color="#0000ff"><strong>button</strong></font> -<font color="#000000"><strong>l</strong></font> <font color="#009933"><strong>"</strong></font><font color="#009933"><strong>NEW</strong></font><font color="#009933"><strong> </strong></font><font color="#009933"><strong>BUTTON</strong></font><font color="#009933"><strong> </strong></font><font color="#009933"><strong>YAY!!!!</strong></font><font color="#009933"><strong>"</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#0000ff"><strong>evalDeferred</strong></font>(<font color="#009933"><strong>"</strong></font><font color="#009933"><strong>updateMyWinSize</strong></font><font color="#009933"><strong>"</strong></font>)<font color="#000000"><strong>;</strong></font> <br /><font color="#000000"><strong>}</strong></font><br /><br /><font color="#000099"><strong>if</strong></font> (<font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>window</strong></font> -<font color="#000000"><strong>q</strong></font> -<font color="#000000"><strong>ex</strong></font> autoUpdateWin<font color="#000000"><strong>`</strong></font>) <font color="#0000ff"><strong>deleteUI</strong></font> autoUpdateWin<font color="#000000"><strong>;</strong></font><br /><font color="#0000ff"><strong>window</strong></font> -<font color="#000000"><strong>t</strong></font> <font color="#009933"><strong>"</strong></font><font color="#009933"><strong>AutoMatic</strong></font><font color="#009933"><strong> </strong></font><font color="#009933"><strong>Size</strong></font><font color="#009933"><strong> </strong></font><font color="#009933"><strong>Updating</strong></font><font color="#009933"><strong>"</strong></font> autoUpdateWin<font color="#000000"><strong>;</strong></font><br /><font color="#0000ff"><strong>columnLayout</strong></font><font color="#000000"><strong>;</strong></font><br /><font color="#666666">//</font><font color="#666666"> </font><font color="#666666">LAYOUT</font><font color="#666666"> </font><font color="#666666">THAT</font><font color="#666666"> </font><font color="#666666">WILL</font><font color="#666666"> </font><font color="#666666">BE</font><font color="#666666"> </font><font color="#666666">QUERIED</font><font color="#666666"> </font><font color="#666666">TO</font><font color="#666666"> </font><font color="#666666">FIND</font><font color="#666666"> </font><font color="#666666">THE</font><font color="#666666"> </font><font color="#666666">HEIGHT</font><font color="#666666"> </font><font color="#666666">NEEDED</font><br /><font color="#0000ff"><strong>rowColumnLayout</strong></font> -<font color="#000000"><strong>nc</strong></font> <font color="#ff0000">1</font> -<font color="#000000"><strong>cw</strong></font> <font color="#ff0000">1</font> <font color="#ff0000">150</font> myTopLayout<font color="#000000"><strong>;</strong></font><br /><font color="#666666">//</font><font color="#666666"> </font><font color="#666666">MAKES</font><font color="#666666"> </font><font color="#666666"> </font><font color="#666666">A</font><font color="#666666"> </font><font color="#666666">BUTTON</font><font color="#666666"> </font><font color="#666666">THAT</font><font color="#666666"> </font><font color="#666666">WILL</font><font color="#666666"> </font><font color="#666666">SET</font><font color="#666666"> </font><font color="#666666">THE</font><font color="#666666"> </font><font color="#666666">PARENT,</font><font color="#666666"> </font><font color="#666666">THEN</font><font color="#666666"> </font><font color="#666666">ADD</font><font color="#666666"> </font><font color="#666666">A</font><font color="#666666"> </font><font color="#666666">NEW</font><font color="#666666"> </font><font color="#666666">BUTTON</font><br /><font color="#0000ff"><strong>button</strong></font> -<font color="#000000"><strong>l</strong></font> <font color="#009933"><strong>"</strong></font><font color="#009933"><strong>ADD</strong></font><font color="#009933"><strong> </strong></font><font color="#009933"><strong>MORE</strong></font><font color="#009933"><strong> </strong></font><font color="#009933"><strong>BUTTONS!!!!</strong></font><font color="#009933"><strong>"</strong></font> -<font color="#000000"><strong>c</strong></font> <font color="#009933"><strong>"</strong></font><font color="#009933"><strong>addNewButton();</strong></font><font color="#009933"><strong>"</strong></font><font color="#000000"><strong>;</strong></font><br /><font color="#0000ff"><strong>button</strong></font> -<font color="#000000"><strong>l</strong></font> <font color="#009933"><strong>"</strong></font><font color="#009933"><strong>CLEAR</strong></font><font color="#009933"><strong> </strong></font><font color="#009933"><strong>THEM</strong></font><font color="#009933"><strong> </strong></font><font color="#009933"><strong>ALL!!!</strong></font><font color="#009933"><strong>"</strong></font> -<font color="#000000"><strong>c</strong></font> <font color="#009933"><strong>"</strong></font><font color="#009933"><strong>clearButtons();</strong></font><font color="#009933"><strong>"</strong></font><font color="#000000"><strong>;</strong></font><br /><font color="#0000ff"><strong>separator</strong></font> -<font color="#000000"><strong>h</strong></font> <font color="#ff0000">15</font><font color="#000000"><strong>;</strong></font><br /><font color="#666666">//</font><font color="#666666"> </font><font color="#666666">THE</font><font color="#666666"> </font><font color="#666666">LAYOUT</font><font color="#666666"> </font><font color="#666666">THAT</font><font color="#666666"> </font><font color="#666666">WILL</font><font color="#666666"> </font><font color="#666666">HOUSE</font><font color="#666666"> </font><font color="#666666">ALL</font><font color="#666666"> </font><font color="#666666">THE</font><font color="#666666"> </font><font color="#666666">OF</font><font color="#666666"> </font><font color="#666666">THE</font><font color="#666666"> </font><font color="#666666">NEW</font><font color="#666666"> </font><font color="#666666">BUTTONS</font><font color="#666666"> </font><br /><font color="#0000ff"><strong>columnLayout</strong></font> -<font color="#000000"><strong>adj</strong></font> <font color="#ff0000">1</font> newButtonLayout<font color="#000000"><strong>;</strong></font><br /><font color="#0000ff"><strong>showWindow</strong></font> autoUpdateWin<font color="#000000"><strong>;</strong></font><br /><font color="#9966ff">updateMyWinSize</font>()<font color="#000000"><strong>;</strong></font><br /></font></pre></blockquote>Jacob Schieckhttp://www.blogger.com/profile/04562687762228940994noreply@blogger.com0tag:blogger.com,1999:blog-8763479184302466845.post-64291474086272001192010-05-13T13:26:00.001-07:002010-05-14T12:51:36.655-07:00Make all file textures relativeHere's a quick way to make all file textures in a scene relative. So that the path will read "sourceimages/filetexture.dds"<br /><br /><blockquote><pre><font color="#000000"><font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>fileNodes</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>ls</strong></font> -<font color="#000000"><strong>type</strong></font> <font color="#006600"><strong>file</strong></font><font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /><br /><font color="#000099"><strong>for</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>c</strong></font> <font color="#000099"><strong>in</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>fileNodes</strong></font>) <font color="#000000"><strong>{</strong></font> <br /> <font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>path</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>getAttr</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>c</strong></font> <font color="#000000"><strong>+</strong></font> <font color="#009933"><strong>"</strong></font><font color="#009933"><strong>.fileTextureName</strong></font><font color="#009933"><strong>"</strong></font>)<font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>temp</strong></font><font color="#000000"><strong>[</strong></font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>temp2</strong></font><font color="#000000"><strong>[</strong></font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#0000ff"><strong>tokenize</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>path</strong></font> <font color="#009933"><strong>"</strong></font><font color="#009933"><strong>/</strong></font><font color="#009933"><strong>"</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>temp</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#0000ff"><strong>tokenize</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>temp</strong></font><font color="#000000"><strong>[</strong></font><font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>size</strong></font>(<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>temp</strong></font>)<font color="#000000"><strong>`</strong></font> - <font color="#ff0000">1</font><font color="#000000"><strong>]</strong></font> <font color="#009933"><strong>"</strong></font><font color="#009933"><strong>\\</strong></font><font color="#009933"><strong>"</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>temp2</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#000099"><strong>if</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>temp2</strong></font><font color="#000000"><strong>[</strong></font><font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>size</strong></font>(<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>temp2</strong></font>)<font color="#000000"><strong>`</strong></font> - <font color="#ff0000">1</font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font><font color="#000000"><strong>=</strong></font> <font color="#009933"><strong>"</strong></font><font color="#009933"><strong>"</strong></font>) <font color="#000000"><strong>{</strong></font><br /> <font color="#000099"><strong>delete</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>c</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#000000"><strong>}</strong></font><br /> <font color="#000099"><strong>else</strong></font> <font color="#000000"><strong>{</strong></font><br /> <font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>newPath</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#009933"><strong>"</strong></font><font color="#009933"><strong>sourceimages\\</strong></font><font color="#009933"><strong>"</strong></font> <font color="#000000"><strong>+</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>temp2</strong></font><font color="#000000"><strong>[</strong></font><font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>size</strong></font>(<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>temp2</strong></font>)<font color="#000000"><strong>`</strong></font> - <font color="#ff0000">1</font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#0000ff"><strong>setAttr</strong></font> -<font color="#000000"><strong>type</strong></font> <font color="#009933"><strong>"</strong></font><font color="#009933"><strong>string</strong></font><font color="#009933"><strong>"</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>c</strong></font> <font color="#000000"><strong>+</strong></font> <font color="#009933"><strong>"</strong></font><font color="#009933"><strong>.fileTextureName</strong></font><font color="#009933"><strong>"</strong></font>) <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>newPath</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#000000"><strong>}</strong></font><br /><font color="#000000"><strong>}</strong></font><br /></font></pre></blockquote>Jacob Schieckhttp://www.blogger.com/profile/04562687762228940994noreply@blogger.com0tag:blogger.com,1999:blog-8763479184302466845.post-15907331989531207322010-05-11T13:07:00.000-07:002010-05-14T12:55:06.651-07:00The start of another blog.I use MEL daily and figured why not share something that learn everyday or just some cool uses for MEL that I find. So here goes the first post...<br /><br /><u><b>Filling in text fields with selection using textFieldButtonGrp</b></u><br />This is a very practical use for filling in a GUI quickly using the pickWalk command and some clever loops.<br /><br />Lets start with an array:<br /><blockquote><pre><font color="#000000"><font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>array</strong></font><font color="#000000"><strong>[</strong></font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>{</strong></font><font color="#009933"><strong>"</strong></font><font color="#009933"><strong>Leg</strong></font><font color="#009933"><strong>"</strong></font><font color="#000000"><strong>,</strong></font> <font color="#009933"><strong>"</strong></font><font color="#009933"><strong>Knee</strong></font><font color="#009933"><strong>"</strong></font><font color="#000000"><strong>,</strong></font> <font color="#009933"><strong>"</strong></font><font color="#009933"><strong>Ankle</strong></font><font color="#009933"><strong>"</strong></font><font color="#000000"><strong>}</strong></font><font color="#000000"><strong>;</strong></font><br /></font></pre></blockquote>So now we want a GUI that displays the name in the label, a textField that loads in the selected joints, and it's corresponding children:<br /><blockquote><pre><font color="#000000"><font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>array</strong></font><font color="#000000"><strong>[</strong></font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>{</strong></font><font color="#009933"><strong>"</strong></font><font color="#009933"><strong>Leg</strong></font><font color="#009933"><strong>"</strong></font><font color="#000000"><strong>,</strong></font> <font color="#009933"><strong>"</strong></font><font color="#009933"><strong>Knee</strong></font><font color="#009933"><strong>"</strong></font><font color="#000000"><strong>,</strong></font> <font color="#009933"><strong>"</strong></font><font color="#009933"><strong>Ankle</strong></font><font color="#009933"><strong>"</strong></font><font color="#000000"><strong>}</strong></font><font color="#000000"><strong>;</strong></font><br /><font color="#0000ff"><strong>window</strong></font> -<font color="#000000"><strong>t</strong></font> <font color="#009933"><strong>"</strong></font><font color="#009933"><strong>Leg</strong></font><font color="#009933"><strong> </strong></font><font color="#009933"><strong>Setup</strong></font><font color="#009933"><strong> </strong></font><font color="#009933"><strong>Maker</strong></font><font color="#009933"><strong>"</strong></font> tempWin<font color="#000000"><strong>;</strong></font><br /><font color="#0000ff"><strong>columnLayout</strong></font><font color="#000000"><strong>;</strong></font><br /><font color="#000099"><strong>for</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>i</strong></font><font color="#000000"><strong>=</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>;</strong></font><font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>i</strong></font><font color="#000000"><strong><</strong></font><font color="#0000ff"><strong>size</strong></font>(<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>array</strong></font>)<font color="#000000"><strong>;</strong></font><font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>i</strong></font><font color="#000000"><strong>+</strong></font><font color="#000000"><strong>+</strong></font>) <font color="#000000"><strong>{</strong></font><br /><font color="#000099"><strong>int</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>numFields</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>size</strong></font>(<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>array</strong></font>)<font color="#000000"><strong>`</strong></font> - <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>i</strong></font><font color="#000000"><strong>;</strong></font><br /><font color="#0000ff"><strong>textFieldButtonGrp</strong></font> -<font color="#000000"><strong>cw</strong></font> <font color="#ff0000">1</font> <font color="#ff0000">50</font> -<font color="#000000"><strong>l</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>array</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>i</strong></font><font color="#000000"><strong>]</strong></font> -<font color="#000000"><strong>text</strong></font> <font color="#009933"><strong>"</strong></font><font color="#009933"><strong>"</strong></font> -<font color="#000000"><strong>buttonLabel</strong></font> <font color="#009933"><strong>"</strong></font><font color="#009933"><strong><<<</strong></font><font color="#009933"><strong>"</strong></font> <br /> -<font color="#000000"><strong>buttonCommand</strong></font> (<font color="#009933"><strong>"</strong></font><font color="#009933"><strong>loadSel(</strong></font><font color="#009933"><strong>"</strong></font> <font color="#000000"><strong>+</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>numFields</strong></font> <font color="#000000"><strong>+</strong></font> <font color="#009933"><strong>"</strong></font><font color="#009933"><strong>)</strong></font><font color="#009933"><strong>"</strong></font>) <br /> (<font color="#009933"><strong>"</strong></font><font color="#009933"><strong>txtFieldGrp</strong></font><font color="#009933"><strong>"</strong></font> <font color="#000000"><strong>+</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>i</strong></font>)<font color="#000000"><strong>;</strong></font><br /><font color="#000000"><strong>}</strong></font><br /><font color="#0000ff"><strong>showWindow</strong></font> tempWin<font color="#000000"><strong>;</strong></font><br /></font></pre></blockquote><br />Our GUI will now be made with whatever is contained in our array. Now all we need is our global procedure "loadSel" that we will be passing in how many times to loop to fill out the rest of our fields.<br /><blockquote><pre><font color="#000000"><font color="#000099"><strong>global</strong></font> <font color="#000099"><strong>proc</strong></font> <font color="#9966ff">loadSel</font>(<font color="#000099"><strong>int</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>numChild</strong></font>) <font color="#000000"><strong>{</strong></font><br /> <font color="#000099"><strong>string</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>sel</strong></font><font color="#000000"><strong>[</strong></font><font color="#000000"><strong>]</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>ls</strong></font> -<font color="#000000"><strong>sl</strong></font><font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font><br /> <font color="#000099"><strong>for</strong></font> (<font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>i</strong></font><font color="#000000"><strong>=</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>;</strong></font><font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>i</strong></font><font color="#000000"><strong><=</strong></font><font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>numChild</strong></font><font color="#000000"><strong>;</strong></font><font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>i</strong></font><font color="#000000"><strong>+</strong></font><font color="#000000"><strong>+</strong></font>) <font color="#000000"><strong>{</strong></font> <br /> <font color="#0000ff"><strong>textFieldButtonGrp</strong></font> -<font color="#000000"><strong>e</strong></font> -<font color="#000000"><strong>text</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>sel</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font> (<font color="#009933"><strong>"</strong></font><font color="#009933"><strong>txtFieldGrp</strong></font><font color="#009933"><strong>"</strong></font> <font color="#000000"><strong>+</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>i</strong></font>)<font color="#000000"><strong>;</strong></font><br /> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>sel</strong></font> <font color="#000000"><strong>=</strong></font> <font color="#000000"><strong>`</strong></font><font color="#0000ff"><strong>pickWalk</strong></font> -<font color="#000000"><strong>d</strong></font> <font color="#009933"><strong>"</strong></font><font color="#009933"><strong>down</strong></font><font color="#009933"><strong>"</strong></font> <font color="#ff0000"><strong>$</strong></font><font color="#ff0000"><strong>sel</strong></font><font color="#000000"><strong>[</strong></font><font color="#ff0000">0</font><font color="#000000"><strong>]</strong></font><font color="#000000"><strong>`</strong></font><font color="#000000"><strong>;</strong></font> <br /> <font color="#000000"><strong>}</strong></font><br /><font color="#000000"><strong>}</strong></font><br /></font></pre></blockquote><br />We get the selection with "ls -sl", the run the for loop for the number of buttons we have left to go through and fill them out with the children. Annnd done!<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_swUKWbO6F1Q/S-m9CR762cI/AAAAAAAAAKM/iWiJR8IfiCI/s1600/legSetupMaker.PNG"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 325px; height: 93px;" src="http://3.bp.blogspot.com/_swUKWbO6F1Q/S-m9CR762cI/AAAAAAAAAKM/iWiJR8IfiCI/s400/legSetupMaker.PNG" border="0" alt="" id="BLOGGER_PHOTO_ID_5470111069290289602" /></a>Jacob Schieckhttp://www.blogger.com/profile/04562687762228940994noreply@blogger.com0