[英]LibGDX - Unknown animation error
我正在libgdx上开发应用程序,并且尝试播放在Blender上创建的动画,但是我仍然遇到未知的动画错误。 我的create方法中有以下代码:
model = modelLoader.loadModel(Gdx.files.getFileHandle("i1.g3db", FileType.Internal));
modelInstance = new ModelInstance(model);
modelInstance.transform.rotate(1, 0, 0, -90);
modelInstance.transform.translate(0, 0, -2);
controller = new AnimationController(modelInstance);
controller.setAnimation("moveHand",1);
这在我的render方法中:
camera.update();
camController.update();
controller.update(Gdx.graphics.getDeltaTime());
modelBatch.begin(camera);
modelBatch.render(modelInstance, environment);
modelBatch.end();
我试图删去与这个问题无关的部分。 这是Blender中的摄影表的图片,显示我已经适当地命名了动画:
任何人都知道可能是什么问题,原因是我被这个问题困扰了很长时间,谢谢! 如果有人想要打开动画文件(.g3db,.blender),请在此处上传:
一般说明:避免在动画名称中使用大写字母(和空格等)。 另请检查https://github.com/libgdx/libgdx/wiki/3D-animations-and-skinning以获取有关动画和https://github.com/libgdx/libgdx/wiki/Importing-Blender-models-in的更多信息-LibGDX有关在LibGDX中使用Blender模型的信息。
使用fbx-conv
的-o G3DJ
命令行选项将文件转换为.g3dj,例如fbx-conv -f -o G3DJ i1.fbx
(其中-f
用于翻转纹理坐标)。 确保更新您的代码以使用此G3DJ文件而不是以前的G3DB文件。 接下来,使用文本编辑器(例如记事本或ide / eclipse的文本编辑器)打开生成的.g3dj文件。 该文件应易于阅读(有关如何读取该文件的更多信息,请参见http://blog.xoppa.com/behind-the-3d-scenes-part1/ ),并包含一个名为animations
的部分(json键)。
如果文件中没有动画,则文件底部应看起来像"animations": []
。 在这种情况下,请确保选中要在Blender中导出动画。 另请参阅: https : //github.com/libgdx/libgdx/wiki/Importing-Blender-models-in-LibGDX
如果文件中有动画,它们将包含在数组内(在"animations": [
之间"animations": [
和]
)。 请注意,动画可能会占用很多空间,因此实际的"animations": [
可能位于文件中间的某个位置。 在这种情况下,请确保动画的名称( id
)与用于指定动画的字符串完全匹配。
如果动画包含在文件中并且字符串匹配,则枚举model / modelinstance内部的所有动画以确保正确加载它们:
for (Animation anim : modelInstance.animations)
Gdx.app.log("Animation", anim.id);
如果动画未包含在modelInstance
,请在此代码段中将modelInstance替换为model
,以确保动画已包含在模型中。 如果模型中也没有包含它,请确保刷新/清理您的工作区。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.