<?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; Simulation</title>
	<atom:link href="http://www.softimageblog.com/archives/category/simulation/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>PPG Based Particle Animation Work Flow With ICE</title>
		<link>http://www.softimageblog.com/archives/410#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=ppg-based-particle-animation-work-flow-with-ice</link>
		<comments>http://www.softimageblog.com/archives/410#comments</comments>
		<pubDate>Fri, 07 Aug 2009 21:04:58 +0000</pubDate>
		<dc:creator>Hans Payer</dc:creator>
				<category><![CDATA[ICE]]></category>
		<category><![CDATA[Simulation]]></category>

		<guid isPermaLink="false">http://www.xsi-blog.com/?p=410</guid>
		<description><![CDATA[About a year ago already, XSI 7.0 was released with much expectations and enthusiasm. Most of us, by now, have played with ICE and if you&#8217;re lucky, you even had the chance to squeeze an operator in a real production. Everyone is still marveled when new videos are posted online showing the latest tricks or [...]]]></description>
			<content:encoded><![CDATA[<p>About a year ago already, XSI 7.0 was released with much expectations and enthusiasm. Most of us, by now, have played with ICE and if you&#8217;re lucky, you even had the chance to squeeze an operator in a real production. Everyone is still marveled when new videos are posted online showing the latest tricks or achievements made with ICE. ICE is an amazing design tool and definitely opens many doors for all Softimage users. But for many, they hit a wall; in order to create even the simplest simulation, they have to learn the meaning of vectors, scalar, arrays and how to use them. If you do have the technical chops, great, new things to learn, but for the more artistically skilled users, the hill is steep.</p>
<p>Everyone complained (including me) that the old particle system was too weak, too limited&#8230;. But it was fast to get some things done.  To randomize a value, for example, you simply had to open a property page and set a variance parameter. Partly because ICE is so open, to vary a parameter, you have to search for the desired compound or node modifier, drag &#038; drop, connect ports and then set values in the new compounds. Read me right, ICE is very powerful but if you have to modify dozens of parameters hundreds of times in one typical work day, this work flow becomes redundant an inefficient. There must be a way to be quicker.</p>
<p>Softimage proposed a work flow that can be described as follows: a technical director connects basic nodes, designs compounds and exposes ports. An artist, who is not necessary knowledgeable of ICE, then sets the different values of the exposed parameters. Some problems may arise with this approach. How can a TD predict every alteration needed by the artist? In the context of a particle simulation of falling rain, for example, a TD may have to design his compounds to support, for a simple shot, wind and gravity. Then, another shot may require water splashes from the droplet hitting the ground. Another still, requires the same rain but with the added effect of coagulating droplets on a smooth surface. And so on. You can easily imagine multiple variations of the same effect. So how are TDs supposed to tailor their compounds to fit all of the artists needs? One obvious solution is to build a system of compounds rather than a top level one. Yet the artists would need to be taught and learn how this system works and therefore, learn how to use ICE. Yes, maybe&#8230; but unlikely. I know many technical XSI users that were clueless on how create a simple simulation; artists, even less probable. How can technical directors empower artists without limiting them with a simple set of parameters?  There should be a window to deliver the power of ICE to artists without being too painful.  Artists should be able to easily create simple particle animation. You do not need to be a mechanic to drive a car.</p>
<p>With these observations in mind came the search for a way to simplify the ICE work flow which any Softimage user would understand and produce simulations in no time.  The intent is not to replace the current work flow but to complement it and accelerate the multiple iterations needed in order to design particle simulations. Subsequent refinements, complex connections or relationships can and should be achieved the traditional way by connecting nodes and compounds in the ICE tree. But once a new solution is found, it should be easy to re-integrate it in a simpler work flow system.  It should also be seen as an added value to cut the time to help generate about 75% of particle animation scenarios.</p>
<p>You do not need to look very far to find solutions. By simply looking at the different ways shaders can be modified, it is easy to wonder why ICE property pages were not designed the same way. Isn&#8217;t it faster in many situations to create connections by using the plug icon in a shader&#8217;s property page rather than opening it in the render tree, dragging and dropping a node, then making the connection? It should be the same in ICE property pages. No?</p>
<p><img src="http://www.xsi-blog.com/userContent/upload/2009/08/dk9zhxb_72gnm2jkfk_b.jpg" alt="dk9zhxb_72gnm2jkfk_b" title="dk9zhxb_72gnm2jkfk_b" width="723" height="525" class="aligncenter size-full wp-image-411" /></p>
<p>Also, all parameters affecting the simulation should reside in the same property page. With a typical ICE tree containing easily 20 compounds or more, finding a parameter often requires a search through many compounds. Too many doubles clicks are required to access the compounds&#8217; parameters; why not put them in one location. When a scalar is randomized for example, the parameters associated with randomization should replace the original scalar in the top property page.  You say: isn&#8217;t the top compound intended for that? Yes, but it doesn&#8217;t expose ports automatically. Remember, the goal here is to create particle simulations in a production environment; not to design ICE trees in a R&#038;D context.</p>
<p><img src="http://www.xsi-blog.com/userContent/upload/2009/08/dk9zhxb_73fgm8zwtz_b.jpg" alt="dk9zhxb_73fgm8zwtz_b" title="dk9zhxb_73fgm8zwtz_b" width="502" height="554" class="aligncenter size-full wp-image-412" /></p>
<p>In the following video, I demonstrate a working prototype. It shows the above ideas in action with the exception of having iterations made through parameter contextual menus instead of the plug connection icon menu. The Softimage development kit does not give access to this type of UI widgets for ICE compounds property pages. Also, for clarity&#8217;s sake, it would have been beneficial to have used tabs in the property page to seperate emission, particle type, forces, triggers and events. This was not implemented. This prototype was written about a year and a half ago with a beta version of XSI 7.0 and unfortunately has not been updated to work with the current version of Softimage but would be relatively simple to rewrite. I must also credit my colleagues at the time, Jeff Wilson, who helped with the original concept and Javier von der Pahlen who co-wrote the prototype. It is important also to say that I was an employee of Softimage at the time when that prototype was written. As a long time user of Softimage&#8217;s products, I was trying to push solutions that made the work of technical directors easier. Unfortunately, this concept was not accepted. But it remains a great concept on how technical directors can go beyond compounds and integrate ICE in production pipelines more efficiently. It clearly illustrate the ability to build a simple particle animation rapidly without having to access the ICE tree. All iterations are made through the property page.</p>
<p>I simply wanted to share these ideas with the Softimage community and start a discussion. As, hopefully, more and more people will be using ICE, I&#8217;m sure that work flows will evolve to more efficient ways to manage ICE trees. Maybe it&#8217;ll lead to similar solutions, whether it comes from Autodesk or the community. I think it&#8217;s really cool concept and it would save many users time and headaches. What do you think? Is this type work flow worth exploring?</p>
<p><object width="400" height="300" class="aligncenter"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=5973056&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=5973056&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="300"></embed></object>
<p><a href="http://vimeo.com/5973056">PPG Based Particle Animation Work Flow With ICE</a> from <a href="http://vimeo.com/user2121705">Hans Payer</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<img src="http://www.softimageblog.com/?ak_action=api_record_view&id=410&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.softimageblog.com/archives/410/feed</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>A tool for visualising particle distributions</title>
		<link>http://www.softimageblog.com/archives/198#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=a-tool-for-visualising-particle-distributions</link>
		<comments>http://www.softimageblog.com/archives/198#comments</comments>
		<pubDate>Sun, 18 Mar 2007 13:04:19 +0000</pubDate>
		<dc:creator>Andy Nicholas</dc:creator>
				<category><![CDATA[JScript]]></category>
		<category><![CDATA[Programming / Scripting]]></category>
		<category><![CDATA[Simulation]]></category>

		<guid isPermaLink="false">http://www.xsi-blog.com/archives/198</guid>
		<description><![CDATA[Some of you may remember the Histogram plugin that I wrote for XSI&#8217;s rendertree. It&#8217;s a tool for visualising exactly what is happening in your shading networks and can be invaluable when trying to find out why your shader is behaving unexpectedly.
Since the Histogram display window is just a COM application launched by the equivalent [...]]]></description>
			<content:encoded><![CDATA[<p>Some of you may remember the Histogram plugin that I wrote for XSI&#8217;s rendertree. It&#8217;s a tool for visualising exactly what is happening in your shading networks and can be invaluable when trying to find out why your shader is behaving unexpectedly.</p>
<p>Since the Histogram display window is just a COM application launched by the equivalent mental ray shader, there&#8217;s nothing stopping you using the Histogram display tool for other uses. Indeed, I included in the original download example source scripts to demonstrate how to drive the COM interface.</p>
<p>Vince Fortin has asked me about whether it&#8217;s possible to get Histogram to show distributions for particle systems. So at his request (thanks for reminding me Vince!) I&#8217;m posting some example code to show you how to do it.</p>
<p>First though, here&#8217;s a quick screen shot of the sort of information it can show:</p>
<p align="center"><a href="/userContent/upload/2007/03/pdistribution.jpg" title="Histogram for particles"><img src="/userContent/upload/2007/03/pdistribution.thumbnail.jpg" alt="Histogram for particles" /></a></p>
<p align="left">Here I&#8217;m using Histogram to show the distribution of the X, Y, and Z positions of the particles. I&#8217;ve also got it to display the particle age too. Note that the number of samples (1853) shown at the bottom, actually corresponds to the number of particles.</p>
<p><span id="more-198"></span>The JScript code below features a reusable object called <strong>HistogramData</strong>. This object has a member function called <strong>ProcessSample()</strong> which will take a sample value and take care of the histogram construction for you. You then push the <strong>curHist </strong>member to the Histogram COM application for display.</p>
<p>The first function in the code is a script callback for a particle event. To make it work, you just need to add a particle event to a PType and create an <strong>OnEveryFrame</strong> event with the trigger value set to 0 so that the script gets called every frame. You can then control the execution of the Histogram display inside the script by changing the trigger frame number.</p>
<p>You can download and find out more about Histogram by following this link:</p>
<p><a href="http://www.andynicholas.com/thezone/index.php?area=downloadinfo&amp;app=XSI&amp;file=2">www.andynicholas.com -&gt; Histogram</a></p>
<p>Please feel free to modify this code for your own usage.</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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> HISTOGRAM_RES <span style="color: #339933;">=</span> <span style="color: #CC0000;">256</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> INV_HISTOGRAM_RES <span style="color: #339933;">=</span> <span style="color: #CC0000;">0.00390625</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> HISTOGRAM_ARRSIZE <span style="color: #339933;">=</span> <span style="color: #CC0000;">257</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> OnEveryFrame<span style="color: #009900;">&#40;</span>inParticleCloud<span style="color: #339933;">,</span> inTriggerParticleIndices<span style="color: #339933;">,</span> inSimFrame<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #006600; font-style: italic;">//Frame 99 is when the distribution will be viewed, and</span>
<span style="color: #006600; font-style: italic;">//you can change it to whatever you want.</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//Note that if you persist the histogram data objects, there's no</span>
<span style="color: #006600; font-style: italic;">//reason you can't gather distributions across multiple frames.</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//To make things a little easier to adjust, you may also want to</span>
<span style="color: #006600; font-style: italic;">//create a custom property in the scene to tie this frame value to.</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>inSimFrame<span style="color: #339933;">==</span><span style="color: #CC0000;">99</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #006600; font-style: italic;">//Initialise the data</span>
<span style="color: #003366; font-weight: bold;">var</span> histx <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> HistogramData<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> histy <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> HistogramData<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> histz <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> HistogramData<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> histage <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> HistogramData<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//This is where we store the data whose distribution we want to look at.</span>
<span style="color: #006600; font-style: italic;">//In this case, we're observing position and age.</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> particles <span style="color: #339933;">=</span> inParticleCloud.<span style="color: #660066;">particles</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> num_particles <span style="color: #339933;">=</span> particles.<span style="color: #660066;">count</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;">&amp;</span>lt<span style="color: #339933;">;</span>num_particles<span style="color: #339933;">;++</span>i<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #003366; font-weight: bold;">var</span> particle <span style="color: #339933;">=</span> particles<span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
histx.<span style="color: #660066;">ProcessSample</span><span style="color: #009900;">&#40;</span>particle.<span style="color: #660066;">position</span>.<span style="color: #660066;">x</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
histy.<span style="color: #660066;">ProcessSample</span><span style="color: #009900;">&#40;</span>particle.<span style="color: #660066;">position</span>.<span style="color: #660066;">y</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
histz.<span style="color: #660066;">ProcessSample</span><span style="color: #009900;">&#40;</span>particle.<span style="color: #660066;">position</span>.<span style="color: #660066;">z</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
histage.<span style="color: #660066;">ProcessSample</span><span style="color: #009900;">&#40;</span>particle.<span style="color: #660066;">age</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//Display the data</span>
<span style="color: #003366; font-weight: bold;">var</span> histWindow <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;HistogramDisplay.Application&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
histWindow.<span style="color: #660066;">SetHistogram</span><span style="color: #009900;">&#40;</span>histx.<span style="color: #660066;">curHist</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;Pos.X&quot;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> histx.<span style="color: #660066;">min</span><span style="color: #339933;">,</span> histx.<span style="color: #660066;">max</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
histWindow.<span style="color: #660066;">SetHistogram</span><span style="color: #009900;">&#40;</span>histy.<span style="color: #660066;">curHist</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;Pos.Y&quot;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> histy.<span style="color: #660066;">min</span><span style="color: #339933;">,</span> histy.<span style="color: #660066;">max</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
histWindow.<span style="color: #660066;">SetHistogram</span><span style="color: #009900;">&#40;</span>histz.<span style="color: #660066;">curHist</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;Pos.Z&quot;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> histz.<span style="color: #660066;">min</span><span style="color: #339933;">,</span> histz.<span style="color: #660066;">max</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
histWindow.<span style="color: #660066;">SetHistogram</span><span style="color: #009900;">&#40;</span>histage.<span style="color: #660066;">curHist</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;Age&quot;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">3</span><span style="color: #339933;">,</span> histage.<span style="color: #660066;">min</span><span style="color: #339933;">,</span> histage.<span style="color: #660066;">max</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
histWindow.<span style="color: #660066;">SetHistogramColor</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">80</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: #009900;">&#41;</span><span style="color: #339933;">;</span>
histWindow.<span style="color: #660066;">SetHistogramColor</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">80</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
histWindow.<span style="color: #660066;">SetHistogramColor</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">2</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> <span style="color: #CC0000;">80</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
histWindow.<span style="color: #660066;">SetHistogramColor</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">3</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> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
histWindow.<span style="color: #660066;">SetNumToDisplay</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
histWindow.<span style="color: #660066;">UpdateWindow</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//Data object representing histogram data</span>
<span style="color: #006600; font-style: italic;">//and contains member function called ProcessSample()</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> HistogramData<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">min</span><span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">max</span><span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">samples</span><span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">curHist</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span>HISTOGRAM_ARRSIZE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">otherHist</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span>HISTOGRAM_ARRSIZE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<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;">&amp;</span>lt<span style="color: #339933;">;</span>HISTOGRAM_ARRSIZE<span style="color: #339933;">;++</span>i<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">curHist</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">otherHist</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">ProcessSample</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>sample<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #006600; font-style: italic;">//This function does all the hard work</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//It is a direct port from C++ of the functionality</span>
<span style="color: #006600; font-style: italic;">//of the original Histogram rendertree shader</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> oldMin <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">min</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> oldMax <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">max</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> oldBucketSize <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>oldMax<span style="color: #339933;">-</span>oldMin<span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span>INV_HISTOGRAM_RES<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> scaleChanged<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">samples</span><span style="color: #339933;">==</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">min</span> <span style="color: #339933;">=</span> sample<span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">max</span> <span style="color: #339933;">=</span> sample<span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">samples</span><span style="color: #339933;">++;</span>
<span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>sample<span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>this.<span style="color: #660066;">min</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">min</span> <span style="color: #339933;">=</span> sample<span style="color: #339933;">;</span>
scaleChanged<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>sample<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span>this.<span style="color: #660066;">max</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">max</span> <span style="color: #339933;">=</span> sample<span style="color: #339933;">;</span>
scaleChanged<span style="color: #339933;">=</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: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">samples</span><span style="color: #339933;">==</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">curHist</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">++;</span>
<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">curHist</span><span style="color: #009900;">&#91;</span>HISTOGRAM_RES<span style="color: #009900;">&#93;</span><span style="color: #339933;">++;</span>
<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">samples</span><span style="color: #339933;">++;</span>
<span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> bucketSize <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">max</span><span style="color: #339933;">-</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">min</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span>INV_HISTOGRAM_RES<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> rangeRatio <span style="color: #339933;">=</span> HISTOGRAM_RES<span style="color: #339933;">/</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">max</span><span style="color: #339933;">-</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">min</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><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">max</span><span style="color: #339933;">-</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">min</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> rangeRatio<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>scaleChanged<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #006600; font-style: italic;">//Swap histograms</span>
<span style="color: #003366; font-weight: bold;">var</span> tempHist<span style="color: #339933;">;</span>
tempHist <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">curHist</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">curHist</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">otherHist</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">otherHist</span> <span style="color: #339933;">=</span> tempHist<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//Copy and rescale the histogram according to the new sample and resample</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;">&amp;</span>lt<span style="color: #339933;">;</span>HISTOGRAM_ARRSIZE<span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #006600; font-style: italic;">//Calculate sample value</span>
<span style="color: #003366; font-weight: bold;">var</span> value <span style="color: #339933;">=</span> oldMin <span style="color: #339933;">+</span> oldBucketSize<span style="color: #339933;">*</span>i<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//Calculate new bucket</span>
<span style="color: #003366; font-weight: bold;">var</span> newBucket <span style="color: #339933;">=</span> Math.<span style="color: #660066;">floor</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>value <span style="color: #339933;">-</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">min</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span>rangeRatio<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>newBucket<span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> newBucket<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>newBucket<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;=</span>HISTOGRAM_ARRSIZE<span style="color: #009900;">&#41;</span> newBucket<span style="color: #339933;">=</span>HISTOGRAM_ARRSIZE<span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">curHist</span><span style="color: #009900;">&#91;</span>newBucket<span style="color: #009900;">&#93;</span><span style="color: #339933;">+=</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">otherHist</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">otherHist</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//Add sample</span>
<span style="color: #003366; font-weight: bold;">var</span> inputBucket <span style="color: #339933;">=</span> Math.<span style="color: #660066;">floor</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>sample <span style="color: #339933;">-</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">min</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span>rangeRatio<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>inputBucket<span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> inputBucket<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>inputBucket<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;=</span>HISTOGRAM_ARRSIZE<span style="color: #009900;">&#41;</span> inputBucket<span style="color: #339933;">=</span>HISTOGRAM_ARRSIZE<span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">curHist</span><span style="color: #009900;">&#91;</span>inputBucket<span style="color: #009900;">&#93;</span><span style="color: #339933;">++;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">samples</span><span style="color: #339933;">++;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<img src="http://www.softimageblog.com/?ak_action=api_record_view&id=198&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.softimageblog.com/archives/198/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Tricks with scripted particle events.</title>
		<link>http://www.softimageblog.com/archives/127#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=tricks-with-scripted-particle-events</link>
		<comments>http://www.softimageblog.com/archives/127#comments</comments>
		<pubDate>Sun, 10 Dec 2006 17:01:15 +0000</pubDate>
		<dc:creator>Francois Lord</dc:creator>
				<category><![CDATA[JScript]]></category>
		<category><![CDATA[Programming / Scripting]]></category>
		<category><![CDATA[Simulation]]></category>

		<guid isPermaLink="false">http://www.xsi-blog.com/?p=127</guid>
		<description><![CDATA[I was recently assigned on a particle recipe that was going to be used by several people on several shots. After some thinking on how I was going to approach the idea, I realized that I needed a few features missing in XSI. In fact, I''ve been wanting those features many times in the past. I decided to take the time to write some scripted events, even though I was on a tight deadline. It turned out it was easier than I thought.]]></description>
			<content:encoded><![CDATA[<p>I was recently assigned on a particle recipe that was going to be used by several people on several shots. After some thinking on how I was going to approach the idea, I realized that I needed a few features missing in XSI. In fact, I&#8217;ve been wanting those features many times in the past. I decided to take the time to write some scripted events, even though I was on a tight deadline. It turned out it was easier than I thought.</p>
<p>I was required to create a bubble stream behind an underwater torpedo. Do torpedoes really have a stream of bubbles behind them in real life? In movies they do, so the question doesn&#8217;t really matter. I wanted to have many small bubbles and a few big bubbles within the same PType. I wanted to have the big bubbles rise faster than the small ones. I also wanted the bubbles to wobble as they were rising, and the wobble to be function of the size and the speed. Finally, I wanted the sprite sequence to begin at a random frame and continue normally as the particle aged. All this is not possible with the actual particle system in XSI 5.11, although they are common requirements in a simulation scene.</p>
<p><span id="more-127"></span><strong>The Distribution problem.</strong><br />
<img src="/userContent/upload/TricksParticleEvents_ExpDist.png" alt="Exponential Distribution" align="right" hspace="0" vspace="7"/><img src="/userContent/upload/TricksParticleEvents_ExpFunc.png" alt="Exponential Fuction" align="right" hspace="10" vspace="7"/> In XSI, you can only choose from uniform and Gaussian distribution. This means you can only have a middle value, and an equal probability on each side.  For what we need here, we will create a scripted event with the trigger on &#8220;Particle Age&#8221; at zero. We will name the event &#8220;<em>BirthControl</em>&#8220;. In the script tab, we set the language to JScript. It&#8217;s a shame we can&#8217;t use Python, since there are many cool random distributions in the standard library. The ScriptContext will be set to &#8220;Per Trigger Particle&#8221;. An exponent function will give a random distribution with a high probability at one end and a progressively lower probability towards the other end.</p>
<p>Size = (random number)5 * 0.025 + 0.005<br />
The &#8220;* 0.025&#8243; sets the difference in size between the biggest and the smallest bubbles.<br />
The &#8220;+ 0.005&#8243; sets the size of the smallest bubble size at 0.005 units. The biggest bubbles will be 0.03 units big.</p>
<p>In JScript, it&#8217;s written like this:</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;">inParticle.<span style="color: #660066;">Size</span> <span style="color: #339933;">=</span> Math.<span style="color: #660066;">pow</span><span style="color: #009900;">&#40;</span>Math.<span style="color: #660066;">random</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">5</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #CC0000;">0.025</span> <span style="color: #339933;">+</span> <span style="color: #CC0000;">0.005</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>The object inParticle is given to the script by XSI and contains the current particle that triggered the event.</p>
<p><strong>The Speed from Size problem.</strong><br />
The size of the particles can be determined randomly. The effect of gravity can also be variable among the particles. But we can&#8217;t set a relation between the two with the tools in the UI. In fact, in scripting we don&#8217;t even have access to the effect of forces per particle. We will need to limit the length of the velocity vector according to the size of each particle. We must create a new scripted event called &#8220;<em>PerFrameControl</em>&#8221; with the trigger at &#8220;Every N Frame&#8221; and the value at 1. The ScriptContext will be &#8220;Per Particle&#8221;.</p>
<p>If a particle&#8217;s speed exceeds the product of it&#8217;s size and a coefficient, bring it back to that product.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">speed <span style="color: #339933;">=</span> inParticle.<span style="color: #660066;">Velocity</span><span style="color: #339933;">;</span>
size <span style="color: #339933;">=</span> inParticle.<span style="color: #660066;">Size</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>speed.<span style="color: #660066;">Length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> size <span style="color: #339933;">*</span> <span style="color: #CC0000;">10</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>  <span style="color: #006600; font-style: italic;">// if speed is bigger than 10 times the size...</span>
    speed.<span style="color: #660066;">NormalizeInPlace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>      <span style="color: #006600; font-style: italic;">// scale the speed to be 1 and</span>
    speed.<span style="color: #660066;">ScaleInPlace</span><span style="color: #009900;">&#40;</span>size <span style="color: #339933;">*</span> <span style="color: #CC0000;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// scale speed to be 10 times the size.</span>
<span style="color: #009900;">&#125;</span>
inParticle.<span style="color: #660066;">Velocity</span> <span style="color: #339933;">=</span> speed<span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>This has the advantage that a particle will have no speed at its birth, and slowly accelerate from the effect of gravity. It will continue to accelerate until it reaches the speed it is allowed. Then it will keep this speed forever unless it has to decelerate, which shouldn&#8217;t happen in our scene.</p>
<p><strong>The Wobble Problem</strong><br />
There is already some perlin noise in the PType to make the bubbles rise in a natural fashion and we don&#8217;t want to lose that. We can&#8217;t add a small brownian noise to simulate the wobble and even if we could, we couldn&#8217;t link it to the size and speed of the particles. Without going into complicated wobble behavior, we will simply randomize the particle position in X and Z over time.</p>
<p>Generate a vector that has a random value for the X and Z axes, and multiply that value by the size and the speed. Add that vector the the particle&#8217;s position.<br />
In the <em>PerFrameControl</em> event, we add:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">pos <span style="color: #339933;">=</span> inParticle.<span style="color: #660066;">Position</span><span style="color: #339933;">;</span>
wobble <span style="color: #339933;">=</span> XSIMath.<span style="color: #660066;">CreateVector3</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>Math.<span style="color: #660066;">random</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #CC0000;">0.5</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> size <span style="color: #339933;">*</span> speed.<span style="color: #660066;">Length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span>Math.<span style="color: #660066;">random</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #CC0000;">0.5</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> size <span style="color: #339933;">*</span> speed.<span style="color: #660066;">Length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
pos.<span style="color: #660066;">AddInplace</span><span style="color: #009900;">&#40;</span>wobble<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
inParticle.<span style="color: #660066;">Position</span> <span style="color: #339933;">=</span> pos<span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>The big particles will wobble more than the small ones, and all particles will wobble progressively more as they gain speed.</p>
<p><strong>The Sprite Sequence Problem.</strong><br />
We have a sequence of images of a bubble rising to the surface to apply on the sprite shader of the particles. It is 100 frames long. There are many choices for the behavior of the sprite sequence on the particles, but an important one is missing. We want each particle to choose a random frame in the sequence at its birth, and take the next frame of that sequence at each frame it ages. For this, we need to create a new User Parameter on the PType. We name it &#8220;BeginSpriteSeq&#8221; and set its type to Integer.</p>
<p>We set this parameter to a random value between 0 and 100, the length of the sequence, on each particle. In the <em>BirthControl</em> event, we add the following line:</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;">inParticle.<span style="color: #660066;">Attributes</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;BeginSpriteSeq&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">Value</span> <span style="color: #339933;">=</span> Math.<span style="color: #660066;">random</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #CC0000;">100</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Then, we need to tell the particle to choose the next frames over time. In the <em>PerFrameControl</em> event, we add the line:</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;">inParticle.<span style="color: #660066;">SpriteIndex</span> <span style="color: #339933;">=</span> inParticle.<span style="color: #660066;">Attributes</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;BeginSpriteSeq&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">Value</span> <span style="color: #339933;">+</span> inParticle.<span style="color: #660066;">Age</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>I know there are ways to fake this in the render tree but the pseudo-random value is not very easy to obtain and it makes a recipe that is more complicated to update from one situation to another. However, contrary to the scripted event solution, it does not increase the simulation time.</p>
<p><strong>The Result.</strong><br />
After all the work, we end up with only two events that solve all the problems encountered with a reasonable simulation time.</p>
<p><em>BirthControl</em> event<br />
trigger: Particle Age = 0<br />
ScriptContext: Per Trigger Particle</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;">inParticle.<span style="color: #660066;">Size</span> <span style="color: #339933;">=</span> Math.<span style="color: #660066;">pow</span><span style="color: #009900;">&#40;</span> Math.<span style="color: #660066;">random</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">5</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #CC0000;">0.025</span> <span style="color: #339933;">+</span> <span style="color: #CC0000;">0.005</span><span style="color: #339933;">;</span>
inParticle.<span style="color: #660066;">Attributes</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;BeginSpriteSeq&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">Value</span> <span style="color: #339933;">=</span> Math.<span style="color: #660066;">random</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #CC0000;">100</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p><em>PerFrameControl</em> event<br />
trigger: Every N Frame = 1<br />
ScriptContext: Per Particle</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
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">//speed control</span>
speed <span style="color: #339933;">=</span> inParticle.<span style="color: #660066;">Velocity</span><span style="color: #339933;">;</span>
size <span style="color: #339933;">=</span> inParticle.<span style="color: #660066;">Size</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>speed.<span style="color: #660066;">Length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> size <span style="color: #339933;">*</span> <span style="color: #CC0000;">10</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>  <span style="color: #006600; font-style: italic;">// if speed is bigger than 10 times the size...</span>
    speed.<span style="color: #660066;">NormalizeInPlace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>      <span style="color: #006600; font-style: italic;">// scale the speed to be 1 and</span>
    speed.<span style="color: #660066;">ScaleInPlace</span><span style="color: #009900;">&#40;</span>size <span style="color: #339933;">*</span> <span style="color: #CC0000;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// scale speed to be 10 times the size.</span>
<span style="color: #009900;">&#125;</span>
inParticle.<span style="color: #660066;">Velocity</span> <span style="color: #339933;">=</span> speed<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//wobble</span>
pos <span style="color: #339933;">=</span> inParticle.<span style="color: #660066;">Position</span><span style="color: #339933;">;</span>
wobble <span style="color: #339933;">=</span> XSIMath.<span style="color: #660066;">CreateVector3</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>Math.<span style="color: #660066;">random</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #CC0000;">0.5</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> size <span style="color: #339933;">*</span> speed.<span style="color: #660066;">Length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span>Math.<span style="color: #660066;">random</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #CC0000;">0.5</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> size <span style="color: #339933;">*</span> speed.<span style="color: #660066;">Length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
pos.<span style="color: #660066;">AddInplace</span><span style="color: #009900;">&#40;</span>wobble<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
inParticle.<span style="color: #660066;">Position</span> <span style="color: #339933;">=</span> pos<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//sprite sequence</span>
inParticle.<span style="color: #660066;">SpriteIndex</span> <span style="color: #339933;">=</span> inParticle.<span style="color: #660066;">Attributes</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;BeginSpriteSeq&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">Value</span> <span style="color: #339933;">+</span> inParticle.<span style="color: #660066;">Age</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Here is a <a href="/userContent/upload/TricksParticleEvents.zip" title="">Quicktime movie</a> of the result.<br />
Here is a <a href="/userContent/upload/TricksParticleEvents_Crop.zip" title="">close-up</a> from the HD version.</p>
<p>In the final version of this recipe, I had to change the script context of the events because I wanted to add a custom PPG on the cloud with some parameters to control the various effects. This required a Dictionary.GetObject() to get the values of those parameters in each event and I didn&#8217;t want to evaluate it for each particle. I set the script contexts to Per Cloud, and did some conditional expressions to replace the triggers.</p>
<p>I&#8217;m glad we can solve these problems since they occur surprisingly often in production. However, I wish the solutions were more accessible from the UI. Not only would it make it easier for an artist to use them, but also the simulation times might be decreased since it would be part of the internal solver. I hope the good people at Softimage consider those problems in the new particle system they are preparing. The ability to customize the distribution of random values on a parameter is essential to a good simulation package. So is the ability to link random values from one parameter to another.</p>
<img src="http://www.softimageblog.com/?ak_action=api_record_view&id=127&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.softimageblog.com/archives/127/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Behavior Table Properties and Caching</title>
		<link>http://www.softimageblog.com/archives/73#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=behavior-table-properties-and-caching</link>
		<comments>http://www.softimageblog.com/archives/73#comments</comments>
		<pubDate>Fri, 09 Dec 2005 21:40:13 +0000</pubDate>
		<dc:creator>Patrick Boucher</dc:creator>
				<category><![CDATA[Behavior]]></category>

		<guid isPermaLink="false">http://www.xsi-blog.com/?p=73</guid>
		<description><![CDATA[The Piccolo language has this neat little function called <em>AddPropertyTable</em> which you can call on pretty much any object. This attaches a table of userdefined properties on the object that you can then fill with whatever you wish. This table of course goes whereever the object goes and is accessible through dot notation.

I use this profusely, especially with my actors. This way I can tack on actor characteristics (i.e.: agression level, strength, sight distance, etc) and refer to these characteristics later in the code.]]></description>
			<content:encoded><![CDATA[<p>The Piccolo language has this neat little function called <em>AddPropertyTable</em> which you can call on pretty much any object. This attaches a table of userdefined properties on the object that you can then fill with whatever you wish. This table of course goes whereever the object goes and is accessible through dot notation.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> world <span style="color: #339933;">=</span> engine.<span style="color: #660066;">GetCurrentWorld</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
world.<span style="color: #660066;">AddPropertyTable</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
world.<span style="color: #660066;">ChanceOfRainInWorld</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">0.8</span><span style="color: #339933;">;</span>
Console.<span style="color: #660066;">PrintNl</span><span style="color: #009900;">&#40;</span>world.<span style="color: #660066;">ChanceOfRainInWorld</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>I use this profusely, especially with my actors. This way I can tack on actor characteristics (i.e.: agression level, strength, sight distance, etc) and refer to these characteristics later in the code.</p>
<p><strong>Actor Caching</strong></p>
<p>Once you&#8217;ve distributed your actors in the world and you&#8217;ve given them characteristics you may need to save these characteristics for future simulations. I built a little helper file that contains two functions to save and retrieve an <em>actor cache</em>. You can then, in your Piccolo startup, load a world with only your environment, and load your actors from this cache that will recreate the property table as it was when you saved the cache. Right now the code only supports saving and retrieving String, Integer and Float values because that&#8217;s what I needed. If you build on this code and add types, I&#8217;d appreciate your contributing back to the community.</p>
<p>The other benefit of this is that you can create your population distribution in XSI along with your actor characteristics, output an actor cache that can then be read back into Behavior as the initial state of your simulation.</p>
<p><strong>Motion Caching</strong></p>
<p>There are also two functions to do home-brewed motion caching. The same kind of thing Behavior does with DrvMotion. The only advantage is that it takes the black out of black-box and you know how the cache is built and what the file format is. It&#8217;s more of a Behavior/Piccolo exercise than anything else. It is definitely slower than DrvMotion because it is pure Piccolo.</p>
<p>You can download an <a href="/userContent/patrickb/behavior/PB_MotionCache.zip">example project</a> (Behavior 2.1) and check out the code.<br />
Any comments would be very welcome!</p>
<img src="http://www.softimageblog.com/?ak_action=api_record_view&id=73&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.softimageblog.com/archives/73/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Render Passes in Behavior</title>
		<link>http://www.softimageblog.com/archives/71#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=render-passes-in-behavior</link>
		<comments>http://www.softimageblog.com/archives/71#comments</comments>
		<pubDate>Wed, 07 Dec 2005 01:14:12 +0000</pubDate>
		<dc:creator>Patrick Boucher</dc:creator>
				<category><![CDATA[Bablings and Ramblings]]></category>
		<category><![CDATA[Behavior]]></category>

		<guid isPermaLink="false">http://www.xsi-blog.com/?p=71</guid>
		<description><![CDATA[I&#8217;m currently winding down on this Behavior project that has been making me loose sleep. I&#8217;m at the stage where I need to create my data for my multiple render passes&#8230;.
Warning: If you&#8217;ve never used Behavior before or don&#8217;t care for crowd sim, skip this one. If you care for a stupid Behavior trick&#8230; Read [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently winding down on this Behavior project that has been making me loose sleep. I&#8217;m at the stage where I need to create my data for my multiple render passes&#8230;.</p>
<p><strong>Warning</strong>: If you&#8217;ve never used Behavior before or don&#8217;t care for crowd sim, skip this one. If you care for a stupid Behavior trick&#8230; Read on&#8230;</p>
<p>Behavior has a rendering pipeline that involves spewing a bunch of files into a directory and rendering them out with a nifty geometry shader and Mental Ray. Thing is, you have to run a simulation for every render pass you have. This means, you don&#8217;t have a choice but to cache your actor&#8217;s motion data in a first pass and then simulate all your other passes using the cache to output your .mi2 files.</p>
<p>When I did all this I wound up with characters that wouldn&#8217;t render at <em>exactly</em> the same spot from pass to pass even if I had used a caching mechanism. We&#8217;re talking pixels here but it was enough to show&#8230;</p>
<p>Ever notice all those .mrd files Behavior creates along with your .mi2 files? They contain your actor positions for every frame of your simulation. To get my passes properly aligned I just copied all the .mrd files from the output directory of one simulation into the output directory of another and voila!</p>
<p>I&#8217;m wondering if this is just a cosmic fluke that should be chaulked up to planetary alignment or if it&#8217;s a legal Behavior move but&#8230; It just saved my butt!</p>
<p>Carry on!</p>
<img src="http://www.softimageblog.com/?ak_action=api_record_view&id=71&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.softimageblog.com/archives/71/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Parameters Units Missing.</title>
		<link>http://www.softimageblog.com/archives/66#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=parameters-units-missing</link>
		<comments>http://www.softimageblog.com/archives/66#comments</comments>
		<pubDate>Tue, 29 Nov 2005 15:30:10 +0000</pubDate>
		<dc:creator>Francois Lord</dc:creator>
				<category><![CDATA[Bablings and Ramblings]]></category>
		<category><![CDATA[Rendering]]></category>
		<category><![CDATA[Simulation]]></category>

		<guid isPermaLink="false">http://www.xsi-blog.com/?p=66</guid>
		<description><![CDATA[A whole lot of time can be wasted by tweeking a parameter in XSI when you don&#8217;t know the units it&#8217;s expressed in. This is especially true in simulation.
Simulations
You can deduce the units of a parameter rapidly with only a few tries. The Age of a particle is expressed in seconds, not frames. The Size [...]]]></description>
			<content:encoded><![CDATA[<p>A whole lot of time can be wasted by tweeking a parameter in XSI when you don&#8217;t know the units it&#8217;s expressed in. This is especially true in simulation.</p>
<p><strong>Simulations</strong></p>
<p>You can deduce the units of a parameter rapidly with only a few tries. The Age of a particle is expressed in seconds, not frames. The Size of  a particle is in scene units, not pixels. Starting from that, we can assume that the Rotation Velocity is in degrees per seconds, not degrees per frame, and that the Allowed Linear Velocity is expressed in units per seconds.</p>
<p>Things get a little more tricky when you want to animate a parameter according to the age of a particle. The key you set at frame 50 doesn&#8217;t mean 50 seconds, but 50 frames. This is not consistent with the other examples stated above, but it&#8217;&#8217;s a lot easier to figure by yourself as it&#8217;s more intuitive.</p>
<p>For a rigid body object, the help file says the Linear Velocity Limit is in units. Of course, experimentation shows it&#8217;s in units per seconds. Setting the Angular Velocity Limit is awkward. The help file says the value is expressed in radians. Experimentation suggests it&#8217;s in degrees per 2 seconds!</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="vb" style="font-family:monospace;">CreatePrim <span style="color: #800000;">&quot;Cube&quot;</span>, <span style="color: #800000;">&quot;MeshSurface&quot;</span>
CreateActiveRigidBody <span style="color: #800000;">&quot;cube&quot;</span>
SetValue <span style="color: #800000;">&quot;cube.DynamicsInitState.angvelz&quot;</span>, 90
SetValue <span style="color: #800000;">&quot;cube.RigidBodyProp.VelLimitsActive&quot;</span>, <span style="color: #000080;">True</span>
SetValue <span style="color: #800000;">&quot;cube.RigidBodyProp.AngVelLimit&quot;</span>, 60
SetValue <span style="color: #800000;">&quot;PlayControl.Format&quot;</span>, 7
SetValue <span style="color: #800000;">&quot;PlayControl.Out&quot;</span>, 25
PlayForwardsFromStart</pre></td></tr></table></div>

<p>After one second of simulation, the rotation is roughly half of the Angular Velocity Limit. </p>
<p><span id="more-66"></span><strong>Displacement</strong></p>
<p>Rendering parameters can also cause a considerable amount of confusion. Displacement and Final Gathering both have parameters that can be switched between absolute and camera view reference. In the Displacement tab of the GeoApprox PPG of an object, when set to Fine, there is a parameter called Length. This parameter is expressed in scene units. Mental ray will try to keep the triangles no bigger than Length. You must adjust this parameter to the scale of your object or scene. The render time can go through the roof if you activate View Dependent without modifying the value of Length because its units have changed. It&#8217;s now expressed in pixels, making the size of the triangles dependent on the distance to the camera, and in this case, smaller than half a pixel by default. </p>
<p><strong>Final Gathering</strong></p>
<p>The same goes for the Min and Max Radius in the Final Gathering tab of the Render Options PPG. Their values are normally expressed in scene units. When you click on the Automatic Compute button, XSI calculates the average bounding box size of all the objects in the scene in scene units and sets the two parameters accordingly. However, when you activate the View Dependent check box, the values of the radius are now in pixels. If you click on the Automatic Compute button, it will still calculate the values in scene units, and set the wrong values in the parameters, possibly increasing render time considerably and unnecessarily. </p>
<p><strong>Volume Effects</strong></p>
<p>I&#8217;ve seen many artists having problems with the Volume Effects shader. This is a fine shader even if it hasn&#8217;t evolved a lot since its early days in Soft|3D. It has a parameter called Step Size, which controls the spatial resolution of the marching algorithm. It&#8217;s expressed in scene units so it is very dependent on the scene scale. Applying this shader on a pass in a very big scene can lead to nightmares in terms of rendering time. It&#8217;s important to understand this parameter when using the Volume Effects shader, and the fact that its units are in scene units scaled by the size of the object it&#8217;s applied on. If you apply it to a scaled up cube (scaling = 100, 100, 100), the Step Size will be expressed in scene units * 100. </p>
<p><strong>Depth of Field</strong></p>
<p>The Depth of Field Shader is particular. Many of its parameters names say they are in inches, when in fact they are in scene units. I suppose the developer wanted us to use a scene scale of 1 unit = 1 inch to make sure the result would match reality. I don&#8217;t think this was a very good idea. It confuses more than anything. </p>
<p>I wish Softimage could add some space or some tooltips in PPGs to display the units. It would help the users determine the best values for certain parameters without having to go in the documentation all the time. In the mean time, experimentation is still our best resource. </p>
<img src="http://www.softimageblog.com/?ak_action=api_record_view&id=66&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.softimageblog.com/archives/66/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Dynamic Hair / Hair Dynamics</title>
		<link>http://www.softimageblog.com/archives/21#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=dynamic-hair-hair-dynamics</link>
		<comments>http://www.softimageblog.com/archives/21#comments</comments>
		<pubDate>Thu, 05 May 2005 22:37:30 +0000</pubDate>
		<dc:creator>Helge Mathee</dc:creator>
				<category><![CDATA[Simulation]]></category>

		<guid isPermaLink="false">http://www.xsi-blog.com/?p=21</guid>
		<description><![CDATA[... most importantly: control. Realistic simulation is out, rigging is in!]]></description>
			<content:encoded><![CDATA[<p>As most of the XSI community probably already knows, the Softimage XSI hair dynamics engine is well suited to do precise collision, but not really for any other task. The stiffness control is totally limited, there is no control over the flex of the hair, there is no rigability to influence the hair&#8217;s dynamic motion, and, annoyingly, there is no way to make the hair find its way back to the original groom (in a dynamic way).</p>
<p>As I usually approach these kind of problems by completely rewriting something, I rewrote the hair dynamics from scratch. The result is a flexible, animatable and controllable hair dynamics system, which I&#8217;d like to present in this article.</p>
<p><img id="image153" src="/userContent/upload/2007/01/hairdyn.jpg" alt="hairdyn.jpg" /></p>
<p>The system works using vector fields for each segment of the hair, respectively each segment of a curve. Each vector&#8217;s force can be controlled along the hair using Softimage XSI&#8217;s fcurve editors for property pages (PPG). There are two curves for each parameter, so you can blend between two different setups and animate the blends.<br />
The dyn_ctrl PPG has control over the following parameters:</p>
<p>stiffness: Controls how much each hair segment tries to straighten based on the previous segment.<br />
flex: Controls each segment&#8217;s movement along the hair. This prevents bending and gives the hair a floaty look, esp. for underwater shots.<br />
damp: This scales the simulation for each segment down, which enables the hair to move more or less depending on the setting.<br />
density: Positive values allow clumping for each segment, negative values prevent hair segments to intersect using an avoidance algorithm.<br />
Grav: Controls the amount of gravity force for each segment.<br />
Wind: Controls the segments&#8217; amount of wind influence.<br />
Groom: Enables a force which makes the hair try to go back to its originally groomed position. Really good for tufts.<br />
Tips: Uses each hair&#8217;s tip controller&#8217;s position as an additional attractor force per segment. This way the hair&#8217;s dynamics can be totally rigged.</p>
<p>All parameters are mappable to a weightmap, so you can get maximum control over each guide hair. The whole engine can be applied to just curves, so you do not need to use hair to get the dynamics working (as seen in the tree example movie).</p>
<p><img id="image154" src="/userContent/upload/2007/01/ppg.jpg" alt="ppg.jpg" /></p>
<p>All the different features can be seen in the following example movies:</p>
<p><a href="/userContent/hmathee/hairDyn/dyn.mov">Teaser (30 MB Sorenson 3 Quicktime)</a></p>
<p><a id="p155" href="/userContent/upload/2007/01/longhair_wind.mov" title="Character with long hair and alot of wind">Character with long hair and alot of wind</a> (2.4 MB Sorenson 3 Quicktime)</p>
<p><a id="p156" href="/userContent/upload/2007/01/mohawk.mov">Character with a mohawk kind of tuft</a> (2.1 MB Sorenson 3 Quicktime)</p>
<p><a id="p157" href="/userContent/upload/2007/01/tree.mov">Tree with chains enveloped to curves with dynamics</a> (1.6 MB Sorenson 3 Quicktime)<br />
<em>(Tree setup by Adam Ferrall)</em></p>
<p>I hope you enjoy watching the movies, and let me know what you think!</p>
<p>best,</p>
<p>-H</p>
<img src="http://www.softimageblog.com/?ak_action=api_record_view&id=21&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.softimageblog.com/archives/21/feed</wfw:commentRss>
		<slash:comments>13</slash:comments>
<enclosure url="http://217.160.138.15/helge/dyn.mov" length="32068100" type="video/quicktime" />
<enclosure url="http://217.160.138.15/helge/hairdyn/longhair_wind.mov" length="2464858" type="video/quicktime" />
<enclosure url="http://217.160.138.15/helge/hairdyn/mohawk.mov" length="2171570" type="video/quicktime" />
<enclosure url="http://217.160.138.15/helge/hairdyn/tree.mov" length="1684862" type="video/quicktime" />
		</item>
		<item>
		<title>Particle Initial State</title>
		<link>http://www.softimageblog.com/archives/14#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=particle-initial-state</link>
		<comments>http://www.softimageblog.com/archives/14#comments</comments>
		<pubDate>Fri, 11 Mar 2005 20:10:27 +0000</pubDate>
		<dc:creator>Helge Mathee</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Simulation]]></category>

		<guid isPermaLink="false">http://www.xsi-blog.com/?p=14</guid>
		<description><![CDATA[What happens when you use too many particles... and what the workarounds are...]]></description>
			<content:encoded><![CDATA[<p>Hi gang,</p>
<p>this beeing my first article here, I&#8217;ll write about something I just discovered the other day.</p>
<p><strong>The problem</strong></p>
<p>We use tons and tons of particles for trees to instance leaves. I am talking about numbers like 120.000 particles per tree, to get a convincing look for the leavework. When you have such a particle cloud in a XSI model, freeze it and reload it a couple of times, you get different results after loading it in, which is a huge problem for our renderfarm. I tried to use the initial state to &#8220;freeze&#8221; the initial state of the particle-cloud, without success though. </p>
<p><strong>The workaround</strong></p>
<p>Write your own particle-cloud initial state! I tried different methods using javascript to read the data from the particle-cloud, store it into a userdatablob and read it back on sceneload/modelimport. It worked, but was slow as hell. So I ended up implementing a compiled custom command (using the command wizard for Visual Studio 6.0) which creates a structure storing arrays for all the different parameters for each particle (position, rotation, size, color&#8230;.) and converted that into a userdatablob-friendly character array.<br />
To read the data back onto the particle-cloud I used a compiled operator, which is evaluated once (either on scene-load or model-import), which works the same way (converting character array to the structure, reading back all the values from the different arrays).</p>
<p>This successfully restored the particle cloud in its frozen state.</p>
<p>More to come!</p>
<img src="http://www.softimageblog.com/?ak_action=api_record_view&id=14&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.softimageblog.com/archives/14/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
