vau*_*uge 1 java 3d animation libgdx
我使用Blender和fbxconv创建了一个.g3db动画文件.现在,我的libGDX项目源代码看起来像这样:
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();
}
}
// [...]
}
Run Code Online (Sandbox Code Playgroud)
当我打开这个游戏时,模型显示完美,但根本没有动画.我对libGDX游戏编程比较陌生,所以我不知道哪里可能出错了.有任何想法吗?
(我不知道这是否与任何事情有关,但是当我使用fbxconv转换fbx文件时,我收到了几个警告,所有这些都是这样的:
WARNING: Node XXX uses RrSs mode, transformation might be incorrect.
Run Code Online (Sandbox Code Playgroud)
但如果我读到的关于这个警告的内容是真的,它实际上不应该导致任何问题...)
你启用了OpenGL ES2.0吗?另请参阅:https://github.com/libgdx/libgdx/wiki/3D-animations-and-skinning.您应该为animationController.update()提供delta值.如果您使用blender创建FBX文件,则可以安全地忽略RrSs警告.
| 归档时间: |
|
| 查看次数: |
2546 次 |
| 最近记录: |