<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Maratis forum - Having a ray perpendicular to the ground]]></title>
	<link rel="self" href="http://forum.maratis3d.com/extern.php?action=feed&amp;tid=479&amp;type=atom"/>
	<updated>2012-11-24T11:45:12Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.maratis3d.com/viewtopic.php?id=479</id>
		<entry>
			<title type="html"><![CDATA[Re: Having a ray perpendicular to the ground]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?pid=2969#p2969"/>
			<content type="html"><![CDATA[<p>We need to add some ready made functions to manipulate vectors,<br />but for now you can do it in lua with something like that :</p><div class="codebox"><pre><code>function rotateX(vec, angle)

    zAngle = math.rad(angle)
    sinZ = math.sin(zAngle)
    cosZ = math.cos(zAngle)

    return {vec[0], vec[1] * cosZ - vec[2] * sinZ, vec[1] * sinZ + vec[2] * cosZ}

end

function rotateY(vec, angle)

    zAngle = math.rad(angle)
    sinZ = math.sin(zAngle)
    cosZ = math.cos(zAngle)

    return {vec[0] * cosZ + vec[2] * sinZ, vec[1], -vec[0] * sinZ + vec[2] * cosZ}

end

function rotateZ(vec, angle)

    zAngle = math.rad(angle)
    sinZ = math.sin(zAngle)
    cosZ = math.cos(zAngle)

    return {vec[0] * cosZ - vec[1] * sinZ, vec[0] * sinZ + vec[1] * cosZ, vec[2]}

end</code></pre></div>]]></content>
			<author>
				<name><![CDATA[anael]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=2</uri>
			</author>
			<updated>2012-11-24T11:45:12Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?pid=2969#p2969</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Having a ray perpendicular to the ground]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?pid=2967#p2967"/>
			<content type="html"><![CDATA[<p>Alright, the idea is good I guess, thanks for the reply. <br />But there&#039;s something I have to do about the definition of my floating. Because currently it is set to 10m above the ground (=10m on the z-axis) which obviously is not right. So I have to redefine my ray. I am aware of trigonometry, but I can&#039;t get this working. I have to get the ray rotating with the object, but I don&#039;t know why. Any idea? <img src="http://forum.maratis3d.com/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></content>
			<author>
				<name><![CDATA[ChickenRunFast]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=1203</uri>
			</author>
			<updated>2012-11-23T20:43:09Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?pid=2967#p2967</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Having a ray perpendicular to the ground]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?pid=2966#p2966"/>
			<content type="html"><![CDATA[<p>Hi,</p><p>an idea, use an invisible small cube placed in front of the floating object.<br />Make the floating obj looking at the small cube (using the look-at behavior).<br />Send a ray from the transparent cube and make it float at the same height, and it should be parallell.</p>]]></content>
			<author>
				<name><![CDATA[anael]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=2</uri>
			</author>
			<updated>2012-11-23T16:55:27Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?pid=2966#p2966</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Having a ray perpendicular to the ground]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?pid=2965#p2965"/>
			<content type="html"><![CDATA[<p>Hey there!<br />So I&#039;m just messing around with this engine and I&#039;m feeling pretty comfortable with it. And lately I have played with some raycasts. There&#039;s one thing that I am really not able to do. I&#039;ve got my object. It&#039;s floating. Works. But now the point is, that I want the object to always be parallel to the ground. So I thought, I could do this by shooting a ray into the ground and check if that is perpendicular. But I can&#039;t get this working. Maybe you could help me.</p><p>In case you are wondering what I am trying to do, go drive that ramp up. Controls are W A S D, have fun! <a href="http://www.file-upload.net/download-6846386/test.zip.html">http://www.file-upload.net/download-684 &#133; t.zip.html</a></p><p>Edit: Im kinda unexperienced in coding and this helps me getting used to it a lot. I would prefer ideas of how to do it over real code snippets. Thanks in advance <img src="http://forum.maratis3d.com/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></content>
			<author>
				<name><![CDATA[ChickenRunFast]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=1203</uri>
			</author>
			<updated>2012-11-23T15:51:34Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?pid=2965#p2965</id>
		</entry>
</feed>
