Why need use multiple mouseRotation behavior objects? Actually, we should use as few as mouse behavior objects. In my Java-based Virtual Instrument program, I use only one custom mousebehavior objects to manipulate more than 25 objects. I do not if this is helful for you. Any questions, you can send to my private email address at [EMAIL PROTECTED] And you can visit our program at http://vlab.ee.nus.edu.sg/vlab/vr-osci
Thanks. Rgds, Cheng Chang Dong http://vlab.ee.nus.edu.sg/~ccd ----- Original Message ----- From: "Charles Whitley" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Saturday, March 09, 2002 12:56 AM Subject: Re: [JAVA3D] Problems with multiple MouseRotate behaviors > On Thu, 7 Mar 2002 13:49:15 -0700, Raj Vaidya <[EMAIL PROTECTED]> wrote: > > >Multiple mousebehaviors ? Do you folks encounter a jump in your > >geometry while doing the following: > > > >1. Enable behavior 1 and manipulate the geometry under it. > >2. Disable behavior 1, enable behavior 2 and manipulate the > > geometry under it. > >3. Disable behavior 2, enable behavior 1. > > > >Now, upon the very first mouse click, the geometry under behavior 1 > >may probably show a sudden jump. I was not sure whether this had > >anything to do with the various other stuff that I had introduced to > >enhance the behaviors, but I was suspicious of the usage of the boolean > >flag "reset". Had a post on this last month, if I remember right. > >Haven't had a chance to dig deeper, since I have now shifted to using > >OrbitBehavior. > > > >Raj > > > > The above behavior is exactly what I was seeing. So following your suggestion > I set the "reset" boolean to "true" after enabling a behavior, and this > stopped the "jump" in the geometry. I looked at the MouseRotate behavior's > processStimulus method, and this seems like a proper fix. > > Now this brings me back to Simeon Fitch's fix for my situation where, using > your example above, I could perform step (1), but then neither behavior > would subsequently respond. > > >>> public static class MouseRotate extends > >>> com.sun.j3d.utils.behaviors.mouse.MouseRotate { > >>> /** > >>> * Overriden to fix a bug that doesn't initialize the class > >>> * correctly after it is reenabled via setEnable(); > >>> */ > >>> public void processMouseEvent(MouseEvent evt) { > >>> if(evt.getID() == MouseEvent.MOUSE_DRAGGED && !buttonPress) { > >>> buttonPress = true; > >>> x_last = evt.getX(); > >>> y_last = evt.getY(); > >>> } > >>> super.processMouseEvent(evt); > >>> } > >>> } > > If the "reset" boolean is set to "true" after enabling the behavior, > this code no longer needs to set the values of "x_last" and "y_last", > but I still need the "buttonPress" set to true. I have been trying to figure > out why. It appears to be related to the fact that I enable and disable > the behaviors with mouse presses and releases, and that the behaviors > also respond to these same events. > > I found that in my case, after the first rotation of my scene, when I then enable one > of the behaviors with a mouse press, the behavior's processStimulus method > sees a "mousePressed" event, followed by a "mouseReleased" event. I don't > know how the "mouseReleased" event got in there, but it sets the boolean > "buttonPress" to false, but then I am saved by Simeon's code. > > Then I found that by reversing how I enabled/disabled the behaviors; > i.e., enabling them (and setting "reset" to "true") on a mouse release and > disabling the one I *didn't* want on a mouse press, I do not need to override > the MouseRotate behaviors with Simeon's code after all. Except sometimes. > Sometimes that rogue "mouseReleased" event slips in behind the "mousePressed" > event and stops my behavior from responding. I try again and it works. > > Sorry for rambling. The good news for me is that a blend of Raj and Simeon's > ideas give me smooth sailing. It's just disconcerting that unknown creatures > lie just beneath my boat. We all know how those kinds of things can jump up and > bite you later. > > Thanks again, > > Charles > > =========================================================================== > 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".
