World Wind Forums

Go Back   World Wind Forums > WorldWind JAVA forums > Development Help

Development Help Help for building applications or diagnosing problems with WWJ

Reply
 
Thread Tools Display Modes
Old 05-14-2010, 12:18 PM   #1
jwheeler
Junior Member
 
Join Date: Apr 2009
Location: UK
Posts: 16
jwheeler is on a distinguished road
Question Picking objects *near* the mouse

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();
    }
jwheeler is offline   Reply With Quote
Old 10-19-2012, 01:59 PM   #2
hnqoliveira
Guest
 
Posts: n/a
Default

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.
  Reply With Quote
Old 10-23-2012, 05:08 PM   #3
ens121
Member
 
Join Date: Mar 2011
Location: Omaha, NE
Posts: 39
ens121 is on a distinguished road
Default

> 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
ens121 is offline   Reply With Quote
Old 10-24-2012, 12:36 PM   #4
Unregistered
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by ens121 View Post
> 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
I'm enable the deep picking and all the points in the same position are picked, exactly how I need.
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.
  Reply With Quote
Old 10-24-2012, 04:40 PM   #5
Unregistered
Guest
 
Posts: n/a
Default all points picked

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.
  Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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


All times are GMT +1. The time now is 10:32 PM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.