Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Java 3D / October 2004

Tip: Looking for answers? Try searching our database.

Two Canvas3D with single MouseRotate?

Thread view: 
maya2000 - 29 Sep 2004 09:35 GMT
Hello,

I have two Canvas3D, one is for object view and the other is only for
axis rotation. I want to get a MouseRotate behavior from the object
view canvas3D to axis Canvas3D, so I can synchronise the rotation
between them.

I couldn't find any similar examples up to now, but some people said
that I should use MouseBehaviorCallback and setupCallback, etc. But I
couldn't figure out how to do it.

Or, should I use one Canvas3D with multiple view? If so, how can I do
it?

Could you give me any simple examples plz?
Thanks for your help.

Sungwoo
maya2000 - 02 Oct 2004 09:27 GMT
I solved my problem. See below code.
Now two Canvas3D receive a same mouseRotate behaviour.
Let me know if there is more better and efficient way.

Sungwoo

-----------
public class MouseSync implements MouseBehaviorCallback {

   public MouseSync() {

       ......

   }
             
   public void threeDSceneCreation() {

       ......

       MouseRotate myMouseRotate = new MouseRotate();
       // Mouse rotate event capture to synchronise the axis view rotation.
       myMouseRotate.setupCallback(this);
       this.transformChanged(MouseBehaviorCallback.ROTATE, matrix1);
    myMouseRotate.setTransformGroup(tg1);
    myMouseRotate.setSchedulingBounds(new BoundingSphere());
    childBG1.addChild(myMouseRotate);

    MouseTranslate myMouseTranslate = new MouseTranslate();
    myMouseTranslate.setTransformGroup(tg1);
    myMouseTranslate.setSchedulingBounds(new BoundingSphere());
    childBG1.addChild(myMouseTranslate);

       MouseZoom myMouseZoom = new MouseZoom();
       myMouseZoom.setTransformGroup(tg1);
       myMouseZoom.setSchedulingBounds(new BoundingSphere());
       childBG1.addChild(myMouseZoom);    
       
       rootBranchGroup.addChild(childBG1);
   }
   
   public void transformChanged(int param, Transform3D transform3D) {
       //------------------------------------------------
       // For all behaviour sync i.e., rotation, zoom, translation.
       //------------------------------------------------
       // axDis.tg.setTransform(transform3D);
       
       //------------------------------------------------
       // For roation behaviour sync only.
       //------------------------------------------------
       Quat4d q4d = new Quat4d();
       AxisAngle4d a4d = new AxisAngle4d();
       // Places the quaternion equivalent of the normalized rotational
       // component of this transform into the quaternion parameter.
       transform3D.get(q4d);
       // Sets the value of this axis-angle to the rotational equivalent  of
       // the passed quaternion.        
       a4d.set(q4d);
       // Sets the rotation from a transform3D data.
       transform3D.set(q4d);
       transform3D.setRotation(a4d);
       // Set the new rotation info to the target Canvas3D.
       axDis.tg.setTransform(transform3D);
   }    
   
}


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.