<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>darkvertex.com &#187; softimage</title> <atom:link href="http://darkvertex.com/wp/category/softimage/feed/" rel="self" type="application/rss+xml" /><link>http://darkvertex.com/wp</link> <description>Bringing CG to life, one rig at a time...</description> <lastBuildDate>Mon, 27 Jun 2011 13:05:03 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <atom:link rel='hub' href='http://darkvertex.com/wp/?pushpress=hub'/> <item><title>Python: Naming Objects for Numerophobes 101</title><link>http://darkvertex.com/wp/2011/04/21/naming-for-numerophobes/</link> <comments>http://darkvertex.com/wp/2011/04/21/naming-for-numerophobes/#comments</comments> <pubDate>Thu, 21 Apr 2011 19:01:16 +0000</pubDate> <dc:creator>Alan</dc:creator> <category><![CDATA[scripting]]></category> <category><![CDATA[softimage]]></category> <category><![CDATA[python]]></category> <category><![CDATA[scripts]]></category> <category><![CDATA[tips]]></category> <category><![CDATA[tutorial]]></category><guid isPermaLink="false">http://darkvertex.com/wp/?p=160</guid> <description><![CDATA[You can call me a numerophobe when naming rig objects, but the reason I personally avoid numbers in my rigging naming conventions (99% of the time) is so that when I duplicate something, a number at the end won&#8217;t increase by itself because there isn&#8217;t one. (The issue can be circumvented by having numbers somewhere [...]]]></description> <content:encoded><![CDATA[<p>You can call me a <em><acronym title="numerophobia, the fear of numbers!">numerophobe</acronym></em> when naming rig objects, but the reason I personally avoid numbers in my rigging naming conventions (99% of the time) is so that when I duplicate something, a number at the end won&#8217;t increase by itself because there isn&#8217;t one. (The issue can be circumvented by having numbers somewhere before the end, but I&#8217;m the kind of weirdo that prefers to go with letters altogether.)</p><p>We humans work numbers in what&#8217;s known as the &#8220;<a href="http://en.wikipedia.org/wiki/Numeral_system">Numeral system</a>&#8220;, also known as the &#8220;base 10&#8243; system (as we have that many fingers&#8230;) but hold on&#8230; the alphabet has 26 letters, not 10, so what do we call that system? It has a name: it&#8217;s the <a href="http://en.wikipedia.org/wiki/Hexavigesimal"><em>Hexavigesimal</em></a> (or &#8220;base 26&#8243;) system.</p><p>As the ever-so-handy Wikipedia denotes,</p><blockquote><p><em>Any number may be converted to base-26 by repeatedly dividing the number by 26.</em></p></blockquote><p>Pretty easy stuff for Python.</p><p>This is how I&#8217;d do it:<span id="more-160"></span></p><div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> base26str<span style="color: black;">&#40;</span>i, padding = <span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#41;</span>:
	<span style="color: #483d8b;">&quot;&quot;&quot;
	Turns a number to a base26 string, with optional padding support.
	&quot;&quot;&quot;</span>
&nbsp;
	alphabet = <span style="color: #008000;">map</span><span style="color: black;">&#40;</span><span style="color: #008000;">chr</span>, <span style="color: #008000;">range</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">65</span>, <span style="color: #ff4500;">91</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
	alphaStr = <span style="color: #483d8b;">&quot;&quot;</span>
&nbsp;
	<span style="color: #ff7700;font-weight:bold;">if</span> i <span style="color: #66cc66;">&gt;</span> <span style="color: #ff4500;">0</span>:
		number = i
		<span style="color: #ff7700;font-weight:bold;">while</span> <span style="color: black;">&#40;</span>number <span style="color: #66cc66;">&gt;</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span>:
			remainder = number <span style="color: #66cc66;">%</span> <span style="color: #ff4500;">26</span>
			alphaStr = alphabet<span style="color: black;">&#91;</span>remainder<span style="color: black;">&#93;</span> + alphaStr
			number /= <span style="color: #ff4500;">26</span>
	<span style="color: #ff7700;font-weight:bold;">else</span>:
		alphaStr = <span style="color: #483d8b;">&quot;A&quot;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;"># Pad to X digits?</span>
	<span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">str</span><span style="color: black;">&#40;</span>padding<span style="color: black;">&#41;</span>.<span style="color: black;">isdigit</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
		alphaStr = alphaStr.<span style="color: black;">zfill</span><span style="color: black;">&#40;</span><span style="color: #008000;">int</span><span style="color: black;">&#40;</span>padding<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>.<span style="color: black;">replace</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;0&quot;</span>,alphabet<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
&nbsp;
	<span style="color: #ff7700;font-weight:bold;">return</span> alphaStr
&nbsp;
<span style="color: #808080; font-style: italic;"># ------------------------------------</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># Check this out...</span>
<span style="color: #ff7700;font-weight:bold;">print</span> base26str<span style="color: black;">&#40;</span><span style="color: #ff4500;">4</span><span style="color: black;">&#41;</span>		<span style="color: #808080; font-style: italic;"># &quot;E&quot;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> base26str<span style="color: black;">&#40;</span><span style="color: #ff4500;">4</span>, <span style="color: #ff4500;">3</span><span style="color: black;">&#41;</span>		<span style="color: #808080; font-style: italic;"># &quot;AAE&quot; (&quot;E&quot; padded to 3 letters. A = 0)</span>
<span style="color: #ff7700;font-weight:bold;">print</span> base26str<span style="color: black;">&#40;</span><span style="color: #ff4500;">28</span><span style="color: black;">&#41;</span>		<span style="color: #808080; font-style: italic;"># &quot;BC&quot;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#</span></pre></div></div><p>Now let&#8217;s put it to use in a simple renamer example. This sample below is Softimage-oriented, but you could easily change it to PyMEL:</p><div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">math</span> <span style="color: #ff7700;font-weight:bold;">import</span> ceil
xsi = Application
&nbsp;
typeSuffix = <span style="color: black;">&#123;</span>
	<span style="color: #483d8b;">&quot;crvlist&quot;</span>:	<span style="color: #483d8b;">&quot;CRV&quot;</span>,
	<span style="color: #483d8b;">&quot;polymsh&quot;</span>:	<span style="color: #483d8b;">&quot;GEO&quot;</span>,
	<span style="color: #483d8b;">&quot;surfmsh&quot;</span>:	<span style="color: #483d8b;">&quot;GEO&quot;</span>,
	<span style="color: #483d8b;">&quot;null&quot;</span>:		<span style="color: #483d8b;">&quot;NULL&quot;</span>,
	<span style="color: #483d8b;">&quot;root&quot;</span>:		<span style="color: #483d8b;">&quot;RT&quot;</span>,
	<span style="color: #483d8b;">&quot;bone&quot;</span>:		<span style="color: #483d8b;">&quot;BN&quot;</span>,
	<span style="color: #483d8b;">&quot;eff&quot;</span>:		<span style="color: #483d8b;">&quot;EFF&quot;</span>
