Hi Adam,
I guess it was my question you read?
In the meantime I changed my PickObjectBehavior class in using
the PickingExt from Doug Gehringer, so I am using now

pickObject.setPickMode(app.gis3D.pickingExt.PickObject.USE_BOUNDS);

pickObject.setPickShapeMode(app.gis3D.pickingExt.PickObject.SHAPE_APERTURE);

Now I can pick points, but I still have problems in picking
Lines.

When I am using pickClosest, I'll often don't get the line I wanted to
pick, but another one, when I am using pickAll, I'll get the line I wanted
to pick and the other one!
Does that mean that the ray intersects both objects? But how can this be,
the line I don't want to pick is at least 1cm away from the other line
on my screen! Any idea anybody?

Thanks for any help!


Desiree


Here is my source code of the Picking Behavior class:

// -------------------------------------------------------------------
//  PickObjectBehavior.java
//
//  Copyright (c) 1999 by IPF
// -------------------------------------------------------------------
package app.gis3D;

import java.util.*;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

import java.math.*;

import gis.gisterm.*;
import gis.gisterm.map.*;
import gis.gisterm.management.*;
import gis.gisterm.gcomponents.*;
import gis.gisterm.gcore.*;

import java.awt.GraphicsConfiguration;
import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.universe.SimpleUniverse;
import javax.media.j3d.Canvas3D;
import javax.media.j3d.BoundingLeaf;
import javax.media.j3d.*;
import javax.vecmath.*;

import com.sun.j3d.utils.behaviors.mouse.*;
import com.sun.j3d.utils.behaviors.mouse.MouseRotate;
import com.sun.j3d.utils.behaviors.mouse.MouseZoom;
import com.sun.j3d.utils.behaviors.mouse.MouseTranslate;
//import com.sun.j3d.utils.behaviors.picking.PickRotateBehavior;
import com.sun.j3d.utils.behaviors.picking.PickMouseBehavior;

import com.sun.j3d.utils.behaviors.keyboard.KeyNavigatorBehavior;

import gis.shared.shapefile.*;

/**
 * PickObjectBehavior
 *
 * @author Desiree Hilbring
 */

/**
 * Behavior class for picking shapes
 * In Version gis3d110899 gibt es ein pickingbehavior dass einen
selektieralgorithmus hat
 * und es hat ausserdem einen flag eingebaut gehabt um auch auf alle Layer
zuzugreifen
 */
public class PickObjectBehavior extends PickMouseBehavior {
    Canvas3D canvas;// canvas to render world in
    BranchGroup pickscene;// BranchGroup node from which picking is
possible
    Bounds pickbounds;// Bounds for picking
    FeatureProxy3D f3dp = null;// picked node from behavior
    FeatureProxy3D f3d = null;// nodes to compare with picked node
    Node node;// help node to find Featureproxy3D
    Node nodep;// help node to find Featureproxy3D
    int dt;// DisplayToolbar mode
    boolean fromLayer;// if true = look through path from above Layer3D,
                      // else from above FaetureProxy3D
    Enumeration enum,enum1,enum2;
    TransformGroup layertrans;// look here for FeatureProxy3D
    SceneGraphPath sceneGraphPath;// path from picked node
    int nodeCount;// number of nodes in sceneGraphPath
    SceneGraphPath sceneGraphPathAll[];
    private Point[] aperture16;


    /**
     * Constructor
     * dt is parameter of DisplayToolbar
     */
    public PickObjectBehavior(Canvas3D canvas,BranchGroup pickscene,Bounds
pickbounds,int dt) {
        super(canvas,pickscene,pickbounds);
        this.canvas = canvas;
        this.pickscene = pickscene;
        this.pickbounds = pickbounds;
        this.setSchedulingBounds(pickbounds);
        this.dt = dt;
        this.fromLayer = fromLayer;

        // versuch pikcingext

        aperture16 = new Point[4];
        aperture16[0] = new Point(-8, -8);
        aperture16[1] = new Point(8, -8);
        aperture16[2] = new Point(8, 8);
        aperture16[3] = new Point(-8, 8);
    }

