/** * Causes the SurfaceObject to draw itself in a unique pick color, and add itself as a pickable object to the * specified pickSupport. * * @param dc the current DrawContext. * @param pickSupport the PickSupport to add the SurfaceObject to. */ protected void pickOrderedRenderable(DrawContext dc, PickSupport pickSupport) { // Register a unique pick color with the PickSupport. We define the pickable object to be the caller specified // delegate owner, or this object if the delegate owner is null. We define the picked position to be the // terrain's picked position to maintain backwards compatibility with previous implementations of SurfaceObject. Color pickColor = dc.getUniquePickColor(); pickSupport.addPickableObject(this.createPickedObject(dc, pickColor)); // Draw an individual representation of this object in a unique pick color. This representation is created // during the preRender pass in makeOrderedPreRenderable(). GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility. gl.glColor3ub((byte)pickColor.getRed(), (byte)pickColor.getGreen(), (byte)pickColor.getBlue()); this.drawPickRepresentation(dc); }
/** * Causes adjacent SurfaceObjects in the DrawContext's ordered surface renderable list to draw themselves in in a * unique pick color, and adds themselves as pickable objects to the specified pickSupport. Adjacent SurfaceObjects * are removed from the DrawContext's list and processed until one is encountered that has a different containing * layer or is not enabled for batch picking. * * @param dc the current DrawContext. * @param pickSupport the PickSupport to add the SurfaceObject to. */ protected void pickBatched(DrawContext dc, PickSupport pickSupport) { // Draw as many as we can in a batch to save pick resolution. Object nextItem = dc.getOrderedSurfaceRenderables().peek(); while (nextItem != null && nextItem is AbstractSurfaceObject) { AbstractSurfaceObject so = (AbstractSurfaceObject)nextItem; // Batch pick only within a single layer, and for objects which are enabled for batch picking. if (so.pickLayer != this.pickLayer || !so.isEnableBatchPicking()) { break; } dc.getOrderedSurfaceRenderables().poll(); // take it off the queue so.pickOrderedRenderable(dc, pickSupport); nextItem = dc.getOrderedSurfaceRenderables().peek(); } }
public void setPickSupport(PickSupport pickSupport) { this.pickSupport = pickSupport; }