<span style="color: black;">&#125;</span>
&nbsp;
oSel = xsi.<span style="color: black;">Selection</span>
prefix = xsi.<span style="color: black;">XSIInputBox</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;What would you like to prefix these objects?&quot;</span>, <span style="color: #483d8b;">&quot;NAME PREFIX&quot;</span>, oSel<span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span>.<span style="color: black;">Name</span> <span style="color: black;">&#41;</span>
&nbsp;
&nbsp;
<span style="color: #808080; font-style: italic;"># Find out the padding required:</span>
padding = <span style="color: #483d8b;">&quot;&quot;</span>
<span style="color: #ff7700;font-weight:bold;">if</span> oSel.<span style="color: black;">Count</span> <span style="color: #66cc66;">&gt;</span> <span style="color: #ff4500;">26</span>:
	padding = <span style="color: #008000;">int</span><span style="color: black;">&#40;</span> ceil<span style="color: black;">&#40;</span> oSel.<span style="color: black;">Count</span> / <span style="color: #ff4500;">26.0</span> <span style="color: black;">&#41;</span> <span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">for</span> i, eachObj <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">enumerate</span><span style="color: black;">&#40;</span>oSel<span style="color: black;">&#41;</span>:
&nbsp;
	<span style="color: #808080; font-style: italic;"># Get suffix if it has been defined, else leave blank:</span>
	suffix = <span style="color: black;">&#40;</span> <span style="color: #483d8b;">&quot;&quot;</span> <span style="color: #ff7700;font-weight:bold;">if</span> eachObj.<span style="color: black;">Type</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #ff7700;font-weight:bold;">in</span> typeSuffix.<span style="color: black;">keys</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: #483d8b;">&quot;_&quot;</span>+typeSuffix<span style="color: black;">&#91;</span>eachObj.<span style="color: black;">Type</span><span style="color: black;">&#93;</span> <span style="color: black;">&#41;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;"># Rename object:</span>
	newname = prefix+<span style="color: #483d8b;">&quot;_&quot;</span>+ base26str<span style="color: black;">&#40;</span>i<span style="color: black;">&#41;</span> +suffix
	<span style="color: #ff7700;font-weight:bold;">print</span> eachObj.<span style="color: black;">Name</span>+<span style="color: #483d8b;">&quot; --RENAMED-TO--&gt; &quot;</span>+newname
	eachObj.<span style="color: black;">Name</span> = newname
