Mercurial > hg > jslab
view src/samer/j3d/FPS.java @ 8:5e3cbbf173aa tip
Reorganise some more
author | samer |
---|---|
date | Fri, 05 Apr 2019 22:41:58 +0100 |
parents | bf79fb79ee13 |
children |
line wrap: on
line source
/* Credit: got this from Particles java 3d demo app by Jeff White (jsw@cs.brown.edu) */ package samer.j3d; import javax.media.j3d.*; import javax.vecmath.*; import java.util.Enumeration; final class FPS extends Behavior { protected int nFrames; protected long startTime; protected final WakeupCondition w; public FPS(int nFrames){ this.nFrames=nFrames; w=new WakeupOnElapsedFrames(nFrames); } public FPS(){ this(100); } public void initialize(){ setSchedulingBounds(new BoundingSphere(new Point3d(),1000)); startTime=System.currentTimeMillis(); wakeupOn(w); } public void processStimulus(Enumeration criteria){ long time=System.currentTimeMillis(); System.err.println("fps: "+ 1000 * (double) nFrames / (double) (time-startTime)); startTime=time; wakeupOn(w); } }