Joined: Aug 17, 2010
Post Count: 5
Status:
Offline
DAELoader Bug Fixes
Hi list,
I was looking for a decent Collada parser for Java3D. I tried several libraries and found that com.eteks.sweethome3d.j3d.DAELoader is the best! It was the fastest and the most correct.
Some of my collada files, however, were not parsed correctly, so I digged into the code, and found several bugs:
- texture coordinate sets are not supported. - inputCount is incorrectly counted, which results in model corruption. - NumberFormatException occurs for some bad collada files, which can be just safely ignored. - node rotations are incorrectly applied. - Y_UP models are facing the other way.
I have made fixes and tested with many collada files from Blender, 3DS Max and Maya. Now it works correctly for all my models!
So, I want to share my fixes but since I'm new here, I'm wondering if someone could merge my changes to the main code. My fixes were made on top of the latest rev 1.9 of com.eteks.sweethome3d.j3d.DAELoader, so it should be easy to merge. Anyone?
France
Joined: Nov 7, 2005
Post Count: 9425
Status:
Offline
Re: DAELoader Bug Fixes
Hi apptaro, Thank you for testing DAELoader class and for your contribution. Send me the modified java file or attach it to a bug request. If possible provide some simple DAE test files.
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D creator
France
Joined: Nov 7, 2005
Post Count: 9425
Status:
Offline
Re: DAELoader Bug Fixes
I updated DAELoader class from your code except the Y_UP fix since it would bring some incompatibilities with existing imported models.
I was a little annoyed by handling multiple texture coordinates sets since OBJ format at export and SunFlow don't support this feature, but I copied your code anyway. To be sure that rendering will be always the same, I stored texture coordinates in a LinkedHashSet instance to ensure they are enumerated always in the same order. By the way, thank you for fixing the bug on the max index in the for loop that creates UV coordinates from larger texture coordinates.
I'm happy you were able to read and improve this class. I was afraid that my code was really too complicated to maintain.
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D creator
France
Joined: Nov 7, 2005
Post Count: 9425
Status:
Offline
Re: DAELoader Bug Fixes
apptaro, I'm astonished you modified DAELoader class to retrieve multiple texture coordinate sets but didn't use them in instance_material elements containing bind_vertex_input elements with a given set. Aren't texture coordinate sets useful for this?
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D creator
Joined: Aug 17, 2010
Post Count: 5
Status:
Offline
Re: DAELoader Bug Fixes
Puybaret, I think you're right. Multiple texture coordinate set support is not well implemented. I just modified the original code to work for my collada files, I didn't look into it very closely.
With more investigation, I found out that my collada files all display correctly without the modification for multiple texture coordinate set. I have sent you a java file, so you know what I mean.
inputCount and node rotation issues are simply bugs.
NumberFormatException issue is caused by an exporter bug, but I think it'd be nice if parser can handle them without raising exceptions. In my case, collada files exported from 3ds max sometimes have invalid value "-1.#IND" in float_array for TEXTANGENT/TEXBINORMAL. They can be safely ignored.
As for Y_UP issue, I needed to rotate 180 degree around y-axis to get Y_UP models in the right direction. I think this shouldn't be necesary because Collada Y_UP and Java3D have the same coordinate system (right-handed & y-up.) I checked the same collada file with Flash PaperVision3D, so maybe PaperVision3D is wrong??
Joined: Aug 17, 2010
Post Count: 5
Status:
Offline
Re: DAELoader Bug Fixes
I only have Blender installed on my PC. Collada files from blender would work with the original DAELoader.
Collada files exported from 3ds Max would suffer from inputCount/rotation/NumberFormatException issues, but I can't create a simple model because I don't have 3ds Max.
Collada files exported from Maya would be Y_UP, but I don't have Maya.
France
Joined: Nov 7, 2005
Post Count: 9425
Status:
Offline
Re: DAELoader Bug Fixes
apptaro, I removed support for multiple texture coordinate sets in DAELoader class. Thank you for your contribution.
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D creator