&nbsp;
<span style="color: #808080; font-style: italic;">#</span></pre></div></div>]]></content:encoded> <wfw:commentRss>http://darkvertex.com/wp/2011/04/21/naming-for-numerophobes/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Softimage: ICE String to Particles trick</title><link>http://darkvertex.com/wp/2010/11/15/softimage-ice-string-to-particles/</link> <comments>http://darkvertex.com/wp/2010/11/15/softimage-ice-string-to-particles/#comments</comments> <pubDate>Mon, 15 Nov 2010 14:30:57 +0000</pubDate> <dc:creator>Alan</dc:creator> <category><![CDATA[softimage]]></category> <category><![CDATA[tutorials]]></category> <category><![CDATA[ice]]></category> <category><![CDATA[tips]]></category> <category><![CDATA[tutorial]]></category><guid isPermaLink="false">http://darkvertex.com/wp/?p=431</guid> <description><![CDATA[[I shared this on the Softimage Mailing List the other day and thought it was worth posting here.] Here&#8217;s a fun trick for parsing an ICE string attribute, identifying the letters and typing out the text with particles: Download the sample scene here and read more about it below. (Soft 2011+ required.) Taking this knowledge [...]]]></description> <content:encoded><![CDATA[<p>[I shared this on the Softimage Mailing List the other day and thought it was worth posting here.]</p><p>Here&#8217;s a fun trick for parsing an ICE string attribute, identifying the letters and typing out the text with particles:<br /> <a rel="shadowbox[Mixed];width=1635;height=1055" href="http://s3.darkvertex.com/hlinked/ice/ICE_string_to_particles.png"><img class="size-medium wp-image-87 " src="http://s3.darkvertex.com/hlinked/ice/ICE_string_to_particles.png" alt="ICE string to particles" width="490" height="316" /></a><br /> Download the <a href="http://s3.darkvertex.com/hlinked/ice/ICE_string_to_particles.zip"><strong>sample scene</strong> <em>here</em></a> and read more about it below. (<strong>Soft 2011+</strong> required.)<br /> <span id="more-431"></span></p><p>Taking this knowledge we can also do variations on the concept like <strong>turning <em>a string into an array of booleans</em></strong>, for example:</p><p><a rel="shadowbox[Mixed];width=975;height=858" href="http://s3.darkvertex.com/hlinked/ice/ICE_string_to_boolean_array.png"><img class="size-medium wp-image-87 " src="http://s3.darkvertex.com/hlinked/ice/ICE_string_to_boolean_array.png" alt="ICE string to array of booleans" width="487" height="429" /></a></p><p>Let me know in the comments if you make anything cool with this technique. <img src='http://darkvertex.com/wp/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p> ]]></content:encoded> <wfw:commentRss>http://darkvertex.com/wp/2010/11/15/softimage-ice-string-to-particles/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>Softimage: Symmetrical Shape Splitting with ICE</title><link>http://darkvertex.com/wp/2010/11/08/symmetrical-shape-split-with-ice/</link> <comments>http://darkvertex.com/wp/2010/11/08/symmetrical-shape-split-with-ice/#comments</comments> <pubDate>Mon, 08 Nov 2010 14:09:02 +0000</pubDate> <dc:creator>Alan</dc:creator> <category><![CDATA[softimage]]></category> <category><![CDATA[tutorials]]></category> <category><![CDATA[blendshapes]]></category> <category><![CDATA[compounds]]></category> <category><![CDATA[shapes]]></category> <category><![CDATA[tips]]></category> <category><![CDATA[tools]]></category> <category><![CDATA[tutorial]]></category><guid isPermaLink="false">http://darkvertex.com/wp/?p=339</guid> <description><![CDATA[I propose a way of using ICE to split symmetrical shape halves. Here it is in action: (Download here and read more about it below.) The classical way of doing symmetrical shapekeys (a.k.a. &#8220;blendshapes&#8221; if you&#8217;re in Maya or morphs if you&#8217;re in Max) is to make a symmetrical one then add it twice and [...]]]></description> <content:encoded><![CDATA[<p>I propose a way of using ICE to split symmetrical shape halves. Here it is in action:<br /> <a rel="shadowbox[Mixed];width=1293;height=878" href="http://wpfiles.darkvertex.com/wp/wp-content/uploads/2010/11/DeformWithSourceMesh_ICEcompound_exampleResult.png"><img class="size-medium wp-image-87 " src="http://wpfiles.darkvertex.com/wp/wp-content/uploads/2010/11/DeformWithSourceMesh_ICEcompound_exampleResult_THUMB.jpg" alt="My "Deform with Source Mesh" compound in action" width="517" height="351" /></a><br /> (<a href="http://s3.darkvertex.com/tools/ICE/Deform%20with%20Source%20Mesh.1.1.xsicompound"><strong>Download here</strong></a> and read more about it below.)<br /> <span id="more-339"></span></p><hr /></p><p>The classical way of doing symmetrical shapekeys (a.k.a. &#8220;<em>blendshapes</em>&#8221; if you&#8217;re in Maya or <em>morphs</em> if you&#8217;re in Max) is to make a symmetrical one then add it twice and paint off its influence with two weight maps, one for each half. In Maya you&#8217;d use the <em>Paint Blend Shape Weights</em> tool, but it&#8217;s basically the same deal.</p><p>In ICE, shapekeys have a <strong>.positions</strong> ICEattribute in them. This is an array of positions (vectors) representing the relative offset from the original mesh. In other words, it means you need to add them to the existing point positions to make said shape occur. That said, we won&#8217;t be using .positions in this post but full PointPosition&#8217;s instead.</p><p>Here&#8217;s what we&#8217;re gonna be working with in my example:<br /> <img src="http://wpfiles.darkvertex.com/wp/wp-content/uploads/2010/11/xsimanFace_neutralAndSmileSymmShape.jpg" alt="Amazing smile!" /></p><p>Normally you would make the 2 weightmaps, select one then Shape->Modulate Shape Key with Weight Map. The map looks kinda like this:<br /> <img src="http://wpfiles.darkvertex.com.s3.amazonaws.com/wp/wp-content/uploads/2010/11/XSIman_weightmap_halfFace.jpg" alt="Middle is 50 percent, rest is 100 percent." /><br /> This involves making sure you have 100% of one half and 50% of the middle. You want 50% because you want to be able to add the shapes for both sides and get 100% of the deformation in the middle, else you&#8217;d get 200% and that&#8217;s no good.</p><p>Let&#8217;s see how we can use ICE to skip that step altogether by only deforming points in one half instead of relying on a map to define it, as pictured at the beginning of this post.</p><p><a rel="shadowbox[Mixed];width=1752;height=972" href="http://wpfiles.darkvertex.com/wp/wp-content/uploads/2010/11/ICEtree_DeformWithSourceMesh.png"><img class="size-medium wp-image-87" src="http://wpfiles.darkvertex.com/wp/wp-content/uploads/2010/11/ICEtree_DeformWithSourceMesh_THUMB.jpg" alt="My "Deform with Source Mesh" compound in action" width="450" height="250" /></a></p><p>So as you can see we read the PointPosition, split out to scalars with the &#8220;<em>3D Vector to Scalar</em>&#8220;, then feed the X to different nodes to see if it&#8217;s bigger or equal to / bigger / smaller or equal to / smaller than zero. With the &#8220;<em>Select Case</em>&#8221; we use the correct one as defined from our dropdown menu input attribute &#8220;<em>Type</em>&#8220;. (If you didn&#8217;t know: to define a dropdown menu for an attribute in a compound just rightclick it and go to <em>Properties</em>, then fill in &#8220;<em>Combo string</em>&#8221; and &#8220;<em>Combo value</em>&#8221; then click &#8220;<em>Add combo</em>&#8221; as desired.)</p><p>The <em>If</em> node before the <em>Linear Interpolate</em> makes sure that if we&#8217;re not dealing with the correct half, we just let the positions pass through untouched. Otherwise, we check if the &#8220;<em>Type</em>&#8221; (mode) is set to one that includes the middle line, and if X is 0 it means we have a point in the perfect middle of the mesh, in which case we only affect it by 50%, else we let it go through. At the end we do one more <em>Linear Interpolate</em> between the affected result and the original mesh, so we can blend it gradually with a slider.</p><p>Lastly, if anyone&#8217;s curious what the word &#8220;<em>Epsilon</em>&#8221; means in regards to an &#8220;<em>Equals</em>&#8221; node, it&#8217;s basically the margin of error permitted in the comparison since vector values aren&#8217;t exact numbers most of the time in 3D. Thus an epsilon of 0.001 in this case means that a vector&#8217;s posX can be off from 0 by 0.001, so it could anywhere between -0.001 and 0.001 and still be considered to equal 0. You can increase the epsilon if you need to.</p><hr /> Long story short, you can <a href="http://s3.darkvertex.com/tools/ICE/Deform%20with%20Source%20Mesh.1.1.xsicompound"><strong>download the compound right here.</strong></a> I find it has greatly sped up my workflow when generating shape halves. Hope it helps you too. <img src='http://darkvertex.com/wp/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p> ]]></content:encoded> <wfw:commentRss>http://darkvertex.com/wp/2010/11/08/symmetrical-shape-split-with-ice/feed/</wfw:commentRss> <slash:comments>5</slash:comments> </item> <item><title>Python: Distance between 2 Position Vectors</title><link>http://darkvertex.com/wp/2010/06/05/python-distance-between-2-vectors/</link> <comments>http://darkvertex.com/wp/2010/06/05/python-distance-between-2-vectors/#comments</comments> <pubDate>Sun, 06 Jun 2010 00:05:31 +0000</pubDate> <dc:creator>Alan</dc:creator> <category><![CDATA[scripting]]></category> <category><![CDATA[softimage]]></category> <category><![CDATA[maya]]></category> <category><![CDATA[python]]></category> <category><![CDATA[scripts]]></category> <category><![CDATA[tutorial]]></category><guid isPermaLink="false">http://darkvertex.com/wp/?p=307</guid> <description><![CDATA[This post surged from a question at a forum where somebody tried to use the ctr_dist() function &#8212; that returns distance between two object centers &#8212; in a Softimage script only to realise that actually it only exists for expressions, not scripting. Here&#8217;s my take on said function for both Softimage and Maya&#8230; First of [...]]]></description> <content:encoded><![CDATA[<p>This post surged from a question <a href="http://www.xsiforum.com/forum/index.php/topic,7677.0.html">at a forum</a> where somebody tried to use the <a href="http://softimage.wiki.softimage.com/sdkdocs/ref_quickref_DistanceFunctions.htm"><strong>ctr_dist()</strong></a> function &#8212; <em>that returns distance between two object centers</em> &#8212; in a Softimage script only to realise that actually it only exists for expressions, not scripting.</p><p>Here&#8217;s my take on said function for both Softimage and Maya&#8230;<br /> <span id="more-307"></span><br /><hr /></p><p>First of all, we need to know the math behind it. Knowing global position vectors A and B, the formula for the distance (d) between them would be:<br /> <span style="white-space: nowrap; font-size:larger"><br /> d = &radic;<span style="text-decoration:overline;">&nbsp; Ax-Bx<sup>2</sup> + Ay-By<sup>2</sup> + Az-Bz<sup>2</sup> &nbsp;</span><br /> </span><br /></p><p>I&#8217;ve decided to borrow sqrt() and pow() functions from Python&#8217;s <a href="http://docs.python.org/library/math.html">math</a> library, by the way.</p><p>First let&#8217;s see how to do this with Python in Softimage:</p><div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">xsi = Application
lm = xsi.<span style="color: black;">LogMessage</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> ctr_dist<span style="color: black;">&#40;</span> objA, objB <span style="color: black;">&#41;</span>:
	<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">math</span> <span style="color: #ff7700;font-weight:bold;">import</span> sqrt,<span style="color: #008000;">pow</span>
&nbsp;
	Ax, Ay, Az = objA.<span style="color: black;">Kinematics</span>.<span style="color: black;">Global</span>.<span style="color: black;">Transform</span>.<span style="color: black;">GetTranslationValues2</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
	Bx, By, Bz = objB.<span style="color: black;">Kinematics</span>.<span style="color: black;">Global</span>.<span style="color: black;">Transform</span>.<span style="color: black;">GetTranslationValues2</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
	<span style="color: #ff7700;font-weight:bold;">return</span> sqrt<span style="color: black;">&#40;</span>  <span style="color: #008000;">pow</span><span style="color: black;">&#40;</span>Ax-Bx,<span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span> + <span style="color: #008000;">pow</span><span style="color: black;">&#40;</span>Ay-By,<span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span> + <span style="color: #008000;">pow</span><span style="color: black;">&#40;</span>Az-Bz,<span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span>  <span style="color: black;">&#41;</span>
