I have written a new utility called CameraFlight. It loads a camera flight previously recorded using the class CameraFlightRecorder (both in org.xith3d.util.view) and moves/rotates the View according to the loaded matrices and times.
I think this would be a good test to compare engines or optimizations. Since it is very important to have the exact same view positions to take FPS test, this is the best solution to be sure.
Take a look at BSPLoaderTest and find these lines (117 - 155):
switch (key)
{
case 120: // F9
if (flightRecorder == null)
{
flightRecorder = new CameraFlightRecorder(view, 100L);
this.addInterval( flightRecorder );
this.addIntervalListener( flightRecorder );
flightRecorder.startRecord(getGameTime(), "camflight.cflt");
}
else
{
flightRecorder.stopRecord();
this.removeIntervalListener( flightRecorder );
flightRecorder.kill();
flightRecorder = null;
}
break;
case 121: // F10
if (camFlight == null)
{
try
{
camFlight = new CameraFlight( "demo/levels/quake3/bdmq3duel5/camflight.cflt" );
camFlight.start( getGameTime() );
}
catch (IOException e)
{
e.printStackTrace();
}
}
else
{
camFlight = null;
}
break;
By pressing F9 you can record a new camera flight (press F9 again to finish). By pressing F10 you can replay a recorded one (in this case the one saved to demo/levels/quake3/bdmq3duel5/camflight.cflt) (press F10 again to get back mouse control).
It should be very straight forward to port the CameraFlight class to other engines to replay a flight recorded in xith.
On my machine this camera flight makes an average FPS of 96, which is printed to the console, when the flight is finished (and restarts from the beginning). This flight takes about a minute or so.
Unfortunately I currently have problems with the interpolation of the matrices (recorded one at 100ms), so I’m currently using uninterpolated flight. But this shouldn’t address the FPS too much, but just looks a bit ugly ;).
Maybe someone could help me with the interpolation. This is the code to be found in org.xith3d.util.CameraFlight:
// ip1 is the last interpolation point (matrix) and ip2 is the next one
float dt = (float)t0t - (float)t0i; // this is the time from the last interpolation point to the current time (between 0 and 100 ms)
float d;
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{
d = ((ip2.matrix.getElement(i, j) - ip1.matrix.getElement(i, j)) * dt); // interpolated value for this element of the matrix
viewMatrix.setElement( i, j, ip1.matrix.getElement(i, j) + d );
}
}
view.getTransform().set( viewMatrix );
Thanks in advance.
Marvin