Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (687)
Games in Android Showcase (198)
games submitted by our members
Games in WIP (759)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Animation and frame-rate  (Read 2181 times)
0 Members and 1 Guest are viewing this topic.
Offline Breakfast

Senior Devvie

for great justice!

« Posted 2003-03-10 08:28:47 »

Any regulars on this forum will probably be aware I've been working on getting stuff animated and moving about. The trouble I'm having now is that I can't work out how much to transform the animated TransformGroup by to ensure standard speed. My little dude walks about quite happily - an AWTEvent starts the movement, which runs every frame while the key is down, a morphbehaviour animates the figure and  the transformGroup is transformed slightly every frame. The trouble comes with either changing the environment complexity or running the code on a different machine which seems to make the movement stupidly slow (the morph animation keeps going at about the same rate, I'm guessing cos it is based on an Alpha)  - I'm assuming that the FPS is falling so that I am getting fewer Transforms per second.

Does anyone know a good way to calculate how large a step needs to be depending on the framerate, or a good alternative way of moving the character about that doesn't depend on the framerate?
Offline Herkules

Senior Devvie

Friendly fire isn't friendly!

« Reply #1 - Posted 2003-03-10 08:42:58 »

Not sure wether I got your problem.....

 dx = v * dt?

But if frametimes vary unexpectedly (a common problem of java games),  there's no way to keep animation smooth.

HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
Offline Breakfast

Senior Devvie

for great justice!

« Reply #2 - Posted 2003-03-10 11:33:28 »

I'm afraid it was the second of those that was bothering me- I was wondering whether therre was a good way of basing the transform change on time rather than on framerate- would that work? If so what would be the best way to do it?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline zero

Junior Devvie

« Reply #3 - Posted 2003-03-11 06:18:29 »

I'd change transformation over time:

do a call to deltaTime every frame:

private boolean init = false;
private long lastTime = 0;

private long deltaTime() {
      if(!init) {
            this.lastTime = J3DTimer.getValue();
            this.init = true;
       long actualTime = J3DTimer.getValue();
       long deltaTime   = actualTime - this.lastTime;
       this.lastTime      = actualTime;
       return deltaTime
Offline Conzar

Junior Devvie

There is nothing common about common sense

« Reply #4 - Posted 2003-03-11 14:20:18 »

Speaking of FrameRate, how is that determined in Java?  Is there an method that you can call to get the current frame rate, ect?

Offline Herkules

Senior Devvie

Friendly fire isn't friendly!

« Reply #5 - Posted 2003-03-11 14:36:52 »


do a call to deltaTime every frame:

Doesn't help anything bc. this measures the time of the LAST frame but give you no idea how long the next frame will take. And that is the frame you calculate the motion for.

For many environments, there is a good coherence between frames so that the deltaT of the last frame is a very good approximation for the coming frame. If that coeherence is not given - as it is for Java - animations are no longer smooth, regardless how exact you can measure time.

- J

HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
Offline bmyers

Junior Devvie

« Reply #6 - Posted 2003-03-11 14:54:15 »

If you need to tie an animation to time explicitly, regardless of the framerate, and regardless of skips, pauses, etc, then you could use an Alpha and base your transformation (either morph weights or key frame index) on the Alpha value.  This would be the case for physics-based animations that are tied to elapsed time in the physics model.  Or if you don't need to animate every frame.

Or you could roll your own Alpha-like behavior and keep track of the timing yourself if you need hi-res timing -- plenty of threads on this!

Depends on your needs.  I've been using Alphas and been pretty happy with them in general.  But the game I'm not working on is not an action game.  YRMV...


Offline Breakfast

Senior Devvie

for great justice!

« Reply #7 - Posted 2003-03-11 15:22:02 »

I'm using alphas to animate the character, so it moves it's limbs at a perfectly regular rate, I was just transforming it every frame to do the movement so when the framerate dropped so did the speed of the character moving across the environment. I think zero's solution will work best- I'll look at this tonight.
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

roseslayer (634 views)
2016-08-06 11:43:29

roseslayer (587 views)
2016-08-06 09:43:11

xTheGamerCodes (660 views)
2016-08-04 15:40:59

xTheGamerCodes (651 views)
2016-08-04 15:40:24

orrenravid (999 views)
2016-07-16 03:57:23

theagentd (1078 views)
2016-07-11 14:28:54

Hydroque (1190 views)
2016-07-06 05:56:57

Hydroque (1105 views)
2016-07-03 08:52:54

GrandCastle (916 views)
2016-07-01 09:13:47

GrandCastle (655 views)
2016-07-01 09:09:45
Rendering resources
by Roquen
2016-08-08 05:55:21

Rendering resources
by Roquen
2016-08-08 05:52:42

Rendering resources
by Roquen
2016-08-08 05:50:38

Rendering resources
by Roquen
2016-08-08 05:49:53

Rendering resources
by Roquen
2016-08-08 05:32:39

Making a Dynamic Plugin System
by Hydroque
2016-06-25 00:13:25

Java Data structures
by BinaryMonkL
2016-06-13 21:22:09

Java Data structures
by BinaryMonkL
2016-06-13 21:20:42 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!