Hi Travis,

On Sun, 24 Jan 1999, Travis Bryson wrote:

> 
> Hi Helmuth,
> 
> Your application sounds very interesting.
> 
> Do you have a reproducible test case that can be run in a standard flat
> screen environment?  

It would take some work, but I could make it work without the glove.  It
works on a flat panel now.

> 
> I am not sure what you mean by this.  You should never call
> processStimulus from your own code.  However, maybe you were trying to
> do something unusual to work around the bug.
> 

This is the code I am using to attach (and unattach) the object to (and
from) the hand:  (sorry it doesn't look very elegant)

I call "attachToHand" when the object is colliding with the hand and the
user is doing a "grasp" gesture with the glove.  And I call
"unattachToHand" when the user does a "release" gesture. 

Most of the code is copied from the SUN examples, specifically
"TickTockCollision".

The problem is that when the user "releases" the object, and I attach it
to its original position, sometimes the object remains "highlighted", the
collision detector waiting for a "WakeupOnCollisionExit", which should
have taken place as soon as it was not colliding with the virtual hand.

Any advice is highly appreciated!

Helmuth

================ start of code ========================

import javax.media.j3d.*;
import javax.vecmath.*;
import java.util.*;

/**
 * Creates a graspable object
 * @author: Helmuth Trefftz
 * January 1999.
 *
 */

public class GraspableObject {

  public boolean colliding = false;
  public boolean grasped = false;
  public Group myGroup;
  public BranchGroup myBranchGroup;
  public BranchGroup myRoot;
  public CollisionDetector cd;
  public Shape3D shape;
  public TransformGroup objTrans;
  public boolean first_time = true;

  private Hand hand;

  public GraspableObject(Hand theHand) {
    hand = theHand; 
  }

  public void attachToHand() {
    int myIndex = 0;
    int nc = myRoot.numChildren();
    for (int i = 0; i < nc; i++) {
      if (myRoot.getChild(i) == myBranchGroup) {
        myIndex = i;
      }
    }
    System.out.println("My Index: " + myIndex);
    myRoot.removeChild(myIndex);
    hand.handYPR.addChild(myBranchGroup);
    grasped = true;
  }

  public void unAttachToHand() {
    int myIndex = 0;
    int nc = hand.handYPR.numChildren();
    for (int i = 0; i < nc; i++) {
      if (hand.handYPR.getChild(i) == myBranchGroup) {
        myIndex = i;
      }
    }
    System.out.println("My Index: " + myIndex);
    hand.handYPR.removeChild(myIndex);
    myRoot.addChild(myBranchGroup);
    grasped = false;
  }

    public Group createBox(double scale, Vector3d pos) {
        // Create a transform group node to scale and position the object.
        Transform3D t = new Transform3D();
        t.set(scale, pos);
        objTrans = new TransformGroup(t);

        // Create a simple shape leaf node and add it to the scene graph
        shape = new Box(1.0, 1.0, 1.0);
        objTrans.addChild(shape);

        // Create a new ColoringAttributes object for the shape's
        // appearance and make it writable at runtime.
        Appearance app = shape.getAppearance();
        ColoringAttributes ca = new ColoringAttributes();
        ca.setColor(0.6f, 0.3f, 0.0f);
        app.setCapability(app.ALLOW_COLORING_ATTRIBUTES_WRITE);
        app.setColoringAttributes(ca);

        addCollisionDetection();

        return objTrans;
    }

    public void addCollisionDetection() {
        // Create a new Behavior object that will perform the collision
        // detection on the specified object, and add it into
        // the scene graph.
        cd = new CollisionDetector(shape,this);
        BoundingSphere bounds =
            new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
        cd.setSchedulingBounds(bounds);

        // Add the behavior to the scene graph
        objTrans.addChild(cd);
    }

}


================ end of code ========================

> 
> Travis Bryson
> 
> Sun Microsystems
> 
> 
> > X-Authentication-Warning: multimodal1.rutgers.edu: trefftz owned process doing 
> -bs
> > Date: Sun, 24 Jan 1999 19:30:56 -0500 (EST)
> > From: Helmuth Trefftz <[EMAIL PROTECTED]>
> > To: [EMAIL PROTECTED]
> > Subject: [java3d] Collision Detection
> > MIME-Version: 1.0
> > 
> > Hi,
> > 
> > I am building a Java3D application in which I grasp and release objects
> > with a VR glove.  When I detect a collision between the object and the
> > virtual hand (using Java3D collision detection) I attach the object to the
> > palm of the hand.  So far so good.  
> > 
> > But when I release the object from the palm, and attach it to its original
> > position, the "WakeupOnCollisionExit" is never produced and the object
> > remains as if colliding with the hand (obviously wrong, since it is now
> > far away from the hand).
> > 
> > I need to force Java to produce a "WakeupOnCollisionExit" when I release
> > the object, but have not found a way to do it.  Calling "processStimulus"
> > with an empty enumeration does not work.  Adding a new "collisionDetector" 
> > (like in the TickTockCollision example) does not work either. 
> > 
> > What can I do?
> > 
> >     -------------------------------------------------------
> >     Helmuth Trefftz
> >     Rutgers University
> >     e-mail: [EMAIL PROTECTED]
> >     tel:    (732) 445 0561          fax:    (732) 445 4775
> >     -------------------------------------------------------
> > 
> > =====================================================================
> > To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
> > Java 3D Home Page: http://java.sun.com/products/java-media/3D/
> 
> 


=====================================================================
To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
Java 3D Home Page: http://java.sun.com/products/java-media/3D/

Reply via email to