This is a fix for bug 1077795, which has been bugging me for about 2
years. It took me ages to figure this out, but the solution is quite
small in the end. There's nothing wrong with what lib3ds itself is
doing, it's just the player's interpretation of the matrices that's
slightly lacking.

If the determinant of the node matrix is less than 0, it means that it
describes a right-hand coordinate system, so it needs mirrored in the
YZ plane, and the pivot.x should be negated too.

Patch follows below.

Cheers,
Dave.

p.s. In trying to solve this, I added some new functionality to do the
"Polar Matrix Decomposition" stuff from Graphics Gems IV. This
includes 3ds Max-like decomp_affine etc, which could be fairly useful.
If you want it, let me know and I'll send in the patches.

p.p.s. Oh, and my problems with getting the build going was due to me
using ancient autoconf and automake. I was on autoconf 2.13 and
automake 1.4-p6. Still toiling away on Mandrake 9.1!


Index: examples/player.c
===================================================================
RCS file: /cvsroot/lib3ds/lib3ds/examples/player.c,v
retrieving revision 1.7
diff -u -r1.7 player.c
--- examples/player.c   10 May 2005 12:02:08 -0000      1.7
+++ examples/player.c   29 Jun 2006 17:45:26 -0000
@@ -672,7 +672,13 @@
       glPushMatrix();
       d=&node->data.object;
       glMultMatrixf(&node->matrix[0][0]);
-      glTranslatef(-d->pivot[0], -d->pivot[1], -d->pivot[2]);
+      if (lib3ds_matrix_det(node->matrix) < 0.0) {
+         glScalef(-1.0, 1.0, 1.0);
+         glTranslatef(d->pivot[0], -d->pivot[1], -d->pivot[2]);
+      }
+      else {
+         glTranslatef(-d->pivot[0], -d->pivot[1], -d->pivot[2]);
+      }
       glCallList(mesh->user.d);
       /* glutSolidSphere(50.0, 20,20); */
       glPopMatrix();

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
lib3ds-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/lib3ds-devel

Reply via email to