Marlamin / WoWExportTools

Tool for exporting WoW assets to more portable formats
MIT License
45 stars 15 forks source link

Importing WMOs exported as OBJ in 3DS Max causes "ERROR - invalid normal index" #75

Closed thunderysteak closed 4 years ago

thunderysteak commented 4 years ago

When importing a large OBJ file that came out of a WMO, 3ds Max fails to import it with the "ERROR - invalid normal index" error as it fails to read the model normals. For example, one of the WMOs that fail the import after being exported are battleforgilneas_alliance_start and 6hu_garrison_inn_v3.

Unfortunately I have no way of getting information of where max errors out on what part of the file, as the OBJ importer doesn't generate any additional information. 3dsmax_2019-12-20_17-55-59

Only problem I could see when comparing Blender's and 3DS Max's OBJ output against the tool's OBJ files, is that it appears not to follow the format spec correctly. Instead of grouping geometric vertices, texture coordinates and vertex normals into their own groups per object, it always puts geometric vertices followed by texture coordinates and followed by vertex normals and then repeats the whole thing until it reaches polygonal face elements.

Examples:

o battleforgilneas_alliance_start.wmo
v -4.65971994400024 0.835629880428314 -65.5237884521484
vt 0.547743618488312 0.267926692962646
vn 0.798897802830 0.554442644119 0.233143106103
v -5.01201868057251 0.808237135410309 -66.9706039428711
vt 0.715215623378754 0.319030106067657
vn 0.716391682625 0.470660537481 -0.515035569668
v -4.98299264907837 1.00568544864655 -66.3355407714844
vt 0.617598831653595 0.387909233570099
vn 0.946586132050 0.228108346462 -0.227906227112

How it should look like according to the spec, or rather how various plugins group things together

o battleforgilneas_alliance_start.wmo
v -4.65971994400024 0.835629880428314 -65.5237884521484
v ...
...
vt 0.547743618488312 0.267926692962646
vt ...
...
vn 0.798897802830 0.554442644119 0.233143106103
vn ...
...
f 1 2 3
f ...
...

This is possibly causing 3ds max to fail importing the file

thunderysteak commented 4 years ago

Fix implemented. Will cause issues with 3DS Max 2018 by erroring out on texture index due of a bug in 3DS Max. Only option on fixing that with that version of max is selecting "Import as single mesh" during import or running it through an external application to convert the model.