<span style="color: #808080; font-style: italic;"># -------------------------</span>
&nbsp;
&nbsp;
<span style="color: #808080; font-style: italic;"># Try it out with 2 selected objects:</span>
fromObj, toObj = xsi.<span style="color: black;">Selection</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span>, xsi.<span style="color: black;">Selection</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>
&nbsp;
lm<span style="color: black;">&#40;</span>
<span style="color: #483d8b;">&quot;Distance between &lt;&quot;</span>+fromObj.<span style="color: black;">FullName</span>+<span style="color: #483d8b;">&quot;&gt; to &lt;&quot;</span>+toObj.<span style="color: black;">FullName</span>+<span style="color: #483d8b;">&quot;&gt; is: &quot;</span>
+<span style="color: #008000;">str</span><span style="color: black;">&#40;</span> ctr_dist<span style="color: black;">&#40;</span>fromObj, toObj<span style="color: black;">&#41;</span> <span style="color: black;">&#41;</span>
<span style="color: black;">&#41;</span></pre></div></div><p>Now let&#8217;s repurpose it for <a href="http://code.google.com/p/pymel/">PyMEL</a> in Maya, without using <a href="http://www.3dtutorialzone.com/tutorial?id=106">distance nodes</a>:</p><div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> pymel.<span style="color: black;">core</span> <span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #66cc66;">*</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> ctr_dist<span style="color: black;">&#40;</span> objA, objB <span style="color: black;">&#41;</span>:
	<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">math</span> <span style="color: #ff7700;font-weight:bold;">import</span> sqrt,<span style="color: #008000;">pow</span>
&nbsp;
	Ax, Ay, Az = objA.<span style="color: black;">getTranslation</span><span style="color: black;">&#40;</span>space=<span style="color: #483d8b;">&quot;world&quot;</span><span style="color: black;">&#41;</span>
	Bx, By, Bz = objB.<span style="color: black;">getTranslation</span><span style="color: black;">&#40;</span>space=<span style="color: #483d8b;">&quot;world&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
	<span style="color: #ff7700;font-weight:bold;">return</span> sqrt<span style="color: black;">&#40;</span>  <span style="color: #008000;">pow</span><span style="color: black;">&#40;</span>Ax-Bx,<span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span> + <span style="color: #008000;">pow</span><span style="color: black;">&#40;</span>Ay-By,<span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span> + <span style="color: #008000;">pow</span><span style="color: black;">&#40;</span>Az-Bz,<span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span>  <span style="color: black;">&#41;</span>
