Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (778)
Games in Android Showcase (231)
games submitted by our members
Games in WIP (856)
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 enhancement  (Read 3025 times)
0 Members and 1 Guest are viewing this topic.
Offline robertMerkle

Junior Newbie

Java games rock!

« Posted 2003-11-22 12:16:13 »


I've been tracking/toying with Xith for some time now,
and like it a lot.
I would like to propose to enhance Xith3D picking somewhat.

Currently Xith3D uses the standard OpenGL picking mechanism with a select buffer,
and picking by Node.
PickRenderResult.getNodes() lists the (I think: single) Node picked
and a zmin, zmax value.

This use of OpenGL picking is quite specific to picking Node's and:
- does not allow identification of primitives (which quad of the
 immense quadarray has been picked?)
- does not allow the application to provide (multiple) pick names
 (the cell picked has this cellId, this segmentId, this clusterId etc.
  Admittedly I haven't seen a number of identification codes > 3,
  and we packed them into a single int. Works, but caused a bit of a range
  limitation )
- any future node predraw hooks for DIY OpenGL drawing cannot get
 custom pick results back.

The proposal below attempts to remedy this and keep on using standard OpenGL picking.

- add to Node:
 // when true, the first name on the stack will be the primitive index.
 // this allows getting (close) to the picked coordinates, for applications that do
 // not want to deal with custom names.
 <not thought through>
 // geoArray.getValidVertexCount()/# vertices_per_primitive for normal geometry
 // igeoArray.getValidIndexCount()/# vertices_per_primitive for indexed geometry ???
 </not thought through>
 boolean pickPrimitiveIndex = false;

 // the number of names that this node can use for identifying its pick result
 // value 0 means that only the default node picking is available.
 int customNameStackDepth = 0;

- change PickRenderResult
 private Node node;       // should be just one Node + all of its sub-identification,
 private int[] names;     // so complete contents of name stack at pick time - 1
                          // (the name used to identify the node itself)

- to allow multiple custom names per primitive of a Node, add to GeomContainer
 // array of size nameStackDepth, containing the pick names per primitive
 <not thought through>
 // the pickNames could be java int arrays, subject to GC
 </not thought through>
 GeomDataInterface[] pickNames;

- add GeomNioIntData (similar to GeomNioFloatData) for use as pickNames

The biggest change is with rendering: with custom names per primitive, we can't use
glDrawArrays or glDrawElements for drawing.
When in pick mode && custom picking is enabled, drawing needs to revert to drawing
per primitive:
- if (pickPrimitiveIndex) push current primitive index
- push all custom (customNameStackDepth) names on the stack
- draw primitive, using the appropriate glArrayElement() call
- pop all custom names off the stack
- if (pickPrimitiveIndex) pop

Thus, ShapeAtomPeer needs to be aware of the pickMode.
Additionally proper checking of the pickNames data should be done,
customNameStackDepth + #internal names should be checked to be < GL_NAME_STACK_DEPTH,
(allthough this is not likely to be a problem as GL_NAME_STACK_DEPTH >= 64 ...)
convertSelectBuffer would need to be changed etc...
But in the end this would provide a very flexible (configurable per Node) picking mechanism.

What do you think?
Does this conflict with other developments in the pipeline?

Offline DavidYazel

Junior Devvie

Java games rock!

« Reply #1 - Posted 2003-11-22 12:42:34 »

I have always thought that opengl screen picking was a sort of stop gap for a more advanced scene based picking system, which is currently under development.  I am not sure I am entirely comfortable with the type of changes you are suggesting, but Yuri is the OpenGL picking guy, so we should get his opinion.

David Yazel
Xith3D Project Founder

It may look complicated, but in the end it is just a bunch of triangles
Offline Jens

Senior Devvie

Java for games!

« Reply #2 - Posted 2003-11-22 12:56:21 »

I don't want to comment on the exact changes, but shochu and I had problems with implementing a movement system using Xith3D (see this thread). Hopefully a more sophisticated implementation of picking can address these issues.

Xith3D Getting Started Guide (PDF,HTML,Source)
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Yuri Vl. Gushchin

Senior Devvie

Speak Java!

« Reply #3 - Posted 2003-11-22 16:38:54 »


I confirm David's information that OpenGL picking is just one of picking techniques to be available in Xith3D and was implemented as fast [in development time sense] solution for object picking in Xith3D.

Next versions of Xith3D will include alternate techniques of object picking, and primary task is to include Java3D-style picking capabilities, including the ability to get geometry-specific parameters, such as vertex and texture coordinates, normals and colors at the object intersection point. Non-ray picking shapes are to be supported, too. Additionally, such programmatic picking techniques will allow to perform pick tests on separate thread and eliminate issues related to OpenGL thread management and rendering thread synchronization.

