hi

Have a look at the following code. It creates a subclass of
Canvas3D and overrides the postSwap() method. The code was taken
from a previous posting - I think it was from the Vrml97Player.

The FrameRateListener was inserted by myself and provides a _simple_
way of registering a listener.


import javax.media.j3d.*;

public class AdvCanvas3D extends Canvas3D
{
    public FrameRateListener   fpsListener;
    long    frameCount = 0;
    double  lastTime = System.currentTimeMillis();

    public AdvCanvas3D(java.awt.GraphicsConfiguration gcon)
    {   super(gcon);
    }

    public void postSwap()
    {   frameCount++;
        if( (System.currentTimeMillis () - lastTime) >= 1000d)
        {   double interval = (System.currentTimeMillis () -
lastTime)/1000d;
            double fps = frameCount / interval;
            // Write your own code instead of fpsListener.update(..)
            // if you like!
            fpsListener.update(fps, frameCount, interval);
            lastTime = System.currentTimeMillis ();
            frameCount = 0;
        }
    }
}

> "A. Dawes" schrieb:
>
> Hello everyone. I'm trying to find out how to control the frame rate
> in Java 3D. What I need to do is render at a specific point in time so
> that I can be sure to render key frames. I was looking at the Canvas3D
> object, but I was not sure what function I should over-ride to achieve
> this. I suppose calling repaint() would work, but am I guaranteed that
> this will force a repaint?
>
> If anyone has any experience with this or knows of an alternate
> method, I would appreciate your advice or opinions.
>

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