<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Maratis forum - Rayhit]]></title>
	<link rel="self" href="http://forum.maratis3d.com/extern.php?action=feed&amp;tid=522&amp;type=atom"/>
	<updated>2013-10-13T17:08:23Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.maratis3d.com/viewtopic.php?id=522</id>
		<entry>
			<title type="html"><![CDATA[Re: Rayhit]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?pid=5500#p5500"/>
			<content type="html"><![CDATA[<div class="quotebox"><cite>com3D wrote:</cite><blockquote><p>If you don&#039;t put it in the if statement, the rayHit will be performed at every sceneUpdate (60 times per second!).<br />If you put it inside, it will be performed only when you click.</p><p>It depends on your needs: do you need to perform it all the time or at demand? The choice is yours. <img src="http://forum.maratis3d.com/img/smilies/big_smile.png" width="15" height="15" alt="big_smile" /></p></blockquote></div><p>Ahh! I see. So the point variable only exists if the mouse is clicked. Otherwise it doesn&#039;t? Gotcha!</p>]]></content>
			<author>
				<name><![CDATA[Tutorial Doctor]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=2493</uri>
			</author>
			<updated>2013-10-13T17:08:23Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?pid=5500#p5500</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Rayhit]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?pid=5487#p5487"/>
			<content type="html"><![CDATA[<p>If you don&#039;t put it in the if statement, the rayHit will be performed at every sceneUpdate (60 times per second!).<br />If you put it inside, it will be performed only when you click.</p><p>It depends on your needs: do you need to perform it all the time or at demand? The choice is yours. <img src="http://forum.maratis3d.com/img/smilies/big_smile.png" width="15" height="15" alt="big_smile" /></p>]]></content>
			<author>
				<name><![CDATA[com3D]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=1488</uri>
			</author>
			<updated>2013-10-13T05:53:57Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?pid=5487#p5487</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Rayhit]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?pid=5479#p5479"/>
			<content type="html"><![CDATA[<p>I have a question. Does:<br /></p><div class="codebox"><pre><code>point = rayHit(Apos, Bpos)</code></pre></div><p>have to be in the if statement? Could I do:</p><div class="codebox"><pre><code>Apos = getPosition(A)
Bpos = getPosition(B)
point = rayHit(Apos, Bpos)
        
-- set Bpos further (1000 is the maximum distance, set higher if needed)
Bpos[1] = Apos[1] + (Bpos[1] - Apos[1])*1000
Bpos[2] = Apos[2] + (Bpos[2] - Apos[2])*1000
Bpos[3] = Apos[3] + (Bpos[3] - Apos[3])*1000

if onKeyDown(&quot;MOUSE_BUTTON1&quot;) then 
    if point then
        print(point)    
    end
end</code></pre></div><p>And be fine?</p>]]></content>
			<author>
				<name><![CDATA[Tutorial Doctor]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=2493</uri>
			</author>
			<updated>2013-10-13T02:43:01Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?pid=5479#p5479</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Rayhit]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?pid=3324#p3324"/>
			<content type="html"><![CDATA[<p>This is great, thank you. It works perfectly!</p>]]></content>
			<author>
				<name><![CDATA[Pär]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=1252</uri>
			</author>
			<updated>2013-01-10T18:22:46Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?pid=3324#p3324</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Rayhit]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?pid=3318#p3318"/>
			<content type="html"><![CDATA[<p>You have to understand that rayHit is like a laser detector in a spy film :</p><p><span class="postimg"><img src="http://blogs.lt.vt.edu/blorg/files/2012/04/GetSmartLaser1-300x225.jpg" alt="http://blogs.lt.vt.edu/blorg/files/2012/04/GetSmartLaser1-300x225.jpg" /></span></p><p>You have to give it the first point and the last point, and if something touch it it detect the intersection.</p>]]></content>
			<author>
				<name><![CDATA[anael]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=2</uri>
			</author>
			<updated>2013-01-10T13:40:41Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?pid=3318#p3318</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Rayhit]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?pid=3317#p3317"/>
			<content type="html"><![CDATA[<p>B is not correct, you have to give the final point of the ray.</p><p>With the new release I&#039;ll show a simpler way to do it with the matrix operation, but for now it can be done like that :</p><p><span class="postimg"><img src="http://www.maratis3d.org/wp-content/uploads/2013/01/rayHit.jpg" alt="http://www.maratis3d.org/wp-content/uploads/2013/01/rayHit.jpg" /></span></p><p>create 2 boxes A and B, don&#039;t link it to any objects (because getPosition return the local position if parented)<br />instead use the &quot;Follow&quot; behavior in &quot;local&quot; mode and set the offset to have A and B like the image (A for the tip and B to give the ray direction).</p><p>then in script :</p><div class="codebox"><pre><code>Apos = getPosition(A)
Bpos = getPosition(B)
        
-- set Bpos further (1000 is the maximum distance, set higher if needed)
Bpos[1] = Apos[1] + (Bpos[1] - Apos[1])*1000
Bpos[2] = Apos[2] + (Bpos[2] - Apos[2])*1000
Bpos[3] = Apos[3] + (Bpos[3] - Apos[3])*1000

if onKeyDown(&quot;MOUSE_BUTTON1&quot;) then 
    point = rayHit(Apos, Bpos)
    if point then
        print(point)    
    end
end</code></pre></div>]]></content>
			<author>
				<name><![CDATA[anael]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=2</uri>
			</author>
			<updated>2013-01-10T13:36:09Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?pid=3317#p3317</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Rayhit]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?pid=3314#p3314"/>
			<content type="html"><![CDATA[<p>I guess I have written a little too much on the forums lately and asking abit too much. My game is coming along really great, and now the only thing that&#039;s needed is a combat system. I have recently started to build an AI-system which makes enemys go somewhat randomly in the world. The only thing that&#039;s needed now is that I want to know if I have used the script up above correctly or if something is needed to make it work correctly.</p>]]></content>
			<author>
				<name><![CDATA[Pär]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=1252</uri>
			</author>
			<updated>2013-01-10T11:58:01Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?pid=3314#p3314</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Rayhit]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?pid=3237#p3237"/>
			<content type="html"><![CDATA[<p>Nice, now I understand it more clearly.</p><p>guntip = getObject(&quot;guntip&quot;)</p><p>&nbsp; &nbsp; Apos = getPosition(guntip)<br />&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; A = {Apos[1], Apos[2], Apos[3]}<br />&nbsp; &nbsp; &nbsp; &nbsp; B = {100, 0, 0}<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; if onKeyDown(&quot;MOUSE_BUTTON1&quot;) then <br />&nbsp; &nbsp; &nbsp; &nbsp; point = rayHit(A, B)<br />&nbsp; &nbsp; &nbsp; &nbsp; if point then<br />&nbsp; &nbsp; &nbsp; &nbsp; print(point)&nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; end<br />&nbsp; &nbsp; end</p><p>This is what I came up with, is it used correctly?</p>]]></content>
			<author>
				<name><![CDATA[Pär]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=1252</uri>
			</author>
			<updated>2013-01-06T15:09:13Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?pid=3237#p3237</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Rayhit]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?pid=3236#p3236"/>
			<content type="html"><![CDATA[<p>It&#039;s like a 3d line, it starts from the start position and goes till end position.<br />In this exemple it goes from xyz(0, 0, 0) to xyz(100, 0, 0).</p><p>If you want to use it to detect a weapon shot, you set start as the tip of the gun and end as the maximum point the bullet can go.<br />The return point will be what you touched.</p><p>I think I&#039;ll make a real example soon.</p>]]></content>
			<author>
				<name><![CDATA[anael]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=2</uri>
			</author>
			<updated>2013-01-06T14:16:04Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?pid=3236#p3236</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Rayhit]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?pid=3235#p3235"/>
			<content type="html"><![CDATA[<p>Hello! Could someone please explain to me how to use Rayhit?</p><p>&nbsp; &nbsp;function onSceneUpdate()<br />&nbsp; &nbsp; &nbsp; &nbsp;start = {0, 0, 0}<br />&nbsp; &nbsp; &nbsp; &nbsp;end = {100, 0, 0}<br />&nbsp; &nbsp; &nbsp; &nbsp;point = rayHit(start, end, object)<br />&nbsp; &nbsp; &nbsp; &nbsp;if point then<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;print(point)<br />&nbsp; &nbsp; &nbsp; &nbsp;end<br />&nbsp; &nbsp;end</p><p>I understand that it goes from the start to the end and if it intersects with an object it prints out &quot;point&quot; in the console. What I don&#039;t understand is from where the ray starts from.</p>]]></content>
			<author>
				<name><![CDATA[Pär]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=1252</uri>
			</author>
			<updated>2013-01-06T13:52:26Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?pid=3235#p3235</id>
		</entry>
</feed>
