Class MouseRotate


  • public class MouseRotate
    extends MouseBehavior
    MouseRotate is a Java3D behavior object that lets users control the rotation of an object via a mouse.

    To use this utility, first create a transform group that this rotate behavior will operate on. Then,

    
         MouseRotate behavior = new MouseRotate();
         behavior.setTransformGroup(objTrans);
         objTrans.addChild(behavior);
         behavior.setSchedulingBounds(bounds);
    
    
    The above code will add the rotate behavior to the transform group. The user can rotate any object attached to the objTrans. Also this: id = event[i].getID(); > if ((id == MouseEvent.MOUSE_DRAGGED) && > ((MouseEvent)event[i]).isMetaDown() && > !((MouseEvent)event[i]).isAltDown()){ Note: By changing the bangs (!), you control which of the mouse buttons are filtered using the Alt and Meta key nomenclature. The old if statement says if the mouse is dragged and neither the right nor middle button are pressed . The new if statement says if the mouse is dragged and the right button and not the middle button is pressed. Made Additions under the mouse conditions for picking Added the algorithm to rotate the object by multiplying the inverse of the viewers rotation then applying the users rotation (just like when looking normal to XY plane) then multiply back in the original users rotation to put object back with the newly applied rotations.
    • Constructor Summary

      Constructors 
      Constructor Description
      MouseRotate()
      Creates a default mouse rotate behavior.
      MouseRotate​(int flags)
      Creates a rotate behavior.
      MouseRotate​(int flags, boolean behaviorfix)
      Same as above but with boolean fix.
      MouseRotate​(int flags, javax.media.j3d.TransformGroup VPTG, boolean behaviorfix)
      Same as above but with Viewer Transform Group and boolean fix.
      MouseRotate​(javax.media.j3d.TransformGroup transformGroup)
      Creates a rotate behavior given the transform group.
      MouseRotate​(javax.media.j3d.TransformGroup transformGroup, javax.media.j3d.TransformGroup VPTG, boolean behaviorfix)
      Creates a new MouseRotate object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      double getXFactor()
      Return the x-axis movement multipler.
      double getYFactor()
      Return the y-axis movement multipler.
      void initialize()
      DOCUMENT ME!
      void processStimulus​(java.util.Enumeration criteria)
      DOCUMENT ME!
      void setFactor​(double factor)
      Set the x-axis amd y-axis movement multipler with factor.
      void setFactor​(double xFactor, double yFactor)
      Set the x-axis amd y-axis movement multipler with xFactor and yFactor respectively.
      void setupCallback​(MouseBehaviorCallback callback)
      The transformChanged method in the callback class will be called every time the transform is updated.
      void transformChanged​(javax.media.j3d.Transform3D transform)
      Users can overload this method which is called every time the Behavior updates the transform.
      • Methods inherited from class javax.media.j3d.Behavior

        getEnable, getNumSchedulingIntervals, getSchedulingBoundingLeaf, getSchedulingBounds, getSchedulingInterval, getView, getWakeupCondition, postId, setEnable, setSchedulingBoundingLeaf, setSchedulingBounds, setSchedulingInterval, updateNodeReferences, wakeupOn
      • Methods inherited from class javax.media.j3d.Node

        cloneNode, cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, duplicateNode, getBounds, getBoundsAutoCompute, getCollidable, getLocale, getLocalToVworld, getLocalToVworld, getParent, getPickable, setBounds, setBoundsAutoCompute, setCollidable, setPickable
      • Methods inherited from class javax.media.j3d.SceneGraphObject

        clearCapability, clearCapabilityIsFrequent, duplicateSceneGraphObject, getCapability, getCapabilityIsFrequent, getName, getUserData, isCompiled, isLive, setCapability, setCapabilityIsFrequent, setName, setUserData, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • x_angle

        double x_angle
        DOCUMENT ME!
      • y_angle

        double y_angle
        DOCUMENT ME!
      • x_factor

        double x_factor
        DOCUMENT ME!
      • y_factor

        double y_factor
        DOCUMENT ME!
    • Constructor Detail

      • MouseRotate

        public MouseRotate()
        Creates a default mouse rotate behavior.
      • MouseRotate

        public MouseRotate​(javax.media.j3d.TransformGroup transformGroup)
        Creates a rotate behavior given the transform group.
        Parameters:
        transformGroup - The transformGroup to operate on.
      • MouseRotate

        public MouseRotate​(int flags)
        Creates a rotate behavior. Note that this behavior still needs a transform group to work on (use setTransformGroup(tg)) and the transform group must add this behavior.
        Parameters:
        flags - interesting flags (wakeup conditions).
      • MouseRotate

        public MouseRotate​(int flags,
                           boolean behaviorfix)
        Same as above but with boolean fix.
        Parameters:
        flags - DOCUMENT ME!
        behaviorfix - DOCUMENT ME!
      • MouseRotate

        public MouseRotate​(int flags,
                           javax.media.j3d.TransformGroup VPTG,
                           boolean behaviorfix)
        Same as above but with Viewer Transform Group and boolean fix.
        Parameters:
        flags - DOCUMENT ME!
        VPTG - DOCUMENT ME!
        behaviorfix - DOCUMENT ME!
      • MouseRotate

        public MouseRotate​(javax.media.j3d.TransformGroup transformGroup,
                           javax.media.j3d.TransformGroup VPTG,
                           boolean behaviorfix)
        Creates a new MouseRotate object.
        Parameters:
        transformGroup - DOCUMENT ME!
        VPTG - DOCUMENT ME!
        behaviorfix - DOCUMENT ME!
    • Method Detail

      • getXFactor

        public double getXFactor()
        Return the x-axis movement multipler.
        Returns:
        DOCUMENT ME!
      • getYFactor

        public double getYFactor()
        Return the y-axis movement multipler.
        Returns:
        DOCUMENT ME!
      • processStimulus

        public void processStimulus​(java.util.Enumeration criteria)
        DOCUMENT ME!
        Specified by:
        processStimulus in class MouseBehavior
        Parameters:
        criteria - DOCUMENT ME!
      • setFactor

        public void setFactor​(double factor)
        Set the x-axis amd y-axis movement multipler with factor.
        Parameters:
        factor - DOCUMENT ME!
      • setFactor

        public void setFactor​(double xFactor,
                              double yFactor)
        Set the x-axis amd y-axis movement multipler with xFactor and yFactor respectively.
        Parameters:
        xFactor - DOCUMENT ME!
        yFactor - DOCUMENT ME!
      • setupCallback

        public void setupCallback​(MouseBehaviorCallback callback)
        The transformChanged method in the callback class will be called every time the transform is updated.
        Parameters:
        callback - DOCUMENT ME!
      • transformChanged

        public void transformChanged​(javax.media.j3d.Transform3D transform)
        Users can overload this method which is called every time the Behavior updates the transform. Default implementation does nothing
        Parameters:
        transform - DOCUMENT ME!