![]() |
|
|||||||
| Development Help Help for building applications or diagnosing problems with WWJ |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Apr 2009
Location: UK
Posts: 16
![]() |
Hi,
For our application we need to extend the picking behaviour as follows: 1. Pick all objects in the pick location not just the top one 2. Find all objects in an area not just under the mouse pointer We have made some progress (below), but if anyone else has looked at either of these, maybe we could discuss. The code below works for ordinary renderables but not for surface objects in a SurfaceShapeLayer as the rendering technique is rather different. Thanks Code:
This new PickSupport method is called after rendering EVERY object:
public void resolvePickArea(final DrawContext dc, java.awt.Point centrePoint, int w, int h)
{
if (this.getPickableObjects().isEmpty())
return;
final GL gl = dc.getGL();
// GL has (0,0) in the bottom left, the point has (0,0) in the top left so we need to convert the y axis
final int x = centrePoint.x - (w / 2);
final int y = dc.getView().getViewport().height - (centrePoint.y + (h / 2)) - 1;
// read the pixels in bulk
gl.glReadPixels(x, y, w, h, javax.media.opengl.GL.GL_RGB, GL.GL_UNSIGNED_BYTE, PickSupport.pixels);
java.awt.Color tCol = null;
final int clearPixel = dc.getClearColor().getRGB();
final List<Integer> prevCols = new ArrayList<Integer> (0);
int c;
Integer cVal;
PickedObject obj;
for (int n = 0; n < (w * h) * 3; n += 3)
{
tCol = new java.awt.Color(PickSupport.pixels.get(n) & 0xff, PickSupport.pixels.get(n + 1) & 0xff,
PickSupport.pixels.get(n + 2) & 0xff, 0);
c = tCol.getRGB();
cVal = Integer.valueOf(c);
if (c != clearPixel && !prevCols.contains(cVal))
{
obj = getPickableObjects().get(cVal);
if (obj != null && !dc.getPickedObjects().contains(obj))
{
dc.addPickedObject(obj);
prevCols.add(cVal);
}
}
}
this.clearPickList();
}
|
|
|
|
|
|
#2 |
|
Guest
Posts: n/a
|
Please, can you post all the code that you have used.
I'm with the problem that I have points very near or in the same position. When they are in the same position only the last is picked. |
|
|
|
#3 |
|
Member
Join Date: Mar 2011
Location: Omaha, NE
Posts: 39
![]() |
> For typical picking, the selection is resolved by color. If your point
> is completely hidden by another point, it won't be picked. There > may be a way around this using picking supplied by WorldWind > but I haven't been able to discover one. Use deep picking -> http://forum.worldwindcentral.com/sh...ad.php?t=33046 http://forum.worldwindcentral.com/sh...ad.php?t=33108 |
|
|
|
|
|
#4 | |
|
Guest
Posts: n/a
|
Quote:
In the post http://forum.worldwindcentral.com/sh...ad.php?t=32709 has the solution to use the deep picking in the renderable layer. Thanks. |
|
|
|
|
#5 |
|
Guest
Posts: n/a
|
Perfect!! I enable the deep picking and all the points is picked, even the points with same coordinates.
I follow the post http://forum.worldwindcentral.com/sh...ad.php?t=32709 to enable the deep picking on the renderable layer. Thanks. |
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Performance with Objects | Kashank | Development Help | 6 | 01-07-2010 03:34 PM |
| [Solved] Picking not returning the expected objects | damienpp | Development Help | 17 | 09-30-2009 09:41 AM |
| SelectListener and SphereAirspace objects | kermit | Development Help | 3 | 05-06-2009 06:48 PM |
| Adding RIght Mouse Click to Icons | nigel_ht | Developers' Corner | 0 | 04-12-2006 03:39 PM |
| Strange Program Behavior Involving Mouse | Mark S | Technical Support | 12 | 06-01-2005 07:46 AM |