    /**
     * Decides from which node in scenegraph to search for FeatureProxy3D
     * Calls pickdecision, which has picking algorithm in it
     */
    public void updateScene(int xpos, int ypos) {
        System.out.println("Hallo ich bin in updatescene");

        // Create a picking object
        System.out.println("Canvas:"+canvas);
        app.gis3D.pickingExt.PickObject pickObject = new
app.gis3D.pickingExt.PickObject(canvas,pickscene);

        // versuch mit pickingExt

pickObject.setPickMode(app.gis3D.pickingExt.PickObject.USE_BOUNDS);

pickObject.setPickShapeMode(app.gis3D.pickingExt.PickObject.SHAPE_APERTURE);
        pickObject.setPickAperture(aperture16);
        //pickObject.generatePickAperture(xpos,ypos);

//pickObject.setPickShapeMode(app.gis3D.pickingExt.PickObject.SHAPE_RAY_APERTURE);

        // Pick the closest Object an get the path to this node
        //sceneGraphPath = pickObject.pickClosest(xpos,ypos);
        //sceneGraphPath = pickObject.pickAny(xpos,ypos);
        sceneGraphPathAll = pickObject.pickAll(xpos,ypos);

        /*
        if (sceneGraphPath != null) {
            //System.out.println("nicht null"+sceneGraphPath);
            if (sceneGraphPath.getNode(4)!=null) {
                node = sceneGraphPath.getNode(4);
                System.out.println("nod(4):"+node);
                if (node instanceof WrapperFeatureProxy3D) {
                    System.out.println("ist f3d"+dt);
                    f3d = (FeatureProxy3D) node;
                    f3d.picked(dt,mevent);
                }
                if (node instanceof ShapeFeatureProxy3D) {
                    System.out.println("ist s3d"+dt);
                    f3d = (FeatureProxy3D) node;
                    f3d.picked(dt,mevent);
                }
            }
        }
        */


        if (sceneGraphPathAll != null) {
            for (int i=0;i<sceneGraphPathAll.length;i++) {

                if (sceneGraphPathAll[i] != null) {
                    //System.out.println("nicht null"+sceneGraphPath);
                    if (sceneGraphPathAll[i].getNode(4)!=null) {
                        node = sceneGraphPathAll[i].getNode(4);
                        System.out.println("nod(4):"+node);
                        if (node instanceof WrapperFeatureProxy3D) {
                            System.out.println("ist f3d"+dt);
                            f3d = (FeatureProxy3D) node;
                            f3d.picked(dt,mevent);
                        }
                        if (node instanceof ShapeFeatureProxy3D) {
                            System.out.println("ist s3d"+dt);
                            f3d = (FeatureProxy3D) node;
                            f3d.picked(dt,mevent);
                        }
                    }
                }
            }
        }

    }

    /**
     * Set DisplayToolbar Mode
     * Needed in modeactionperformed of Gis3DView, that picking behavior
knows,
     * which kind of picking behavior is enabled
     */
    public void setDisplayToolbar(int dt) {
        this.dt = dt;
    }

    /**
     * Get DisplayToolbar Mode
     */
    public int getDisplayToolbar() {
        return dt;
    }
}





On Wed, 29 Sep 1999, Adam Belmont <Adam Belmont wrote:

> I saw a question about this earlier, but didn't see a response.. So
> I'm asking it again.
>
> I've been able to pick Shape3D's created from QuadArray's and
> LineArray's but I'm having no luck with PointArray's.
>
> I have a version of PickMouseBehavior that allows me to define a pick
> mode of PICK_ARPETURE (or something close to that name).
>
> This mode *should* make picking point easier? Any other suggestions
> for picking points?
>
> Thanks,
>
> -- Adam Belmont
>
> ===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff JAVA3D-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
>

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to