<?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>The 3DGS Nerd &#187; hint</title>
	<atom:link href="http://3dgsnerd.xware-cg.com/tag/hint/feed/" rel="self" type="application/rss+xml" />
	<link>http://3dgsnerd.xware-cg.com</link>
	<description>A blog about 3DGS, Nerds and a lot of other stuff</description>
	<lastBuildDate>Mon, 07 Dec 2009 23:54:59 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Modulo &#8211; The Mystery Operator</title>
		<link>http://3dgsnerd.xware-cg.com/modulo-the-mystery-operator/</link>
		<comments>http://3dgsnerd.xware-cg.com/modulo-the-mystery-operator/#comments</comments>
		<pubDate>Mon, 05 Jan 2009 16:08:52 +0000</pubDate>
		<dc:creator>Michael Schwarz</dc:creator>
				<category><![CDATA[3DGS]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[help]]></category>
		<category><![CDATA[hint]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[modulo]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[optimize]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://3dgsnerd.xware-cg.com/modulo-the-mystery-operator/</guid>
		<description><![CDATA[Well, most people &#8211; mainly beginners &#8211; are very confused about what this “%” or “Modulo” operator does. Well simply put, it returns the “remainder” of a division. Let’s take a look at some easy-to-understand examples:
 
Let’s do something simple:
4 / 2 = 2 &#8211; Rest: 0
We all know how to do this, 2 fits [...]]]></description>
			<content:encoded><![CDATA[<p>Well, most people &#8211; mainly beginners &#8211; are very confused about what this “%” or “Modulo” operator does. Well simply put, it returns the “remainder” of a division. Let’s take a look at some easy-to-understand examples:</p>
<p> <span id="more-94"></span>
<p>Let’s do something simple:</p>
<p align="center"><strong>4 / 2 = 2 &#8211; Rest: 0</strong></p>
<p align="left">We all know how to do this, 2 fits two times into 4, nothing remains and thus rest is = 0.   <br />The modulo operation to get this “0” would be</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">var</span> rest = 4 % 2;</pre>
</p></div>
</div>
<p>Now let’s actually take it into account with something that gives us some “rest”:</p>
<p align="center"><strong>5 / 2 = 2.5; Rest: 1</strong></p>
<p align="center">Okay, stop now. That doesn’t make sense. Right?! 2.5 times 2 is 5, there is nothing left over!? Well no. If you make a modulo operation, it is as if you make the division with integer numbers. In this case this means:</p>
<p align="center"><strong>5 / 2 = 4; Rest 1</strong></p>
<p align="left">Because as an integer number, 2 only fits two times inside 5. And the remainder of the operation is 1, the number it takes to make the full 5.</p>
<p align="left">And again, in modulo this is:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">var</span> rest = 5 % 2; <span style="color: #008000">// = 1</span></pre>
</p></div>
</div>
<p>One more example before I go into “<em>real-life-application</em>” examples:</p>
<p><strong>8 / 3 = 2.666~; Rest: 2 &#8211; Or in Modulo result:<br />
    <br />8 / 3 = 2; Rest: 2</strong></p>
<p>Okay, let’s make this a real life example. For instance, a simple function that tell us if the a number is odd or even:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">function</span> IsEven(num)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">{</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #0000ff">return</span> !(num % 2);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">}</pre>
</p></div>
</div>
<p>This is easy explained. The function calculates the modulo for the division “num/2” if the number is even, the result will be 0. As the function is called “IsEven” I invert the result (using !) so that instead of 0 it returns 1. If the function would be called “IsOdd” you can leave it without the !, like this:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">function</span> IsOdd(num)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">{</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #0000ff">return</span> (num % 2);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">}</pre>
</p></div>
</div>
<p>We can even use it in a clever way to execute something every <strong>n</strong>’th frame:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">...</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">while</span>(1)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">{</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #0000ff">if</span>(total_frames % 5 == 0) <span style="color: #008000">// every 5 frames</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        temp += 1; <span style="color: #008000">// add 1 to temp</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    wait(1);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">}</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">...</pre>
</p></div>
</div>
<p>Modulo is a great way to do counters and do lots of tricky operations in just a matter of a single line. If you know how to use it, modulo is a mighty operator and can optimize your code <strong>BIG TIME</strong>.</p>
]]></content:encoded>
			<wfw:commentRss>http://3dgsnerd.xware-cg.com/modulo-the-mystery-operator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Review 12th Week 2008</title>
		<link>http://3dgsnerd.xware-cg.com/review-12th-week-2008/</link>
		<comments>http://3dgsnerd.xware-cg.com/review-12th-week-2008/#comments</comments>
		<pubDate>Wed, 26 Mar 2008 11:34:03 +0000</pubDate>
		<dc:creator>Michael Schwarz</dc:creator>
				<category><![CDATA[3DGS]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[forum]]></category>
		<category><![CDATA[help]]></category>
		<category><![CDATA[hint]]></category>
		<category><![CDATA[Lightning]]></category>
		<category><![CDATA[ligth]]></category>
		<category><![CDATA[review]]></category>
		<category><![CDATA[tip]]></category>

		<guid isPermaLink="false">http://3dgsnerd.xware-cg.com/?p=26</guid>
		<description><![CDATA[Hope next week gets more calm, cause I have been very busy with my job that I just got some 5 minutes to make this blog entry.

As the forum is down, it&#8217;s a little difficult to get what I need, but gladly I saved the most important post of the last week.
Lightning Lesson
Again, as the [...]]]></description>
			<content:encoded><![CDATA[<p>Hope next week gets more calm, cause I have been very busy with my job that I just got some 5 minutes to make this blog entry.</p>
<p><span id="more-26"></span></p>
<p>As the forum is down, it&#8217;s a little difficult to get what I need, but gladly I saved the most important post of the last week.</p>
<h3>Lightning Lesson</h3>
<p><em>Again, as the forum is down, I can&#8217;t really tell who posted this, but I&#8217;ll add it as soon as the forum is up again.</em></p>
<p>OK, for lighting I&#8217;ll try and give you some quick tips&#8230; </p>
<p><a href="http://3dgsnerd.xware-cg.com/wp-content/uploads/2008/03/light1.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="237" alt="light1" src="http://3dgsnerd.xware-cg.com/wp-content/uploads/2008/03/light1-thumb.jpg" width="474" border="0" /></a> </p>
<p><font color="#0080c0">Figure A :</font> Lights won&#8217;t make a cone shape (unless you use certain blocks) because they cast light in a sphere shape. If you don&#8217;t want the impression of a cone shape spotlight you have to fake it. A small light at the source (like a light fixture) and a larger light on the opposite surface (in this case, the floor). Make sure your light &#8216;bulbs&#8217; aren&#8217;t right on top of a surface. </p>
<p><font color="#0080c0">Figure B :</font> I see you have enclosed light fixtures on your ceiling. These should not cast light on the ceiling as if they were bare bulbs.     <br />You want a bit of shadow surrounding the light fixtures. If your fixtures are blocks, move your lights up close to the block so it creates some shadow at the sides.     <br />But if your light fixtures are models, the way to create shadows is to still put a block the size of the fixture there. Then select the surfaces of the block and set them all to &#8216;none&#8217;. Invisible blocks don&#8217;t block light, so you must set the flags to &#8216;none&#8217;, and it will become invisible and still block light.</p>
<p><a href="http://3dgsnerd.xware-cg.com/wp-content/uploads/2008/03/light2.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="240" alt="light2" src="http://3dgsnerd.xware-cg.com/wp-content/uploads/2008/03/light2-thumb.jpg" width="480" border="0" /></a> </p>
<p><font color="#0080c0">Figure C :</font> What if you have a ledge within your imaginary cone of light? You will need to add another light to make it appear the light is shining on the ledge too. Simple To make the most realistic lighting, you must do all lights so the follow the light source. If it&#8217;s a cone shape, your light for the ledge should be bigger than the source, but smaller than the floor in this case. </p>
<p><font color="#0080c0">Figure D :</font> This step is almost the most important step for good lighting. Ambient lighting. Notice how your areas of shadow are completely black and dark? You won&#8217;t find this in real life. All those lights you have will reflect off walls and the floor, and while it may be dark, it won&#8217;t be completely black. </p>
<p>There are 2 methods for creating the bit of light you need. As mentioned above, and what I do too, is create a light, and set its diameter large enough to reach all walls. Then set it&#8217;s brightness to 10, 10, 10 for starters. if it&#8217;s too bright, lower the numbers, and if it&#8217;s too dark, raise the numbers. </p>
<p>Now look closely at <font color="#0080c0">Figure D</font>&#8230; there&#8217;s a ledge there, so you must use 2 lights. If you use only one up high, the underside will still be black. If you put only one down low, then the upper side of the ledge will be black shadows. If you use only one light right in the middle, odds are you&#8217;ll be too dark on top of the ledge AND below it. So put one higher than the ledge, and one lower. </p>
<p>Now, chances are you&#8217;ll need multiple lights as well depending on the shapes of your rooms. </p>
<p>Now for the second, and easiest method for ambient light. At the top of WED, go to FILE &gt; Map Properties </p>
<p>Here you can set the level ambient. Again, start with, like 10, 10, 10. This method will make it so you don&#8217;t have to use big ambient lights. </p>
<p>There is a trade off though. This will effect every room in your level. If you don&#8217;t plan on having any super dark areas at all, it&#8217;s an easy method. But if you want the ambient to be brighter in one room, you&#8217;ll have to use lights again. </p>
<p>Just a quick note. When you make a change to the map properties, first you must click SAVE to save your level and then reopen it. only THEN build your level again to see the changes.    <br />Just placing lights, as you know, all you need to do is rebuild the level to see the changes. But not when setting map properties. </p>
<p>Hope this little &#8216;tutorial&#8217; helps </p>
<p>- Jason</p>
<p>Now playing: <a href="http://www.last.fm/music/Feist/">Feist</a> &#8211; <a href="http://www.last.fm/music/Feist/_/1234/">1234</a> [<a href="http://www.last.fm/music/Feist/The+Reminder/">The Reminder</a>]</p>
]]></content:encoded>
			<wfw:commentRss>http://3dgsnerd.xware-cg.com/review-12th-week-2008/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
