libgdx / fbx-conv

Command line utility using the FBX SDK to convert FBX/Collada/Obj files to a custom text/binary format for static, keyframed and skinned meshes.
Apache License 2.0
447 stars 117 forks source link

empty indices caused whole game crash issue #58

Closed xeoshow closed 10 years ago

xeoshow commented 10 years ago

Hi,

I found if there is empty indeces node in in my g3db file, it will cause the whole game to be crashed. Not sure if it is possbile to just spit some warning info, and take the empty node as "nothing" and continue?

Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: Not enough indices at com.badlogic.gdx.graphics.Mesh.extendBoundingBox(Mesh.java:659) at com.badlogic.gdx.graphics.g3d.model.Node.extendBoundingBox(Node.java:126) at com.badlogic.gdx.graphics.g3d.model.Node.extendBoundingBox(Node.java:114) at com.badlogic.gdx.graphics.g3d.ModelInstance.extendBoundingBox(ModelInstance.java:394) at com.badlogic.gdx.graphics.g3d.ModelInstance.calculateBoundingBox(ModelInstance.java:384)

xoppa commented 10 years ago

Would you mind to provide a test fbx file to reproduce the issue (and to test a fix)?

xeoshow commented 10 years ago

How could I send to you? looks like github can not upload file? In the g3dj file, it will contains data like below:

            }, 
            {
                "id": "shape3_part1", 
                "type": "TRIANGLES", 
                "indices": []
            }, 
            {
                "id": "shape3_part2", 
                "type": "TRIANGLES", 
                "indices": [
                     1151,  1152,  1153,  1153,  1154,  1151,  1152,  1151,  1155,  1155,  1156,  1152, 
                     1157,  1152,  1156,  1156,  1158,  1157,  1159,  1153,  1152,  1152,  1157,  1159, 
                     1160,  1161,  1162,  1163,  1164,  1165,  1166,  1167,  1168,  1169,  1167,  1166
                ]
            }, 
            {
xeoshow commented 10 years ago

And the full log trace:

Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: Not enough indices ( offset=3786, count=0, max=3858 ) at com.badlogic.gdx.graphics.Mesh.extendBoundingBox(Mesh.java:661) at com.badlogic.gdx.graphics.g3d.model.Node.extendBoundingBox(Node.java:126) at com.badlogic.gdx.graphics.g3d.model.Node.extendBoundingBox(Node.java:114) at com.badlogic.gdx.graphics.g3d.ModelInstance.extendBoundingBox(ModelInstance.java:394) at com.badlogic.gdx.graphics.g3d.ModelInstance.calculateBoundingBox(ModelInstance.java:384) ...... at com.badlogic.gdx.scenes.scene2d.utils.ClickListener.touchUp(ClickListener.java:89) at com.badlogic.gdx.scenes.scene2d.InputListener.handle(InputListener.java:57) at com.badlogic.gdx.scenes.scene2d.Stage.touchUp(Stage.java:272) at com.badlogic.gdx.InputMultiplexer.touchUp(InputMultiplexer.java:94) at com.badlogic.gdx.backends.lwjgl.LwjglInput.processEvents(LwjglInput.java:305) at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:199) at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:114)

xeoshow commented 10 years ago

This happened when calculating boundingbox, while I think we could safely ignore the "indices": [] and just give some warning info...

xoppa commented 10 years ago

looks like github can not upload file?

You cannot attach a file to an issue, but you can push files to your repo and link them. Because it are text files, you could also use github gist (https://gist.github.com/). Alternatively you could use a service like dropbox or pastebin.

This happened when calculating boundingbox, while I think we could safely ignore the "indices": [] and just give some warning info...

Obviously the easiest solution is to not throw an exception when the mesh part size=0 when calculating the bounding box. However, imo fbx-conv should not generate a meshpart when there's no geometry (which is what indices: [] implies). To fix this, I'll need an fbx file to reproduce the problem and check if a possible solution really fixes it.

xeoshow commented 10 years ago

Here it is: https://www.dropbox.com/s/qkj4uuwge86tnfa/car.FBX

xeoshow commented 10 years ago

Actually such empty indices are just created by 3ds max by unknown reason and seems totally useless, so hopefully it could be completely ignored by your new solution and minimized the g3db file size...

Thanks!

xoppa commented 10 years ago

Thanks for reporting. Apparently the nodes back_light_left (with space suffix) and back_light_right contain a reference to the material initialShadingGroup while no polygons attached to it. This fix should skip these parts in the created g3dx file. Given the cause of this problem, I'd expect that you should be able to see (and remove) this reference in your modeling application as well (one obvious method would be to remove the material, since it is not used for any other part either).

xeoshow commented 10 years ago

Thanks for fixing! While I tried version on 24-Jul-2014 17:39, still the same error...

http://libgdx.badlogicgames.com/fbx-conv/ fbx-conv.zip 24-Jul-2014 17:39 12257662

xoppa commented 10 years ago

It looks like there's currently an issue with the windows build slave, causing it not to pull in changes.

xeoshow commented 10 years ago

Not sure if the issue of windows build is fixed? Hopefully could test the new version, since there are many models need to be verified, thanks!