Better Collada and OBJ support...
Better Collada and OBJ support...
Hi all,
Here's an update to the OBJ loader, to preserve smoothing groups. This is necessary for proper normal-mapping. Also an update to the Collada loader, which preserves smoothing groups AND adds support for meshes in the Collada 1.4 format.
http://www.ryanclark.net/irrlicht/S3DVertex.h
http://www.ryanclark.net/irrlicht/CColl ... Loader.cpp
http://www.ryanclark.net/irrlicht/COBJM ... Loader.cpp
Please feel free to republish these under any license.
cheers,
-Ryan Clark
Here's an update to the OBJ loader, to preserve smoothing groups. This is necessary for proper normal-mapping. Also an update to the Collada loader, which preserves smoothing groups AND adds support for meshes in the Collada 1.4 format.
http://www.ryanclark.net/irrlicht/S3DVertex.h
http://www.ryanclark.net/irrlicht/CColl ... Loader.cpp
http://www.ryanclark.net/irrlicht/COBJM ... Loader.cpp
Please feel free to republish these under any license.
cheers,
-Ryan Clark
Last edited by RyanClark on Tue Sep 04, 2007 10:58 pm, edited 2 times in total.
-
hybrid
- Admin
- Posts: 14144
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Ok, then I'll wait for the next version. I guess there are enough things with the animation system to work on until then
BTW: Remember to ignore smoothing groups in .obj meshes when finding vertex normals. These override the smoothing group marker.
Also could you develop the code against the latest SVN revision? There are some conflicts between my latest changes and your code.
BTW: Remember to ignore smoothing groups in .obj meshes when finding vertex normals. These override the smoothing group marker.
Also could you develop the code against the latest SVN revision? There are some conflicts between my latest changes and your code.
I've updated the code now. I'm developing against v1.31. I hope I'm not duplicating work that's already been done!
I'm not actually looking at smoothing group flags; all I'm doing is sharing identical vertices between faces. For some reason, the old code was breaking faces apart, duplicating vertices that should be shared. This was causing bad seams in the tangent space.
Also, the Collada 1.4 support is only for basic meshes. I haven't updated lights or scenes or other Collada stuff to 1.4.
Here is an image to illustrate the change.

I'm not actually looking at smoothing group flags; all I'm doing is sharing identical vertices between faces. For some reason, the old code was breaking faces apart, duplicating vertices that should be shared. This was causing bad seams in the tangent space.
Also, the Collada 1.4 support is only for basic meshes. I haven't updated lights or scenes or other Collada stuff to 1.4.
Here is an image to illustrate the change.

Here is the teapot model used in the above images.
http://cggmwww.csie.nctu.edu.tw/courses ... teapot.obj
Seams will appear when you use the mesh manipulator to calculate "smooth" normals. or to generate a smooth tangent space using the code I posted previously. http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=23046
Since faces were not connected to each other by the old loader, smooth operations on the mesh were impossible.
The new code does preserve non-smooth faces. In fact, it makes no change to the appearance of the mesh; It simply preserves the relationship between smooth faces, so that the mesh manipulator can use it in the future, to calculate smooth normals or tangents.
The new code also makes the mesh a lot smaller. So even if you aren't normal mapping, you should see improved performance.
http://cggmwww.csie.nctu.edu.tw/courses ... teapot.obj
Seams will appear when you use the mesh manipulator to calculate "smooth" normals. or to generate a smooth tangent space using the code I posted previously. http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=23046
Since faces were not connected to each other by the old loader, smooth operations on the mesh were impossible.
The new code does preserve non-smooth faces. In fact, it makes no change to the appearance of the mesh; It simply preserves the relationship between smooth faces, so that the mesh manipulator can use it in the future, to calculate smooth normals or tangents.
The new code also makes the mesh a lot smaller. So even if you aren't normal mapping, you should see improved performance.
-
hybrid
- Admin
- Posts: 14144
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Ok, I understand the intention now. It's indeed a known problem that, due to the vertex normals used, we often duplicate vertices. It's not strictly necessary, and as we now see it is often evil, but this was done in favor of speed. So did you already measure larger meshes? Just curious before I'm going to commit this to the core
Which will last some more time anyway as I'll have to port your code to the latest SVN revisions.