Here's how I do it:
I fire PropertyChangeEvents to alert my listeners about the pick
my 'LightPanel' object extends TransformGroup, and is the parent of some
Shape3D
The PropertyChangeListeners change the TransformGroup's Transform3D, to move
the item that was picked.

Tom

//-----------------------------------------------------------------------
import com.sun.j3d.utils.behaviors.picking.*;
import com.sun.j3d.utils.behaviors.mouse.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.media.j3d.*;
import javax.vecmath.*;
import com.sun.j3d.utils.geometry.*;
import java.beans.*;

public class PickPanelBehavior extends PickMouseBehavior {

   PropertyChangeSupport propertyChangeSupport;
   Bounds bounds;
   BranchGroup root;

   public PickPanelBehavior(BranchGroup root, Canvas3D canvas, Bounds bounds){
      super(canvas, root, bounds);
      this.setSchedulingBounds(bounds);
      this.bounds = bounds;
      this.root = root;
   }


   public void updateScene(int xpos, int ypos){

      TransformGroup primitive = null;
      if(!mevent.isAltDown() && !mevent.isMetaDown()) {  // ButtonOne
          primitive =
              (TransformGroup)pickScene.pickNode(pickScene.pickClosest(xpos,
ypos,

PickObject.USE_GEOMETRY),
                                                 PickObject.TRANSFORM_GROUP);
          if(primitive != null && primitive instanceof LightPanel) {
              LightPanel panel = (LightPanel)primitive;
              if(propertyChangeSupport != null)

propertyChangeSupport.firePropertyChange("LightPanelSelection", null, panel);
          }
      }
   }

   public void addPropertyChangeListener(PropertyChangeListener l) {
      if(propertyChangeSupport == null) {
         propertyChangeSupport = new PropertyChangeSupport(this);
      }
      propertyChangeSupport.addPropertyChangeListener(l);
   }

   public void removePropertyChangeListener(PropertyChangeListener l) {
      if(propertyChangeSupport == null) {
         propertyChangeSupport = new PropertyChangeSupport(this);
      }
      propertyChangeSupport.removePropertyChangeListener(l);
   }
}




Dennis Goetz wrote:

> Hello,
>
> I was wondering if anyone could give me some sample code for how to make
> my own PickingBehavior that uses the geometry of the objects?  I have
> looked through the online tutorial, but am still having a hard time
> figuring out how you put everything together...
>
> Specifically, I would like to be able to click on my scene and then
> change the appearance of the selected object and also be able to
> retrieve information about that object.
>
> Thanks,
>
> Dennis Goetz
> [EMAIL PROTECTED]
>
> ===========================================================================
> 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