<span style="color: #808080; font-style: italic;"># -------------------------</span>
&nbsp;
&nbsp;
<span style="color: #808080; font-style: italic;"># Try it out with 2 selected objects:</span>
sel = ls<span style="color: black;">&#40;</span>sl=<span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Distance between &lt;&quot;</span>+sel<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>+<span style="color: #483d8b;">&quot;&gt; to &lt;&quot;</span>+sel<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>+<span style="color: #483d8b;">&quot;&gt; is: &quot;</span>+<span style="color: #008000;">str</span><span style="color: black;">&#40;</span> ctr_dist<span style="color: black;">&#40;</span>sel<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>,sel<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span> <span style="color: black;">&#41;</span></pre></div></div><p>By the way, note the awesomeness of Python for letting you assign multiple variables from an array using a single line. That&#8217;s pretty nice. <img src='http://darkvertex.com/wp/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p><p>Hope somebody finds this useful! You can use it a <strong>measuring tool</strong> or for <strong>distance-dependent rigging logic</strong>.</p><p><strong>If you do use it for rigging</strong>, please remember that <strong>if you want the distance to stay the same while a character is scaled, you must divide the distance by the scaling value.</strong></p> ]]></content:encoded> <wfw:commentRss>http://darkvertex.com/wp/2010/06/05/python-distance-between-2-vectors/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>Softimage: Undocumented TEMP Folder that cleans up after itself</title><link>http://darkvertex.com/wp/2010/05/04/undocumented-softimage-temp-directory/</link> <comments>http://darkvertex.com/wp/2010/05/04/undocumented-softimage-temp-directory/#comments</comments> <pubDate>Wed, 05 May 2010 01:37:39 +0000</pubDate> <dc:creator>Alan</dc:creator> <category><![CDATA[softimage]]></category> <category><![CDATA[scripts]]></category> <category><![CDATA[tips]]></category><guid isPermaLink="false">http://darkvertex.com/wp/?p=262</guid> <description><![CDATA[Environment variables are no secret and neither is the system-set &#8220;TEMP&#8221; variable, but what is not really mentioned in the SDK Docs is that Softimage overrides the TEMP and TMP environment variables with a temporary folder made by XSI: LogMessage&#40; XSIUtils.Environment&#40;&#34;TEMP&#34;&#41; &#41;; If I run that (JavaScript) I get something like: C:\Users\Alan\AppData\Local\Temp\XSI_Temp_15076 The number is [...]]]></description> <content:encoded><![CDATA[<p>Environment variables are no secret and neither is the system-set &#8220;TEMP&#8221; variable, but what is not really mentioned in the <em>SDK Docs</em> is that Softimage overrides the TEMP and TMP environment variables with a temporary folder made by XSI:</p><div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">LogMessage<span style="color: #009900;">&#40;</span> XSIUtils.<span style="color: #660066;">Environment</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;TEMP&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div><p>If I run that (JavaScript) I get something like: <strong>C:\Users\Alan\AppData\Local\Temp\XSI_Temp_15076</strong><br /> <span id="more-262"></span><br /> The number is unique every time and if you open multiple XSI sessions, each will get their own temp folder. <strong><span style="color: #ff0000;">If you close Softimage, the corresponding temp folder is deleted completely.</span></strong></p><p>This is a much more elegant solution to temporary filepaths because <strong>you don&#8217;t have to waste time coding a purging/cleanup mechanism in your plugin.</strong></p><p>Furthermore, <strong><span style="color: #ff0000;">if Softimage crashes it will get cleaned anyways next time you run it.</span></strong> It seems to check for XSI_Temp_* folders on startup and delete any that are not in use by an existing session.</p><p>I found this feature by accident when I needed a temp file function for a scripted tool I was working on. I was expecting to get the normal TEMP path set by Windows, but to my surprise Softimage had overriden it with their own that autopurges by itself. Handy! <img src='http://darkvertex.com/wp/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p> ]]></content:encoded> <wfw:commentRss>http://darkvertex.com/wp/2010/05/04/undocumented-softimage-temp-directory/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Softimage: RefModel Deltas&#8217; Hygiene in Production</title><link>http://darkvertex.com/wp/2010/02/21/clean-softimage-deltas/</link> <comments>http://darkvertex.com/wp/2010/02/21/clean-softimage-deltas/#comments</comments> <pubDate>Sun, 21 Feb 2010 20:38:27 +0000</pubDate> <dc:creator>Alan</dc:creator> <category><![CDATA[softimage]]></category> <category><![CDATA[scripts]]></category> <category><![CDATA[tips]]></category> <category><![CDATA[tools]]></category><guid isPermaLink="false">http://darkvertex.com/wp/?p=185</guid> <description><![CDATA[I used to think refmodels were buggy, annoying and out to get me. After some exploration, they exhibit a couple patterns of fixable issues. Let&#8217;s bring them to light, shall we? Here&#8217;s some of my observations with them in the context of artists animating a referenced rig in production: StoredExpressions doesn&#8217;t always store expressions. They [...]]]></description> <content:encoded><![CDATA[<p>I used to think refmodels were buggy, annoying and out to get me. After some exploration, they exhibit a couple patterns of fixable issues. Let&#8217;s bring them to light, shall we?</p><p>Here&#8217;s some of my observations with them in the context of artists animating a referenced rig in production:<br /> <span id="more-185"></span></p><ul><li><strong>StoredExpressions</strong> doesn&#8217;t always store expressions. They actually show up in StoredPositions almost every time you touch something with an expression. They often also break / stop evaluating when this happens. (They often get stored even when you disable storing of expressions in your Delta, but it&#8217;s hard to repro.)<br /> &nbsp;</li><li><strong>StoredPositions</strong> remembers transforms by the mere act of selecting and having translate/rotate/scale tool active. While not exactly a bug, it easily causes problems if you edit centers later on, because the transforms get remembered and so it causes a wacky offset.<br /> Stuff can exist in both StoredPositions and StoredFCurves but it shouldn&#8217;t. If it&#8217;s keyed/animated, keys take priority, which means you got redundant junk in StoredPositions. XSI won&#8217;t remove the StoredPositions entry when setting a key (which makes a StoredFCurves entry.)<br /> &nbsp;</li><li><strong>StoredPositions</strong> will (from time to time) remember changes to a referenced material&#8217;s parameters. This combines with the annoyance of updating a material later and having old values mysteriously enforced on it because they were in StoredPositions and shared the same names. (Maybe a better name is &#8220;StoredValues&#8221;, since it stores more than <em>positions</em>.)<br /> &nbsp;</li><li>Generally rigs don&#8217;t come preanimated so there&#8217;s no point for &#8220;<strong>StoredRemoveAnimations</strong>&#8221; to exist. It gets created whenever you remove keys from something in the rig.<br /> &nbsp;</li><li><strong>StoredConstraints</strong> remembers constraint relations by explicit naming. Sometimes these don&#8217;t update when the objects name changes, and sometimes they do.<br /> So say if you constrain an arm of the referenced character rig to a null you just made, THEN rename the null, there&#8217;s a very high chance when you save and reopen the constraint won&#8217;t be connected, since it will be expecting the original null name. The good news is you can open the Delta in an Explorer, doubleclick the StoredConstraints subproperty and rename the object names in each row to whatever are the correct ones.<br /> &nbsp;</li><li>Whenever you edit contents of a Delta by hand and want to see the updated result, you must rightclick on the referenced model in an Explorer and &#8220;<em>Update Referenced Model</em>.&#8221;<br /> &nbsp;</li><li>You need a Delta per model&#8230; and in the case of having a rig with one or more models inside it, this rule still applies.<br /> &nbsp;</li><li>Just because a Delta sits below a model that doesn&#8217;t necessarily mean that is the model it&#8217;s working on. It&#8217;s actually working on whatever its &#8220;Target&#8221; parameter specifies.<br /> &nbsp;</li><li>If &#8220;<em>Record</em>&#8221; isn&#8217;t <strong>ON</strong> (in the Delta&#8217;s PPG) before you make changes, they don&#8217;t get saved. End of story. &#8212; Turning it on after doing changes won&#8217;t save your ass. (Good thing it&#8217;s on by default, eh?)<br /> &nbsp;</li><li>If you have a convoluted/complex rig that crashes when you do &#8220;<em>Update Reference Model</em>&#8221; or when simply offloading, but works fine otherwise&#8230; if you need to update the refmodel path, you can do this without opening your scene by editing the relevant scntoc file and then when you open your scene it&#8217;ll be path you wanted. <img src='http://darkvertex.com/wp/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br /> &nbsp;</li><li>When you duplicate a material from a referenced model, it duplicates fine EXCEPT for the image clips/sources, which stay referenced and when you reopen the scene, they will have dissapeared.<br /> &nbsp;</li><li>Using <strong>Animation Layers</strong> with referenced models is <s><strong>not to be trusted</strong>.</s> [*<strong>update</strong>*: Steven Caron from Blur Studios has noted that as of Soft 2010 SP1, animation layers work fine with referenced models. Beware if you are using a previous version.]<br /> If you use them, always open the scene you just saved in a new XSI without closing the first one so you can check that when it opens all the animation is still there and works properly. (I haven&#8217;t confirmed, but I believe I read on the mailing list that you can collapse animation layers before you save and then it&#8217;s okay.)<br /> &nbsp;</li><li>Someone on the Softimage mailing list mentioned once that only the first Delta for a particular model remembers Mixer stuff like actionclips and such, regardless of what you set. Good to bare in mind.<br /> &nbsp;</li><li>[*<strong>Update 23/Dec/2010</strong>*] <a href="http://www.ethivierge.com/">Eric Thivierge</a> has brought up that apparently if you key a refmodel&#8217;s object to another and animate the Active parameter, those keys will not be saved. However, if you key the Blend instead, you&#8217;ll be fine.</li><li>[*<strong>Update 05/May/2011</strong>*] There&#8217;s a very interesting SDK bug (confirmed in 2011 SAP, not checked other versions) whereby dealing with Model Instances with refmodels will create an instance group and seems to work fine, but if you try to get the .ActionDeltas of the Delta via scripting, it will fail as if it didn&#8217;t exist. Rename the group once and then .ActionDeltas work again. Very strange!!</li><li>[*<strong>Update 13/May/2011</strong>*] With 2011.0 (the first one) there is a serious bug whereby shaders may get disconnected. The bug that causes the issue is fixed in the ServicePacks that followed. Inform yourself straight from the source <a href="http://xsisupport.wordpress.com/2011/05/13/service-packs-and-disconnected-shaders/">at Stephen Blair&#8217;s eX-SI Support blog.</a></li></ul><p>At work I made two relatively simple scripts that help us with refmodel woes. I&#8217;d like to share them with you:</p><p>&nbsp;</p><hr /> <strong>&#8220;Import Referenced Rig&#8221;:</strong><br /> If you do File-&gt;Import-&gt;Referenced Model and begin working without doing anything, it&#8217;s set to remember *anything* and *everything*. It&#8217;ll break in no time.</p><p>This really simple script imports a refmodel, make a fresh empty delta for it (and extra Deltas for any models in it) and sets these defaults automatically:</p><ul><li>Static Pos and Other Parameters ON</li><li>FCurves ON</li><li>Expressions OFF</li><li>Constraints ON</li><li>Animation Mixer ON</li><li>Group Relations ON<br /> (this stores partitions relationships so it&#8217;s very important!)</li><li>Model Instances OFF<br /> (could be left ON if you need it)</li><li>External Connections ON<br /> (this remembers stuff like constraining something in the refmodel to an external object)</li><li>New Properties OFF</li><li>Clusters OFF</li><li>Cluster Properties OFF</li><li>Operators OFF</li></ul><p>then in Mixer Modifications:</p><ul><li>Animation ON</li><li>Shapes OFF</li><li>Audio ON</li><li>Cache ON</li></ul><p>These are the ideal settings for using a referenced model to move/animate it, put it in partitions/groups/layers and render.</p><p><a href="http://wpfiles.darkvertex.com/wp/wp-content/uploads/2010/02/AF_ImportRefModelForAnimation.py">Download the <strong><em>AF_ImportRefModelForAnimation.py</em></strong> Python script here.</a> Make it into a button or incorporate it into your workflow tools if you have any.</p><p>&nbsp;</p><hr /><p><strong>&#8220;Clean Delta&#8221;:</strong><br /> It deletes stuff from a Delta that shouldn&#8217;t be there if you just wanted to animate and render a referenced rig or model. See the code for more specifics.</p><p><a href="http://wpfiles.darkvertex.com/wp/wp-content/uploads/2010/02/AF_DeltaCleaner.py">Download the <strong><em>AF_DeltaCleaner.py</em></strong> Python script here</a> and run it from a button with refmodels selected. I&#8217;ve left plenty of code comments to make sense of what it does. I urge you to read them.</p><hr /> &nbsp;</p><p>I hope these scripts assist you in having a more pleasant experience with referenced models. They&#8217;re actually quite wonderful after you learn their quirks.</p><p>If anyone has anything else to say about deltas, modifications, suggestions, code improvements, constructive critique, cheese and monkeys, etc. please leave a comment. Thank you. <img src='http://darkvertex.com/wp/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /></p> ]]></content:encoded> <wfw:commentRss>http://darkvertex.com/wp/2010/02/21/clean-softimage-deltas/feed/</wfw:commentRss> <slash:comments>6</slash:comments> </item> <item><title>Softimage: Automatic Symmetry Mapping Template</title><link>http://darkvertex.com/wp/2010/01/18/auto-symmetry-mapping-template/</link> <comments>http://darkvertex.com/wp/2010/01/18/auto-symmetry-mapping-template/#comments</comments> <pubDate>Mon, 18 Jan 2010 20:41:16 +0000</pubDate> <dc:creator>Alan</dc:creator> <category><![CDATA[softimage]]></category> <category><![CDATA[scripts]]></category> <category><![CDATA[tools]]></category><guid isPermaLink="false">http://darkvertex.com/wp/?p=151</guid> <description><![CDATA[If you do rigging in Softimage you probably know when trying to Mirror Weights it only pays attention to the last created Symmetry Mapping Template for that model. There&#8217;s no interface to append to or join mapping templates. It gets annoying having to recreate them and verify that Soft guessed all the correct symmetrical equivalents, [...]]]></description> <content:encoded><![CDATA[<p>If you do rigging in Softimage you probably know when trying to <em>Mirror Weights</em> it only pays attention to the last created Symmetry Mapping Template for that model. There&#8217;s no interface to append to or join mapping templates. It gets annoying having to recreate them and verify that Soft guessed all the correct symmetrical equivalents, so&#8230;</p><p><span id="more-151"></span><br /> The following Python script iterates through your selected enveloped objects, creates SymmetryMaps if one doesn&#8217;t exist, and then goes through their envelope deformers and appends them to the SymmetryMappingTemplate for that model based on the naming convention of prefixing &#8220;L_&#8221; for left-side and &#8220;R_&#8221; for right-side objects.</p><p>It assumes the following: (and maybe in the future I&#8217;ll make the code smarter&#8230;)<br /> - Your selected objects all have envelopes.<br /> - Your left-side objects begin with &#8220;L_&#8221; and the right-side with &#8220;R_&#8221;.<br /> - All your selected objects belong to the same Model.<br /> - That you don&#8217;t have more than one SymmetryMappingTemplate under your model. (It will append to the first one found under the model, and create one if one isn&#8217;t found.) I recommend not having one to start with.</p><p>Make yourself a button with this:</p><div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">xsi = Application
lm = xsi.<span style="color: black;">LogMessage</span>
<span style="color: #ff7700;font-weight:bold;">from</span> win32com.<span style="color: black;">client</span> <span style="color: #ff7700;font-weight:bold;">import</span> constants <span style="color: #ff7700;font-weight:bold;">as</span> c
<span style="color: #ff7700;font-weight:bold;">import</span> win32com.<span style="color: black;">client</span>
&nbsp;
objects = win32com.<span style="color: black;">client</span>.<span style="color: black;">Dispatch</span><span style="color: black;">&#40;</span> <span style="color: #483d8b;">&quot;XSI.Collection&quot;</span> <span style="color: black;">&#41;</span>
objects.<span style="color: black;">AddItems</span><span style="color: black;">&#40;</span>xsi.<span style="color: black;">Selection</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># Iterate through selection</span>
<span style="color: #ff7700;font-weight:bold;">for</span> envObj <span style="color: #ff7700;font-weight:bold;">in</span> objects:
	lm<span style="color: black;">&#40;</span> <span style="color: #483d8b;">&quot;Iterating through: &quot;</span>+envObj.<span style="color: black;">FullName</span>, c.<span style="color: black;">siVerbose</span> <span style="color: black;">&#41;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;"># Create a SymmetryMappingTemplate if needed.</span>
	oSymmetryMapTemplate = xsi.<span style="color: black;">Dictionary</span>.<span style="color: black;">GetObject</span><span style="color: black;">&#40;</span> envObj.<span style="color: black;">Model</span>.<span style="color: black;">Name</span>+<span style="color: #483d8b;">&quot;.SymmetryMappingTemplate&quot;</span>, <span style="color: #008000;">False</span> <span style="color: black;">&#41;</span>
	<span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> oSymmetryMapTemplate:
		oSymmetryMapTemplate = xsi.<span style="color: black;">CreateSymmetryMappingTemplate</span><span style="color: black;">&#40;</span>envObj, <span style="color: #008000;">False</span>, <span style="color: #ff4500;">0</span>, <span style="color: #008000;">False</span><span style="color: black;">&#41;</span>
		lm<span style="color: black;">&#40;</span> <span style="color: #483d8b;">&quot;Symmetry Mapping Template not found; created one.&quot;</span>, c.<span style="color: black;">siVerbose</span> <span style="color: black;">&#41;</span>
