Thanks for the quick response.

  Sounds like a great idea, how can I implement it? Below is part of the
behavior I'm using to do the picking (some of the code is based on
the j3d.ord site). And even lower I post the settings for the Branch
englobing the collidable objets (my Quads).

  Many thanks in advance.


========================================================================
The behavoir
========================================================================

class behavior2 extends Behavior
{
 private TransformGroup TG;
 private Transform3D rot=new Transform3D();
 private Transform3D rotation=new Transform3D();
 private Vector3f vctTransl;
  private Vector3f forward, backwards, left, right, forwLeft, forwRight,
                   backwLeft, backwRight;

  protected Transform3D viewTx = new Transform3D();
  protected Transform3D worldEyeTransform = new Transform3D();
  protected Vector3d oneFrameTranslation = new Vector3d();
  protected TransformGroup viewTg;
  protected Vector3d locationVector = new Vector3d();
  protected Point3d locationPoint = new Point3d();

  /** The vector along which we do collision detection */
  private Vector3d collisionVector = new Vector3d();

  private static final Vector3d COLLISION_DIRECTION = new Vector3d(0, 0, -
1);

    /** Point 3D use to calculate the end point for collisions per frame */
    private Point3d locationEndPoint = new Point3d();

    /** Pick shape for collision detection */
    private PickSegment collisionPicker = new PickSegment();

  private float deltaStep;
  protected BranchGroup collidables;

 private WakeupOnAWTEvent keyEvent=new WakeupOnAWTEvent
(KeyEvent.KEY_PRESSED);

 behavior2(TransformGroup TG)
 {
  this.TG=TG;
    this.viewTg=TG;
      deltaStep = 0.2f;
      forward   = new Vector3f(0.0f, 0.0f, deltaStep);
      backwards  = new Vector3f(0.0f, 0.0f, -deltaStep);
      left      = new Vector3f(deltaStep, 0.0f, 0.0f);
      right     = new Vector3f(-deltaStep, 0.0f, 0.0f);
      forwLeft  = new Vector3f(deltaStep, 0.0f, deltaStep);
      forwRight = new Vector3f(-deltaStep, 0.0f, deltaStep);
      backwLeft = new Vector3f(deltaStep, 0.0f, -deltaStep);
      backwRight = new Vector3f(-deltaStep, 0.0f, -deltaStep);


  vctTransl = new Vector3f();
 }

 public void initialize()
 {
  this.wakeupOn(keyEvent);
 }

 public void processStimulus(Enumeration criteria)
 {

    Transform3D td = new Transform3D();
    viewTg.getTransform(td);
    td.get(oneFrameTranslation);

    viewTx.transform(oneFrameTranslation);

    viewTg.getChild(0).getLocalToVworld(worldEyeTransform);

    worldEyeTransform.mul(viewTx);

    worldEyeTransform.get(locationVector);
    locationPoint.set(locationVector);

    worldEyeTransform.transform(COLLISION_DIRECTION, collisionVector);

    collisionVector.scale(0.15f);


oneFrameTranslation.set(0.0d, 0.0d, -0.15d);

    locationEndPoint.add(locationVector, collisionVector);
    locationEndPoint.add(oneFrameTranslation);

    collisionPicker.set(locationPoint, locationEndPoint);
System.out.println("start..." + locationPoint + "end..." +
locationEndPoint);
    SceneGraphPath[] closest = collidables.pickAllSorted(collisionPicker);

    if(closest == null)
        return;


  boolean real_collision = false;

    for(int i = 0; (i < closest.length) && !real_collision; i++)
    {
        Shape3D i_shape = (Shape3D)closest[i].getObject();

  System.out.println("shape" + i_shape);

        Enumeration geom_list = i_shape.getAllGeometries();

        while(geom_list.hasMoreElements() && !real_collision)
        {
            GeometryArray geom = (GeometryArray)geom_list.nextElement();

            if(geom == null)
                continue;

            real_collision = true;    // call specialist routine here
            System.out.println("geom" + geom);
        }
    }
========================================================================

========================================================================
The settings
========================================================================
   wallsBranch = new BranchGroup();
   wallsBranch.setPickable(true);

   //Here I only post one, but I have 8 of these transformGroups
   TransformGroup trGrp = new TransformGroup();
   trGrp.setPickable(true);

   //Here I only post one, but I have 8 of these QuadArrays
   QuadArray wall = new QuadArray(4, QuadArray.COORDINATES|
                                     QuadArray.TEXTURE_COORDINATE_2);
   wall.setCapability(QuadArray.ALLOW_COORDINATE_READ);
   wall.setCapability(QuadArray.ALLOW_FORMAT_READ);
   wall.setCapability(QuadArray.ALLOW_COUNT_READ);

   //Here I set the coordinates of the vertex, code not worth posting?

   //Here I only post one, but I have 8 of these Shape3D
   Shape3D theWall = new Shape3D(wall, appWalls) ;
   theWall.setCapability(Shape3D.ALLOW_GEOMETRY_READ);

   //I append the shape3D to the transformGroup, and then this last one
   //to the branch
   wallsBranch.compile();

===========================================================================
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