Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (576)
games submitted by our members
Games in WIP (497)
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  
  Problems with key-framed (MD2) animations  (Read 1378 times)
0 Members and 1 Guest are viewing this topic.
Offline gouessej

« In padded room »



TUER


« Posted 2013-04-23 01:22:21 »

Hi

When I try to use a MD2 model on a very slow machine (then I have a low frame rate), the very last interpolation seems wrong, the model looks weird, especially when dying. This bug is reproducible with JMonkeyEngine 2 and Ardor3D:

Have you ever had the same problem?

The source code of the key frame controller is here:
https://github.com/Renanse/Ardor3D/blob/master/ardor3d-extras/src/main/java/com/ardor3d/extension/model/util/KeyframeController.java

The delta is always in [0;1]. I wonder if the variable containing the index of the next frame can take a wrong value, for example the first frame of the next part would be picked instead of the last frame of the current part.

Offline Riven
« League of Dukes »

JGO Overlord


Medals: 605
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #1 - Posted 2013-04-23 02:45:07 »

I'm sure there already was a thread about this, right? persecutioncomplex

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 605
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #2 - Posted 2013-04-23 03:12:45 »

if you look at line 436 you'll see that the author already tried to fix this case. my assumption is the bug is in findFrame. why not do some system-out's (or breakpoints) when _curFrame and _nextFrame are assigned. the business logic there seems like it can miss several edge cases.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Online Stranger

Senior Member


Medals: 6



« Reply #3 - Posted 2013-04-23 08:43:08 »

I wonder if the variable containing the index of the next frame can take a wrong value, for example the first frame of the next part would be picked instead of the last frame of the current part.
Looks like that. Suspicious lines:

630                 _nextFrame = 1;
...
639                 for (_nextFrame = 0; _nextFrame < _keyframes.size() - 1; _nextFrame++) {

Anton
Offline gouessej

« In padded room »



TUER


« Reply #4 - Posted 2013-04-23 10:50:35 »

Thank you for your help. I'm going to give it another try tonight. I think that it would be better if I kept a laptop with me to make some tests during my pause at work but my battery is broken.

Edit.: I don't call setSmoothTranslation in my case, _isSmooth is then always set to false.

Online Stranger

Senior Member


Medals: 6



« Reply #5 - Posted 2013-04-23 18:10:03 »

I think _nextFrame < _keyframes.size() should be in line 639 (and 671 too):

1  
2  
3  
4  
5  
6  
//line 639 
for (_nextFrame = 0; _nextFrame < _keyframes.size() - 1; _nextFrame++) {
    if (getMinTime() <= _keyframes.get(_nextFrame)._time) {
        break;
    }
}

Anton
Offline gouessej

« In padded room »



TUER


« Reply #6 - Posted 2013-04-23 23:55:55 »

I get this: http://pastebin.java-gaming.org/f809147595e

Offline gouessej

« In padded room »



TUER


« Reply #7 - Posted 2013-04-24 00:37:11 »

Stranger's suggestion doesn't work.

I get this with some more logs:
delta:3.3000550600000054 _curTime:53.300055060000005 _curFrame:50 _nextFrame:51 _before._time:50.0 _after._time51.0 minTime:46.0 maxTime:53.0

delta is a lot too big, it can only produce something completely absurd.

Offline gouessej

« In padded room »



TUER


« Reply #8 - Posted 2013-04-24 00:48:48 »

The problem seems to come from delta and _curTime. When "time" is too big (low frame rate -> big period), the interpolations are wrong. Forcing the delta to keep between -1 and 1 almost fixed the bug but animations are stopped before their end :s

Offline Riven
« League of Dukes »

JGO Overlord


Medals: 605
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #9 - Posted 2013-04-24 00:52:40 »

Whatever the delta is, the logic should never allow the 'cursor' to go beyond its allowed range.

IMHO the implementation is very messy, and it could be replaced with a much simpler version that simply steps through the frames one at a time (like a doubly linked list, to support going backwards) , taking into account RepeatType when choosing the next frame.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline gouessej

« In padded room »



TUER


« Reply #10 - Posted 2013-04-24 11:21:22 »

This class was not designed to support this case, in which the passed time is so big that it is longer than the time required to play all animations of a frame set. My animations would look a bit unregular without morphing, wouldn't it? I ws too lazy to rewrite this class, maybe I will have to do so.

Offline gouessej

« In padded room »



TUER


« Reply #11 - Posted 2013-04-24 14:17:30 »

Riven, you're probably right, the bug comes from findFrame. Look at this case:
delta:3.3000550600000054 _curTime:53.300055060000005 _curFrame:50 _nextFrame:51 _before._time:50.0 _after._time51.0 minTime:46.0 maxTime:53.0

This happens at the end of an attack. _curTime becomes bigger than _maxTime and findFrame just does that:
line 631
1  
if (_curTime > getMaxTime()) {

line 652
1  
2  
} else if (getRepeatType() == ComplexSpatialController.RepeatType.CLAMP) {
                return;


It should clamp _curTime to _maxTime if _movingForward is set to true instead of allowing the morphing code to use _curTime as is.

Offline Riven
« League of Dukes »

JGO Overlord


Medals: 605
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #12 - Posted 2013-04-24 14:41:27 »

That whole class desperately needs a complete overhaul, but I guess you can simple tell Renanse to patch it Smiley

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline gouessej

« In padded room »



TUER


« Reply #13 - Posted 2013-04-24 16:19:34 »

Then I have to provide the patch  Sad

Offline gouessej

« In padded room »



TUER


« Reply #14 - Posted 2013-04-24 20:52:39 »

This seems to work:
1  
2  
3  
4  
double localMinTime = Math.min(_before._time, _after._time);
          double localMaxTime = Math.max(_before._time, _after._time);
          double clampedCurTime = Math.max(localMinTime, Math.min(_curTime, localMaxTime));
          double delta = (clampedCurTime - _before._time) / (_after._time - _before._time);

but the weapon stays above the dead guy  Sad

Offline gouessej

« In padded room »



TUER


« Reply #15 - Posted 2013-04-24 21:18:43 »

I forgot that weapons have only 173 frames (less than enemies).

Offline gouessej

« In padded room »



TUER


« Reply #16 - Posted 2013-04-24 21:32:15 »

I have fixed this bug with your help, thank you very much. I will make a pull request as soon as possible. I'm very happy as this class is very important for my game, I don't want to use skeletal animations yet.

Offline gouessej

« In padded room »



TUER


« Reply #17 - Posted 2013-04-24 22:06:01 »

The pull request is here:
https://github.com/Renanse/Ardor3D/pull/44

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 (14 views)
2014-04-15 18:08:23

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

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

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

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

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

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

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

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

CJLetsGame (184 views)
2014-04-01 02:16:10
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

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:05:20
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!