<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://www.jpct.net/wiki/skins/common/feed.css?207"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://www.jpct.net/wiki/index.php?title=Special:RecentChanges&amp;feed=atom</id>
		<title>JPCT  - Recent changes [en]</title>
		<link rel="self" type="application/atom+xml" href="http://www.jpct.net/wiki/index.php?title=Special:RecentChanges&amp;feed=atom"/>
		<link rel="alternate" type="text/html" href="http://www.jpct.net/wiki/index.php/Special:RecentChanges"/>
		<updated>2010-09-10T10:44:13Z</updated>
		<subtitle>Track the most recent changes to the wiki in this feed.</subtitle>
		<generator>MediaWiki 1.15.1</generator>

	<entry>
		<id>http://www.jpct.net/wiki/index.php?title=Picking&amp;diff=241&amp;oldid=prev</id>
		<title>Picking</title>
		<link rel="alternate" type="text/html" href="http://www.jpct.net/wiki/index.php?title=Picking&amp;diff=241&amp;oldid=prev"/>
				<updated>2010-09-06T19:28:37Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=== Picking ===&lt;br /&gt;
&lt;br /&gt;
Picking in jPCT can be implemented in two ways. One of these ways is usually a bit faster but doesn't work for compiled objects, while the other one works for all objects but might be a bit slower.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== The fast way ====&lt;br /&gt;
&lt;br /&gt;
As said, this doesn't work on compiled objects. If you are using the software renderer only or the hardware renderer in hybrid mode (i.e. without compiled objects), it's save to use though. To use this way, you have to make the objects in questions &amp;quot;selectable&amp;quot;. You can do this be calling &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
obj.setSelectable(Object3D.MOUSE_SELECTABLE);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
on your objects. Then, you render the scene and get your picking coordinates from your input device in screen space. Most likely mouse coordinates or similar. Then you do this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
SimpleVector dir=Interact2D.reproject2D3D(camera, frameBuffer, x, y);&lt;br /&gt;
int[] res=Interact2D.pickPolygon(world.getVisibilityList(), dir);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In res, you'll find the polygon- and the object number (in that order), if the picking actually picked something. If not, res is null. Your picked Object3D is now&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Object3D picked=world.getObject(res[1]);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Please note that there are two variants of the pickPolygon-methods. The simple one (see above) makes unselectable objects act as a block to the picking ray, i.e. even if an object isn't selectable, it will still block the ray so that no object behind that object can be picked.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== The compatible way ====&lt;br /&gt;
&lt;br /&gt;
This works with all renderers and all objects, but depending on the scene it might by a bit slower. It's the only one that is available in jPCT-AE. Unlike the former approach, this is actually a kind of collision detection, which is why it triggers collision events too. Just like above, you have to make your objects pickable. However, because it's a collision detection, this works different. Instead of using setSelectable(...), you have to use setCollisionMode(...). For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
obj.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Like above, you need your 2D picking coordinates. With them, you need a direction vector in world space. This is simple:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
SimpleVector dir=Interact2D.reproject2D3DWS(camera, frameBuffer, x, y);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Armed with this vector, you can now go to World and do&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Object[] res=world.calcMinDistanceAndObject3D(camera.getPosition(), dir, 10000 /*or whatever*/);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The result is an Object[]-array with the Float-distance to the picked object in the first slot and the picked Object3D in the second. If nothing has been hit, the result will be [COLLISION_NONE, null].&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://www.jpct.net/wiki/index.php?title=Main_Page&amp;diff=237&amp;oldid=prev</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://www.jpct.net/wiki/index.php?title=Main_Page&amp;diff=237&amp;oldid=prev"/>
				<updated>2010-09-06T19:09:03Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;

		&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
		&lt;col class='diff-marker' /&gt;
		&lt;col class='diff-content' /&gt;
		&lt;col class='diff-marker' /&gt;
		&lt;col class='diff-content' /&gt;
		&lt;tr valign='top'&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 19:09, 6 September 2010&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 48:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 48:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[ Compiled objects ]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[ Compiled objects ]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;[[ Picking ]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[ Shaders ]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[ Shaders ]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff generator: internal 2010-09-10 10:44:14 --&gt;
&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>