I already was starting once an attempt to port Java3D picking code to Xith3D, but after figuring out the amount of work decided to implement OpenGL-based picking, which is enough for many [but not all] applications.

Identification of specific geometry primitives is to be implemented using programmatic (non-OpenGL) picking techniques, at least because of OpenGL picking anyway has a lot of limitations: a) MUST be executed on rendering thread, causing jitters and slowdowns in animations; b) has numerous driver-specific problems, especially on non-Windows operating systems; c) does not solve a problem of getting 3D coordinates of the intersection point.

The idea with supplying custom nodeIds for every specific elementary component [quad, triangle, line, point] is nice, but I see it causing too big changes in rendering process - as Robert already mentioned, renderer will not be able to use glDrawArrays, etc., and will MUST render all the geometry per individual primitive during picking pass, which, being executed on the Rendering thread and between rendering visible frames, will [OK, may] cause [probably] bigger delays and frame skips, resulting in non-smooth animations during the mouse clicks. Also this technique may cause some questions when used in conjunction with OpenGL evaluators and Vertex Programs [which are to be added to Xith3D].

So, besides of I developed OpenGL-based picking code, I treat is as a solution targeted to simple Node-based picking applications [OK, and also as a temporary solution], and will vote for sophisticated programmatic picking functionality.

Anyway, all the contributions to Xith3D are really welcome, and I think we are not limited to having one and only picking technique in Xith3D.


Yuri Vl. Gushchin
JProof Group
Offline robertMerkle

Junior Newbie

Java games rock!

« Reply #4 - Posted 2003-11-22 20:55:14 »

Thanks for your explanation Yuri; I can see why you'd prefer the picking not to clutter
up the rendering thread.
My particular interest is volume (simply outer hull) and cross-section visualization of lots of
cells, where, after having created the shapes for rendering, the only connection back to the
underlying data structures is really only the index of each primitive in the shape's
geometry array.
Based on a pick result intersection point, and/or closest vertex alone it is very
clumsy and time-consuming to determine the exact primitive by doing all sorts of 'isInside'
tests Sad
Will the programmatic picking you guys are developing support giving back the primitive
index in the pick result? Would solve all my picking issues, and actually there'd
be no need to bother the renderer with custom pick names.

Remains possible gl picking support for DIY jogl drawing in future shape predraw hooks.
It may still be a good idea to alter PickRenderResult as mentioned above, so
to contain a single Node + the pick names, minus the one used for node id.
I like the idea of toying will jogl knowing that the bulk of the transforms is dealt with by
the scene graph.

Offline Yuri Vl. Gushchin

Senior Devvie

Speak Java!

« Reply #5 - Posted 2003-11-23 08:33:24 »

Will the programmatic picking you guys are developing support giving back the primitive index in the pick result?

I hope so [read: I am sure]. Anyway, picking logic have to inspect all the primitives for intersection, so I don't see the reason of why it should not return the primitive index.

Only question will be to exactly specify how it should work for non-plain geometries, i.e. indexed arrays, strip arrays and fan arrays.


Yuri Vl. Gushchin
JProof Group
Offline Yuri Vl. Gushchin

Senior Devvie

Speak Java!

« Reply #6 - Posted 2003-11-23 08:37:02 »

Another note:

Remains possible gl picking support for DIY jogl drawing in future shape predraw hooks.

If you mean programmatic [Java-level] pre-draw hooks, I see no pbs. If you mean Vertex Programs and Evaluators - this is something different... and I don;t know how GL_SELECT interacts with that. Could be that GL_SELECT is only a way of picking geoms generated/transformed by Vertex Programs... but we will see this very very soon.


Yuri Vl. Gushchin
JProof Group
Pages: [1]
  ignore  |  Print  

hadezbladez (353 views)
2018-11-16 13:46:03

hadezbladez (184 views)
2018-11-16 13:41:33

hadezbladez (356 views)
2018-11-16 13:35:35

hadezbladez (86 views)
2018-11-16 13:32:03

EgonOlsen (2179 views)
2018-06-10 19:43:48

EgonOlsen (2221 views)
2018-06-10 19:43:44

EgonOlsen (1379 views)
2018-06-10 19:43:20

DesertCoockie (2012 views)
2018-05-13 18:23:11

nelsongames (1671 views)
2018-04-24 18:15:36

nelsongames (2310 views)
2018-04-24 18:14:32
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46 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‑
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!