John, Dave,
If you are running on Windows NT (I hope you are!) you can access the
underlying "high performance" timer, which has an accuracy of several
nanoseconds. Unfortunately Java does not do this by default on NT so you are
stuck with the default timer (GetTickCount). On Windows NT I believe this
has an accuracy of about 5-10 ms.
Incidentally, there is no excuse for Java using the default timer on either
platform - SUN could use the Windows multimedia timer (same API on NT/95)
which has an accuracy of about 1 ms.
I have a vague recollection that several months (years?) back someone posted
a JNI interface to the high performance timer to the list.
Sincerely,
Daniel Selman
-----Original Message-----
From: Discussion list for Java 3D API
[mailto:[EMAIL PROTECTED]]On Behalf Of John Wright
Sent: Sunday, March 04, 2001 10:54 AM
To: [EMAIL PROTECTED]
Subject: Re: Java timer, frame/time based calculations
Dave,
Switch to Linux? {grin}
If I'm not mistaken the timer for DOS (hence Win9x) is once every 18.2
seconds. Thus the timer has a resolution of 55 ms. So unless you
switch operating systems (or write your own timer in native code) you
won't get better resolution.
If someone else knows an alternative solution PLEASE let me know too.
I've seen this discussed several times (not on this list) and I'm not
aware of any solution... Java uses Win9x's timer and it's not very
accurate.
- John Wright
Starfire Research
(Dave - I'm bcc'ing you on this so it arrives to you faster).
Dave - sub-note: For our player we update at 20 times per second, but we
only update NPC movement at 10 times per second. It may not be
perfectly smooth but it's decent enough for playing.
David wrote:
>
> We do our view changes and animations per frame, using elapsed time to
> calculate rotations in degrees/sec and movements in meters/sec. That way
> our scene stays consistant even if frame rates drop. But I had long felt
> things were not as smooth as they could be and never looked into it until
> now. Turns out that we are getting elapsed time from one frame to another
> of zero very often, causing our scene to be rendered exactly the same as
> several frames in a row, then a draw a new frame then a few copies, etc.
It
> looks like at around 50 fps, I am getting 3 dups for every 1 real frame
> recalc. Course everything still looks right, but I am losing 3 steps of
> smoothness.
>
> For example if I am rotating my view at 90 degrees per second I am doing
> that in N steps, instead of N*4 steps, thus the rotation is not as smooth
as
> it should be.
>
> At 50 fps, I am calculating a frame every 20 ms. I thought the
> System.currentTimeMillis() had a resolution of 5ms, but it looks like I am
> dead wrong. The numbers below look like 60ms, but its probably 50ms. How
> can I get the time to a better resolution?
>
> Dave Yazel
>
> In printing out the time stamps I get this:
>
> Frame got elapsed time of zero (last=983725910240, cur=983725910240 [1 min
7
> sec, 55mb]
> Frame got elapsed time of zero (last=983725910290, cur=983725910290 [1 min
7
> sec, 55mb]
> Frame got elapsed time of zero (last=983725910290, cur=983725910290 [1 min
7
> sec, 55mb]
> Frame got elapsed time of zero (last=983725910350, cur=983725910350 [1 min
7
> sec, 55mb]
> Frame got elapsed time of zero (last=983725910350, cur=983725910350 [1 min
7
> sec, 55mb]
> Frame got elapsed time of zero (last=983725910350, cur=983725910350 [1 min
7
> sec, 55mb]
> Frame got elapsed time of zero (last=983725910400, cur=983725910400 [1 min
7
> sec, 55mb]
> Frame got elapsed time of zero (last=983725910400, cur=983725910400 [1 min
7
> sec, 55mb]
> Frame got elapsed time of zero (last=983725910400, cur=983725910400 [1 min
7
> sec, 55mb]
> Frame got elapsed time of zero (last=983725910400, cur=983725910400 [1 min
7
> sec, 55mb]
> Frame got elapsed time of zero (last=983725910460, cur=983725910460 [1 min
7
> sec, 55mb]
> Frame got elapsed time of zero (last=983725910460, cur=983725910460 [1 min
7
> sec, 55mb]
> Frame got elapsed time of zero (last=983725910460, cur=983725910460 [1 min
7
> sec, 55mb]
> Frame got elapsed time of zero (last=983725910510, cur=983725910510 [1 min
7
> sec, 55mb]
> Frame got elapsed time of zero (last=983725910510, cur=983725910510 [1 min
7
> sec, 55mb]
>
>
===========================================================================
> 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".
===========================================================================
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".
===========================================================================
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".