Hi Mike,

I use something like this for simple (non-behavior) animation:

public class Animator extends Applet implements ActionListener {
protected int counter = 0;
float z=0;
Timer timer = new Timer(100,this); //10 frames per second

public void actionPerformed(ActionEvent e ) {
  counter++;
  //set translations etc.
  if (counter < 100)
      z=z-0.2f;
      translation.set(0,0,z);
      transform3D.setTranslation(translation);
      transformGroup.setTransform(transform3D);
  }
}

This works fine for me, although I've heard rumors that Sun have used a duff
clock on PCs, so the
timing may not be very accurate.

Instead of a timer, you can subclass Canvas3D and override postRender() or
postSwap(). I haven't tried this yet,
but I imagine it might freeze up if you didn't make any movements in a
particular frame, or if you try to update
swing components at the same time.

A class from Josh Richmond that was posted recently: CatDogMouseBehaviour does
the same thing using behaviors.


From,

Greg. (java3d.org)

>>"Michael P. McCutcheon" wrote:
>>
>> I am used to programming in VRML.  With it, you would have a
>> TimeSensor...you would route the timesensor to a particular object, on
>which
>> you would have a method that was called after each frame.  In this method
>> you would update the position of your objects, then when the method
>> completed, VRML did it's rendering, and the time sensor would then do it
>all
>> over again.
>>
>> What I'm wondering, if I want to move a simple object around from 0 to
>-500,
>> say in 1 increments, (without using an interpolator, I want to explictly
>set
>> it my self), how would I do this?  I ran some code like this but it
simply
>> does not seem to work:
>>
>> I have this in an event handler of a AWT button:
>>
>>   for(int counter=0; counter<100; counter++) {
>>    z=z-0.2f;
>>    translation.set(0,0,z);
>>    transform3D.setTranslation(translation);
>>    transformGroup.setTransform(transform3D);
>>   }
>>
>> Any tips on what classes I should be looking at to do such a thing the
>right
>> way?
>>
>> Thanks for any info...
>>
>> Mike
>>



This communication is for informational purposes only.  It is not intended as
an offer or solicitation for the purchase or sale of any financial instrument
or as an official confirmation of any transaction. All market prices, data
and other information are not warranted as to completeness or accuracy and
are subject to change without notice. Any comments or statements made herein
do not necessarily reflect those of J.P. Morgan Chase & Co., its
subsidiaries and affiliates.

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