You need to do three things to get it to work.
First, look through Sun's tutorial and become completely familiarized with
using the TransformChanged Method/Callback that they have an example of in
the section on Picking Behaviors.


Second, you need to either write a class (seperate file) or use an inner
class which is what they did and also what I did.

Here is the example of the inner class from my main class:

         static class myPickingCallbackClass extends Object implements
PickingCallback
         {
                 public void transformChanged(int type, TransformGroup tg)
                 {
                 //      Must test to see if a TransformGroup is not null
before calling
                 //      loadStarProperties Method.
                 //      Otherwise get a nullpointer exception in Method
                         if ((tg != null) && !(usingViewer) &&
!CheckboxMenuItemToolsOrbitStar.getState())
                         {
//                              usingViewer = false;
                                 previousStar = currentStar;
                                 SetCurrentStarFromTransformGroup(tg);
                                 loadStarProperties(currentStar);

                                 double distanceToObject =
findDistanceToObject(currentStar,meViewer);
                                 
(pickTranslate.translate).setFactor((0.001334)*distanceToObject);
//(0.02) 0.001334 * distance 15
                                 (pickRotate.drag).setFactor(0.03);
                                 
(pickZoom.zoom).setFactor((0.002667)*distanceToObject);
// (0.04) 0.002667 * distance 15
                                 notSaved = true;        // Set to true
since just made a change
                         }
                 }

                 public void transformClicked(int type, TransformGroup tg)
                 {
                         if ((tg != null) && !(usingViewer) &&
!CheckboxMenuItemToolsOrbitStar.getState())
                         {
//                              usingViewer = false;
                                 previousStar = currentStar;
                                 SetCurrentStarFromTransformGroup(tg);
                                 loadStarProperties(currentStar);
                         }
                 }

                 public void transformDoubleClicked(int type,
TransformGroup tg)
                 {
                         if ((tg != null) && !(usingViewer) &&
!CheckboxMenuItemToolsOrbitStar.getState())
                         {
//                              usingViewer = false;
                                 previousStar = currentStar;
                                 SetCurrentStarFromTransformGroup(tg);
                         //      System.out.println("Fire off this TG's
Properties Dialog.\n");
                                 currentStar.changeProperties(Stars);
                                 notSaved = currentStar.notSaved;
                         }
                 }
         }

You will notice that I have added a few lines of code inside the
transformChanged method compaired to Sun's example.  I also have a
transformClicked and a transformDoubleClicked method.

I use the transformClicked method to set the object I single click on to
make the active object for performing operations using menus and not the
mouse  The transformClicked  method also causes the position, rotation,
name and group of the object to be loaded into fields on the screen.  I use
the transformDoubleClicked method to bring up a properties box with
non-Java3D related info about the object.  The only difference between the
transformClicked and transformDoubleClicked is that in order to distinguish
between a single click and a double click, I count the number of mouse
clicks in the transformDoubleClicked method to watch for two clicks and
then bring up the properties of the object.

For the transformClicked , I wasn't worried about the count since loading
the position, rotation, name and group of the objects isn't time consuming.

Finally, you need to write your own method for doing whatever you want when
someone doubleclicks.  Mine was called changeProperties(); which you see
inside the transformDoubleClicked method.



Additional warnings.
Make sure you import the copy of my behaviors that you compile in your
project and not point to Sun's copy.

Make sure you setup the callbacks when you add the behavior to the universe
or whatever BranchGroup you are using.


If you need any further help, or something explained more closely, don't
hesitate to email me.








At 03:17 PM 01/12/2001 +0100, you wrote:
>Dear Mr. Eric Reiss,
>
>I went thru your very intresting collection of modified behaviors, the link
>to which u gave on the java3D usergroup.
>I am a student at ETH, Zurich and am using java3D for the first time. For
>most of my requirements as of now i can use the pre-defined behaviors fairly
>well. but for one particular need i found your transformDoubleClicked
>behavior very useful.
>
> >Likewise, I wanted a way to launch a dialog that shows non-Java3D related
>properties of 3D objects when a user >doubleclicked over an object so I
>created the transformDoubleClicked callback method.
>
>To get a dialog box on clicking some 3D objects with non 3D info on it is
>exactly my need. but i realise the same problem that operating on 3D objects
>where the viewer is not normal to the XY plane, gives trouble.
>so I tried to get the required code for my purpose from your research
>homepage but find it very difficult to separate out only what i need.
>I could not manage to locate the main code for the transformDoubleClicked
>callback method.
>Can u please help me by guiding me as to how I can achieve what i want in my
>program.
>I am not a programmer by profession and hence i am really learning this from
>scratch, so if this kind of a very simple question is bugging for U, then i
>apologise in advance.
>but would be very grateful if U could still help me with my task.
>Thanks a ton in advance
>
>R. Jindal

***********************************************************************
Eric Reiss
Manager MEMS Lab
Swanson New Product Incubator
School of Engineering  - University of Pittsburgh

3700 O'Hara Street
647 Benedum Hall
Pittsburgh, PA 15261
Phone: 412-624-9696
Email: [EMAIL PROTECTED]
http://www.sigda.acm.org/Eric/
***********************************************************************

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