Skip to content

ClassCastException in FbxBindPose.fromElement() #1932

Closed
@stephengold

Description

@stephengold

I'm testing current "master" branch with FBX assets downloaded from CGtrader, Mixamo, and Sketchfab.
Attempting to import a certain FBX file causes the following crash:

Jan 28, 2023 11:34:36 PM com.jme3.app.LegacyApplication handleError
SEVERE: Uncaught exception thrown in Thread[jME3 Main,5,main]
java.lang.ClassCastException: class java.lang.Double cannot be cast to class [D (java.lang.Double and [D are in module java.base of loader 'bootstrap')
	at com.jme3.scene.plugins.fbx.anim.FbxBindPose.fromElement(FbxBindPose.java:65)
	at com.jme3.scene.plugins.fbx.obj.FbxObjectFactory.createObject(FbxObjectFactory.java:192)
	at com.jme3.scene.plugins.fbx.FbxLoader.loadObjects(FbxLoader.java:195)
	at com.jme3.scene.plugins.fbx.FbxLoader.loadData(FbxLoader.java:161)
	at com.jme3.scene.plugins.fbx.FbxLoader.load(FbxLoader.java:110)
	at com.jme3.asset.DesktopAssetManager.loadLocatedAsset(DesktopAssetManager.java:272)
	at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:388)
	at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:439)
	at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:444)
	at jme3test.helloworld.HelloJME3.loadModel(HelloJME3.java:88)
	at jme3test.helloworld.HelloJME3.simpleInitApp(HelloJME3.java:67)
	at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:240)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:139)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:221)
	at java.base/java.lang.Thread.run(Thread.java:833)

The code in "FbxBindPose.java" assumes that the bind pose will come in the form of 16 properties of type Double, but the FBX format also allows it to be in the form of a single property of type Double[]. The FBX importer should handle both possibilities.

There's a similar issue in "FbxCluster.java", where the fromElement() method assumes weights and indexes will come in the form of array properties, but the FBX format also allows them each to be multiple properties. Let's solve those issues as well!

Metadata

Metadata

Assignees

No one assigned

    Labels

    defectSomething that is supposed to work, but doesn't. Less severe than a "bug"

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions