libGDX:3d 动画不起作用 [英] libGDX: 3d animation not working
问题描述
我使用 Blender 和 fbxconv 创建了一个 .g3db 动画文件.现在,我的 libGDX 项目源代码如下所示:
I've created a .g3db animation file using Blender and fbxconv. Now, my libGDX project source code looks something like this:
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 游戏编程比较陌生,所以我不知道我哪里出错了.有什么想法吗?
When I open this game, the model shows up perfectly, but there's no animation at all. I'm relatively new to libGDX game programming, so I have no ideas where I could have gone wrong. Any ideas?
(我不知道这是否与任何事情有关,但是当我使用 fbxconv 转换 fbx 文件时,我收到了几个警告,看起来像这样:
(I don't know if this has something to do with anything, but when I converted the fbx file using fbxconv, I got several warnings, all looking like this:
WARNING: Node XXX uses RrSs mode, transformation might be incorrect.
但是如果我读到的关于这个警告的信息是真的,它实际上应该不会引起任何问题......)
But if what I read about this warning is true, it shouldn't actually cause any problems...)
推荐答案
您是否启用了 OpenGL ES2.0?也看看:https://github.com/libgdx/libgdx/wiki/3D-animations-and-skinning.您应该向 animationController.update() 提供增量值.如果您使用 Blender 创建 FBX 文件,则可以放心地忽略 RrSs 警告.
Did you enable OpenGL ES2.0? Also have a look at: https://github.com/libgdx/libgdx/wiki/3D-animations-and-skinning. You should provide the delta value to animationController.update(). If you used blender to create the FBX file, you can safely ignore the RrSs warning.
这篇关于libGDX:3d 动画不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!