static const char sccsid[] = "@(#)hypertorus.c 1.2 05/09/28 xlockmore";
#endif
-/* Copyright (c) 2003-2005 Carsten Steger <carsten@mirsanmir.org>. */
+/* Copyright (c) 2003-2007 Carsten Steger <carsten@mirsanmir.org>. */
/*
* Permission to use, copy, modify, and distribute this software and its
* C. Steger - 03/05/18: Initial version
* C. Steger - 05/09/28: Added the spirals appearance mode
* and trackball support
+ * C. Steger - 07/01/23: Improved 4d trackball support
*/
/*
#define DTHETA 2.1
#define DTHETA_STR "2.1"
-#define DEF_DISPLAY_MODE DISP_SURFACE_STR
+#define DEF_DISPLAY_MODE DISP_TRANSPARENT_STR
#define DEF_APPEARANCE APPEARANCE_BANDS_STR
#define DEF_COLORS COLORS_COLORWHEEL_STR
#define DEF_3D_PROJECTION DISP_3D_PERSPECTIVE_STR
rotatewx(m,al);
rotatewy(m,be);
rotatewz(m,de);
- rotatexy(m,ze);
rotatexz(m,et);
+ rotatexy(m,ze);
rotateyz(m,th);
}
r12 = 2.0*(q[1]*q[2]+q[0]*q[3]);
r22 = 1.0-2.0*(q[1]*q[1]+q[0]*q[0]);
- ze = atan2(-r12,r22)*180.0/M_PI;
- et = atan2(r02,sqrt(r00*r00+r01*r01))*180.0/M_PI;
- th = atan2(-r01,r00)*180.0/M_PI;
+ et = atan2(-r12,r22)*180.0/M_PI;
+ th = atan2(r02,sqrt(r00*r00+r01*r01))*180.0/M_PI;
+ ze = atan2(-r01,r00)*180.0/M_PI;
- rotateall(al,be,de,ze,et,th,m);
+ rotateall(al,be,de,ze,et,-th,m);
}
will only work correctly if numu and numv are set to 64 or any higher
power of 2. Similarly, the banded appearance will only work correctly
if numu and numv are divisible by 4. */
-static void hypertorus(ModeInfo *mi, double umin, double umax, double vmin,
+static int hypertorus(ModeInfo *mi, double umin, double umax, double vmin,
double vmax, int numu, int numv)
{
+ int polys = 0;
static const GLfloat mat_diff_red[] = { 1.0, 0.0, 0.0, 1.0 };
static const GLfloat mat_diff_green[] = { 0.0, 1.0, 0.0, 1.0 };
static const GLfloat mat_diff_trans_red[] = { 1.0, 0.0, 0.0, 0.7 };
n[2] /= t;
glNormal3fv(n);
glVertex3fv(p);
+ polys++;
}
}
glEnd();
}
+ polys /= 2;
+ return polys;
}
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
- hypertorus(mi,0.0,2.0*M_PI,0.0,2.0*M_PI,64,64);
+ mi->polygon_count = hypertorus(mi,0.0,2.0*M_PI,0.0,2.0*M_PI,64,64);
}