Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (578)
games submitted by our members
Games in WIP (499)
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 1288 times)
0 Members and 1 Guest are viewing this topic.
Offline Breakfast

Senior Member




for great justice!


« Posted 2003-03-10 09: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 Member




Friendly fire isn't friendly!


« Reply #1 - Posted 2003-03-10 09: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 Member




for great justice!


« Reply #2 - Posted 2003-03-10 12: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 Member





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

I'd change transformation over time:

do a call to deltaTime every frame:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
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 Member




There is nothing common about common sense


« Reply #4 - Posted 2003-03-11 15: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?

Ubuntu
Offline Herkules

Senior Member




Friendly fire isn't friendly!


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

Quote

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 Member





« Reply #6 - Posted 2003-03-11 15: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...

--Brad

Offline Breakfast

Senior Member




for great justice!


« Reply #7 - Posted 2003-03-11 16: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.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (28 views)
2014-04-15 18:08:23

BurntPizza (25 views)
2014-04-15 03:46:01

UprightPath (40 views)
2014-04-14 17:39:50

UprightPath (22 views)
2014-04-14 17:35:47

Porlus (38 views)
2014-04-14 15:48:38

tom_mai78101 (62 views)
2014-04-10 04:04:31

BurntPizza (121 views)
2014-04-08 23:06:04

tom_mai78101 (221 views)
2014-04-05 13:34:39

trollwarrior1 (188 views)
2014-04-04 12:06:45

CJLetsGame (195 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org 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‑gaming.org
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!