Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix fbxloader error #11956

Closed
wants to merge 1,263 commits into from
Closed

fix fbxloader error #11956

wants to merge 1,263 commits into from

Conversation

FishOrBear
Copy link
Contributor

@FishOrBear FishOrBear commented Aug 15, 2017

Drawing1.zip
Fixed an error.
The error caused fbx not to be imported properly.

#9860

@FishOrBear FishOrBear mentioned this pull request Aug 15, 2017
12 tasks
@@ -4010,7 +4010,10 @@
while ( ! this.endOfContent( reader ) ) {

var node = this.parseNode( reader, version );
if ( node !== null ) allNodes.add( node.name, node );
if ( node !== null )
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about reversing it?

if ( node === null ) break;
allNodes.add( node.name, node );

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice.
I have modified pr

@takahirox
Copy link
Collaborator

Let me review if this fix is correct.

@mrdoob mrdoob requested a review from takahirox August 16, 2017 01:47
@takahirox
Copy link
Collaborator

takahirox commented Aug 16, 2017

It doesn't seem this change is correct.
With Drawing1.fbx, this change makes FBXLoader break a loop at a certain point in the binary file but there still be some data following the point.
This means FBXLoader loses some data.

Probably "Unknown property type" isn't a root issue.
There seems being another root issue which causes it.
I'm taking a look closer...

@FishOrBear
Copy link
Contributor Author

FishOrBear commented Aug 16, 2017

3dmax before exporting
image
After import

image

There is also a problem that causes the imported grid to appear incorrectly.

test.zip

tv.zip

@takahirox

@takahirox
Copy link
Collaborator

Thanks for reporting. Would you please check if there's any existing similar/same issue threads and open another issue for that if there isn't?

@FishOrBear
Copy link
Contributor Author

@takahirox
Find 2 related questions.

#11697 #11895

I copied the wrong instance file to #11895

@takahirox
Copy link
Collaborator

takahirox commented Aug 16, 2017

If I'm right, Drawing1.fbx includes two combined FBX files...?
I found two end footers in the file, one is from 0x4160 and the other one is from 0x4440.

How was this file generated?

@FishOrBear
Copy link
Contributor Author

FishOrBear commented Aug 16, 2017

@takahirox
This is the AutoCAD2016 export fbx file.
If I quit in the middle, then the entity is loaded normally.

@takahirox
Copy link
Collaborator

If I quit in the middle

What do you mean by that?

@FishOrBear
Copy link
Contributor Author

Sorry, this is the result of Google translation, may be somewhat misleading.

That is, if i follow my code.
It can load the model correctly.

That is to say

If (null === node) // exit. (If I quit in the middle) (google translation error)

@takahirox

@takahirox
Copy link
Collaborator

takahirox commented Aug 16, 2017

OK. Let me explain what I mentioned again.

FBX binary has 16-byte end-footer in the end of the file.

0xf8 0x5a 0x8c 0x6a 0xde 0xf5 0xd9 0x7e 0xec 0xe9 0x0c 0xe3 0x75 0x8f 0x29 0x0b

But Drawing1.fbx has two footers, at address 0x4160 and 0x4440.
I suppose Drawing1.fbx includes two FBX data.
Probably you can load without any FBXLoader change if you cut the second data.

I'm really not sure if this "two (or more) combined data in one file" is proper FBX specification.

IMO We can consider to support it if

  • It's FBX proper specification

or

  • There're (not a few) this type of existing files
  • Other libs/viewers can load and render them correctly

@FishOrBear
Copy link
Contributor Author

This file is imported into u3d, or UE4, which can be imported correctly.

I do not know how to split the file.

@takahirox
Copy link
Collaborator

Can you generate the ascii version file and share?
I'm wondering how we should handle the second data.
(Just ignore?)

@FishOrBear
Copy link
Contributor Author

@takahirox
I do not know how to generate ascii files.
I think i can try fbxSDK

@FishOrBear
Copy link
Contributor Author

Drawing1Ascii.zip
I tried using fbxConver to convert the file.

http://usa.autodesk.com/adsk/servlet/pc/item?siteID=123112&id=22694909

@looeee
Copy link
Collaborator

looeee commented Aug 19, 2017

@FishOrBear @takahirox I've tested loading the original file (Drawing1.fbx) in a couple of ways, including importing it back into 3ds Max. In all cases it doesn't look like the original screenshot - it's just six planes making up a box.

Additionally as you can see in the following screen shot, the planes are missing names - this is unusual (actually first time I've seen this in max, generally everything is named).

box

Could it be that the original export didn't work properly for some reason?

@FishOrBear
Copy link
Contributor Author

FishOrBear commented Aug 20, 2017

@looeee
I guess this is not the reason.
You can try the following file.

Drawing4.zip

In the autocad.
these meshes are no name

@takahirox
Copy link
Collaborator

takahirox commented Aug 22, 2017

Anyways, I want something proof which indicates this type of files follows a proper FBX format. I'd never seen two or more footers in one FBX file in other files.

looeee and others added 26 commits November 21, 2017 17:14
ColladaLoader: Added possibility to manually set path
Fbx loader split monolithic parseScene method
FBXLoader correctly parse duplicate embedded textures
TDSLoader: Use path and manager for all Loaders
Propagate error during loading of STL files via onError callback
FBXLoader refactor parseAnimation and remove unused entities from return object
ShapeUtils: Use earcut for polygon triangulation (2nd attempt)
@mrdoob
Copy link
Owner

mrdoob commented Nov 22, 2017

This got messed up...

@mrdoob mrdoob closed this Nov 22, 2017
@FishOrBear
Copy link
Contributor Author

@takahirox Hi,After many years, I continued the discussion of this issue.

https://github.com/mont29/blender-io-fbx/blob/master/io_scene_fbx/parse_fbx.py#L166

I think my conjecture is right, because the code of blender is also like this.

@FishOrBear
Copy link
Contributor Author

https://github.com/mrdoob/three.js/blob/dev/examples/js/loaders/FBXLoader.js#L1697

Actually in my file, this property may be null, so I am modifying it so

if (node.attrName)
    model.name = THREE.PropertyBinding.sanitizeNodeName(node.attrName);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet