<?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>Softimage Blog &#187; Plugins</title>
	<atom:link href="http://www.softimageblog.com/archives/category/plugins/feed" rel="self" type="application/rss+xml" />
	<link>http://www.softimageblog.com</link>
	<description>People and thoughts behind Softimage in production...</description>
	<lastBuildDate>Mon, 21 Jun 2010 20:40:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Vintage Softimage &#8211; A tribute to Phoenix Tools and Arete</title>
		<link>http://www.softimageblog.com/archives/504#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=vintage-softimage-a-tribute-to-phoenix-tools-and-arete</link>
		<comments>http://www.softimageblog.com/archives/504#comments</comments>
		<pubDate>Fri, 04 Jun 2010 16:55:40 +0000</pubDate>
		<dc:creator>Stefano Jannuzzo</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Rendering]]></category>
		<category><![CDATA[Texturing]]></category>
		<category><![CDATA[World of VFX]]></category>

		<guid isPermaLink="false">http://www.softimageblog.com/?p=504</guid>
		<description><![CDATA[The middle-aged of you will probably remember those names from the 90s.
Phoenix Tools was a plugin company for Softimage 3D, and I was one of the founders. We did good and bad, and we eventually closed down in 2002.
Arete had an excellent reputation for their ocean and atmospheric library, called Digital Nature Tools. I think [...]]]></description>
			<content:encoded><![CDATA[<p>The middle-aged of you will probably remember those names from the 90s.</p>
<p>Phoenix Tools was a plugin company for Softimage 3D, and I was one of the founders. We did good and bad, and we eventually closed down in 2002.</p>
<p>Arete had an excellent reputation for their ocean and atmospheric library, called Digital Nature Tools. I think their main business was in military simulation, however they had a part in every cg-generated ocean in the movies of the 90s.</p>
<p>In 2001 we joined forces to port their software under XSI (I think it was 2.0). Unfortunately, after the first version came out, both companies shut down.</p>
<p>8 years later, I am working on a feature animation with a few shots in water, and I realized I still had on some cd the arete psunami libraries. So, I decided to give it a try. I removed the license check from the shaders and I compiled them with good old Visual Studio 6, linking against the oldest mental ray library I could find (3.3), and in the end it worked. I was kind of touched when I finally saw the displaced grid rendering in Softimage 2010.</p>
<p>I think I will do no harm to anybody releasing these shaders. Both companies are dead since long, and this is my little tribute to them and the talented people who worked there.</p>
<p>The <a href='http://www.softimageblog.com/userContent/upload/2010/06/PT_Arete_Dnt.xsiaddon.zip'>addon is only available for win32</a>, and no, no chances for other platforms. That Arete library is the only one I have. If you do, use it at your own risk (and fun, i would say. There are probably better ways to do oceans nowadays).</p>
<p>And, you know what, I don&#8217;t even know how the full package works. I don&#8217;t have anymore the documentation, nor the scripts we provided. If my old companions will find them, I will post them later.</p>
<p>The basic usage however is easy. You have to connect a DNT_Ocean_Sh and DNT_Time to a DNT_Ocean_Evolver. What come out is the ocean instance, that can then go into the other nodes. Also, you want to apply DNT_Air as environment to have nice reflection and the atmosphere.</p>

<a href='http://www.softimageblog.com/archives/504/arete-1' title='Arete #1'><img width="150" height="103" src="http://www.softimageblog.com/userContent/upload/2010/06/arete.1.jpg" class="attachment-thumbnail" alt="Arete - displacement and optics" title="Arete #1" /></a>
<a href='http://www.softimageblog.com/archives/504/arete-2' title='Arete #2'><img width="150" height="100" src="http://www.softimageblog.com/userContent/upload/2010/06/arete.2.jpg" class="attachment-thumbnail" alt="Arete - Optics only" title="Arete #2" /></a>
<a href='http://www.softimageblog.com/archives/504/arete-3' title='Arete #3'><img width="150" height="99" src="http://www.softimageblog.com/userContent/upload/2010/06/arete.3.jpg" class="attachment-thumbnail" alt="Arete - Bump only rendered with a phong material" title="Arete #3" /></a>

<img src="http://www.softimageblog.com/?ak_action=api_record_view&id=504&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.softimageblog.com/archives/504/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Dynamic Callbacks In Plugins</title>
		<link>http://www.softimageblog.com/archives/265#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=dynamic-callbacks-in-plugins</link>
		<comments>http://www.softimageblog.com/archives/265#comments</comments>
		<pubDate>Thu, 12 Jun 2008 01:12:46 +0000</pubDate>
		<dc:creator>Patrick Boucher</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.xsi-blog.com/?p=265</guid>
		<description><![CDATA[I really like applications that provide rich SDKs for it&#8217;s users to play around with. I also like event based systems and callbacks. These are all things that make me absolutely love writing up plugins inside XSI. But there is one small problem, I find, with XSI&#8217;s callbacks.
Callbacks in XSI plugins are functions in the [...]]]></description>
			<content:encoded><![CDATA[<p>I really like applications that provide rich SDKs for it&#8217;s users to play around with. I also like event based systems and callbacks. These are all things that make me absolutely love writing up plugins inside XSI. But there is one small problem, I find, with XSI&#8217;s callbacks.</p>
<p>Callbacks in XSI plugins are functions in the global scope who&#8217;s name must be defined exactly the way XSI expects to find them.</p>
<p>I would have preferred callbacks to be supplied by the user in a way that allows them to have any name and in a way that allows them to be changed on the fly. In all fairness, Softimage probably has some very good reasons for the way they did things.</p>
<p>So this is where we, as users, exploit the power that has been given to us and take things into our own hands. Here is my implementation of dynamic, interchangeable, replaceable callbacks.</p>
<p><span id="more-265"></span><strong>Code Time!</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> win32com.<span style="color: black;">client</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;">from</span> vg.<span style="color: black;">xsi</span>.<span style="color: black;">dynamic</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> XSILoadPlugin<span style="color: black;">&#40;</span> in_reg <span style="color: black;">&#41;</span>:
	in_reg.<span style="color: black;">Author</span> = <span style="color: #483d8b;">&quot;Patrick Boucher&quot;</span>
	in_reg.<span style="color: black;">Name</span> = <span style="color: #483d8b;">&quot;dynCbCommandPlugin&quot;</span>
	in_reg.<span style="color: black;">Major</span> = <span style="color: #ff4500;">1</span>
	in_reg.<span style="color: black;">Minor</span> = <span style="color: #ff4500;">0</span>
	in_reg.<span style="color: black;">RegisterCommand</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;dynCbCommand&quot;</span>, <span style="color: #483d8b;">&quot;dynCbCommand&quot;</span><span style="color: black;">&#41;</span>
	<span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">True</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> XSIUnloadPlugin<span style="color: black;">&#40;</span> in_reg <span style="color: black;">&#41;</span>:
	strPluginName = in_reg.<span style="color: black;">Name</span>
	Application.<span style="color: black;">LogMessage</span><span style="color: black;">&#40;</span><span style="color: #008000;">str</span><span style="color: black;">&#40;</span>strPluginName<span style="color: black;">&#41;</span> + <span style="color: #008000;">str</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot; has been unloaded.&quot;</span><span style="color: black;">&#41;</span>,c.<span style="color: black;">siVerbose</span><span style="color: black;">&#41;</span>
	<span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">True</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> dynCbCommand_Init<span style="color: black;">&#40;</span> in_ctxt <span style="color: black;">&#41;</span>:
	oCmd = in_ctxt.<span style="color: black;">Source</span>
	oCmd.<span style="color: black;">Description</span> = <span style="color: #483d8b;">&quot;&quot;</span>
	oCmd.<span style="color: black;">ReturnValue</span> = <span style="color: #008000;">True</span>
	<span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">True</span>
&nbsp;
@dynamic
<span style="color: #ff7700;font-weight:bold;">def</span> dynCbCommand_Execute<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
	Application.<span style="color: black;">LogMessage</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'In original callback!'</span><span style="color: black;">&#41;</span>
	setCallback<span style="color: black;">&#40;</span>dynCbCommand_Execute, callbackTwo<span style="color: black;">&#41;</span>
	<span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">True</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> callbackTwo<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
	Application.<span style="color: black;">LogMessage</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'In %s!'</span> <span style="color: #66cc66;">%</span> callback<span style="color: black;">&#40;</span>dynCbCommand_Execute<span style="color: black;">&#41;</span>.<span style="color: black;">func_name</span><span style="color: black;">&#41;</span>
	setCallback<span style="color: black;">&#40;</span>dynCbCommand_Execute, callbackThree<span style="color: black;">&#41;</span>
	<span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">True</span>	
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> callbackThree<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
	Application.<span style="color: black;">LogMessage</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'In callback three!'</span><span style="color: black;">&#41;</span>
	restoreCallback<span style="color: black;">&#40;</span><span style="color: #483d8b;">'dynCbCommand_Execute'</span><span style="color: black;">&#41;</span>
	<span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">True</span>	
&nbsp;
setCallback<span style="color: black;">&#40;</span>dynCbCommand_Execute, callbackTwo<span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>The first time you run this command it will run the code in <code>callbackTwo</code> and switch itself to new code. The next time it will run <code>callbackThree</code> and the next time it will run the original callback code. It will then, with each consecutive invocation of the command, continue on in this loop. This plugin, as you have guessed, is just a demo of the dynamic callbacks.</p>
<p>The lines you have to concentrate on are the following:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> vg.<span style="color: black;">xsi</span>.<span style="color: black;">dynamic</span> <span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #66cc66;">*</span></pre></div></div>

<p>and</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">@dynamic</pre></div></div>

<p>These are the lines that provide the core of the functionality which is imported from the <code>vg.xsi.dynamic</code> module. Here it is&#8230;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>
&nbsp;
__all__ = <span style="color: black;">&#91;</span><span style="color: #483d8b;">'dynamic'</span>, <span style="color: #483d8b;">'setCallback'</span>, <span style="color: #483d8b;">'callback'</span>, <span style="color: #483d8b;">'restoreCallback'</span><span style="color: black;">&#93;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> Wrapper<span style="color: black;">&#40;</span><span style="color: #008000;">object</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, cb<span style="color: black;">&#41;</span>:
        <span style="color: #008000;">self</span>.__defaultCb = cb
        <span style="color: #008000;">self</span>.__cb = cb
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> call<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, <span style="color: #66cc66;">*</span>args, <span style="color: #66cc66;">**</span>kwargs<span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">self</span>.__cb<span style="color: black;">&#40;</span><span style="color: #66cc66;">*</span>args, <span style="color: #66cc66;">**</span>kwargs<span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> setCallback<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, newCb<span style="color: black;">&#41;</span>:
        <span style="color: #008000;">self</span>.__cb = newCb
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> callback<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">self</span>.__cb
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> restoreCallback<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #008000;">self</span>.__cb = <span style="color: #008000;">self</span>.__defaultCb
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> dynamic<span style="color: black;">&#40;</span>func<span style="color: black;">&#41;</span>:
    cbWrap = Wrapper<span style="color: black;">&#40;</span>func<span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> cbWrap.<span style="color: black;">call</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> setCallback<span style="color: black;">&#40;</span>bound, newCb<span style="color: black;">&#41;</span>:
    bound = _getCallable<span style="color: black;">&#40;</span>bound<span style="color: black;">&#41;</span>
    newCb = _getCallable<span style="color: black;">&#40;</span>newCb<span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> bound.<span style="color: black;">im_self</span>.<span style="color: black;">setCallback</span><span style="color: black;">&#40;</span>newCb<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> callback<span style="color: black;">&#40;</span>bound<span style="color: black;">&#41;</span>:
    bound = _getCallable<span style="color: black;">&#40;</span>bound<span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> bound.<span style="color: black;">im_self</span>.<span style="color: black;">callback</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> restoreCallback<span style="color: black;">&#40;</span>bound<span style="color: black;">&#41;</span>:
    bound = _getCallable<span style="color: black;">&#40;</span>bound<span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> bound.<span style="color: black;">im_self</span>.<span style="color: black;">restoreCallback</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> _getCallable<span style="color: black;">&#40;</span>req<span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">callable</span><span style="color: black;">&#40;</span>req<span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">return</span> req
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">type</span><span style="color: black;">&#40;</span>req<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">is</span> <span style="color: #008000;">str</span>:
        g = <span style="color: #dc143c;">sys</span>._getframe<span style="color: black;">&#40;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span>.<span style="color: black;">f_globals</span>
        <span style="color: #ff7700;font-weight:bold;">return</span> g<span style="color: black;">&#91;</span>req<span style="color: black;">&#93;</span></pre></td></tr></table></div>

<p>I&#8217;ve removed any comments or docstrings for the sake of brevity.</p>
<p><strong>About Decorators</strong></p>
<p>The import line I said was of particular interest. Well it is but only in the sense that it will allow you to use the module in which the features are implemented&#8230; Moving on quickly.</p>
<p>The real fun is with the <code>@dynamic</code> decorator. What is a decorator and what happens when we use one (or this one in particular)? Before we look at what a decorator is and does, let&#8217;s look at what happens when we define a function.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">def</span> func<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">pass</span></pre></td></tr></table></div>

<p>When a function is defined, what is happening is that an identifier is created in your current scope and this identifier is given the name of your function. Now let&#8217;s add the decorator. A decorator is just a simple function, but a function who&#8217;s purpose is very specific and a function that must return a callable (another function most of the time).</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="python" style="font-family:monospace;">@myDecorator
<span style="color: #ff7700;font-weight:bold;">def</span> func<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">pass</span></pre></td></tr></table></div>

<p>What happens here is that the identifier <code>func</code> is still created but what lies &#8216;in&#8217; this identifier is not the function itself but the result of passing said function to <code>myDecorator</code>. To help you visualize, the above code could just as easily been written like so:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">def</span> func<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">pass</span>
func = myDecorator<span style="color: black;">&#40;</span>func<span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p><strong>Let&#8217;s Get Specific</strong></p>
<p>The decorator <code>@dynamic</code> takes your callback and wraps it inside a <code>Wrapper</code> object and returns the <code>call</code> method of this new object. When XSI tries to call what it thinks is just a simple callback it is actually calling the <code>call</code> method of an object that in turn calls your original callback. Whew!</p>
<p>This means that you now have the liberty of querying and editing the <em>callback object</em> and telling it to call something different depending on context. This functionality is provided by the <code>setCallback</code>, <code>callback</code> and <code>restoreCallback</code> functions.</p>
<p>These three functions either take the callback function objects or the callback&#8217;s names (as a string) as arguments.</p>
<p>There are some more particularities to this code such as the use of <code>sys._getframe</code>, the <code>im_self</code> attribute or the use of the <code>call</code> method on the <code>Wrapper</code> object instead of implementing <code>__call__</code> but I think they might be outside the scope of this article. If there are requests for it I can expand in the comments or another post.</p>
<p>Meanwhile you can <a href='http://www.xsi-blog.com/userContent/upload/2008/06/dynamiccallbacks.zip'>download the example</a>. Drop the plugin into a plugin folder (user, factory or workgroup) and drop the <em>vg</em> folder somewhere in your Python path.</p>
<p>Cheers!</p>
<img src="http://www.softimageblog.com/?ak_action=api_record_view&id=265&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.softimageblog.com/archives/265/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Proxy Select And Anticipating A User&#8217;s Needs</title>
		<link>http://www.softimageblog.com/archives/263#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=proxy-select-and-anticipating-a-users-needs</link>
		<comments>http://www.softimageblog.com/archives/263#comments</comments>
		<pubDate>Sun, 08 Jun 2008 19:09:41 +0000</pubDate>
		<dc:creator>Patrick Boucher</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://www.xsi-blog.com/?p=263</guid>
		<description><![CDATA[Two weeks ago Bryan Blevins, CG Supervisor at Wild Canary, asked a question on the Softimage&#124;Net community about the possibility of doing proxy selects.
You all remember the idea of a proxy parameter where editing a parameter in a custom PPG (lets call this one the source) will in fact be changing another elsewhere in the [...]]]></description>
			<content:encoded><![CDATA[<p>Two weeks ago Bryan Blevins, CG Supervisor at <a title="Wild Canary" href="http://www.wildcanary.com/" target="_blank">Wild Canary</a>, asked a question on the <a title="Softimage|Net" href="http://community.softimage.com" target="_blank">Softimage|Net</a> community about the <a href="http://community.softimage.com/showthread.php?t=1361" target="_blank">possibility of doing proxy selects</a>.</p>
<p>You all remember the idea of a proxy parameter where editing a parameter in a custom PPG (lets call this one the source) will in fact be changing another elsewhere in the scene (this one we will call the target). Extend this idea to a selection where selecting a source will in fact &#8216;transfer&#8217; the selection to another object. This could be useful, among other cases, in a rigging scenario.</p>
<p>As it was suggested in the thread, there are many use cases for a functionality like this that can be addressed with native XSI tools and methodologies but nonetheless, I felt like there might be some cases where an actual proxy select could be useful. So I cooked one up for Bryan, and <a title="Proxy Select" href="http://www.xsi-blog.com/userContent/upload/2008/06/proxyselect.zip">here it is</a>.</p>
<p>Select one or more targets and then go to Get -&gt; Property -&gt; Proxy Select and then pick one or more source objects. From then on whenever you select a source object, it will unselect itself and select the targets instead. There is some sanity checking in there to try and avoid dependency loops and the like, just in case.</p>
<p>There are also three menu items in the MCP Select menu that will toggle proxy select functionality in six different ways.</p>
<ul>
<li>Toggle on proxy select for all objects &#8211; when nothing is selected</li>
<li>Toggle off proxy select for all objects &#8211; when nothing is selected</li>
<li>Toggle/Inverse proxy select state for all objects &#8211; when nothing is selected</li>
<li>Toggle on proxy select for selected objects</li>
<li>Toggle off proxy select for selected objects</li>
<li>Toggle/Inverse proxy select state for selected objects</li>
</ul>
<p>I can already hear you asking: &#8220;How can I select a proxy select source to toggle it&#8217;s functionality if it is already on and automatically transfers it&#8217;s selection?&#8221;</p>
<p>Well,</p>
<ul>
<li>If it is only one object you wish to toggle you can go directly to it&#8217;s Proxy Select custom property.</li>
<li>If you wish to act on multiple objects with these toggle menus, you can multi select the objects and toggle them all together. When multiple objects are selected, no selection transfer takes place.</li>
<li>This also means that you can multi select a proxy select source with any other object and then use the menu items, any object that isn&#8217;t a proxy select source will be safely ignored.</li>
</ul>
<p><strong>And then came Thiago</strong></p>
<p>One of the people involved in the thread was Thiago Costa from <a href="http://www.nervo.tv/" target="_blank">Nervo.tv</a>. He is actually the one who suggested an approach for creating the Proxy Select plugin in the first place. Well, about the same time I had sent Bryan my first draft Thiago posted <a href="http://community.softimage.com/showthread.php?p=5744#poststop" target="_blank">his version</a>. I said it in the thread and I will say it again, it is very nicely executed.</p>
<p>One of the things he did is that he anticipated the user&#8217;s needs and thought for a second about what you would like to do with the resulting select.</p>
<p>Something that happens to often (well for me anyway), and especially in the heat of production, is that we fail to properly establish requirements.</p>
<p><em>These requirement will inevitably change.<br />
</em></p>
<p>When the first wave of requirements is put down on paper some time should be spent trying to anticipate the user&#8217;s needs as well as possible future requirements. Even if these extra features aren&#8217;t initially implemented, having this foresight will allow the resulting code to better accomodate change.</p>
<p><strong>Downloads</strong></p>
<p>Check out the <a href="http://community.softimage.com/showthread.php?p=5744#poststop" target="_blank">thread at Softimage|Net</a> for Thiago&#8217;s version.</p>
<p>Download my version from <a href="http://www.xsi-blog.com/userContent/upload/2008/06/proxyselect.zip">here</a>.</p>
<img src="http://www.softimageblog.com/?ak_action=api_record_view&id=263&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.softimageblog.com/archives/263/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Steven Caron, OBJ Files, Sexy Bits and Waste</title>
		<link>http://www.softimageblog.com/archives/249#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=steven-caron-obj-files-sexy-bits-and-waste</link>
		<comments>http://www.softimageblog.com/archives/249#comments</comments>
		<pubDate>Sat, 01 Mar 2008 20:25:45 +0000</pubDate>
		<dc:creator>Patrick Boucher</dc:creator>
				<category><![CDATA[Bablings and Ramblings]]></category>
		<category><![CDATA[Modeling]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.xsi-blog.com/archives/249</guid>
		<description><![CDATA[What do all these things have in common?
The weird wirings in my brain. That&#8217;s what.
Back to the beginning
At the end of last October Steven Caron sent me a plugin he wrote that allows an XSI user to drag and drop .obj files into the interface and have them import automatically according to settings in a [...]]]></description>
			<content:encoded><![CDATA[<p>What do all these things have in common?</p>
<p>The weird wirings in my brain. That&#8217;s what.</p>
<p><strong>Back to the beginning</strong></p>
<p>At the end of last October Steven Caron sent me a <a href="http://www.xsi-blog.com/userContent/scaron/ObjDnD.xsiaddon">plugin</a> he wrote that allows an XSI user to drag and drop .obj files into the interface and have them import automatically according to settings in a custom preference. I was a bit swamped at the time putting up the infrastructure for a new VFX department at my new workplace. And then I totally forgot about it&#8230; Sorry Steven.</p>
<p>This past week Steven politely reminded me of my omission so I ran back to my email archives and installed it. Neat piece of work.</p>
<p>I didn&#8217;t want to just post up the tool as I don&#8217;t really see this blog being about tool distribution but about how said tools work and the neat tricks they use. With that philosophy in mind I cracked open Steven&#8217;s tool to dig out some of its sexier bits and maybe demystify them for the audience.</p>
<p>To my surprise there weren&#8217;t any sexy bits. Please don&#8217;t get me wrong, the tool works superbly, how much more intuitive can you get than drag and drop. The tool is also extremely well written, concise and straightforward. There just aren&#8217;t any weird tricks or convoluted syntax or things that would generally have you scratching your head.</p>
<p>Then I noticed this in his version trapping code (yes folks, the drag and drop event is new in XSI 6.5):</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>27
28
29
30
31
32
33
34
35
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">int</span><span style="color: black;">&#40;</span> tXSIVersion<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> <span style="color: black;">&#41;</span> <span style="color: #66cc66;">&lt;</span> <span style="color: #ff4500;">6</span>:
    xsiPrint<span style="color: black;">&#40;</span> xsi.<span style="color: black;">Version</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> + <span style="color: #483d8b;">&quot; doesn't support the 'siOnDragAndDrop' event!&quot;</span> <span style="color: black;">&#41;</span>
    xsi.<span style="color: black;">UnloadPlugin</span><span style="color: black;">&#40;</span> in_reg.<span style="color: black;">name</span>, <span style="color: #008000;">True</span> <span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">False</span>
<span style="color: #ff7700;font-weight:bold;">else</span>:
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">int</span><span style="color: black;">&#40;</span> tXSIVersion<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: #66cc66;">&lt;</span> <span style="color: #ff4500;">5</span>:
        xsiPrint<span style="color: black;">&#40;</span> xsi.<span style="color: black;">Version</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> + <span style="color: #483d8b;">&quot; doesn't support the 'siOnDragAndDrop' event!&quot;</span> <span style="color: black;">&#41;</span>
        xsi.<span style="color: black;">UnloadPlugin</span><span style="color: black;">&#40;</span> in_reg.<span style="color: black;">name</span>, <span style="color: #008000;">True</span> <span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">False</span></pre></td></tr></table></div>

<p><span id="more-249"></span><b>About the waste part</b></p>
<p>Bare with me&#8230;</p>
<p>Last week I was reading a really neat <a href="http://www.wired.com/techbiz/it/magazine/16-03/ff_free">article</a> in <a href="http://www.wired.com">Wired</a> by Chris Anderson entitled <i>&#8220;Free! Why $0.00 Is the Future of Business&#8221;</i>. I invite you to read it, especially the section beginning on page two: <i>Waste and Waste Again</i>.</p>
<p>&#8230;So if in the seventies you had to be really tight with your algorithms and optimizations because cpu cycles were so scarce, today I guess we can really waste them. Just the other day I setup an 8 core MacPro with BootCamp, XP x64 and XSI. Whatever I did to the machine, I swear, I could hear it yawn because it was bored.</p>
<p>Which brings me back to Steven&#8217;s code. Could it have been written like so:</p>
</pre>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>27
28
29
30
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">int</span><span style="color: black;">&#40;</span> tXSIVersion<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> <span style="color: black;">&#41;</span> <span style="color: #66cc66;">&lt;</span> <span style="color: #ff4500;">6</span> <span style="color: #ff7700;font-weight:bold;">or</span> <span style="color: #008000;">int</span><span style="color: black;">&#40;</span> tXSIVersion<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: #66cc66;">&lt;</span> <span style="color: #ff4500;">5</span>:
    xsiPrint<span style="color: black;">&#40;</span> xsi.<span style="color: black;">Version</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> + <span style="color: #483d8b;">&quot; doesn't support the 'siOnDragAndDrop' event!&quot;</span> <span style="color: black;">&#41;</span>
    xsi.<span style="color: black;">UnloadPlugin</span><span style="color: black;">&#40;</span> in_reg.<span style="color: black;">name</span>, <span style="color: #008000;">True</span> <span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">False</span></pre></td></tr></table></div>

<p>Is it more or less readable by a programmer?<br />
It probably executes in a few cycles less but is it worth it?<br />
Python is interpreted so if the parser goes through this version quicker, is it worty of any mention?<br />
Is it more maintainable?</p>
<p>This example is really simple but in a bigger project, or with more complex cases, should we really be worrying if today transistors and cpu cycles are so cheap as to not even matter anymore</p>
<p>When I'm stuck on a piece of code or when I hit that time of the afternoon where most of my energy is diverted to digesting, I'll often reread my code and tighten it, remove redundancy, put in functions instead of copying a few lines in two locations, consolidate <i>if</i> statements, etc... One of my colleagues used to tell me that <i>"Premature optimization is the root of all evil."</i></p>
<p>Honestly, if I look back at a good proportion of the code I have written, it either executes in a blink of an eye on today's computers or it sits there waiting 90% of the time for user interaction. Should we, as technical XSI users, XSI scripters or TDs, even worry about optimization from a performance standpoint or a maintainability standpoint? What can be considered a good optimization and what should be considered a bad one?</p>
<p>And now that you're really wondering what I'm rambling about, I'll shut up and let you <a href="http://www.xsi-blog.com/userContent/scaron/ObjDnD.xsiaddon">download Steven's addon</a>.</p>
<p>Have a good weekend.</pre>
<img src="http://www.softimageblog.com/?ak_action=api_record_view&id=249&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.softimageblog.com/archives/249/feed</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Points of Light</title>
		<link>http://www.softimageblog.com/archives/219#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=points-of-light</link>
		<comments>http://www.softimageblog.com/archives/219#comments</comments>
		<pubDate>Wed, 06 Jun 2007 02:56:18 +0000</pubDate>
		<dc:creator>Vladimir Jankijevic</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Rendering]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://www.xsi-blog.com/archives/219</guid>
		<description><![CDATA[Some time ago, I stumbled across the MapVIZ node in Maya and was surprised, that Softimage didn&#8217;t implement something like this in our beloved software package, XSI. Well, last weekend I decided to code it myself.
The first step to take, was to decipher the the file structure of the FG and Photon maps. Since the [...]]]></description>
			<content:encoded><![CDATA[<p>Some time ago, I stumbled across the MapVIZ node in Maya and was surprised, that <a href="http://www.softimage.com">Softimage</a> didn&#8217;t implement something like this in our beloved software package, XSI. Well, last weekend I decided to code it myself.</p>
<p>The first step to take, was to decipher the the file structure of the FG and Photon maps. Since the files are written in binary, this wasn&#8217;t that easy. But with the help of UltraEdit, a HEX editor for Windows, and some trial and error, the main file structure mystery was unveiled. Here is an example of how this looks like in a FG map:</p>
<p><img src='http://www.xsi-blog.com/userContent/upload/2007/06/hex.gif' alt='hex.gif' width='600'/></p>
<p>The blue marked part is the file type and the version of MentalRay. The green part is a 32 bit integer value which is the total FG Point count. Next comes the FG Point itself. One FG point is represented in 104 bytes in total. That&#8217;s the first bright block. The first 12 bytes are the x, y and z coordinates in 32bit floating point numbers. And so on&#8230;</p>
<p><span id="more-219"></span>Final Gathering maps have another structure than Photon maps and thus it took me twice the time to build the file structure.</p>
<p>Once this was done, I had a little look into OpenGL programming and had a little talk to Andrea Interguglielmi. He helped me with the Logic behind the connection between XSI and OpenGL.</p>
<p>What this tool does is in fact pretty simple. When the plugin is loaded, it registers a new DisplayCallback and allocates some basic memory. Then, after you select a map and press on the &#8220;Show Map&#8221; button, it reads the chosen file and creates an array of position and color values which are stored in the memory and then displayed through some basic OpenGL functions.</p>
<p><img src='http://www.xsi-blog.com/userContent/upload/2007/06/ppg.gif' alt='ppg.gif' /></p>
<p>With this tool you have the ability to view your saved FG and Photon maps in your 3D-Viewport of XSI. After installation, you can find it under Get-> Property-> JV_MapMiner. It is provided as is and nobody is responsible in any way for any possible damage.</p>
<p>I hope this tool can help people to optimize their renderings and make their lives a little bit more comfortable.</p>
<p>You can download the <a href="http://www.xsi-blog.com/userContent/upload/2007/06/mapMinerAddon.rar">.xsiaddon</a> (tested on XSI 5.x and 6.1) and a <a href="http://www.xsi-blog.com/userContent/upload/2007/06/mapMinerScene.rar">demo project</a> with one FG map, one GI map, one Caustic map and one GI+Caustic map combined (27mb).</p>
<p>You are welcome to send me bug-reports or suggestions.</p>
<p><a href='http://www.xsi-blog.com/userContent/upload/2007/06/fg_s.mov' title='fg_s.mov'>FG Quicktime</a><br />
<a href='http://www.xsi-blog.com/userContent/upload/2007/06/gi_s.mov' title='gi_s.mov'>GI Quicktime</a><br />
<a href='http://www.xsi-blog.com/userContent/upload/2007/06/caustics_s.mov' title='caustics_s.mov'>Caustics Quicktime</a></p>
<p><img src='http://www.xsi-blog.com/userContent/upload/2007/06/types.gif' alt='types.gif' /></p>
<p>Buddha 3D-Model courtesy of the <a href="http://graphics.stanford.edu/data/3Dscanrep">Stanford Computer Graphics Laboratory</a>.</p>
<img src="http://www.softimageblog.com/?ak_action=api_record_view&id=219&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.softimageblog.com/archives/219/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
<enclosure url="http://www.xsi-blog.com/userContent/upload/2007/06/fg_s.mov" length="1318982" type="video/quicktime" />
<enclosure url="http://www.xsi-blog.com/userContent/upload/2007/06/gi_s.mov" length="1713249" type="video/quicktime" />
<enclosure url="http://www.xsi-blog.com/userContent/upload/2007/06/caustics_s.mov" length="1443768" type="video/quicktime" />
		</item>
		<item>
		<title>Normal to Vertex Color</title>
		<link>http://www.softimageblog.com/archives/125#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=normal-to-vertex-color</link>
		<comments>http://www.softimageblog.com/archives/125#comments</comments>
		<pubDate>Sat, 09 Dec 2006 20:11:03 +0000</pubDate>
		<dc:creator>Patrick Boucher</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Rendering]]></category>

		<guid isPermaLink="false">http://www.xsi-blog.com/?p=125</guid>
		<description><![CDATA[Buzz has been working for a little while on a show that required us to create quite a few shots of water surfaces. One of the guys here, Pierre-Simon Lebrun-Chaput, cooked up a really cool recipe for our water surfaces but to get the look to where he wanted it he was missing a critical [...]]]></description>
			<content:encoded><![CDATA[<p>Buzz has been working for a little while on a show that required us to create quite a few shots of water surfaces. One of the guys here, Pierre-Simon Lebrun-Chaput, cooked up a really cool recipe for our water surfaces but to get the look to where he wanted it he was missing a critical piece of information for his shader tree: geometry normals.</p>
<p><strong>Missing Normals?</strong></p>
<p>The normals weren&#8217;t missing per say. His geometry had deformations, displacement and bump mapping. In the render tree, normals could be accessed after displacement and after bump but we couldn&#8217;t access them before displacement to save our lives.</p>
<p>This is when we decided to create an XSI Operator that would convert geometry normals prior to displacement into vertex colors that could then be used in the render tree through a Vertex_rgba node. It did the job quite nicely.</p>
<p><span id="more-125"></span><strong>Results</strong></p>
<p>Here is a screen grab from a slightly mushed sphere with the Operator applied:</p>
<p><img src="/userContent/patrickb/VCNormals/VCNormals.jpg" alt="XSI Screengrab of NormalToVertexColor Operator applied." /></p>
<p>You can also view a <a href="/userContent/patrickb/VCNormals/Sea.mov">quicktime movie</a> (requires QT7) of a preliminary test of the sea recipe that uses this operator.</p>
<p>If you wish you can <a href="/userContent/patrickb/VCNormals/NormalToVertexColor.zip">download</a> the operator and dump it into your favorite Application/Plugins folder.</p>
<p>Get a poly geometry and apply the op through Render -> Get -> Property -> Normal Vertex Color</p>
<p>Cheers,<br />
Patrick</p>
<img src="http://www.softimageblog.com/?ak_action=api_record_view&id=125&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.softimageblog.com/archives/125/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
<enclosure url="http://www.xsi-blog.com/userContent/patrickb/VCNormals/Sea.mov" length="2557210" type="video/quicktime" />
		</item>
		<item>
		<title>More Jitters</title>
		<link>http://www.softimageblog.com/archives/124#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=more-jitters</link>
		<comments>http://www.softimageblog.com/archives/124#comments</comments>
		<pubDate>Sat, 09 Dec 2006 19:14:23 +0000</pubDate>
		<dc:creator>Patrick Boucher</dc:creator>
				<category><![CDATA[Animation]]></category>
		<category><![CDATA[Plugins]]></category>

		<guid isPermaLink="false">http://www.xsi-blog.com/?p=124</guid>
		<description><![CDATA[A while ago I posted a Scripted Operator for XSI that generates jittering animation.
Well, a colleague of mine, Etienne Pellerin, and myself are starting to work in C++ in XSI so the Jitter tool was rewritten.
New in Jitter v1.5:

Installation is smoother &#8211; just drop it into your favourite Application/Plugins folder
Performance is increased when you have [...]]]></description>
			<content:encoded><![CDATA[<p>A <a href="http://www.xsi-blog.com/?p=23">while ago</a> I posted a Scripted Operator for XSI that generates jittering animation.</p>
<p>Well, a colleague of mine, Etienne Pellerin, and myself are starting to work in C++ in XSI so the Jitter tool was rewritten.</p>
<p>New in Jitter v1.5:</p>
<ul>
<li>Installation is smoother &#8211; just drop it into your favourite Application/Plugins folder</li>
<li>Performance is increased when you have large numbers of Jitter Ops</li>
<li>You can now apply the operator to parameter groups such as kine.local.ori.euler</li>
</ul>
<p><span id="more-124"></span>You can <a href="/userContent/patrickb/Jitter/Jitter_v1.5.zip">download</a> the new version and beat the snot out of it if you wish. I can&#8217;t guarantee it&#8217;ll survive though, and if it doesn&#8217;t drop me a line and I can fix bugs.</p>
<p>I only have a windows version but if someone has a Linux box and would care to recompile I can host both versions.</p>
<p>Cheers,<br />
Patrick</p>
<img src="http://www.softimageblog.com/?ak_action=api_record_view&id=124&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.softimageblog.com/archives/124/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Enveloping rigid elements</title>
		<link>http://www.softimageblog.com/archives/110#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=enveloping-rigid-elements</link>
		<comments>http://www.softimageblog.com/archives/110#comments</comments>
		<pubDate>Mon, 21 Aug 2006 10:15:24 +0000</pubDate>
		<dc:creator>Helge Mathee</dc:creator>
				<category><![CDATA[JScript]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Rigging]]></category>

		<guid isPermaLink="false">http://www.xsi-blog.com/?p=110</guid>
		<description><![CDATA[how to get elements on a surface, while they are not deforming.]]></description>
			<content:encoded><![CDATA[<p>Alright, here&#8217;s a new article of mine. This time I am dealing with a problem a lot of people are facing when trying to envelope a large number of objects onto a surface, while the objects themselves are not supposed to deform. As this is a typical problem related to objects like feathers, all scripts + tools are named somewhat related to feathers. All of these techniques can be applied to other objects as well, though.</p>
<p>Lets start. One easy way to approach this problem is to create a mesh including all objects we want to envelope, and then simply set the envelope weights of all points of a single instance to the exact same weight, aka:</p>
<p>In this image we have a mesh with 6 cubes (all merged together) enveloped to a two-bone chain.<br />
By default the weight is blended in the middle part,</p>
<p><img src="http://www.xsi-blog.com/userContent/hmathee/wingRig/rigid_env_01.jpg" alt="" /></p>
<p>which results in a deform for the middle two cubes:</p>
<p><img src="http://www.xsi-blog.com/userContent/hmathee/wingRig/rigid_env_02.jpg" alt="" /></p>
<p><span id="more-110"></span>by using the weight editor, I adjusted the weight of all cubes so they only target one bone:</p>
<p><img src="http://www.xsi-blog.com/userContent/hmathee/wingRig/rigid_env_03.jpg" alt="" /></p>
<p>which results in movement, but not deformation for each one:</p>
<p><img src="http://www.xsi-blog.com/userContent/hmathee/wingRig/rigid_env_04.jpg" alt="" /></p>
<p>So this is all working, why bother dealing with a system to deal with these things? Well, as long as we are dealing with six cubes it is all cheesy and simple, but as soon as we start dealing with something like feathers on a bird, we can&#8217;t just go in and envelope each feather with the weight editor, well, we could, but it would just take forever.</p>
<p>What I used to do in those cases is to build an instancer operator, which would take a mesh containing &#8220;where-and-how-to-instance&#8221; information, and a single mesh which is supposed to be instanced. First, lets clarify the &#8220;where&#8230;to-instance&#8221; part:</p>
<p>When instancing an object, all you need is a position, orientation and scaling, which can be stored as three points really, but in this example I am going to use 4 points:</p>
<p><img src="http://www.xsi-blog.com/userContent/hmathee/wingRig/rigid_env_05.jpg" alt="" /></p>
<p>1. Pos: The position of the object to be instanced<br />
2. Cns: The Z-Direction of the object (seen from pos)<br />
3. Upv: The Y-Direction of the object (seen from pos)<br />
4. Bnd: An additional point to be used for deformation (later)</p>
<p>So basically we could draw a quadrangular polygon instead of four points, like below, where we are instancing ten grids:</p>
<p><img src="http://www.xsi-blog.com/userContent/hmathee/wingRig/rigid_env_06.jpg" alt="" /></p>
<p>Now: Instead of enveloping the objects we want to be instanced, we envelope the mesh containing the quads. This is going to be called our &#8220;Instancing-Cloud&#8221;. It contains all of the information we need to instance our objects. Moreover, it is easy to envelope, as we know exactly which points are to be enveloped where. Every first out of four points is the position, every second out of four points is the z-direction etc&#8230; All we need to build is a couple of scripts:</p>
<p>1. One which adds a quadrangle to a mesh based on a transform of a null.<br />
2. One which creates a new mesh and instances an object onto an Instancing-Cloud.<br />
3. One which generates clusters for the instance-cloud for easier enveloping.</p>
<p>A finished setup could look something like this: We see the quads representing the instances:</p>
<p><img src="http://www.xsi-blog.com/userContent/hmathee/wingRig/rigid_env_07.jpg" alt="" /></p>
<p>When deformed: The quads deform, but the instances will not:</p>
<p><img src="http://www.xsi-blog.com/userContent/hmathee/wingRig/rigid_env_08.jpg" alt="" /></p>
<p>Including the instances it should look like this:</p>
<p><img src="http://www.xsi-blog.com/userContent/hmathee/wingRig/rigid_env_09.jpg" alt="" /></p>
<p>When deformed:</p>
<p><img src="http://www.xsi-blog.com/userContent/hmathee/wingRig/rigid_env_10.jpg" alt="" /></p>
<p>As we have point clusters for each type of point in the instance-cloud (pos, cns, upv and bnd) it is quite simple to rig the cns for example to a bunch of rotational controllers:</p>
<p><img src="http://www.xsi-blog.com/userContent/hmathee/wingRig/rigid_env_11.jpg" alt="" /></p>
<p>And when we rotate them, only the cns points are deformed, therefore the instances rotate as well:</p>
<p><img src="http://www.xsi-blog.com/userContent/hmathee/wingRig/rigid_env_12.jpg" alt="" /></p>
<p>Additionally we can deform the cloud overall:</p>
<p><img src="http://www.xsi-blog.com/userContent/hmathee/wingRig/rigid_env_13.jpg" alt="" /></p>
<p>So now lets discuss the last part of the story: What&#8217;s the bnd position for?<br />
The bnd position is used for deformation of each instance. As this is quite limited, all I am going to do is move the instances points using a sinus function, to get somewhat of twisting and bending going on. This is up to your imagination, as I said, this setup has been used for feathers, that&#8217;s why the bnd position is used for bending (and named like that as well: bnd = bending).</p>
<p>In the next image I rigged the bnd position to the rotational controller earlier used for cns, to show what happens:</p>
<p><img src="http://www.xsi-blog.com/userContent/hmathee/wingRig/rigid_env_11.jpg" alt="" /></p>
<p>So now when I rotate them:</p>
<p><img src="http://www.xsi-blog.com/userContent/hmathee/wingRig/rigid_env_14.jpg" alt="" /></p>
<p>Or along another axis:</p>
<p><img src="http://www.xsi-blog.com/userContent/hmathee/wingRig/rigid_env_15.jpg" alt="" /></p>
<p>As always &#8211; <a href="http://www.xsi-blog.com/userContent/hmathee/wingRig/mt_feathers.js">I&#8217;d like to share the progress so far</a>, but I have to warn you, it is not at all documented:</p>
<p>Put the file into one of the plugins folders, and run the following script to get some feather setup going:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">NewScene<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> cloud <span style="color: #339933;">=</span> mt_createFeatherCloud<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> grid <span style="color: #339933;">=</span> CreatePrim<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Grid&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;MeshSurface&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
SetValue<span style="color: #009900;">&#40;</span>grid<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;.grid.ulength&quot;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0.4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
SetValue<span style="color: #009900;">&#40;</span>grid<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;.grid.vlength&quot;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
SetValue<span style="color: #009900;">&#40;</span>grid<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;.polymsh.geom.subdivu&quot;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Translate<span style="color: #009900;">&#40;</span>grid<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;.pnt[*]&quot;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1.4</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> siRelative<span style="color: #339933;">,</span> siLocal<span style="color: #339933;">,</span> siObj<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
FreezeObj<span style="color: #009900;">&#40;</span>grid<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> mesh <span style="color: #339933;">=</span> mt_createFeatherMesh<span style="color: #009900;">&#40;</span>cloud<span style="color: #339933;">,</span> grid<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> feathers <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> ActiveXObject<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;XSI.Collection&quot;</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: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span><span style="color: #CC0000;">10</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
feathers.<span style="color: #660066;">Add</span><span style="color: #009900;">&#40;</span>mt_createFeatherNull<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
feathers<span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">kinematics</span>.<span style="color: #660066;">local</span>.<span style="color: #660066;">posx</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> i<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
mt_addFeathersToCloud<span style="color: #009900;">&#40;</span>cloud<span style="color: #339933;">,</span>feathers<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
mt_createCloudClusters<span style="color: #009900;">&#40;</span>cloud<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
DeselectAll<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Let me know how it goes,</p>
<p>enjoy!</p>
<img src="http://www.softimageblog.com/?ak_action=api_record_view&id=110&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.softimageblog.com/archives/110/feed</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Writing a Phenomenon for Softimage XSI and Mental Ray</title>
		<link>http://www.softimageblog.com/archives/105#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=writing-a-phenomenon-for-softimage-xsi-and-mental-ray</link>
		<comments>http://www.softimageblog.com/archives/105#comments</comments>
		<pubDate>Sun, 02 Jul 2006 13:00:38 +0000</pubDate>
		<dc:creator>Stefano Jannuzzo</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Programming / Scripting]]></category>
		<category><![CDATA[Rendering]]></category>
		<category><![CDATA[User Interface]]></category>

		<guid isPermaLink="false">http://www.xsi-blog.com/?p=105</guid>
		<description><![CDATA[Have you ever used Apple&#8217;s Shake? Have you ever built macros with Shake? Have you ever wished you could create macros in XSI&#8217;s Render Tree?
Well you can, these are called Phenomenon. A Phenomenon is group of shaders exposed to the users as a single entity. You can hide or show, as you see fit, any [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever used Apple&#8217;s Shake? Have you ever built macros with Shake? Have you ever wished you could create macros in XSI&#8217;s Render Tree?</p>
<p>Well you can, these are called Phenomenon. A Phenomenon is group of shaders exposed to the users as a single entity. You can hide or show, as you see fit, any parameter of the enclosed shaders making a Phenomenon a very powerful tool for sharing shader recipes or building tools for larger productions.</p>
<p>The advantages are:</p>
<ol>
<li>Have a more compact and readable rendertree.</li>
<li>Allow for only a set of significant parameters to be tuned by the artist.</li>
</ol>
<p>Let&#8217;s see how it is possible to make up a phenomenon starting from a basic rendertree.</p>
<p><span id="more-105"></span><strong>The Goal</strong></p>
<p>The following network returns red if the x coordinate of the point is lower than 1, blue elsewhere. The picture should be quite self-explanatory:</p>
<p><a href="/userContent/sjannuzzo/phenomenon/Pheno0.jpg"><img src="/userContent/sjannuzzo/phenomenon/Pheno0.jpg" alt="Initial Shader Tree" width="610" /></a></p>
<p>In this case study we want to make a new node enclosing the four primary shaders of the tree, and exposing only three parameters: the two colors and the &#8220;threshold&#8221; value.</p>
<p><strong>Creating Our SPDL</strong></p>
<p>We need to create a spdl file, which will be later registered.</p>
<p>For those who want a bit of a primer, a SPDL file is a file that defines how XSI will display a certain PPG or Shader. Check the <a href="http://softimage.wiki.avid.com/index.php/SPDL">wiki page on SPDL</a> for more info.</p>
<p>The first part of the file contains a header and the declaration of the parameters we want to expose. All the guids must be <a href="/archives/104">randomly generated</a>, except the one identifing the output (color) parameter.</p>
<p><!-- google_ad_section_start(weight=ignore) --></p>
<pre>SPDL
Version = "2.0.0.0";
Reference = "{19671971-1008-0000-8410-6A45FDB990DD}";
PropertySet "PhenoTest_params"
{
    Parameter "out" output
    {
        title = "PhenoTest";
        guid = "{4C6879FF-7EC8-11D0-8E3B-00A0C90640EC}";
        type = color;
    }
    Parameter "threshold" input
    {
        guid  = "{19671971-1008-0002-8410-6A45FDB990DD}";
        type  = scalar;
        value = 1.0;
        texturable = on;
    }
    Parameter "color1" input
    {
        guid = "{19671971-1010-0001-8410-6A45FDB990DD}";
        type = color;
        value = 1.0 0.0 0.0 1.0;
        texturable = on;
    }
    Parameter "color2" input
    {
        guid = "{19671971-1011-0001-8410-6A45FDB990DD}";
        type = color;
        value = 0.0 0.0 1.0 1.0;
        texturable = on;
    }
}</pre>
<p><!-- google_ad_section_end --></p>
<p>The bottom part is also quite standard. It just defines the parameter&#8217;s defaults and their position in the layout.</p>
<p><!-- google_ad_section_start(weight=ignore) --></p>
<pre>BEGIN "{24810490-56FF-11d2-BF23-00A0C982CE5D}"

Defaults
{
    threshold
    {
        Name = "Threshold";
        UIRange = -10.0 to 10.0 by 0.01;
    }
    color1
    {
        Name = "Color 1";
        UIType = "rgba",4;
        Commands = "{F5C75F11-2F05-11d3-AA95-00AA0068D2C0}";
    }
    color2
    {
        Name = "Color 2";
        UIType = "rgba",4;
        Commands = "{F5C75F11-2F05-11d3-AA95-00AA0068D2C0}";
    }
}

Layout "Default"
{
    Name;
    threshold;
    color1;
    color2;
}

Logic
{
}
END</pre>
<p><!-- google_ad_section_end --></p>
<p>What interests us is the middle section, where you hardcode the connections between shaders. This is, in essence, the part of the SPDL where you create your mini Render Tree.</p>
<p><!-- google_ad_section_start(weight=ignore) --></p>
<pre>MetaShader "PhenoTest_declare"
{
    Name = "PhenoTest";
    Type = texture;
    Renderer "mental ray"
    {
        Name = "PhenoTest";

        BeginText

        Node "vector_state"      = guid "{BDE291C7-077A-11D2-8A1A-00A0C9892542}";
        Node "vector_2_scalar"   = guid "{A4F08C3F-AA3A-11D2-AFD4-00A024191B9D}";
        Node "scalar_math_logic" = guid "{4D9E6800-AC2F-11D3-AE56-00A0C96E63E1}";
        Node "boolean_switch"    = guid "{85C16046-BCFA-11D1-90E9-0000F804EB21}";

        Connection "vector_state::mode"	    = value 2;

        Connection "vector_2_scalar::input"     = "vector_state";
        Connection "vector_2_scalar::component" = value 0;

        Connection "scalar_math_logic::input1"  = "vector_2_scalar";
        Connection "scalar_math_logic::input2"  = interface "threshold";
        Connection "scalar_math_logic::op"      = value 2;

        Connection "boolean_switch::input1"     = interface "color1";
        Connection "boolean_switch::input2"     = interface "color2";
        Connection "boolean_switch::switch"     = "scalar_math_logic";

        Connection root                         = "boolean_switch";

        EndText
    }
}</pre>
<p><!-- google_ad_section_end --></p>
<p>Aching for more details? Read on&#8230;</p>
<img src="http://www.softimageblog.com/?ak_action=api_record_view&id=105&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.softimageblog.com/archives/105/feed</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>The ScriptedSequencer</title>
		<link>http://www.softimageblog.com/archives/69#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=the-scriptedsequencer</link>
		<comments>http://www.softimageblog.com/archives/69#comments</comments>
		<pubDate>Sun, 27 Nov 2005 20:10:21 +0000</pubDate>
		<dc:creator>Andrea Interguglielmi</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[JScript]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[VBScript]]></category>

		<guid isPermaLink="false">http://www.xsi-blog.com/?p=69</guid>
		<description><![CDATA[When it comes to math, sometimes is hard to visualize what you are doing, if you are working with vectors and transformations the debugging process can be slow and tedious, you cannot even use primitives to trace positions and rotations if you are writing scripted operators.
My workflow was to write quick run-once scripts in the [...]]]></description>
			<content:encoded><![CDATA[<p>When it comes to math, sometimes is hard to visualize what you are doing, if you are working with vectors and transformations the debugging process can be slow and tedious, you cannot even use primitives to trace positions and rotations if you are writing scripted operators.</p>
<p>My workflow was to write quick run-once scripts in the script editor, use curves and nulls to be sure that everything was ok and then write the scripted operator. But, if scripting is meant to make your life easier, this case makes you change your mind a bit. So I decided to take advantage of both c++ and scripting by wrapping some simple OpenGL drawing functions and exposing them to scripting.</p>
<p>Since the result seems to be quite handy, I decided to make this little utility available on XSIBlog. Lionhead, the company I work for, kindly allowed me to publish it.</p>
<p><span id="more-69"></span>So here is the ScriptedSequencer, a small utility to draw vectors and rotation axis on screen.</p>
<p><img style="width: 416px; height: 303px; border-width: 0px" src="/userContent/ainterguglielmi/scriptedSequencer/sequencer.jpg" border="0" /></p>
<p>The tool uses a JScript object to wrap some c++ registered commands, you can use this object from Python and VBScript as well.</p>
<p>First get an instance of the object:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> s <span style="color: #339933;">=</span> NewSequencer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>then call one of the drawing functions:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> vec <span style="color: #339933;">=</span> XSIMath.<span style="color: #660066;">CreateVector3</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
vec.<span style="color: #660066;">Set</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> s.<span style="color: #660066;">DrawVector</span><span style="color: #009900;">&#40;</span>vec<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>to erase the stack and start again use:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">s.<span style="color: #660066;">Flush</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>All the drawings are collected by the c++ plug-in and then rendered at the right time using the GraphicSequencer, so you don&#8217;t have to care about synchronizing with the viewport&#8217;s OpenGL rendering, which means in other words that you can draw OpenGL stuff from wherever you are, run once scripts, scripted operators or compiled plug-ins at any moment.</p>
<p>As it is nothing more than a debugging utility it doesn&#8217;t support multiple clients, it means that every time you&#8217;ll flush the stack all the drawings drawn by every script will be flushed at once.</p>
<p>By typing <code>NewSequencer().Help()</code> you&#8217;ll get a quick help about the sequencer object and its methods.</p>
<p>I hope you&#8217;ll find it useful to debug your scripts!</p>
<p>Please note that this utility is not released by Lionhead Ltd., it is not covered by any guarantee and nobody is responsible in any way for any possible troubleshoot.</p>
<p>Download the ScriptedSequencer addon and a sample scene <a href="/userContent/upload/ScriptedSequencer1.zip">here</a> (XSI 5.X required).</p>
<p>You are more than welcome to report possible bugs or give me suggestions, just drop me a line at <a href="mailto:andrea@ray-t.net">andrea@ray-t.net</a>.</p>
<img src="http://www.softimageblog.com/?ak_action=api_record_view&id=69&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.softimageblog.com/archives/69/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
