Created
December 20, 2012 00:14
-
-
Save talklittle/4341953 to your computer and use it in GitHub Desktop.
the libgdx render code for MD2 model used in Frog Ball
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// private KeyframedModel currentModel; | |
// use ModelLoaderRegistry.loadKeyframedModel() to load MD2 models | |
// in render(): | |
if (currentModel != desiredModel) { | |
currentModel = desiredModel; | |
animationTime = 0; | |
} | |
// fixed value for MD2 exporter from | |
// http://www.junaio.com/develop/docs/documenation/general/3dmodels/ | |
String animation = "all"; | |
animationTime += Gdx.graphics.getDeltaTime(); | |
float totalDuration = currentModel.getAnimation(animation).totalDuration; | |
if (loop) { | |
while (animationTime > totalDuration) | |
animationTime -= totalDuration; | |
} | |
else { | |
if (animationTime > totalDuration) | |
animationTime = totalDuration - 0.000001f; // libgdx crash when animationTime == totalDuration | |
} | |
currentModel.setAnimation(animation, animationTime, loop); | |
currentModel.render(shader); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment