Mercurial > hg > jslab
view src/samer/j3d/FPS.java @ 0:bf79fb79ee13
Initial Mercurial check in.
author | samer |
---|---|
date | Tue, 17 Jan 2012 17:50:20 +0000 |
parents | |
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); } }