<?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>talino.org &#187; Tutorials</title>
	<atom:link href="http://www.talino.org/category/tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.talino.org</link>
	<description>Permanently under construction</description>
	<lastBuildDate>Sun, 23 May 2010 13:28:41 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Install Python 2.6.1 without trashing Ubuntu</title>
		<link>http://www.talino.org/tutorials/install-python-261-without-trashing-ubuntu/</link>
		<comments>http://www.talino.org/tutorials/install-python-261-without-trashing-ubuntu/#comments</comments>
		<pubDate>Thu, 22 Jan 2009 20:33:01 +0000</pubDate>
		<dc:creator>Tal</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.talino.org/?p=105</guid>
		<description><![CDATA[<a href="/tutorials/install-python-261-without-trashing-ubuntu/"><img class="alignleft" src="/resources/images/tutorials/python261-ubuntu/thumbs/python261-ubuntu.jpg" alt="" /></a>Getting an independent Python 2.6.1 version running smoothly on <a href="http://www.ubuntu.com/">Ubuntu 8.10 ("Intrepid")</a>, without interfering with the system's reliance on Python 2.5 and without breaking the entire package dependency system.]]></description>
			<content:encoded><![CDATA[<p><a href="/tutorials/install-python-261-without-trashing-ubuntu/"><img class="alignleft" src="/resources/images/tutorials/python261-ubuntu/thumbs/python261-ubuntu.jpg" alt="" /></a>After <a href="http://python-forum.org/pythonforum/viewtopic.php?f=1&amp;t=10870&amp;start=0&amp;sid=a3a82a1171e4cd15e6544735d79d9f56">several</a> <a href="http://python-forum.org/pythonforum/viewtopic.php?f=1&amp;t=10924&amp;start=0&amp;sid=a3a82a1171e4cd15e6544735d79d9f56">trials</a> and <a href="http://python-forum.org/pythonforum/viewtopic.php?f=1&amp;t=10958&amp;start=0&amp;sid=a3a82a1171e4cd15e6544735d79d9f56">tribulations</a>, I finally managed to get an independent Python 2.6.1 version running smoothly on <a href="http://www.ubuntu.com/">Ubuntu 8.10 (&#8220;Intrepid&#8221;)</a>, without interfering with the system&#8217;s reliance on Python 2.5 and without breaking the entire package dependency system. The procedure described here has been successfully carried out on the <a href="http://www.geteasypeasy.com/">Easy Peasy</a> distribution of Ubuntu (ex-&#8221;Ubuntu-eee&#8221;), specifically tailored for the <a href="http://eeepc.asus.com/">Asus EEE-PC</a>. It should work, though, with any other 8.10 version of Ubuntu. It has also been tested successfully on Ubuntu 8.04 (&#8220;Hardy&#8221;).<br />
<span id="more-105"></span><br />
A lot of the following information will be obvious to people with a thorough knowledge of both Linux and Python. However, coming from Mac OSX, things haven&#8217;t been that obvious. For the poor souls who will be frantically googling for &#8220;zlib&#8221;, &#8220;zipimport.ZipImportError&#8221;, &#8220;setuptools&#8221;, &#8220;ipython&#8221;, &#8220;readline&#8221; and &#8220;ubuntu&#8221;, I offer a series of steps which, so far, haven&#8217;t disturbed the operating system and allow one to run the essential <a href="http://ipython.scipy.org/moin/">IPython</a> environment (and a lot more) without pulling one&#8217;s hair out. It&#8217;s actually quick and easy and involves no hacking whatsoever (I wouldn&#8217;t know how to hack either Python or Linux anyhow).</p>
<p>DISCLAIMER: My knowledge of linux is superficial. I write the following with the intent of helping out newbies such as myself. Do not hold me reponsible if you follow my method and end up with a system that&#8217;s pushing up the daisies.</p>
<p>NOTE: This method has been tested on <a href="http://www.gnome.org/">GNOME</a>, the default desktop environment for my distribution. I haven&#8217;t tried it with <a href="http://www.kde.org/">KDE</a> and, now that it&#8217;s finally working, I don&#8217;t think I will.</p>
<p>ACKNOWLEDGEMENT: I would never have gotten Python 2.6.1 and Ubuntu to work together if it hadn&#8217;t been for the precious help of wacky, a member of the <a href="http://www.python-forum.org/pythonforum/index.php">Python forum</a>, who saw me through several nightmarish reinstallations of both Ubuntu and Python. Several of his suggestions have been incorporated into the steps below.</p>
<p>I suggest you read through the entire list of steps so that you have an idea of what&#8217;s going to happen before actually running any command.</p>
<ol>
<li>Install a fresh copy of Ubuntu 8.10 if your system has been hopelessly pulverized by repeated tests, errors and packages scattered in the wrong places.</li>
<li>Before doing anything directly related to Python, you need to install the packages listed below. The list is an amalgam of several suggestions I found around the web, so one package or more might not be absolutely essential. But since it works, here&#8217;s the list:
<ul>
<li>build-essential</li>
<li>libncursesw5-dev</li>
<li>libreadline5-dev</li>
<li>libssl-dev</li>
<li>libgdbm-dev</li>
<li>libbz2-dev</li>
<li>libc6-dev</li>
<li>libsqlite3-dev</li>
<li>libdb-dev</li>
<li>tk-dev</li>
</ul>
<p>The easiest way to install a package is to use the <em>aptitude</em> command. Make sure you&#8217;re connected to the internet, open a terminal session and type the following: <code>sudo aptitude install package-name</code> You will be prompted for your password the first time you invoke the <em>sudo</em> command, which executes everything typed after it as a &#8220;superuser&#8221; (or &#8220;root&#8221; user). Instead of entering the command for each and every package, you can may prefer to enter them all at once (all of the following should be typed on a single line): <code>sudo aptitude install build-essential libncursesw5-dev libreadline5-dev libssl-dev libgdbm-dev libbz2-dev libc6-dev libsqlite3-dev libdb-dev tk-dev</code></li>
<li>Download and extract the <a href="http://www.python.org/download/">Python 2.6.1 source</a>. From inside the source directory, enter (still and always, one single line):<br />
<code>./configure --prefix=/home/yourusername/python/2.6</code>This will setup Python to install into a &#8216;python/2.6&#8242; directory inside your home directory, far away from anything system-like. You may choose to simply name the directory &#8216;python&#8217;, but the &#8216;2.6&#8242; subdirectory will help separate the installation from yet another custom setup, such as version 3.0, if you ever need to install one. Note, though, that this doesn&#8217;t mean I&#8217;ve tested the steps described in this tutorial with Python 3.0.</li>
<li>Compile Python with the standard command:<code>make</code>When the compile process finishes, read the few last lines it printed: you might get a couple of modules which can&#8217;t be found. I don&#8217;t remember their names but from searching around I gather that a lot of people can&#8217;t seem to find them and that nobody really cares. Most importantly, make sure that you don&#8217;t get a module missing error for <em>zlib</em> or <em>readline</em>, which are essential for the following steps. The packages installed previously will have taken care of that, though.</li>
<li>Install Python. I tried to do a <em>make altinstall</em> (after going through the Python source readme file), but for some reason I ended up without an executable. So just go through a regular install. Since you&#8217;re installing the Python files into your home directory, you don&#8217;t need to use <em>sudo</em>:<br />
<code>make install</code></li>
<li>Now, if you enter <em>python</em> in the terminal you should get the default Python version that comes with Ubuntu (currently 2.5.2). Typing <em>which python</em> should point to /usr/bin/python, not to the directory you just installed 2.6.1 into. All of this is normal and is actually what you&#8217;re looking for.</li>
<li>Optional: if you need an additional Python module (such as <a href="http://numpy.scipy.org/">Numpy</a>), install it from its source directory by typing: <code>/home/yourusername/python/2.6/bin/python setup.py install --prefix=/home/yourusername/python/2.6</code> This runs the setup script using the 2.6.1 interpreter and installs the module into the 2.6.1 directory structure (since we&#8217;re using the same prefix we specified when installing Python itself).</li>
<li>Create a symbolic link to the 2.6.1 interpreter so that the next step doesn&#8217;t blow up in your face: <code>sudo ln -s /home/yourusername/python/2.6/bin/python /usr/local/bin/python2.6</code> It is important that you <strong>do not</strong> use a different name of your fancy for the link. Now, if you enter <em>python</em> you&#8217;ll still have 2.5.2, whereas entering <em>python2.6</em> will launch, well, 2.6.1. This will also make sure that non-system versions of Python have to be run explicitly. Keeping the &#8216;python&#8217; command reserved for the exclusive use of the system&#8217;s Python version is likely to avoid headaches in the future.</li>
<li>In order to use the <em>easy_install</em> command which facilitates the installation of additional modules, you first need to install <a href="http://peak.telecommunity.com/DevCenter/setuptools">setuptools</a>: download the <a href="http://pypi.python.org/pypi/setuptools#downloads">egg file</a> for Python 2.6 and enter: <code>sh setuptools-0.6c9-py2.6.egg</code> This is the reason why the symbolic link created in the previous step must be called &#8216;python2.6&#8242; (the setuptools script runs a <em>python2.6 exec</em> command and will complain about a missing 2.6 version if it&#8217;s not linked with &#8216;python2.6&#8242;).</li>
<li>Optional but highly recommended: install <a href="http://ipython.scipy.org/moin/">IPython</a>, an enhanced command-line environment for Python. Do not download anything manually. With <em>setuptools</em> installed, you can simply go into your Python <em>bin</em> directory (with <em>cd /home/yourusername/python/2.6/bin</em>) and type: <code>./easy_install IPython</code>Apparently you may also enter the following directly, which saves you the directory switching part: <code>easy_install-2.6 IPython</code> I haven&#8217;t tried it myself, though. Anyway, download and install will be automatic.</li>
<li>You have to add the path to IPython to your terminal environment, so that the executable can be launched from any directory. Add the following line to the end of the <em>.bashrc</em> file which is located in your home directory. <code>PATH=$PATH:/home/yourusername/python/2.6/bin</code> I suppose you could create a symbolic link instead but i haven&#8217;t tried it.</li>
<li>If you use <a href="http://www.geany.org/">Geany</a> for Python development, you need to edit one of its configuration files so that the application&#8217;s <em>Run</em> command executes the proper interpreter: <code>sudo gedit /usr/share/geany/filetypes.python</code> Modify the <em>run_cmd</em> line to read: <code>run_cmd=python2.6 "%f"</code> This will use the symbolic link you created earlier.</li>
</ol>
<p>You can now run IPython, develop in the Geany IDE, and still install packages through aptitude or the Synaptic Package Manager without all hell breaking loose. If you&#8217;re using a tiny screen and touchpad I strongly recommend installing <a href="http://do.davebsd.com/">GNOME Do</a> to avoid mousing around too much. Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.talino.org/tutorials/install-python-261-without-trashing-ubuntu/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Faking Global Illumination</title>
		<link>http://www.talino.org/tutorials/gi/</link>
		<comments>http://www.talino.org/tutorials/gi/#comments</comments>
		<pubDate>Sun, 19 Nov 2006 13:57:31 +0000</pubDate>
		<dc:creator>Tal</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://192.168.0.4:8888/tutorials/gi/</guid>
		<description><![CDATA[<a href="/tutorials/gi/"><img class="alignleft" src="/resources/images/tutorials/gi/thumbs/gi.jpg"/></a>Instead of waiting 27 hours for a Global Illumination render to finish, it's possible to achieve realistic results by faking natural light. There are a zillion techniques for achieving that. Here's one of them.]]></description>
			<content:encoded><![CDATA[<p><a href="/tutorials/gi/"><img class="alignleft" src="/resources/images/tutorials/gi/thumbs/gi.jpg" alt="" /></a>The first image of mine that actually got printed in a proper magazine (<a href="http://www.3dworldmag.com">3d World</a>) was geometrically very simple. A few boxes, extruded surfaces etc. What  made it stand out, in my opinion, are three things: First, it is proportionally correct, based on a real-world environment studied down to the most ridiculous details, of which many are too small to be seen (big mistake). Second, it uses high-resolution bitmapped textures which were hand-painted and then dirtied in precise places, and third, it uses very diffuse lighting which works well under the circumstances (one very strong light source coming from above), and which is the object of this tutorial. A hi-res version of the image can be found in the <a href="http://www.talino.org/3d/">cgi section</a>.</p>
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/gi/gi_01.jpg" alt="Simple model, nice lighting" width="300" height="200" /><p class="wp-caption-text">Simple model, nice lighting</p></div>
<h3>First steps</h3>
<p>I had spent two days trying to light this thing, using preposterous light arrays (10&#215;10x10 attenuated omnis), domelights, whatever. But I found that the following method works well, simply because it gives you precise control over every surface. It&#8217;s a bit more tedious, but it works (at least it did for me).</p>
<p>Start by adding one Omni Light in the middle of the scene. A very warm color, a low multiplier (0.2) and a progressive attenuation, it will act as an ambient light surrounding the area where the sunlight hits the floor. It also simulates the subtle yellow light reflected from the beige floor. It shouldn&#8217;t affect specular highlights so I turn this off.</p>
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/gi/gi_02.jpg" alt="Start with almost nothing" width="300" height="200" /><p class="wp-caption-text">Start with almost nothing</p></div>
<h3>Light from the Sun</h3>
<p>Next comes the sunlight itself, which is a Direct Light. It shines through a skylight above which is actually modeled, so I don&#8217;t need a projection map. The light multiplier is set at 0.8 and there&#8217;s no need for attenuation. With shadow-mapped shadows at their defaults you get this, which is an OK shadow.</p>
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/gi/gi_03.jpg" alt="Add direct lighting" width="300" height="200" /><p class="wp-caption-text">Add direct lighting</p></div>
<h3>Separate the walls</h3>
<p>What I do now is simply separate lights and surfaces using the Exclude/Include function of each light. Now, for example, I add a spotlight which includes all the objects on the front wall, as well as the wall itself.</p>
<p>Almost everything about the light is at its default setting, except the attenuation which start a bit in front of the wall, and ends behind it. Since the spot is at an angle, the attenuation factor varies over the surface and looks quite nice.</p>
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/gi/gi_04.jpg" alt="Light the back wall" width="300" height="200" /><p class="wp-caption-text">Light the back wall</p></div>
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/gi/gi_05.jpg" alt="Simulate attenuation" width="300" height="200" /><p class="wp-caption-text">Simulate attenuation</p></div>
<p>The left wall (and all its associated objects) is going through the same treatment. The spot shines a bit from behind, and has its attenuation factor set to achieve the same principle described above.</p>
<p>Same drill for the right wall.</p>
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/gi/gi_06.jpg" alt="Light the left wall" width="300" height="200" /><p class="wp-caption-text">Light the left wall</p></div>
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/gi/gi_07.jpg" alt="And the right one" width="300" height="200" /><p class="wp-caption-text">And the right one</p></div>
<h3>Finishing touches</h3>
<p>In order to obtain a natural-looking light for the floor and the railing, two spots were added (including only the required objects, of course). They are pointing at the floor from opposite directions and are set up so as to attenuate progressively over the surface. Both have their Multiplier at around 0.8 &#8211; this prevents overexposure of the surface but still keeps a nice strong light.</p>
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/gi/gi_08.jpg" alt="And the floor" width="300" height="200" /><p class="wp-caption-text">And the floor</p></div>
<p>Because the right door was to be rendered closely, I dedicated two more spotlights to it. This was enough to consider the image finished.</p>
<h3>Conclusion</h3>
<p>Another advantage of this technique is that it allows you to quickly render any part of your scene, from almost any angle, without worrying about the lighting at all.</p>
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/gi/gi_09.jpg" alt="The finished image" width="300" height="200" /><p class="wp-caption-text">The finished image</p></div>
<p>Don&#8217;t expect to get perfect results the first time. It took a lot of tweaking to get the attenuation, color and multiplier right for each light. 3D artists should consider this as fun, although I had some persons asking why I didn&#8217;t just photograph the bloody thing. Anyway, I hope this gave you some ideas.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.talino.org/tutorials/gi/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Maya Expressions 1</title>
		<link>http://www.talino.org/tutorials/exp1/</link>
		<comments>http://www.talino.org/tutorials/exp1/#comments</comments>
		<pubDate>Sun, 19 Nov 2006 13:43:33 +0000</pubDate>
		<dc:creator>Tal</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://192.168.0.4:8888/uncategorized/exp1/</guid>
		<description><![CDATA[<a href="/tutorials/exp1/"><img class="alignleft" src="/resources/images/tutorials/exp1/thumbs/exp1.jpg"/></a>As an introduction to the basics of using expressions in Maya, this tutorial shows how to make simple wings flap at a controllable speed without setting a single keyframe.]]></description>
			<content:encoded><![CDATA[<p><a href="/tutorials/exp1/"><img class="alignleft" src="/resources/images/tutorials/exp1/thumbs/exp1.jpg"/></a>Once you figure out the basics of expressions in Maya, you&#8217;ll find yourself using them all the time, avoiding manual keyframing as much as possible. Expressions are, in my opinion, Maya&#8217;s strongest feature. In order to explain the basic idea of using them, this tutorial will show how to create a very simple animation: a bug flapping its wings with a controllable speed attribute. The model is very sketchy, since it&#8217;s not the focus of this tutorial.</p>
<h3>Quick modeling</h3>
<p>Create three Nurbs spheres, and move and scale them so that you get a very rough representation of a body with a couple of wings. Name the wings &#8220;rWing&#8221; and &#8220;lWing&#8221;, and name the body &#8220;bug&#8221; or whatever. Throw a basic texture on them if you wish.</p>
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/exp1/exp1_02.jpg" alt="It's a bird!" width="300" /><p class="wp-caption-text">It's a bird!</p></div>
<p>Move the pivot points of both wings so that they can rotate around the proper axis.</p>
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/exp1/exp1_03.jpg" alt="Proper pivoting..." width="300" /><p class="wp-caption-text">Proper pivoting...</p></div>
<p>Parent the wings to the main body so that they move with it.</p>
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/exp1/exp1_04.jpg" alt="...and parenting" width="300" /><p class="wp-caption-text">...and parenting</p></div>
<h3>The Expression Editor</h3>
<p>Open the Expression Editor (Window > Animation Editors > Expression Editor&#8230;). You&#8217;ll find it useful to assign a hotkey to that (ALT+e is unassigned by default and is a good choice).</p>
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/exp1/exp1_05.jpg" alt="The not-so-daunting Expression Window" width="300" /><p class="wp-caption-text">The not-so-daunting Expression Window</p></div>
<p>On the left you&#8217;ll see your currently selected object, and on the right the list of its keyable attributes. Expression are typed into the bottom box. It&#8217;s important to know that expressions do NOT relate to the currently selected object. You can write expressions for anything, another object, a shader, whatever you want. If have an object selected, though, it&#8217;s easier to know the exact name of an attribute you want to control, since all keyable attributes at listed on the right.</p>
<p>Type &#8220;wingFlap&#8221; into the Expression Name box, and type the following into the Expression box at the bottom of the dialog box:</p>
<p><code>lWing.rotateX = time * 10;</code></p>
<p>Click &#8220;Create&#8221;. This creates the expression.</p>
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/exp1/exp1_06.jpg" alt="Your first expression" width="300" /><p class="wp-caption-text">Your first expression</p></div>
<p>The syntax is very simple: you type the object name (or, rather, the node name), followed by a period and the attribute you want to control. In this case, we want to control the X rotation of the left wing&#8217;s transform node. The &#8220;time&#8221; attribute is a built-in value in Maya, which returns the current time of the animation in seconds. Its multiplied by ten so that the result is more immediately visible (the flapping is faster). The semicolon simply marks the end of every statement in Maya. Click &#8220;Play&#8221;, and the you&#8217;ll see the wing rotate as time goes by. Check the Hypergraph, and you&#8217;ll see lWing controlled by the wingFlap expression. Also, in the Channel Box, lWing&#8217;s rotateX attribute turns orange to show that it&#8217;s controlled by something and that you can&#8217;t change it directly.</p>
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/exp1/exp1_07.jpg" alt="A transform node controlled by an expression" width="300" /><p class="wp-caption-text">A transform node controlled by an expression</p></div>
<h3>The Sine function</h3>
<p>The simplest way to create a back-and-forth motion is to use a sine function. Modify the expression so that it looks like this:</p>
<p><code>lWing.rotateX = sin (time * 10) * 40;</code></p>
<p>If the expression has disappeared from the Expression Editor, simply click Select Filter > By Expression Name and click on wingFlap.</p>
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/exp1/exp1_08.jpg" alt="Finding lost expressions" width="300" /><p class="wp-caption-text">Finding lost expressions</p></div>
<p>The result of the sine function is multiplied by forty so that the motion describes a larger arc. Otherwise, the flapping goes back and both between two very small values.</p>
<p>Click &#8220;Edit&#8221;. This button, which replaced the &#8220;Create&#8221; button, updates the expression to reflect the changes you&#8217;ve made. If you get the message &#8220;Error: Expression invalid after edit&#8221;, check your syntax. If you play the animation after this error without correcting it, Maya evaluates the last valid expression that you entered.</p>
<p>Play the animation. The wing flaps back and forth.</p>
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/exp1/exp1_09.jpg" alt="The wing flaps. Wow." width="300" /><p class="wp-caption-text">The wing flaps. Wow.</p></div>
<p>To get both wings to flap, copy and paste the expression into the line below, but change lWing to rWing, so that the whole expression now reads:</p>
<p><code>lWing.rotateX = sin (time * 10) * 40;</br><br />
rWing.rotateX = sin (time * 10) * 40;</code></p>
<p>You&#8217;ll see a motion which isn&#8217;t at the cutting-edge of aerodynamics. This is because the X rotation of the opposite wing should be reversed.</p>
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/exp1/exp1_10.jpg" alt="You're going the wrong way" width="300" /><p class="wp-caption-text">You're going the wrong way</p></div>
<p>Add a minus sign before the sine function of the right wing, to read:</p>
<p><code>lWing.rotateX = sin (time * 10) * 40;</br><br />
rWing.rotateX = -sin (time * 10) * 40;</code></p>
<p>Play the animation. The bug now has more chances of survival.</p>
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/exp1/exp1_11.jpg" alt="That's more like it" width="300" /><p class="wp-caption-text">That's more like it</p></div>
<h3>Controlling the wing speed</h3>
<p>Now suppose you want to control the wings&#8217; flapping speed. Currently, the speed is determined by the *10 part of the expression. Let&#8217;s create an attribute for wing speed that would allow us to change the speed dynamically, and even keyframe it. In the Attribute Editor, select the bug&#8217;s transform node (the one simply called &#8220;bug&#8221;), and choose Attributes > Add Attributes. </p>
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/exp1/exp1_12.jpg" alt="Creating a new attribute" width="300" /><p class="wp-caption-text">Creating a new attribute</p></div>
<p>Type WingSpeed into the Attribute Name field, make sure Float is selected, and set 0 as Minimum value, 10 as Maximum and 5 as the Default value. Make sure that &#8220;Make Attribute Keyable&#8221; is checked (so that is shows up in the Channel Box), and click on OK.</p>
<p>The Add button allows you to add several attributes without closing the window every time.</p>
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/exp1/exp1_13.jpg" alt="The new wingSpeed attribute" width="300" /><p class="wp-caption-text">The new wingSpeed attribute</p></div>
<p>In the Extra Attributes folder of the bug&#8217;s transform node, you now have a fresh new attribute called wingspeed, nicely displayed with a space (Wing Speed) because of the capital S. It&#8217;s set at the default of 5, and doesn&#8217;t do anything at the moment.</p>
<p>Back in the Expression Editor, change the 10 value to bug.WingSpeed in both lines. They should now read:</p>
<p><code>lWing.rotateX = sin (time * bug.WingSpeed) * 40;</br><br />
rWing.rotateX = -sin (time * bug.WingSpeed) * 40;</code></p>
<h3>Conclusion</h3>
<p>Notice a couple of things: the capitalization (it&#8217;s very important to type the attribute name exactly as you defined it) and the fact that we&#8217;re controlling the wings via an attribute which belongs to the bug node, hence the bug.WingSpeed. Move the Wing Speed slider around and see how it affects the wings&#8217; motion.</p>
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/exp1/exp1_13.jpg" alt="Final expression" width="300" /><p class="wp-caption-text">Final expression</p></div>
<p>Play around with this in order to get a feel for the almost infinite possibilities it offers. Try to control the size of the wing arc (currently 40) with another, new attribute. Also, you can attach the bug node to a turbulence field, and try to control the wing speed via, for example, the translateY attribute of the bug, so that its wings flap more quickly when it approach the ground. Bear in mind that you&#8217;ve still haven&#8217;t set a single keyframe. Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.talino.org/tutorials/exp1/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Maya Expressions 2</title>
		<link>http://www.talino.org/tutorials/exp2/</link>
		<comments>http://www.talino.org/tutorials/exp2/#comments</comments>
		<pubDate>Sun, 19 Nov 2006 13:15:39 +0000</pubDate>
		<dc:creator>Tal</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://192.168.0.4:8888/tutorials/exp2/</guid>
		<description><![CDATA[<a href="/tutorials/exp2/"><img class="alignleft" src="/resources/images/tutorials/exp2/thumbs/exp2.jpg"/></a>The hidden distanceBetween node - and the more common clamp function - are explained using a simple example: making two spheres glow as they approach each other.]]></description>
			<content:encoded><![CDATA[<p><a href="/tutorials/exp2/"><img class="alignleft" src="/resources/images/tutorials/exp2/thumbs/exp2.jpg"/></a>One day, a mischievous Alias|Wavefront programmer took the decision to create  a wonderfully useful function in Maya. He or she then proceeded to hide it  deeply enough inside the interface so that as few people as possible could hope to find it (although I think I saw it somewhere more visible in Maya 6).  The function is called the distanceBetween node, and is the object of this  tutorial. If you&#8217;re new to expressions, you might want to check out my first  tutorial on the subject before tackling this one.</p>
<p>What this node basically does is take two vector inputs (such as Translate X, Y and Z), calculate the distance between them, and then output the result into a distance attribute. This allows for some very basic effects to be achieved with little fuss. </p>
<p>The distanceBetween node doesn&#8217;t have to have translate values as inputs, but they are the best way to explain how it works. So here goes.</p>
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/exp2/exp2_01.jpg" alt="The distanceBetween node" width="300" /><p class="wp-caption-text">The distanceBetween node</p></div>
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/exp2/exp2_02.jpg" alt="A simple vector" width="300" /><p class="wp-caption-text">A simple vector</p></div>
<h3 class="topaligned">Creating the node</h3>
<p>In the Command Line, type the following MEL command:</p>
<p><code>createNode distanceBetween</code></p>
<p>and press Enter.</p>
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/exp2/exp2_03.jpg" alt="Now isn't that user-friendly" width="300" /><p class="wp-caption-text">Now isn't that user-friendly</p></div>
<p>As you probably figured out, this command creates the node. Following the logic which dictates that this node should be hidden from most mortals, it doesn&#8217;t appear in the Outliner, Hypershade or Hypergraph. You&#8217;ll need to go to the Outliner, and turn off DAG Objects Only from the Display menu.</p>
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/exp2/exp2_04.jpg" alt="Still invisible..." width="300" /><p class="wp-caption-text">Still invisible...</p></div>
<p>Tada. Since you&#8217;ll spend quite some time hunting for it later, you might find it useful to create a button which selects it for you. Just select another node and then select the distanceBetween1 node again. Open the Script Editor, highlight the &#8220;select -r distanceBetween1 ;&#8221; command which will show up there and middle-drag it to a shelf.</p>
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/exp2/exp2_05.jpg" alt="...but not for long" width="300" /><p class="wp-caption-text">...but not for long</p></div>
<h3 class="topaligned">A simple application</h3>
<p>Now for the fun part. Create a couple of spheres and assign the same material to both of them. Give it a nice, popular color such as red. Open the Connection Editor (Window > General Editors > Connection Editor&#8230;), select one of the spheres and click Reload Left. Select the distanceBetween1 node (either through the Outliner or with your shelf button), and click Reload Right.</p>
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/exp2/exp2_06.jpg" alt="Connecting the node" width="300" /><p class="wp-caption-text">Connecting the node</p></div>
<p>Towards the bottom of the list on the left, click the Translate attribute. On the right-hand side, click the Point1 attribute. This connects the sphere&#8217;s XYZ translate values to the distanceBetween node&#8217;s first input.</p>
<p>Select the second sphere and click Reload Left in the Connection Editor. This time, connect the Translate attribute to the Point2 attribute. Check the Hypergraph to see how the nodes are connected.</p>
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/exp2/exp2_07.jpg" alt="Two vector inputs" width="300" /><p class="wp-caption-text">Two vector inputs</p></div>
<p>The resulting value, which is contained in the distanceBetween1.distance attribute, can be used in an infinite number of ways. Let&#8217;s assume that we want the spheres to glow when they get close to one another. You could connect the distance attribute to, say, the incandescence R, G &#038; B values for the material you assigned (remember that distance is a float value, so it goes into each channel separately), but this can be problematic. The distance is measured in world units, and unless your spheres stay within a 0 to 1 distance from each other, you can get funky results. It&#8217;s better to write an expression for it.</p>
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/exp2/exp2_08.jpg" alt="Mapping the Distance to Incandescence" width="300" /><p class="wp-caption-text">Mapping the Distance to Incandescence</p></div>
<h3 class="topaligned">An expression for more control</h3>
<p>Assuming the material assigned to both spheres is called blinn1, create a new expression with the following lines (ignore any line breaks, and you might double check your spelling if you get an error, incandescence is a particularily treacherous attribute to type in):</p>
<p><code>blinn1.incandescenceR = (10-distanceBetween1.distance)/8 ;</br><br />
blinn1.incandescenceG = (10-distanceBetween1.distance)/8 ;</br><br />
blinn1.incandescenceB = (10-distanceBetween1.distance)/8 ;</code></p>
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/exp2/exp2_09.jpg" alt="An expression might be more handy..." width="300" /><p class="wp-caption-text">An expression might be more handy...</p></div>
<p>What this does is take the distance and subtract it from 10, so that the spheres glow when they approach each other, instead of when they move away. The 10 value determines at what distance the glow starts. The result is then further divided by 8 so that the transition of the glow is more gradual. Move the spheres around in textured mode to see it in action. Also, try this with different values and see what happens.</p>
<p>There&#8217;s still a problem. When the spheres are farther than 10 units apart in this example, the incandescence becomes negative and they go completely black. Remedy this by adding a clamp function, so that the expression reads:</p>
<p><code>blinn1.incandescenceR = clamp(0,1,(10-distanceBetween1.distance)/8) ;</code></p>
<p>The same should go for the Green and Blue channels.</p>
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/exp2/exp2_10.jpg" alt="...if it's written correctly" width="300" /><p class="wp-caption-text">...if it's written correctly</p></div>
<p>What this does is specify Minimum and Maximum values (the 0 and the 1) to be allowed for the third value in the function (the distance value in this case).</p>
<p>For some eye candy, move the spheres apart so that they don&#8217;t share any axis, and attach them both to a Newton field positioned between them.</p>
<p>Nicolas Aithadi has created a <a href="http://morphose.free.fr/Tutorials/CornellBox/CornellBox.htm">Cornell Box simulation</a> using the distanceBetween node. I actually wrote this tutorial because I got confused half way about what should be connected where. </p>
<p>Emmanuel Campin, author of the SkyLightControl MEL Script, has an even more involved example which <a href="http://www.highend3d.com/maya/tutorials/emmanuel2/">fakes soft shadows with Dmaps.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.talino.org/tutorials/exp2/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Flying Balloon</title>
		<link>http://www.talino.org/tutorials/balloon/</link>
		<comments>http://www.talino.org/tutorials/balloon/#comments</comments>
		<pubDate>Sun, 19 Nov 2006 10:29:51 +0000</pubDate>
		<dc:creator>Tal</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://192.168.0.4:8888/?p=16</guid>
		<description><![CDATA[<a href="/tutorials/balloon/"><img class="alignleft" src="/resources/images/tutorials/balloon/thumbs/balloon.jpg"/></a>Using soft body dynamics in Maya to animate a flying balloon with a string attached to it. This tutorial introduces the concepts of Goal Curves, Wire Deformers and GoalPP Weights.]]></description>
			<content:encoded><![CDATA[<p><a href="/tutorials/balloon/"><img class="alignleft" src="/resources/images/tutorials/balloon/thumbs/balloon.jpg" alt="" /></a>This tutorial was written as a response to an email asking how one could go about animating a balloon flying in the air — complete with attached string. I believe the quickest way to create a realistic motion would be to use soft body dynamics, which is the method described here. As usual, there are many other methods. Suggestions and corrections are welcome.</p>
<p>Check out the following playblast to see the result:</p>
[See post to watch Flash video]
<h3 class="topaligned">Quick modeling</h3>
<p>The geometry was simplified since it&#8217;s not the issue here. Create a sphere, tweak it a bit and name it balloon. Next create a NURBS cylinder and non-proportionally scale it so that it looks like a string (the name used in this example is string1 because Maya seems to reserve the name string for internal use). The cylinder should have enough spans to deform properly later. I used six spans here.</p>
<p>Delete history on both objects.</p>
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/balloon/balloon_01.jpg" alt="A sphere and a cylinder" width="300" /><p class="wp-caption-text">A sphere and a cylinder</p></div>
<h3 class="topaligned">A curve to deform the string</h3>
<p>The cylinder itself could be turned into a soft body, but since it has volume (eight sections by default), deforming it directly will create irregularities in its thickness. Instead, we will use a curve.</p>
<p>In the side or front view, create a CV curve with six evenly spaced vertices going down straight through the cylinder. Use Snap to Grid (hold down the X key by default) in order to make it completely straight.</p>
<p>This curve will be used as a Wire deformer: when vertices move, they will deform the geometry they are attached to.</p>
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/balloon/balloon_02.jpg" alt="The deformation curve" width="300" /><p class="wp-caption-text">The deformation curve</p></div>
<h3 class="topaligned">The Wire Deformer</h3>
<p>From the Animation menu set, select Deform &gt; Wire Tool and set its options to the default. Following the prompts on the Help Line, select the shape to deform (string1), press Enter, then select the Wire curve (curve1) and press Enter. You can do this through the Outliner.</p>
<p>This creates a new node, curve1BaseWire. To see the results of this operation, select a CV on curve1 and move it around. The string should deform accordingly.</p>
<p>Undo any CV tweaks so that the curve is straight again.</p>
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/balloon/balloon_03.jpg" alt="The Wire Deformer" width="300" /><p class="wp-caption-text">The Wire Deformer</p></div>
<h3 class="topaligned">The Soft Body</h3>
<p>Now for the soft body. Select the original curve (curve1) and from the Dynamics<br />
menu set choose Soft/Rigid Bodies &gt; Create Soft Body options. Set the options<br />
shown to the right and click Create. In the Outliner, you will see a new Particle<br />
object parented to the curve. This object has six particles, one for each CV<br />
of the curve.</p>
<p>The curve has also been duplicated as copyOfcurve1 and is used as a Goal. This means the particles will tend to align themselves to the CVs of the duplicate curve, and while doing so will deform, or move, the CVs of the original curve.</p>
<p>We need to attach the string to the balloon, so that it follows it everywhere. To do this, parent the Goal curve (copyOfcurve1) to the balloon. Since that curve is hidden, the quickest way to do that is to use the Outliner: middle-mouse drag copyOfcurve1 onto balloon.</p>
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/balloon/balloon_04.jpg" alt="Creating the Soft Body" width="300" /><p class="wp-caption-text">Creating the Soft Body</p></div>
<h3 class="topaligned">Relationship summary</h3>
<p>The diagram to the right (&#8220;Parents and children&#8221;) sums up the relations we just set up. Make sure you understand the relationships and the role of each node.</p>
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/balloon/balloon_05.jpg" alt="Parents and children" width="300" /><p class="wp-caption-text">Parents and children</p></div>
<h3 class="topaligned">Particle Goal Weights</h3>
<p>If you now keyframe a motion for the balloon you&#8217;ll see the string move along with it, although it will remain quite stiff. This is because the Goal weight for the Particle object has been set to 1. You can lower it in the Particle object&#8217;s Attribute Editor section called Goal Weights and Objects, but this won&#8217;t be enough. We need to assign a specific Goal Weight to each particle, so that the top CV stays glued to the balloon while the lower ones move more freely.</p>
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/balloon/balloon_06.jpg" alt="The string is a bit stiff" width="300" /><p class="wp-caption-text">The string is a bit stiff</p></div>
<h3 class="topaligned">Practice&#8230;</h3>
<p>Go into Component Mode (F8), select a Pick Mask for Particles from the Status Line and drag-select the six particles in the perspective window (don&#8217;t select the particle object from the Outliner). This selects the individual particles. Go into Window &gt; General Editors &gt; Component Editor&#8230; and select the Particles tab. You will see a list of the particles (pt[0] through [5]) with several attributes columns. At the very end you&#8217;ll see goalPP, which is the Per Particle Goal attribute.</p>
<p>Modifying these values requires quite a bit of experimentation to get the proper look. Start with a value of 1.00 for the first particle (the one we want to keep glued to the balloon), 0.40 for the second particle and 0.20 for the remaining four. Tweak them until you&#8217;re satisfied with the motion. These values are multiplied by the particle object&#8217;s Goal Weight attribute (the one mentioned earlier), which is why you&#8217;ll want to keep it at a value of 1.00 to get predictable results.</p>
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/balloon/balloon_07.jpg" alt="Modifying GoalPP weights" width="300" /><p class="wp-caption-text">Modifying GoalPP weights</p></div>
<h3 class="topaligned">&#8230;makes perfect</h3>
<p>Now if you keyframe the balloon&#8217;s translation and rotation, you get something a little bit more interesting. The string now moves realistically.</p>
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/balloon/balloon_08.jpg" alt="This looks more natural" width="300" /><p class="wp-caption-text">This looks more natural</p></div>
<h3 class="topaligned">Keeping everything together</h3>
<p>You might find that the particles stretch the cylinder out of proportion. It order to help the particles maintain the overall length and shape of the cylinder, select the particle object and add Springs to it (Dynamics menu set &gt; Soft/Rigid Bodies &gt; Create Springs). Choose All as the Creation Method. This creates springs between all the particles. Since there are only six of them, you won&#8217;t get much of a hit on interactivity and frame rate. You&#8217;ll now have to play around with Stiffness and Damping to get the proper behavior. Don&#8217;t go over 1 for Damping or the simulation will collapse. I took Stiffness up to 20 which kept the shape nicely while still allowing for a fluid deformation.</p>
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/balloon/balloon_09.jpg" alt="Some Springs might help" width="300" /><p class="wp-caption-text">Some Springs might help</p></div>
<h3 class="topaligned">Conclusion</h3>
<p>For some added randomness in the string&#8217;s deformation, add a Turbulence Field to the particles. Set its Attenuation to zero, and tweak its Magnitude and Frequency to get the look you want.</p>
<p>The rest is basically a tweaking process between several influences which are summed up in the diagram to the left. Remember that the string will &#8220;follow through&#8221; the movement of the balloon, which should be keyframed carefully. You can make the balloon into a Rigid Body if you want, but I found it too hard to control that way.</p>
<p>Compare the following playblast with the previous one. The only values changed were the goalPP weights:</p>
[See post to watch Flash video]
<p>This method has one disadvantage. Because the Goal curve is a straight line parented to the balloon, if the balloon comes to a rest while in a non-vertical position, the string will eventually settle down somewhat horizontally, depending on the direction of the Goal curve. That said, unless you&#8217;re going to follow the balloon into the stratosphere, you should be ok.<br />
<div class="wp-caption aligncenter" style="width: 310px"><img src="/resources/images/tutorials/balloon/balloon_10.jpg" alt="Summary of influences" width="300" /><p class="wp-caption-text">Summary of influences</p></div></p>
]]></content:encoded>
			<wfw:commentRss>http://www.talino.org/tutorials/balloon/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
