slade
Just dropped in
Offline
Posts: 7
|
 |
« on: 13. June 2007, 05:11:57 pm » |
|
Is there a way to pick from a 3-dimensional point in space to a 2-dimensional point on the screen? Sort of a reverse pick?
|
|
|
|
|
Logged
|
|
|
|
|
'n ddrylliog
|
 |
« Reply #1 on: 13. June 2007, 08:21:31 pm » |
|
I haven't really had to solve this problem, but I think you could investigate with the transform of the view...
|
|
|
|
|
Logged
|
|
|
|
Marvin Fröhlich
Xith Lord
Administrator
Guru
   
Offline
Posts: 4381
May the 4th, be with you...
|
 |
« Reply #2 on: 13. June 2007, 08:51:02 pm » |
|
In principle you would have to multiply something with the inverse of the view's matrix. Have a look at org.xith3d.picking.PickRay.recalculate(). You would have to invert the whole calculation, and especially the view-transform-matrix.
Hope, this helps.
Marvin
|
|
|
|
|
Logged
|
|
|
|
slade
Just dropped in
Offline
Posts: 7
|
 |
« Reply #3 on: 13. June 2007, 09:16:02 pm » |
|
Am I missing something? The recalculate calls all have 2-dimensional coordinates... we are starting with a 3D coordinate and trying to come back to an x,y on the screen. Thanks...
|
|
|
|
|
Logged
|
|
|
|
Marvin Fröhlich
Xith Lord
Administrator
Guru
   
Offline
Posts: 4381
May the 4th, be with you...
|
 |
« Reply #4 on: 13. June 2007, 10:02:04 pm » |
|
Am I missing something? The recalculate calls all have 2-dimensional coordinates... we are starting with a 3D coordinate and trying to come back to an x,y on the screen. Thanks...
As I said. You have to invert the calculation. So it's not a wonder, that the parameters are what you want to retrieve. btw. What do you need this for? Marvin
|
|
|
|
|
Logged
|
|
|
|
|
Arne Müller
|
 |
« Reply #5 on: 13. June 2007, 10:38:33 pm » |
|
I have no idea how to do this, but it never the less should be easy and actually be very fast, because I think, thats one of the things your gpu is doing all the time...
my guess: dig in View, probably even in the underlying renderer stuff. There should be something. Simply keep in mind, when searching, what you need to compute those coordinates. - your world coordinate - your screen position and rotation in the 3d world - your screen resolution, field of view (view angle) - Projection-Type
Arne
|
|
|
|
|
Logged
|
42.
|
|
|
Marvin Fröhlich
Xith Lord
Administrator
Guru
   
Offline
Posts: 4381
May the 4th, be with you...
|
 |
« Reply #6 on: 13. June 2007, 11:01:48 pm » |
|
I have no idea how to do this, but it never the less should be easy and actually be very fast, because I think, thats one of the things your gpu is doing all the time...
Yeah, it is done by the GPU. But this is exactly the reason, why you won't find any code for this in xith. What you would need is the code to transform world coordinates to rasterization coordinates. And this is done transparently by the GPU. Though you should find documentation about this calculation somewhere in OpenGL. Marvin
|
|
|
|
|
Logged
|
|
|
|
|
Mathias 'cylab' Henze
|
 |
« Reply #7 on: 13. June 2007, 11:18:13 pm » |
|
Isn't this just applying the current ModelView and Projection Matrix to the 3D coordinate?
|
|
|
|
|
Logged
|
|
|
|
Marvin Fröhlich
Xith Lord
Administrator
Guru
   
Offline
Posts: 4381
May the 4th, be with you...
|
 |
« Reply #8 on: 14. June 2007, 07:52:38 am » |
|
Isn't this just applying the current ModelView and Projection Matrix to the 3D coordinate?
Yeah. But I'm pretty sure, that there's an additional step to rasterize them (produce pixel coordinates). Marvin
|
|
|
|
|
Logged
|
|
|
|
|
Mathias 'cylab' Henze
|
 |
« Reply #9 on: 14. June 2007, 08:14:11 am » |
|
Should be a simple projection to from viewport space to window coordinates.
|
|
|
|
|
Logged
|
|
|
|
slade
Just dropped in
Offline
Posts: 7
|
 |
« Reply #10 on: 14. June 2007, 05:56:51 pm » |
|
btw. What do you need this for?
Well I'd like to be able to, say, pick on an object, and then using this projection I'd like to have a window, perhaps a HUD display, pop up next to it at an appropriate screen x,y.
|
|
|
|
|
Logged
|
|
|
|
Marvin Fröhlich
Xith Lord
Administrator
Guru
   
Offline
Posts: 4381
May the 4th, be with you...
|
 |
« Reply #11 on: 14. June 2007, 07:15:35 pm » |
|
Well I'd like to be able to, say, pick on an object, and then using this projection I'd like to have a window, perhaps a HUD display, pop up next to it at an appropriate screen x,y.
So wouldn't it suffice to take the initial picking x,y coordinates to popup the widget at? Marvin
|
|
|
|
|
Logged
|
|
|
|
slade
Just dropped in
Offline
Posts: 7
|
 |
« Reply #12 on: 14. June 2007, 07:35:52 pm » |
|
So wouldn't it suffice to take the initial picking x,y coordinates to popup the widget at?
Marvin
Nope... I want to be able to move my View around and have that widget follow the object's relative position unless the object (or some arbitrary point on the object) leaves the screen.
|
|
|
|
|
Logged
|
|
|
|
|
kukanani
|
 |
« Reply #13 on: 14. June 2007, 07:46:27 pm » |
|
Could you maybe, instead of using a HUD display, just use a automatic billboard floating over the object and then use normal picking to emulate buttons, etc.? Just an idea.
|
|
|
|
|
Logged
|
xith.setCoolnessLevel(10); jMe.setCoolnessLevel(0); xith.rock();
|
|
|
slade
Just dropped in
Offline
Posts: 7
|
 |
« Reply #14 on: 14. June 2007, 09:09:49 pm » |
|
Could you maybe, instead of using a HUD display, just use a automatic billboard floating over the object and then use normal picking to emulate buttons, etc.? Just an idea.
I'm not sure if this is an option or not. Some of the HUD widgets look pretty convenient, such as Image. If I can fake these in other ways, I might go that direction.
|
|
|
|
|
Logged
|
|
|
|
|