&nbsp;
&nbsp;
&nbsp;
	<span style="color: #808080; font-style: italic;"># Create a SymmetryMap if it doesn't exist.</span>
	sMapCls = envObj.<span style="color: black;">ActivePrimitive</span>.<span style="color: black;">Geometry</span>.<span style="color: black;">Clusters</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;SymmetryMapCls&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
	found = <span style="color: #008000;">False</span>
	<span style="color: #ff7700;font-weight:bold;">if</span> sMapCls:
		sMap_props = sMapCls.<span style="color: black;">LocalProperties</span>
		<span style="color: #ff7700;font-weight:bold;">for</span> eachProp <span style="color: #ff7700;font-weight:bold;">in</span> sMap_props:
			<span style="color: #ff7700;font-weight:bold;">if</span> eachProp.<span style="color: black;">Type</span> == <span style="color: #483d8b;">&quot;map&quot;</span> <span style="color: #ff7700;font-weight:bold;">and</span> <span style="color: #ff7700;font-weight:bold;">not</span> found:
				sMap = eachProp
				found = <span style="color: #008000;">True</span>
				lm<span style="color: black;">&#40;</span> <span style="color: #483d8b;">&quot;Found SymmetryMap: &quot;</span>+sMap.<span style="color: black;">FullName</span>, c.<span style="color: black;">siVerbose</span> <span style="color: black;">&#41;</span>
