brendan-duncan / dart_fbx

Open Source FBX decoder for Dart
Other
27 stars 4 forks source link

UVIndex not handled #5

Open klaszlo8207 opened 4 years ago

klaszlo8207 commented 4 years ago

You assume that the UvIndices is in order but not, you have to handle that and order manually

in

void _loadUvs(FbxElement e) { //fbx_mesh.dart

add this

//TODO UVIndex
      else if (c.id == 'UVIndex' && p.isNotEmpty) {
        uvs.indexArray = List<int>(p.length);
        for (var i = 0, j = 0, len = p.length; i < len; i++) {
          uvs.indexArray[j++] = toInt(p[i]);
        }
      }

then in generateDisplayMeshes: (to the last line add)

      //TODO disp uvs ordering
      Float32List newUvs = Float32List(disp.uvs.length);

      int j = 0;
      for (int index = 0; index < uvs.indexArray.length; index++) {
        final uvIndex = uvs.indexArray[index];
        final temp = uvs.data[uvIndex];
        newUvs[j++] = temp.x;
        newUvs[j++] = temp.y;
      }
      disp.uvs = newUvs;
brendan-duncan commented 4 years ago

Thanks. Do you happen to have a fbx with this data in it so I can make sure it's correct?

klaszlo8207 commented 4 years ago

https://github.com/klaszlo8207/Flutter-FBX-3D-Viewer/tree/master/assets

Here it is some fbx files, version 7.4.0 ASCII

Brendan I had to update some BUGS in your code and I had to upload to my package:

https://github.com/klaszlo8207/Flutter-FBX-3D-Viewer/tree/master/lib/fbx_parser

If you FIX those all I can use your library then later

I found 3 BUGS (mentioned here in the issues as well), you can find in my repo with searching for: "//TODO"

or just compare the codes

https://github.com/klaszlo8207/Flutter-FBX-3D-Viewer/search?q=%2F%2FTODO&unscoped_q=%2F%2FTODO

Thanks.

klaszlo8207 commented 4 years ago

More on the BUGS:

https://github.com/klaszlo8207/Flutter-FBX-3D-Viewer/blob/ae68cd2ad367cd7916593d3c25ad68a07fd4477b/lib/fbx_parser/fbx/scene/fbx_mesh.dart

line 175-184

line 390 null check (crash was)

line 414-424

klaszlo8207 commented 4 years ago

and

https://github.com/klaszlo8207/Flutter-FBX-3D-Viewer/blob/ae68cd2ad367cd7916593d3c25ad68a07fd4477b/lib/fbx_parser/fbx/fbx_loader.dart

line 268-290 maybe

brendan-duncan commented 4 years ago

That's great, I'll add those fixes and make sure those fbx files work. I did add a couple fixes last night to get an fbx file exported out of blender to load.

You're the first person I know of to have used this library, so much appreciated sharing your fixes. I haven't even used it for anything, I was just curious what was inside fbx files.

oengmengthong commented 1 year ago

that issues already fixed? or not yet?

@klaszlo8207 I updated some code and already pull request to your repo package.

i hope this package will be work again.