Index  | Recent Threads  | List Attachments  | Search
 Welcome Guest  |  Register  |  Login
Login Name  Password
 

Sweet Home 3D Forum



No member browsing this thread
Thread Status: Active
Total posts in this thread: 9
[ Jump to Last Post ]
Post new Thread
Author
Previous Thread This topic has been viewed 4627 times and has 8 replies Next Thread
apptaro
Newbie




Joined: Aug 17, 2010
Post Count: 5
Status: Offline
Reply to this Post  Reply with Quote 
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?
[Aug 17, 2010, 1:53:18 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Puybaret
Expert
Member's Avatar

France
Joined: Nov 7, 2005
Post Count: 9425
Status: Offline
Reply to this Post  Reply with Quote 
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
[Aug 17, 2010, 3:41:13 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
apptaro
Newbie




Joined: Aug 17, 2010
Post Count: 5
Status: Offline
Reply to this Post  Reply with Quote 
Re: DAELoader Bug Fixes

Thank you for your response!
I have sent the modified java file.

I made a mistake on the original post. inputCount is incorrectly counted, and that causes corrupted texture, not corrupted model.
[Aug 17, 2010, 4:07:02 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Puybaret
Expert
Member's Avatar

France
Joined: Nov 7, 2005
Post Count: 9425
Status: Offline
Reply to this Post  Reply with Quote 
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. wink

I'm happy you were able to read and improve this class. I was afraid that my code was really too complicated to maintain. smile
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D creator
[Aug 17, 2010, 6:44:28 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Puybaret
Expert
Member's Avatar

France
Joined: Nov 7, 2005
Post Count: 9425
Status: Offline
Reply to this Post  Reply with Quote 
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
[Aug 17, 2010, 8:08:29 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
apptaro
Newbie




Joined: Aug 17, 2010
Post Count: 5
Status: Offline
Reply to this Post  Reply with Quote 
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??
[Aug 18, 2010, 8:10:27 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
apptaro
Newbie




Joined: Aug 17, 2010
Post Count: 5
Status: Offline
Reply to this Post  Reply with Quote 
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.

Sorry for not providing test cases...
[Aug 18, 2010, 8:15:36 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Puybaret
Expert
Member's Avatar

France
Joined: Nov 7, 2005
Post Count: 9425
Status: Offline
Reply to this Post  Reply with Quote 
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
[Aug 18, 2010, 9:28:55 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
apptaro
Newbie




Joined: Aug 17, 2010
Post Count: 5
Status: Offline
Reply to this Post  Reply with Quote 
Re: DAELoader Bug Fixes

You're welcome. Thank you for including my contribution!
[Aug 19, 2010, 3:34:09 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
[ Jump to Last Post ]
Show Printable Version of Thread  Post new Thread

  Get Sweet Home 3D at SourceForge.net. Fast, secure and Free Open Source software downloads  
© Copyright 2024 Space Mushrooms - All rights reserved