我已經使用Blender和fbxconv創建了一個.g3db動畫文件。現在,我的libGDX項目源代碼看起來是這樣的:libGDX:3d動畫無效
public class test implements ApplicationListener {
// ...
public ModelInstance fred
public AnimationController animationController;
public void create() {
modelBatch = new ModelBatch();
// ...
assets = new AssetManager();
assets.load("data/fred.g3db", Model.class);
loading = true;
}
private void doneLoading() {
Model fredData = assets.get("data/fred.g3db", Model.class);
fred = new ModelInstance(fredData);
animationController = new AnimationController(fred);
animationController.animate(fred.animations.get(0).id, -1, 1f, null, 0.2f);
loading = false;
}
public void render() {
if (loading && assets.update())
doneLoading();
camController.update();
Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
if(!loading) {
animationController.update(10);
modelBatch.begin(cam);
modelBatch.render(fred,lights);
modelBatch.end();
}
}
// [...]
}
當我打開這個遊戲,模型完美展現,但沒有動畫的。我對libGDX遊戲編程比較陌生,所以我沒有任何想法,我可能會出錯。有任何想法嗎?
(我不知道這事做任何事情,但是當我轉換使用fbxconv FBX文件,我得到了幾個警告,都在尋找這樣的:
WARNING: Node XXX uses RrSs mode, transformation might be incorrect.
但如果我閱讀有關此警告是真的,它不應該實際上導致任何問題...)
您是否啓用OpenGL ES2.0?也可以看看:https://github.com/libgdx/libgdx/wiki/3D-animations-and-skinning。您應該將delta值提供給animationController.update()。如果您使用攪拌器來創建FBX文件,則可以放心地忽略RrSs警告。 – Xoppa
Woah謝謝,使OpenGL ES2.0實際上做到了。如果您發佈這個答案,我會接受它! – vauge