<?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>Keltic Games &#187; compass</title>
	<atom:link href="http://www.kelticgames.com/index.php/tag/compass/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.kelticgames.com</link>
	<description></description>
	<lastBuildDate>Wed, 27 May 2009 15:20:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>SL Rotations</title>
		<link>http://www.kelticgames.com/index.php/2008/04/29/sl-rotations/</link>
		<comments>http://www.kelticgames.com/index.php/2008/04/29/sl-rotations/#comments</comments>
		<pubDate>Wed, 30 Apr 2008 01:53:45 +0000</pubDate>
		<dc:creator>Keltic</dc:creator>
				<category><![CDATA[Second Life]]></category>
		<category><![CDATA[camera]]></category>
		<category><![CDATA[compass]]></category>
		<category><![CDATA[degrees]]></category>
		<category><![CDATA[direction]]></category>
		<category><![CDATA[hud]]></category>
		<category><![CDATA[llGetCameraRot]]></category>
		<category><![CDATA[llGetRootRotation]]></category>
		<category><![CDATA[lsl]]></category>
		<category><![CDATA[radians]]></category>
		<category><![CDATA[rotation]]></category>
		<category><![CDATA[sl]]></category>
		<category><![CDATA[vector]]></category>
		<category><![CDATA[vehicle]]></category>

		<guid isPermaLink="false">http://www.kelticgames.com/index.php/2008/04/29/sl-rotations/</guid>
		<description><![CDATA[I recently completed the construction of a transportation system within an island of Second Life. This included a vehicle which needed to operate along a generally fixed but not exact path. Instead of putting the vehicle on some type of an rail, I placed the vehicle in the space, pointed it in a particular direction [...]]]></description>
			<content:encoded><![CDATA[<p>I recently completed the construction of a transportation system within an island of Second Life. This included a vehicle which needed to operate along a generally fixed but not exact path. Instead of putting the vehicle on some type of an rail, I placed the vehicle in the space, pointed it in a particular direction and let it go. I lined the space with invisible bumpers. When the vehicle collides with the invisible bumpers, it changes direction. This would allow the vehicle paths to vary slightly on each pass. I discussed the communication issues in <a href="http://www.kelticgames.com/index.php/2008/04/15/second-life-phantom-collisions/">Second Life Phantom Collisions</a>.</p>
<p>I encountered a very complex subject in SL: rotations. Since the vehicles needed to point in a particular compass direction at start and on collision, I would need to know the direction for each of these cases. This required determining the compass direction in an easy to read number from 0 to 359 degrees. This number was then converted to a vector (&lt;x, y, z&gt;), where x and y are both 0 and the degrees assume the z value (&lt;0.0, 0.0, direction&gt;). This vector was then converted from degrees to radians and then to a rotation. This was fairly easy to piece together using examples from the various LSL wikis (<a href="http://lslwiki.net/lslwiki/wakka.php?wakka=rotation" target="_blank">lslwiki.net</a> and <a href="http://wiki.secondlife.com/wiki/Rotation" target="_blank">wiki.secondlife.com</a>). However, as is with SL, there are always a few undocumented catches.</p>
<p>First, the degrees value is not what you might think. I would expect 0 degrees to represent North and proceed clockwise around the compass. I could also see the values starting at East and progressing clockwise. Neither was the case, 0 starts at East and proceeds <em>counter-clockwise</em> around the compass: 90 degrees is North, 180 degrees is West, 270 degrees is South, etc.</p>
<p>It was much too inaccurate to guess the degree values based on the compass headings in the mini-map, so I built a HUD to display an exact value based on the facing of my avatar. This way, I could point my avatar, read the value and plug it into the object needing a direction. After a series of tests, it became clear that the HUD was inaccurate anywhere between 1 and 9 degrees. After some trial and error, I switched from the rotation of the avatar with llGetRootRotation()  to the rotation of the camera with llGetCameraRot(). This produced an accurate result.</p>
<p>To summarize, the HUD would convert the rotation of the camera to a human-friendly direction in degrees and the objects could convert that direction back to a SL-friendly rotation.</p>
<p>The HUD simply consisted of floating text on an invisible prim. I had originally attached this to my head, which worked but lead to my fellow developers wondering why I had text floating above my head all the time. n00b! Instead, I attached the prim directly to my HUD, so that only I would see it. My first HUD attachment.</p>
<p>I&#8217;ve also been attempting to convert local rotations to global rotations and then modify those further based on a particular direction, but this has proved extremely challenging and beyond the scope of any SL rotation documentation that I have found. According to the documentation, it should be possible, I just haven&#8217;t figured it out yet.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kelticgames.com/index.php/2008/04/29/sl-rotations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
