Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (481)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (548)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  picking problems  (Read 14562 times)
0 Members and 1 Guest are viewing this topic.
Offline apohlmann

Senior Newbie





« Posted 2006-11-09 09:53:17 »

Hi all,

I am new here (and finaly here ... long story ^^).
I used to test the code written in xin "chapter 9a picking" and i have some problems.
The first problem:  env.getRootBranchGroup()  seems to be wrong (?!)...  env offers getBranchGroup() is this correct?
and the second: all seems to be correct but I am not able to pick the rotating cube! -> "You just picked nothing!"
I added cube.setPickable(true) but it is still the same  Undecided




PS: Thanks to Marvin for support via e-mail (i wasn't able to login here ) 
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #1 - Posted 2006-11-09 10:42:58 »

Hi, Andre

Welcome to the forum... finally Wink

The first problem:  env.getRootBranchGroup()  seems to be wrong (?!)...  env offers getBranchGroup() is this correct?

Oh. Thanks. getRootBranchGroup() existed only a few days. I'll change that in XIN.

and the second: all seems to be correct but I am not able to pick the rotating cube! -> "You just picked nothing!"

I'll check that. Have you checked the tests in org.xith3d.test.picking?

I added cube.setPickable(true) but it is still the same  Undecided

When you're using (Ext)Xith3DEnvironment all Nodes are pickable by default. So this line is not necessary.

PS: Thanks to Marvin for support via e-mail (i wasn't able to login here ) 

You're welcome Smiley

Marvin
Offline apohlmann

Senior Newbie





« Reply #2 - Posted 2006-11-09 11:09:04 »

I checked the PickingLibraryTest and it works fine  Smiley
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #3 - Posted 2006-11-09 17:43:32 »

Hi apohlmann ! And welcome to Xith3D and its board.

I see Marvin beat me one this one so I don't have anything to answer to, just the usual question, are you planning to achieve something special with Xith ?

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline apohlmann

Senior Newbie





« Reply #4 - Posted 2006-11-09 21:32:41 »

Hi Amos,

I am working on my project at university. It's a technology research about tools, engines and more.
Anything you can use to build a simulator for mobile robotics.
And so I have to test some of these things...
There are a lot of projects that offer useful things but not all are comfortable enough.
Xith seems to be a bit further than J3D.

And at the End  I hope to implement some of my ideas with Xith....
To many ideas and not enough time  Grin ....
Offline apohlmann

Senior Newbie





« Reply #5 - Posted 2006-11-10 08:43:28 »

Picking works now.

I replaced PickResult pr = PickingLibrary.pickNearest(env.getRootGroup(), env.getCanvas(), pickX,pickY); by
List<PickResult> pr = PickingLibrary.pickAll(env.getRootGroup(), env.getCanvas(), pickX, pickY); from the picking-test.
And I replaced pr.getShape().getName() by
                    int i = 0;
                    for (PickResult pr: results)
                    {
                        System.out.println("  Hit (" + i++ + "): Shape3D: \"" + pr.getShape().getName() + "\", distance=" + pr.getMedialDistance()                                           + " position=" + pr.getPos());
                    }
that's from the picking-test too...  Cool

But why is the example from xin not working?
Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #6 - Posted 2006-11-10 14:24:30 »

But why is the example from xin not working?
Marvin will fix that soon hopefully.

I wish you good luck for your project, if you have any problem/comment/idea/suggestion/rant/whatever, don't hesitate to post.. I just remember how sad that Niwak said (a year ago) the core code was ugly while it was being refactored, and that it lacked a particle system whereas JavaCoolDude did one long ago.. and so on.. There are LOTS that have been done for Xith3D, some old work just asks for being picked and adapted a little bit. (Whenever I need particle system in my game, I'll *finally* dig JCD's work).

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #7 - Posted 2006-11-10 19:38:23 »

Marvin will fix that soon hopefully.

I'll do. I anyway need to dig into GLSelect picking code again. After Yuri last fixed it to support picking in parallel projection, the picking in BSPTest runs into a deadlock. I'll look for it the next days (maybe tonight, don't know).

Marvin
Offline hawkwind

Junior Member




Java games rock!


« Reply #8 - Posted 2006-11-10 21:20:57 »

Yoicks!!!!  This surprised me..

Quote
When you're using (Ext)Xith3DEnvironment all Nodes are pickable by default. So this line is not necessary.

I have been managing the pickability of objects myself, to isolate scene items that can be interacted with,  I did not expect everything to be set as pickable.  Can an option to control this behavior be added.  I would prefer to control this myself.
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #9 - Posted 2006-11-10 21:51:32 »

Yoicks!!!!  This surprised me..

Quote
When you're using (Ext)Xith3DEnvironment all Nodes are pickable by default. So this line is not necessary.

I have been managing the pickability of objects myself, to isolate scene items that can be interacted with,  I did not expect everything to be set as pickable.  Can an option to control this behavior be added.  I would prefer to control this myself.

Hmm, yes. This makes sense. I added a new property to Xith3DEnvironment (also available in ExtXith3DEnvironment, too, of course). Call
1  
(Ext)Xith3DEnvironment.setDefaultPickableEnabled( false );

before you create your Xith3DEnvironment instance.

Marvin.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #10 - Posted 2006-11-12 20:07:16 »

Picking works now.

I replaced PickResult pr = PickingLibrary.pickNearest(env.getRootGroup(), env.getCanvas(), pickX,pickY); by
List<PickResult> pr = PickingLibrary.pickAll(env.getRootGroup(), env.getCanvas(), pickX, pickY); from the picking-test.
And I replaced pr.getShape().getName() by
                    int i = 0;
                    for (PickResult pr: results)
                    {
                        System.out.println("  Hit (" + i++ + "): Shape3D: \"" + pr.getShape().getName() + "\", distance=" + pr.getMedialDistance()                                           + " position=" + pr.getPos());
                    }
that's from the picking-test too...  Cool

But why is the example from xin not working?

The example from XIN worked for me. Anyway, I modified the XIN picking cheapter to fit the new implementation of GLSelect picking. Please have a look.

Marvin
Offline apohlmann

Senior Newbie





« Reply #11 - Posted 2006-11-13 13:08:15 »

Actually I am getting some problems... but the day isn't over yet Wink
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #12 - Posted 2006-11-13 13:40:56 »

Actually I am getting some problems... but the day isn't over yet Wink

What kind of problems? If they're deadock related, then I'm also getting these ones in BSPLoaderTest, but not in other tests.

Are you still using PickingLibrary?

When these synchronization/deadlock problems are gone, GLSelect picking is better than PickingLibrary picking. It should be faster and doesn't need to be synchronized from outside or scheduled.

Marvin
Offline apohlmann

Senior Newbie





« Reply #13 - Posted 2006-11-14 12:46:24 »

O.K. I tested the code from chapter 9a.
Everything seems to be all right but I got an Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException.  Undecided

Then I tested the code from 9b... the Exception is gone but I always "Pick nothing" ....

Maybe I am doing something wrong? (Maybe lol... I am sure ...)
It's a shame that I am not that deep into this material to solve the problem  Cry

Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #14 - Posted 2006-11-14 20:36:05 »

O.K. I tested the code from chapter 9a.
Everything seems to be all right but I got an Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException.  Undecided

Then I tested the code from 9b... the Exception is gone but I always "Pick nothing" ....

Maybe I am doing something wrong? (Maybe lol... I am sure ...)
It's a shame that I am not that deep into this material to solve the problem  Cry

Could you send me your code?

Marvin
Offline Zer Gut Shnitzel

Senior Newbie





« Reply #15 - Posted 2006-12-11 15:34:21 »

Hi,

Is there a way to get the Pick Ray object like in the old version. Also can someone provide a lilttle details on inner workings of different picking methods in the current version.

Thanks.
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #16 - Posted 2006-12-11 19:27:01 »

Is there a way to get the Pick Ray object like in the old version.

In the old version it wasn't possible to get a pick ray object. You could only call the picking method on the View class (if I remember right), which filled two tuples, one for the origin and one for the direction.

Now the way to go is create a new instance of the class PickRay. It will then hold two tuple instances with the values like in the old version. Please also check all the constructors and methods of the PickRay class. They might be useful.

Also can someone provide a lilttle details on inner workings of different picking methods in the current version.

Well, the picking initiated by canvas.pick*() uses GLSelect to pick the scene. In large scenes this is too slow. PickingLibrary uses pure software picking, which traverses the scenegraph just as far as it is possible (if a whole group is not picked, no shape can be and the group is not further traversed). This picking method needs to be synchronized with the render thread. ExtXith3DEnvironment (together with ExtRenderLoop) does it for you. So you only need to use the pick*() methods of the ExtXith3DEnvironment. Please read XIN for more details.

Marvin
Offline Zer Gut Shnitzel

Senior Newbie





« Reply #17 - Posted 2006-12-11 20:05:32 »

Quote
if a whole group is not picked

Does that mean that the groups have correct bounds to check againts the ray intersection?

Does the software picking method (Picking Library) intersects down to Shape's polygons?

Thanks
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #18 - Posted 2006-12-11 21:09:14 »

Does that mean that the groups have correct bounds to check againts the ray intersection?

No, they don't have correct bounds. But it is guaranteed, that all the shapes in a groupd are inside these bounds.

Does the software picking method (Picking Library) intersects down to Shape's polygons?

No, it doesn't. A Shape3D is an "atom" for this algorithm.

Do you need the information, which polygon was picked?

Marvin
Offline Zer Gut Shnitzel

Senior Newbie





« Reply #19 - Posted 2006-12-11 22:28:20 »

Quote
Do you need the information, which polygon was picked?

No, but I need the ray to precisely pick the shape based on the geometry rather then bounds.

We worked pretty much like this. Project the ray into our main 3D space (which is different than Xith's world space) then use space partitions and bounds to check for the ray intersection in our core data graph use all these results to set the branches pickable in the Xith scene graph and then do the view.pick that was based on a slow but precise (polygon based) GL_SELECT I assume.  Since mostly one branch containing shapes would be marked pickable the view.pick was actually fast enough and precise. I am trying to figure out if we can speed up the process of picking by using some of the new methods you created.

Thanks.
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #20 - Posted 2006-12-11 23:21:55 »

No, but I need the ray to precisely pick the shape based on the geometry rather then bounds.

Isn't PickRay everything you need? If not, what do you need further?

We worked pretty much like this. Project the ray into our main 3D space (which is different than Xith's world space) then use space partitions and bounds to check for the ray intersection in our core data graph use all these results to set the branches pickable in the Xith scene graph and then do the view.pick that was based on a slow but precise (polygon based) GL_SELECT I assume.  Since mostly one branch containing shapes would be marked pickable the view.pick was actually fast enough and precise. I am trying to figure out if we can speed up the process of picking by using some of the new methods you created.

Yeah, maybe you can use one of the pick methods taking a group to pick solely in it. Please keep in mind, that the Canvas3D.pick*() methods don't need to be synchoronized anymore (and shouldn't be). They are synchronized internally. the current VirtualUniverse instance is used as the mutex by the render thread, which is used by the pick methods, too. So double synchronization could become very slow or cause a deadlock.

This view.pick method was exactly, what canvas.pick methods are now (GL_SELECT picking).

Do you consider your picking algorithm to be worth being put into the xith toolkit?

Marvin
Offline Zer Gut Shnitzel

Senior Newbie





« Reply #21 - Posted 2006-12-11 23:59:01 »

Quote
Isn't PickRay everything you need? If not, what do you need further?

It should be, I am gonna do some tests to see how it compares with our old system...

Quote
Do you consider your picking algorithm to be worth being put into the xith toolkit?


We tried building this using Xith volumes initialy but we could not figure out how Xith's bounds work, so we built our own system of groups/bounds and TransformGroups. I guess our picking system is way to coupled with our core data structure at this point, moving it back to Xith would require the bounding volumes / space partitioning to work properly and update dinamically.

Cheers
Offline apohlmann

Senior Newbie





« Reply #22 - Posted 2006-12-12 13:24:27 »

Hi again,

I tested the PickingLibrary, works fine so far. Than I used to create an example for picking under J3D, just to compare it with xith....
and now I've got a question: why is it necessary to set the transformgroup and the element (e.g a cube) pickable = true ?? OK I know, setting it to fals means the cube is not pickable... but what is the reason for that? In J3D it seems that everything is pickable at the beginnig. Something about performance?
I don't want to criticize someone... I just want to know  Cool

Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #23 - Posted 2006-12-12 16:26:39 »

Something about performance?
All right, doc. Less nodes to test, thus the algorithm runs faster.

I don't want to criticize someone... I just want to know  Cool
You're welcome.

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #24 - Posted 2006-12-12 19:38:38 »

I tested the PickingLibrary, works fine so far. Than I used to create an example for picking under J3D, just to compare it with xith....
and now I've got a question: why is it necessary to set the transformgroup and the element (e.g a cube) pickable = true ?? OK I know, setting it to fals means the cube is not pickable... but what is the reason for that? In J3D it seems that everything is pickable at the beginnig. Something about performance?
I don't want to criticize someone... I just want to know  Cool

You can modify the default xith Xith3DDefaults class. And when you use Xith3DEnvironment, the default is true.

Marvin
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

atombrot (27 views)
2014-08-19 09:29:53

Tekkerue (25 views)
2014-08-16 06:45:27

Tekkerue (23 views)
2014-08-16 06:22:17

Tekkerue (15 views)
2014-08-16 06:20:21

Tekkerue (22 views)
2014-08-16 06:12:11

Rayexar (61 views)
2014-08-11 02:49:23

BurntPizza (39 views)
2014-08-09 21:09:32

BurntPizza (31 views)
2014-08-08 02:01:56

Norakomi (37 views)
2014-08-06 19:49:38

BurntPizza (67 views)
2014-08-03 02:57:17
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!