&nbsp;
	<span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> found:
		lm<span style="color: black;">&#40;</span> <span style="color: #483d8b;">&quot;SymmetryMap not found; created one.&quot;</span>, c.<span style="color: black;">siVerbose</span> <span style="color: black;">&#41;</span>
		<span style="color: #808080; font-style: italic;">#sMap = xsi.CreateSymmetryMap(&quot;&quot;, envObj, &quot;Symmetry_Map&quot;)(0)</span>
		sMap = xsi.<span style="color: black;">CreateSymmetryMap</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;&quot;</span>, envObj, <span style="color: #483d8b;">&quot;&quot;</span>, <span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span>
&nbsp;
&nbsp;
&nbsp;
	<span style="color: #808080; font-style: italic;"># Add envelope deformers to template by name:</span>
	i = xsi.<span style="color: black;">GetNumMappingRules</span><span style="color: black;">&#40;</span> oSymmetryMapTemplate <span style="color: black;">&#41;</span> + <span style="color: #ff4500;">1</span>
	oppositeNaming = <span style="color: black;">&#123;</span><span style="color: #483d8b;">&quot;L_&quot;</span>:<span style="color: #483d8b;">&quot;R_&quot;</span>, <span style="color: #483d8b;">&quot;R_&quot;</span>:<span style="color: #483d8b;">&quot;L_&quot;</span><span style="color: black;">&#125;</span>
	envelope = envObj.<span style="color: black;">Envelopes</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span>
	deformers = envelope.<span style="color: black;">Deformers</span>
	<span style="color: #ff7700;font-weight:bold;">for</span> eachDef <span style="color: #ff7700;font-weight:bold;">in</span> deformers:
		name_A = eachDef.<span style="color: black;">Name</span>
&nbsp;
		<span style="color: #ff7700;font-weight:bold;">if</span> name_A<span style="color: black;">&#91;</span>:<span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span> <span style="color: #ff7700;font-weight:bold;">in</span> oppositeNaming.<span style="color: black;">keys</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
			name_B = name_A.<span style="color: black;">replace</span><span style="color: black;">&#40;</span>name_A<span style="color: black;">&#91;</span>:<span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span>, oppositeNaming.<span style="color: black;">get</span><span style="color: black;">&#40;</span>name_A<span style="color: black;">&#91;</span>:<span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>, <span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>
&nbsp;
			xsi.<span style="color: black;">AddMappingRule</span><span style="color: black;">&#40;</span> oSymmetryMapTemplate, name_A, name_B, i<span style="color: black;">&#41;</span>
			lm<span style="color: black;">&#40;</span> <span style="color: #483d8b;">&quot;Adding Mapping Rule #&quot;</span>+<span style="color: #008000;">str</span><span style="color: black;">&#40;</span>i<span style="color: black;">&#41;</span>+<span style="color: #483d8b;">&quot;: &quot;</span>+name_A+<span style="color: #483d8b;">&quot; &lt;--&gt; &quot;</span>+name_B, c.<span style="color: black;">siVerbose</span> <span style="color: black;">&#41;</span>
			i += <span style="color: #ff4500;">1</span>
&nbsp;
xsi.<span style="color: black;">SelectObj</span><span style="color: black;">&#40;</span>objects<span style="color: black;">&#41;</span></pre></div></div><p>I might update the code in the future to support multiple models and check if an entry in the template has been added already, but for now this above will have to do.</p><p>Hope it&#8217;s useful to somebody! <img src='http://darkvertex.com/wp/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p> ]]></content:encoded> <wfw:commentRss>http://darkvertex.com/wp/2010/01/18/auto-symmetry-mapping-template/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Rendertree Compound: Shadow AO</title><link>http://darkvertex.com/wp/2009/12/24/shadow-ao-rtcompound/</link> <comments>http://darkvertex.com/wp/2009/12/24/shadow-ao-rtcompound/#comments</comments> <pubDate>Fri, 25 Dec 2009 02:18:08 +0000</pubDate> <dc:creator>Alan</dc:creator> <category><![CDATA[softimage]]></category> <category><![CDATA[compounds]]></category> <category><![CDATA[rendering]]></category><guid isPermaLink="false">http://darkvertex.com/wp/?p=94</guid> <description><![CDATA[Ever noticed that Ambient Occlusion doesn&#8217;t happen in the real world in lit areas? It&#8217;s more of a darkness thing&#8230; so why apply it everywhere? With this Rendertree compound you have AO in darkness and that&#8217;s it. Simple! Now&#8230;.. can you spot the differences between these images below? Diffuse pass, boring looking, no AO: BAD [...]]]></description> <content:encoded><![CDATA[<p>Ever noticed that Ambient Occlusion doesn&#8217;t happen in the real world in lit areas? It&#8217;s more of a darkness thing&#8230; so why apply it everywhere?</p><p><a href="http://s3.darkvertex.com/tools/ShadowAO_ExampleSceneAndCompound.zip">With this Rendertree compound</a> you have AO in darkness and that&#8217;s it. Simple! <img src='http://darkvertex.com/wp/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br /> <a href="http://s3.darkvertex.com/tools/ShadowAO_ExampleSceneAndCompound.zip"><img src="http://wpfiles.darkvertex.com/wp/wp-content/uploads/2009/12/ShadowAO__Good_Comp.png" alt="Notice how there's no AO in lit areas" width="640" height="303" /></p><p><img title="Shadow AO compound" src="http://wpfiles.darkvertex.com/wp/wp-content/uploads/2009/12/ShadowAO_RTcompound_screenshot.png" alt="Shadow AO compound" width="509" height="430" /></a><br /> <span id="more-94"></span></p><p>Now&#8230;.. can you spot the differences between these images below?</p><p>Diffuse pass, boring looking, no AO:<br /> <img src="http://wpfiles.darkvertex.com/wp/wp-content/uploads/2009/12/ShadowAO__Color_Pass.png" alt="" width="640" height="303" /></p><p><strong><span style="color: #ff0000;">BAD</span></strong> &#8212; Sloppy AO that&#8217;s been applied everywhere: (notice how dirty it looks towards the center light)<br /> <img src="http://wpfiles.darkvertex.com/wp/wp-content/uploads/2009/12/ShadowAO__Bad_Comp.png" alt="" width="640" height="303" /></p><p><span style="color: #00ff00;">GOOD</span> &#8212; Shadow-aware AO, only exists where it should&#8230; in darkness:<br /> <img src="http://wpfiles.darkvertex.com/wp/wp-content/uploads/2009/12/ShadowAO__Good_Comp.png" alt="" width="640" height="303" /></p><p><em>Credit where credit is due; this method was originally </em><a href="http://www.grabiller.com/site/download/AOInShadow.JPG" rel="shadowbox[sbpost-94];player=img;"><em>pointed out</em></a><em> by Guy Rabiller many years ago, back when our software was called a 3 letter word.</em></p> ]]></content:encoded> <wfw:commentRss>http://darkvertex.com/wp/2009/12/24/shadow-ao-rtcompound/feed/</wfw:commentRss> <slash:comments>8</slash:comments> </item> <item><title>Softimage: A Self-Contained CurveLength Operator</title><link>http://darkvertex.com/wp/2009/12/17/selfcontained-curvelength-operator/</link> <comments>http://darkvertex.com/wp/2009/12/17/selfcontained-curvelength-operator/#comments</comments> <pubDate>Thu, 17 Dec 2009 22:26:04 +0000</pubDate> <dc:creator>Alan</dc:creator> <category><![CDATA[softimage]]></category> <category><![CDATA[scripts]]></category> <category><![CDATA[tools]]></category><guid isPermaLink="false">http://darkvertex.com/wp/?p=96</guid> <description><![CDATA[Sometimes you need to know the length of a curve for some setups; for a while I sometimes used an addon called jsCurveLength. However, the way it&#8217;s designed relies on the existance of the addon to evaluate. Without it, your rig is broken. I&#8217;ve made a version which is self-contained, so when you export your [...]]]></description> <content:encoded><![CDATA[<p>Sometimes you need to know the length of a curve for some setups; for a while I sometimes used an addon called <a href="http://www.xsibase.com/forum/index.php?board=11;action=display;threadid=35052">jsCurveLength</a>.</p><p>However, the way it&#8217;s designed relies on the existance of the addon to evaluate. Without it, your rig is broken. I&#8217;ve made a version which is self-contained, so when you export your rig you don&#8217;t need to tell people to install any addon.<span id="more-96"></span></p><p>Select your curve(s) and run this code from either a button or the <em>Script Editor</em>. Here&#8217;s the JavaScript:</p><div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Self-Contained CurveLength Op -- http://darkvertex.com/</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> CurveLengthOp_Update<span style="color: #009900;">&#40;</span> In_UpdateContext<span style="color: #339933;">,</span> Out<span style="color: #339933;">,</span> Incrvlist <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	Out.<span style="color: #660066;">Value</span> <span style="color: #339933;">=</span> Incrvlist.<span style="color: #660066;">Value</span>.<span style="color: #660066;">Geometry</span>.<span style="color: #660066;">Curves</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">Length</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> ApplyCurveLengthProp<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	oEnum <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Enumerator<span style="color: #009900;">&#40;</span> Application.<span style="color: #660066;">Selection</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">;!</span>oEnum.<span style="color: #660066;">atEnd</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>oEnum.<span style="color: #660066;">moveNext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> sel <span style="color: #339933;">=</span> oEnum.<span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>sel.<span style="color: #660066;">Type</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;crvlist&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003366; font-weight: bold;">var</span> oProp <span style="color: #339933;">=</span> sel.<span style="color: #660066;">AddProperty</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;Custom_parameter_list&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;CurveLength&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003366; font-weight: bold;">var</span> p <span style="color: #339933;">=</span> oProp.<span style="color: #660066;">AddParameter2</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;CurveLength&quot;</span><span style="color: #339933;">,</span>siDouble<span style="color: #339933;">,</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,-</span><span style="color: #CC0000;">8000</span><span style="color: #339933;">,</span><span style="color: #CC0000;">8000</span><span style="color: #339933;">,-</span><span style="color: #CC0000;">8000</span><span style="color: #339933;">,</span><span style="color: #CC0000;">8000</span><span style="color: #339933;">,</span>siClassifUnknown<span style="color: #339933;">,</span>siPersistable <span style="color: #339933;">|</span> siAnimatable<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;Length&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003366; font-weight: bold;">var</span> crvList <span style="color: #339933;">=</span> sel.<span style="color: #660066;">ActivePrimitive</span><span style="color: #339933;">;</span>
			<span style="color: #003366; font-weight: bold;">var</span> newOp <span style="color: #339933;">=</span> AddScriptedOp<span style="color: #009900;">&#40;</span> p<span style="color: #339933;">,</span> CurveLengthOp_Update.<span style="color: #660066;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> crvList<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;CurveLengthOp&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;JScript&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			newOp.<span style="color: #660066;">Debug</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
			newOp.<span style="color: #660066;">AlwaysEvaluate</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
			newOp.<span style="color: #660066;">Connect</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			LogMessage<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Added CurveLengthOp to: &quot;</span><span style="color: #339933;">+</span>sel.<span style="color: #660066;">FullName</span><span style="color: #339933;">,</span> siVerbose<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
