"Don Casteel" <[EMAIL PROTECTED]> on 08/12/99 10:06:00 AM
To: [EMAIL PROTECTED]
cc:  (bcc: Gary Moss/arl)
Subject: Re: [JAVA3D] FrameRate ?


I've tried this, and only get zero values. Also I get an array out of bounds
exception from the
                long[] startTimes = new long[10];
                view.getFrameStartTimes(startTimes);
part of the code. I've commented out this part of the code for now.


 Here is my implementation, based now on Doug's example.  It doesn't "wake up"
until I start moving my viewplatform around, haven't looked into why that is:

-Gary


 // I attach the behavior to my platform geometry.
 DashBoard extends PlatformGeometry
  {
  public DashBoard()
   {
   ...
   // Display Frames/Second.
   FPSBehavior fpsBehavior = new FPSBehavior();
   fpsBehavior.setSchedulingBounds( bounds );
   addChild( fpsBehavior );
   ...
   }
  }

 private class FPSBehavior extends Behavior
  {
  WakeupCondition FPSCriterion;
       long [] startTimes;
  int nframes = 10;

  public FPSBehavior()
   {
   super();
   }

  public void initialize()
   {
   WakeupCriterion crit = new WakeupOnElapsedFrames( nframes );
   FPSCriterion = crit;
        nframes = view.getMaxFrameStartTimes();
        startTimes = new long[nframes];
   wakeupOn( FPSCriterion );
   }

  public void processStimulus( Enumeration criteria )
   {
   // Calculate elapsed time in milliseconds since last wakeup.
   Date current = new Date();
        long curframe = view.getFrameNumber();
        int idx;
        if( curframe > nframes )
             idx = nframes;
        else
             idx = (int) curframe;
        view.getFrameStartTimes( startTimes );
        double elapsedms = (current.getTime() - startTimes[idx-1]) / 1000.0;
   double FPS = ((double) nframes) / elapsedms;
        DisplayFPS( (int)(FPS + 0.5) ); // XXX Your display routine here
    wakeupOn( FPSCriterion );
   }
  }

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