将Blender动画加载到libGDX

将Blender动画加载到libGDX,libgdx,blender,Libgdx,Blender,嗨,Blender&libGDX大师 我正在尝试将blender动画加载到android应用程序的libGDX中。所以我用Blenders动作编辑器创建了一个动画,我将其导出为.fbx格式。然后我运行了fbx conv工具来创建一个.G3DB文件。然后,我继续使用modelLoader将该文件上传到libGDX中 一切似乎都正常(我没有收到任何错误消息),只是屏幕是空白的我看不到任何动画或模型 我已经在运行kitkat的三星galaxy平板电脑、运行棉花糖的nexus手机和模拟器上运行了这段代码

嗨,Blender&libGDX大师

我正在尝试将blender动画加载到android应用程序的libGDX中。所以我用Blenders动作编辑器创建了一个动画,我将其导出为.fbx格式。然后我运行了fbx conv工具来创建一个.G3DB文件。然后,我继续使用modelLoader将该文件上传到libGDX中

一切似乎都正常(我没有收到任何错误消息),只是屏幕是空白的我看不到任何动画或模型

我已经在运行kitkat的三星galaxy平板电脑、运行棉花糖的nexus手机和模拟器上运行了这段代码,但结果相同

我浏览了教程,正在使用一些代码上传我的一个搅拌机模型。我还是搞不清楚,我需要帮助才能弄清楚

任何帮助都将不胜感激

以下是搅拌机文件的链接:

这是我在libGDX中上传模型的代码。我基本上是在使用教程中的代码

@Override
public void create () {

    // Create camera sized to screens width/height with Field of View of 75 degrees
    camera = new PerspectiveCamera(
            75,
            Gdx.graphics.getWidth(),
            Gdx.graphics.getHeight());

    // Move the camera 5 units back along the z-axis and look at the origin
    camera.position.set(0f,0f,7f);
    camera.lookAt(0f,0f,0f);

    // Near and Far (plane) represent the minimum and maximum ranges of the camera in, um, units
    camera.near = 0.1f;
    camera.far = 300.0f;
    camera.update();

    // A ModelBatch  to batch up geometry for OpenGL
    modelBatch = new ModelBatch();

    // Model loader needs a binary json reader to decode
    UBJsonReader jsonReader = new UBJsonReader();
    // Create a model loader passing in our json reader
    G3dModelLoader modelLoader = new G3dModelLoader(jsonReader);
    // Now load the model by name
    // Note, the model (g3db file ) and textures need to be added to the assets folder of the Android proj
    model = modelLoader.loadModel(Gdx.files.getFileHandle("AnimatedLowPolyHorseStageFenced_Ver5.g3db", Files.FileType.Internal));
    // Now create an instance.  Instance holds the positioning data, etc of an instance of your model
    modelInstance = new ModelInstance(model);

    //fbx-conv is supposed to perform this rotation for you... it doesnt seem to
    modelInstance.transform.rotate(1, 0, 0, -90);
    //move the model down a bit on the screen ( in a z-up world, down is -z ).
    modelInstance.transform.translate(0, 0, -2);

    // Finally we want some light, or we wont see our color.  The environment gets passed in during
    // the rendering process.  Create one, then create an Ambient ( non-positioned, non-directional ) light.
    environment = new Environment();
    environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.8f, 0.8f, 0.8f, 1.0f));
    environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.2f));

    // You use an AnimationController to um, control animations.  Each control is tied to the model instance
    controller = new AnimationController(modelInstance);
    // Pick the current animation by name

    controller.setAnimation("Armature|ArmatureAction",1, new AnimationListener(){

        @Override
        public void onEnd(AnimationDesc animation) {
            // this will be called when the current animation is done.
            // queue up another animation called "balloon".
            // Passing a negative to loop count loops forever.  1f for speed is normal speed.
            //controller.queue("Armature|ArmatureAction",-1,1f,null,0f);
        }

        @Override
        public void onLoop(AnimationDesc animation) {
            // TODO Auto-generated method stub

        }

    });

}

@Override
public void resize(int width, int height) {
    super.resize(width, height);
}

@Override
public void render () {
    Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    //Gdx.gl.glClearColor(1, 1, 1, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);

    // For some flavor, lets spin our camera around the Y axis by 1 degree each time render is called

    // You need to call update on the animation controller so it will advance the animation.  Pass in frame delta
    controller.update(Gdx.graphics.getDeltaTime());
    // Like spriteBatch, just with models!  pass in the box Instance and the environment
    modelBatch.begin(camera);
    modelBatch.render(modelInstance, environment);
    modelBatch.end();
}

当使用fbxconv转换为G3DB时,您会收到警告, “网格包含具有零骨骼权重的顶点”

请尝试以下步骤: -向混合添加新骨骼 -将其连接到非动画(或所有)顶点 -转口及转换

如果仍然收到警告,请重复,但将新骨骼连接到所有顶点

我知道这是一个老问题,但我最近遇到了一个类似的问题,这个问题解决了