ApplyCurveLengthProp<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>]]></content:encoded> <wfw:commentRss>http://darkvertex.com/wp/2009/12/17/selfcontained-curvelength-operator/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Softimage Tip: ExtrudeOp Transforms</title><link>http://darkvertex.com/wp/2009/12/03/softimage-extrude-transforms/</link> <comments>http://darkvertex.com/wp/2009/12/03/softimage-extrude-transforms/#comments</comments> <pubDate>Thu, 03 Dec 2009 06:19:10 +0000</pubDate> <dc:creator>Alan</dc:creator> <category><![CDATA[softimage]]></category> <category><![CDATA[tutorials]]></category> <category><![CDATA[tips]]></category> <category><![CDATA[tutorial]]></category><guid isPermaLink="false">http://darkvertex.com/wp/?p=86</guid> <description><![CDATA[A lot of people are unaware of the possibilities of the ExtrudeOp operator.  See below&#8230; Try this yourself: Get a sphere. (My screenshot example was a half-sphere.) Select all polys. (Press Y to enter poly mode then Ctrl+A to select all.) Press Ctrl+D to Extrude. In an Explorer open your object&#8217;s operator stack, find the ExtrudeOp and [...]]]></description> <content:encoded><![CDATA[<p>A lot of people are unaware of the possibilities of the ExtrudeOp operator.  See below&#8230;</p><div id="attachment_87" class="wp-caption alignnone" style="width: 310px"><a rel="shadowbox[Mixed];width=1176;height=713" href="http://wpfiles.darkvertex.com/wp/wp-content/uploads/2009/12/xsi_extrudes_great.jpg"><img class="size-medium wp-image-87 " title="xsi_extrudeop_transforms_trick" src="http://wpfiles.darkvertex.com/wp/wp-content/uploads/2009/12/xsi_extrudes_great-300x181.jpg" alt="Fiddling with the ExtrudeOp options" width="300" height="181" /></a><p class="wp-caption-text">Fiddling with the ExtrudeOp options</p></div><p><span id="more-86"></span><br /> Try this yourself:</p><ol><li>Get a sphere. (My screenshot example was a half-sphere.)</li><li>Select all polys. (Press <strong>Y</strong> to enter poly mode then <strong>Ctrl+A</strong> to select all.)</li><li>Press <strong>Ctrl+D</strong> to <em>Extrude</em>.</li><li>In an <em>Explorer</em> open your object&#8217;s operator stack, find the <em><strong>ExtrudeOp</strong></em> and open its PPG.</li><li><strong>Turn off <em>Merge</em></strong>, then fiddle with <strong><em>Length</em></strong>, <strong><em>Inset Amount</em></strong> and <strong><em>Subdivs</em></strong>.</li><li>Then in the <em>Transform</em> tab, play with the sliders there.<br /> You can get some very interesting (and often abstract) results! <img src='http://darkvertex.com/wp/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></li></ol><p><span style="color: #ffcc00;">*</span><strong><span style="color: #ffcc00;">UPDATE [21/05/10]*</span></strong><strong>:</strong> A buddy of mine who uses Maya informs me that the mayan Extrude has options to do this as well if you peek in the channel box. Just so you know. <img src='http://darkvertex.com/wp/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p> ]]></content:encoded> <wfw:commentRss>http://darkvertex.com/wp/2009/12/03/softimage-extrude-transforms/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
