4 * Freeglut geometry rendering methods.
6 * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
7 * Written by Pawel W. Olszta, <olszta@sourceforge.net>
8 * Creation date: Fri Dec 3 1999
10 * Permission is hereby granted, free of charge, to any person obtaining a
11 * copy of this software and associated documentation files (the "Software"),
12 * to deal in the Software without restriction, including without limitation
13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 * and/or sell copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following conditions:
17 * The above copyright notice and this permission notice shall be included
18 * in all copies or substantial portions of the Software.
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
24 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 #include <GL/freeglut.h>
33 #include "freeglut_internal.h"
36 * TODO BEFORE THE STABLE RELEASE:
38 * Following functions have been contributed by Andreas Umbach.
40 * glutWireCube() -- looks OK
41 * glutSolidCube() -- OK
43 * Those functions have been implemented by John Fay.
45 * glutWireTorus() -- looks OK
46 * glutSolidTorus() -- looks OK
47 * glutWireDodecahedron() -- looks OK
48 * glutSolidDodecahedron() -- looks OK
49 * glutWireOctahedron() -- looks OK
50 * glutSolidOctahedron() -- looks OK
51 * glutWireTetrahedron() -- looks OK
52 * glutSolidTetrahedron() -- looks OK
53 * glutWireIcosahedron() -- looks OK
54 * glutSolidIcosahedron() -- looks OK
56 * The Following functions have been updated by Nigel Stewart, based
57 * on FreeGLUT 2.0.0 implementations:
59 * glutWireSphere() -- looks OK
60 * glutSolidSphere() -- looks OK
61 * glutWireCone() -- looks OK
62 * glutSolidCone() -- looks OK
66 /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
69 * Draws a wireframed cube. Code contributed by Andreas Umbach <marvin@dataway.ch>
71 void FGAPIENTRY glutWireCube( GLdouble dSize )
73 double size = dSize * 0.5;
75 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireCube" );
77 # define V(a,b,c) glVertex3d( a size, b size, c size );
78 # define N(a,b,c) glNormal3d( a, b, c );
80 /* PWO: I dared to convert the code to use macros... */
81 glBegin( GL_LINE_LOOP ); N( 1.0, 0.0, 0.0); V(+,-,+); V(+,-,-); V(+,+,-); V(+,+,+); glEnd();
82 glBegin( GL_LINE_LOOP ); N( 0.0, 1.0, 0.0); V(+,+,+); V(+,+,-); V(-,+,-); V(-,+,+); glEnd();
83 glBegin( GL_LINE_LOOP ); N( 0.0, 0.0, 1.0); V(+,+,+); V(-,+,+); V(-,-,+); V(+,-,+); glEnd();
84 glBegin( GL_LINE_LOOP ); N(-1.0, 0.0, 0.0); V(-,-,+); V(-,+,+); V(-,+,-); V(-,-,-); glEnd();
85 glBegin( GL_LINE_LOOP ); N( 0.0,-1.0, 0.0); V(-,-,+); V(-,-,-); V(+,-,-); V(+,-,+); glEnd();
86 glBegin( GL_LINE_LOOP ); N( 0.0, 0.0,-1.0); V(-,-,-); V(-,+,-); V(+,+,-); V(+,-,-); glEnd();
93 * Draws a solid cube. Code contributed by Andreas Umbach <marvin@dataway.ch>
95 void FGAPIENTRY glutSolidCube( GLdouble dSize )
97 double size = dSize * 0.5;
99 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidCube" );
101 # define V(a,b,c) glVertex3d( a size, b size, c size );
102 # define N(a,b,c) glNormal3d( a, b, c );
104 /* PWO: Again, I dared to convert the code to use macros... */
106 N( 1.0, 0.0, 0.0); V(+,-,+); V(+,-,-); V(+,+,-); V(+,+,+);
107 N( 0.0, 1.0, 0.0); V(+,+,+); V(+,+,-); V(-,+,-); V(-,+,+);
108 N( 0.0, 0.0, 1.0); V(+,+,+); V(-,+,+); V(-,-,+); V(+,-,+);
109 N(-1.0, 0.0, 0.0); V(-,-,+); V(-,+,+); V(-,+,-); V(-,-,-);
110 N( 0.0,-1.0, 0.0); V(-,-,+); V(-,-,-); V(+,-,-); V(+,-,+);
111 N( 0.0, 0.0,-1.0); V(-,-,-); V(-,+,-); V(+,+,-); V(+,-,-);
119 * Compute lookup table of cos and sin values forming a cirle
122 * It is the responsibility of the caller to free these tables
123 * The size of the table is (n+1) to form a connected loop
124 * The last entry is exactly the same as the first
125 * The sign of n can be flipped to get the reverse loop
128 static void fghCircleTable(double **sint,double **cost,const int n)
132 /* Table size, the sign of n flips the circle direction */
134 const int size = abs(n);
136 /* Determine the angle between samples */
138 const double angle = 2*M_PI/(double)( ( n == 0 ) ? 1 : n );
140 /* Allocate memory for n samples, plus duplicate of first entry at the end */
142 *sint = (double *) calloc(sizeof(double), size+1);
143 *cost = (double *) calloc(sizeof(double), size+1);
145 /* Bail out if memory allocation fails, fgError never returns */
147 if (!(*sint) || !(*cost))
151 fgError("Failed to allocate memory in fghCircleTable");
154 /* Compute cos and sin around the circle */
159 for (i=1; i<size; i++)
161 (*sint)[i] = sin(angle*i);
162 (*cost)[i] = cos(angle*i);
165 /* Last sample is duplicate of the first */
167 (*sint)[size] = (*sint)[0];
168 (*cost)[size] = (*cost)[0];
172 * Draws a solid sphere
174 void FGAPIENTRY glutSolidSphere(GLdouble radius, GLint slices, GLint stacks)
178 /* Adjust z and radius as stacks are drawn. */
183 /* Pre-computed circle */
185 double *sint1,*cost1;
186 double *sint2,*cost2;
188 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidSphere" );
190 fghCircleTable(&sint1,&cost1,-slices);
191 fghCircleTable(&sint2,&cost2,stacks*2);
193 /* The top stack is covered with a triangle fan */
196 z1 = cost2[(stacks>0)?1:0];
198 r1 = sint2[(stacks>0)?1:0];
200 glBegin(GL_TRIANGLE_FAN);
203 glVertex3d(0,0,radius);
205 for (j=slices; j>=0; j--)
207 glNormal3d(cost1[j]*r1, sint1[j]*r1, z1 );
208 glVertex3d(cost1[j]*r1*radius, sint1[j]*r1*radius, z1*radius);
213 /* Cover each stack with a quad strip, except the top and bottom stacks */
215 for( i=1; i<stacks-1; i++ )
217 z0 = z1; z1 = cost2[i+1];
218 r0 = r1; r1 = sint2[i+1];
220 glBegin(GL_QUAD_STRIP);
222 for(j=0; j<=slices; j++)
224 glNormal3d(cost1[j]*r1, sint1[j]*r1, z1 );
225 glVertex3d(cost1[j]*r1*radius, sint1[j]*r1*radius, z1*radius);
226 glNormal3d(cost1[j]*r0, sint1[j]*r0, z0 );
227 glVertex3d(cost1[j]*r0*radius, sint1[j]*r0*radius, z0*radius);
233 /* The bottom stack is covered with a triangle fan */
238 glBegin(GL_TRIANGLE_FAN);
241 glVertex3d(0,0,-radius);
243 for (j=0; j<=slices; j++)
245 glNormal3d(cost1[j]*r0, sint1[j]*r0, z0 );
246 glVertex3d(cost1[j]*r0*radius, sint1[j]*r0*radius, z0*radius);
251 /* Release sin and cos tables */
260 * Draws a wire sphere
262 void FGAPIENTRY glutWireSphere(GLdouble radius, GLint slices, GLint stacks)
266 /* Adjust z and radius as stacks and slices are drawn. */
271 /* Pre-computed circle */
273 double *sint1,*cost1;
274 double *sint2,*cost2;
276 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireSphere" );
278 fghCircleTable(&sint1,&cost1,-slices );
279 fghCircleTable(&sint2,&cost2, stacks*2);
281 /* Draw a line loop for each stack */
283 for (i=1; i<stacks; i++)
288 glBegin(GL_LINE_LOOP);
290 for(j=0; j<=slices; j++)
296 glVertex3d(x*r*radius,y*r*radius,z*radius);
302 /* Draw a line loop for each slice */
304 for (i=0; i<slices; i++)
306 glBegin(GL_LINE_STRIP);
308 for(j=0; j<=stacks; j++)
310 x = cost1[i]*sint2[j];
311 y = sint1[i]*sint2[j];
315 glVertex3d(x*radius,y*radius,z*radius);
321 /* Release sin and cos tables */
332 void FGAPIENTRY glutSolidCone( GLdouble base, GLdouble height, GLint slices, GLint stacks )
336 /* Step in z and radius as stacks are drawn. */
341 const double zStep = height / ( ( stacks > 0 ) ? stacks : 1 );
342 const double rStep = base / ( ( stacks > 0 ) ? stacks : 1 );
344 /* Scaling factors for vertex normals */
346 const double cosn = ( height / sqrt ( height * height + base * base ));
347 const double sinn = ( base / sqrt ( height * height + base * base ));
349 /* Pre-computed circle */
353 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidCone" );
355 fghCircleTable(&sint,&cost,-slices);
357 /* Cover the circular base with a triangle fan... */
365 glBegin(GL_TRIANGLE_FAN);
367 glNormal3d(0.0,0.0,-1.0);
368 glVertex3d(0.0,0.0, z0 );
370 for (j=0; j<=slices; j++)
371 glVertex3d(cost[j]*r0, sint[j]*r0, z0);
375 /* Cover each stack with a quad strip, except the top stack */
377 for( i=0; i<stacks-1; i++ )
379 glBegin(GL_QUAD_STRIP);
381 for(j=0; j<=slices; j++)
383 glNormal3d(cost[j]*sinn, sint[j]*sinn, cosn);
384 glVertex3d(cost[j]*r0, sint[j]*r0, z0 );
385 glVertex3d(cost[j]*r1, sint[j]*r1, z1 );
388 z0 = z1; z1 += zStep;
389 r0 = r1; r1 -= rStep;
394 /* The top stack is covered with individual triangles */
396 glBegin(GL_TRIANGLES);
398 glNormal3d(cost[0]*sinn, sint[0]*sinn, cosn);
400 for (j=0; j<slices; j++)
402 glVertex3d(cost[j+0]*r0, sint[j+0]*r0, z0 );
403 glVertex3d(0, 0, height);
404 glNormal3d(cost[j+1]*sinn, sint[j+1]*sinn, cosn );
405 glVertex3d(cost[j+1]*r0, sint[j+1]*r0, z0 );
410 /* Release sin and cos tables */
419 void FGAPIENTRY glutWireCone( GLdouble base, GLdouble height, GLint slices, GLint stacks)
423 /* Step in z and radius as stacks are drawn. */
428 const double zStep = height / ( ( stacks > 0 ) ? stacks : 1 );
429 const double rStep = base / ( ( stacks > 0 ) ? stacks : 1 );
431 /* Scaling factors for vertex normals */
433 const double cosn = ( height / sqrt ( height * height + base * base ));
434 const double sinn = ( base / sqrt ( height * height + base * base ));
436 /* Pre-computed circle */
440 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireCone" );
442 fghCircleTable(&sint,&cost,-slices);
444 /* Draw the stacks... */
446 for (i=0; i<stacks; i++)
448 glBegin(GL_LINE_LOOP);
450 for( j=0; j<slices; j++ )
452 glNormal3d(cost[j]*sinn, sint[j]*sinn, cosn);
453 glVertex3d(cost[j]*r, sint[j]*r, z );
462 /* Draw the slices */
468 for (j=0; j<slices; j++)
470 glNormal3d(cost[j]*sinn, sint[j]*sinn, cosn );
471 glVertex3d(cost[j]*r, sint[j]*r, 0.0 );
472 glVertex3d(0.0, 0.0, height);
477 /* Release sin and cos tables */
485 * Draws a solid cylinder
487 void FGAPIENTRY glutSolidCylinder(GLdouble radius, GLdouble height, GLint slices, GLint stacks)
491 /* Step in z and radius as stacks are drawn. */
494 const double zStep = height / ( ( stacks > 0 ) ? stacks : 1 );
496 /* Pre-computed circle */
500 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidCylinder" );
502 fghCircleTable(&sint,&cost,-slices);
504 /* Cover the base and top */
506 glBegin(GL_TRIANGLE_FAN);
507 glNormal3d(0.0, 0.0, -1.0 );
508 glVertex3d(0.0, 0.0, 0.0 );
509 for (j=0; j<=slices; j++)
510 glVertex3d(cost[j]*radius, sint[j]*radius, 0.0);
513 glBegin(GL_TRIANGLE_FAN);
514 glNormal3d(0.0, 0.0, 1.0 );
515 glVertex3d(0.0, 0.0, height);
516 for (j=slices; j>=0; j--)
517 glVertex3d(cost[j]*radius, sint[j]*radius, height);
525 for (i=1; i<=stacks; i++)
530 glBegin(GL_QUAD_STRIP);
531 for (j=0; j<=slices; j++ )
533 glNormal3d(cost[j], sint[j], 0.0 );
534 glVertex3d(cost[j]*radius, sint[j]*radius, z0 );
535 glVertex3d(cost[j]*radius, sint[j]*radius, z1 );
539 z0 = z1; z1 += zStep;
542 /* Release sin and cos tables */
549 * Draws a wire cylinder
551 void FGAPIENTRY glutWireCylinder(GLdouble radius, GLdouble height, GLint slices, GLint stacks)
555 /* Step in z and radius as stacks are drawn. */
558 const double zStep = height / ( ( stacks > 0 ) ? stacks : 1 );
560 /* Pre-computed circle */
564 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireCylinder" );
566 fghCircleTable(&sint,&cost,-slices);
568 /* Draw the stacks... */
570 for (i=0; i<=stacks; i++)
575 glBegin(GL_LINE_LOOP);
577 for( j=0; j<slices; j++ )
579 glNormal3d(cost[j], sint[j], 0.0);
580 glVertex3d(cost[j]*radius, sint[j]*radius, z );
588 /* Draw the slices */
592 for (j=0; j<slices; j++)
594 glNormal3d(cost[j], sint[j], 0.0 );
595 glVertex3d(cost[j]*radius, sint[j]*radius, 0.0 );
596 glVertex3d(cost[j]*radius, sint[j]*radius, height);
601 /* Release sin and cos tables */
610 void FGAPIENTRY glutWireTorus( GLdouble dInnerRadius, GLdouble dOuterRadius, GLint nSides, GLint nRings )
612 double iradius = dInnerRadius, oradius = dOuterRadius, phi, psi, dpsi, dphi;
613 double *vertex, *normal;
615 double spsi, cpsi, sphi, cphi ;
617 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireTorus" );
619 if ( nSides < 1 ) nSides = 1;
620 if ( nRings < 1 ) nRings = 1;
622 /* Allocate the vertices array */
623 vertex = (double *)calloc( sizeof(double), 3 * nSides * nRings );
624 normal = (double *)calloc( sizeof(double), 3 * nSides * nRings );
628 dpsi = 2.0 * M_PI / (double)nRings ;
629 dphi = -2.0 * M_PI / (double)nSides ;
632 for( j=0; j<nRings; j++ )
638 for( i=0; i<nSides; i++ )
640 int offset = 3 * ( j * nSides + i ) ;
643 *(vertex + offset + 0) = cpsi * ( oradius + cphi * iradius ) ;
644 *(vertex + offset + 1) = spsi * ( oradius + cphi * iradius ) ;
645 *(vertex + offset + 2) = sphi * iradius ;
646 *(normal + offset + 0) = cpsi * cphi ;
647 *(normal + offset + 1) = spsi * cphi ;
648 *(normal + offset + 2) = sphi ;
655 for( i=0; i<nSides; i++ )
657 glBegin( GL_LINE_LOOP );
659 for( j=0; j<nRings; j++ )
661 int offset = 3 * ( j * nSides + i ) ;
662 glNormal3dv( normal + offset );
663 glVertex3dv( vertex + offset );
669 for( j=0; j<nRings; j++ )
671 glBegin(GL_LINE_LOOP);
673 for( i=0; i<nSides; i++ )
675 int offset = 3 * ( j * nSides + i ) ;
676 glNormal3dv( normal + offset );
677 glVertex3dv( vertex + offset );
689 * Draws a solid torus
691 void FGAPIENTRY glutSolidTorus( GLdouble dInnerRadius, GLdouble dOuterRadius, GLint nSides, GLint nRings )
693 double iradius = dInnerRadius, oradius = dOuterRadius, phi, psi, dpsi, dphi;
694 double *vertex, *normal;
696 double spsi, cpsi, sphi, cphi ;
698 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidTorus" );
700 if ( nSides < 1 ) nSides = 1;
701 if ( nRings < 1 ) nRings = 1;
703 /* Increment the number of sides and rings to allow for one more point than surface */
707 /* Allocate the vertices array */
708 vertex = (double *)calloc( sizeof(double), 3 * nSides * nRings );
709 normal = (double *)calloc( sizeof(double), 3 * nSides * nRings );
713 dpsi = 2.0 * M_PI / (double)(nRings - 1) ;
714 dphi = -2.0 * M_PI / (double)(nSides - 1) ;
717 for( j=0; j<nRings; j++ )
723 for( i=0; i<nSides; i++ )
725 int offset = 3 * ( j * nSides + i ) ;
728 *(vertex + offset + 0) = cpsi * ( oradius + cphi * iradius ) ;
729 *(vertex + offset + 1) = spsi * ( oradius + cphi * iradius ) ;
730 *(vertex + offset + 2) = sphi * iradius ;
731 *(normal + offset + 0) = cpsi * cphi ;
732 *(normal + offset + 1) = spsi * cphi ;
733 *(normal + offset + 2) = sphi ;
741 for( i=0; i<nSides-1; i++ )
743 for( j=0; j<nRings-1; j++ )
745 int offset = 3 * ( j * nSides + i ) ;
746 glNormal3dv( normal + offset );
747 glVertex3dv( vertex + offset );
748 glNormal3dv( normal + offset + 3 );
749 glVertex3dv( vertex + offset + 3 );
750 glNormal3dv( normal + offset + 3 * nSides + 3 );
751 glVertex3dv( vertex + offset + 3 * nSides + 3 );
752 glNormal3dv( normal + offset + 3 * nSides );
753 glVertex3dv( vertex + offset + 3 * nSides );
767 void FGAPIENTRY glutWireDodecahedron( void )
769 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireDodecahedron" );
771 /* Magic Numbers: It is possible to create a dodecahedron by attaching two pentagons to each face of
772 * of a cube. The coordinates of the points are:
773 * (+-x,0, z); (+-1, 1, 1); (0, z, x )
774 * where x = (-1 + sqrt(5))/2, z = (1 + sqrt(5))/2 or
775 * x = 0.61803398875 and z = 1.61803398875.
777 glBegin ( GL_LINE_LOOP ) ;
778 glNormal3d ( 0.0, 0.525731112119, 0.850650808354 ) ; glVertex3d ( 0.0, 1.61803398875, 0.61803398875 ) ; glVertex3d ( -1.0, 1.0, 1.0 ) ; glVertex3d ( -0.61803398875, 0.0, 1.61803398875 ) ; glVertex3d ( 0.61803398875, 0.0, 1.61803398875 ) ; glVertex3d ( 1.0, 1.0, 1.0 ) ;
780 glBegin ( GL_LINE_LOOP ) ;
781 glNormal3d ( 0.0, 0.525731112119, -0.850650808354 ) ; glVertex3d ( 0.0, 1.61803398875, -0.61803398875 ) ; glVertex3d ( 1.0, 1.0, -1.0 ) ; glVertex3d ( 0.61803398875, 0.0, -1.61803398875 ) ; glVertex3d ( -0.61803398875, 0.0, -1.61803398875 ) ; glVertex3d ( -1.0, 1.0, -1.0 ) ;
783 glBegin ( GL_LINE_LOOP ) ;
784 glNormal3d ( 0.0, -0.525731112119, 0.850650808354 ) ; glVertex3d ( 0.0, -1.61803398875, 0.61803398875 ) ; glVertex3d ( 1.0, -1.0, 1.0 ) ; glVertex3d ( 0.61803398875, 0.0, 1.61803398875 ) ; glVertex3d ( -0.61803398875, 0.0, 1.61803398875 ) ; glVertex3d ( -1.0, -1.0, 1.0 ) ;
786 glBegin ( GL_LINE_LOOP ) ;
787 glNormal3d ( 0.0, -0.525731112119, -0.850650808354 ) ; glVertex3d ( 0.0, -1.61803398875, -0.61803398875 ) ; glVertex3d ( -1.0, -1.0, -1.0 ) ; glVertex3d ( -0.61803398875, 0.0, -1.61803398875 ) ; glVertex3d ( 0.61803398875, 0.0, -1.61803398875 ) ; glVertex3d ( 1.0, -1.0, -1.0 ) ;
790 glBegin ( GL_LINE_LOOP ) ;
791 glNormal3d ( 0.850650808354, 0.0, 0.525731112119 ) ; glVertex3d ( 0.61803398875, 0.0, 1.61803398875 ) ; glVertex3d ( 1.0, -1.0, 1.0 ) ; glVertex3d ( 1.61803398875, -0.61803398875, 0.0 ) ; glVertex3d ( 1.61803398875, 0.61803398875, 0.0 ) ; glVertex3d ( 1.0, 1.0, 1.0 ) ;
793 glBegin ( GL_LINE_LOOP ) ;
794 glNormal3d ( -0.850650808354, 0.0, 0.525731112119 ) ; glVertex3d ( -0.61803398875, 0.0, 1.61803398875 ) ; glVertex3d ( -1.0, 1.0, 1.0 ) ; glVertex3d ( -1.61803398875, 0.61803398875, 0.0 ) ; glVertex3d ( -1.61803398875, -0.61803398875, 0.0 ) ; glVertex3d ( -1.0, -1.0, 1.0 ) ;
796 glBegin ( GL_LINE_LOOP ) ;
797 glNormal3d ( 0.850650808354, 0.0, -0.525731112119 ) ; glVertex3d ( 0.61803398875, 0.0, -1.61803398875 ) ; glVertex3d ( 1.0, 1.0, -1.0 ) ; glVertex3d ( 1.61803398875, 0.61803398875, 0.0 ) ; glVertex3d ( 1.61803398875, -0.61803398875, 0.0 ) ; glVertex3d ( 1.0, -1.0, -1.0 ) ;
799 glBegin ( GL_LINE_LOOP ) ;
800 glNormal3d ( -0.850650808354, 0.0, -0.525731112119 ) ; glVertex3d ( -0.61803398875, 0.0, -1.61803398875 ) ; glVertex3d ( -1.0, -1.0, -1.0 ) ; glVertex3d ( -1.61803398875, -0.61803398875, 0.0 ) ; glVertex3d ( -1.61803398875, 0.61803398875, 0.0 ) ; glVertex3d ( -1.0, 1.0, -1.0 ) ;
803 glBegin ( GL_LINE_LOOP ) ;
804 glNormal3d ( 0.525731112119, 0.850650808354, 0.0 ) ; glVertex3d ( 1.61803398875, 0.61803398875, 0.0 ) ; glVertex3d ( 1.0, 1.0, -1.0 ) ; glVertex3d ( 0.0, 1.61803398875, -0.61803398875 ) ; glVertex3d ( 0.0, 1.61803398875, 0.61803398875 ) ; glVertex3d ( 1.0, 1.0, 1.0 ) ;
806 glBegin ( GL_LINE_LOOP ) ;
807 glNormal3d ( 0.525731112119, -0.850650808354, 0.0 ) ; glVertex3d ( 1.61803398875, -0.61803398875, 0.0 ) ; glVertex3d ( 1.0, -1.0, 1.0 ) ; glVertex3d ( 0.0, -1.61803398875, 0.61803398875 ) ; glVertex3d ( 0.0, -1.61803398875, -0.61803398875 ) ; glVertex3d ( 1.0, -1.0, -1.0 ) ;
809 glBegin ( GL_LINE_LOOP ) ;
810 glNormal3d ( -0.525731112119, 0.850650808354, 0.0 ) ; glVertex3d ( -1.61803398875, 0.61803398875, 0.0 ) ; glVertex3d ( -1.0, 1.0, 1.0 ) ; glVertex3d ( 0.0, 1.61803398875, 0.61803398875 ) ; glVertex3d ( 0.0, 1.61803398875, -0.61803398875 ) ; glVertex3d ( -1.0, 1.0, -1.0 ) ;
812 glBegin ( GL_LINE_LOOP ) ;
813 glNormal3d ( -0.525731112119, -0.850650808354, 0.0 ) ; glVertex3d ( -1.61803398875, -0.61803398875, 0.0 ) ; glVertex3d ( -1.0, -1.0, -1.0 ) ; glVertex3d ( 0.0, -1.61803398875, -0.61803398875 ) ; glVertex3d ( 0.0, -1.61803398875, 0.61803398875 ) ; glVertex3d ( -1.0, -1.0, 1.0 ) ;
820 void FGAPIENTRY glutSolidDodecahedron( void )
822 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidDodecahedron" );
824 /* Magic Numbers: It is possible to create a dodecahedron by attaching two pentagons to each face of
825 * of a cube. The coordinates of the points are:
826 * (+-x,0, z); (+-1, 1, 1); (0, z, x )
827 * where x = (-1 + sqrt(5))/2, z = (1 + sqrt(5))/2 or
828 * x = 0.61803398875 and z = 1.61803398875.
830 glBegin ( GL_POLYGON ) ;
831 glNormal3d ( 0.0, 0.525731112119, 0.850650808354 ) ; glVertex3d ( 0.0, 1.61803398875, 0.61803398875 ) ; glVertex3d ( -1.0, 1.0, 1.0 ) ; glVertex3d ( -0.61803398875, 0.0, 1.61803398875 ) ; glVertex3d ( 0.61803398875, 0.0, 1.61803398875 ) ; glVertex3d ( 1.0, 1.0, 1.0 ) ;
833 glBegin ( GL_POLYGON ) ;
834 glNormal3d ( 0.0, 0.525731112119, -0.850650808354 ) ; glVertex3d ( 0.0, 1.61803398875, -0.61803398875 ) ; glVertex3d ( 1.0, 1.0, -1.0 ) ; glVertex3d ( 0.61803398875, 0.0, -1.61803398875 ) ; glVertex3d ( -0.61803398875, 0.0, -1.61803398875 ) ; glVertex3d ( -1.0, 1.0, -1.0 ) ;
836 glBegin ( GL_POLYGON ) ;
837 glNormal3d ( 0.0, -0.525731112119, 0.850650808354 ) ; glVertex3d ( 0.0, -1.61803398875, 0.61803398875 ) ; glVertex3d ( 1.0, -1.0, 1.0 ) ; glVertex3d ( 0.61803398875, 0.0, 1.61803398875 ) ; glVertex3d ( -0.61803398875, 0.0, 1.61803398875 ) ; glVertex3d ( -1.0, -1.0, 1.0 ) ;
839 glBegin ( GL_POLYGON ) ;
840 glNormal3d ( 0.0, -0.525731112119, -0.850650808354 ) ; glVertex3d ( 0.0, -1.61803398875, -0.61803398875 ) ; glVertex3d ( -1.0, -1.0, -1.0 ) ; glVertex3d ( -0.61803398875, 0.0, -1.61803398875 ) ; glVertex3d ( 0.61803398875, 0.0, -1.61803398875 ) ; glVertex3d ( 1.0, -1.0, -1.0 ) ;
843 glBegin ( GL_POLYGON ) ;
844 glNormal3d ( 0.850650808354, 0.0, 0.525731112119 ) ; glVertex3d ( 0.61803398875, 0.0, 1.61803398875 ) ; glVertex3d ( 1.0, -1.0, 1.0 ) ; glVertex3d ( 1.61803398875, -0.61803398875, 0.0 ) ; glVertex3d ( 1.61803398875, 0.61803398875, 0.0 ) ; glVertex3d ( 1.0, 1.0, 1.0 ) ;
846 glBegin ( GL_POLYGON ) ;
847 glNormal3d ( -0.850650808354, 0.0, 0.525731112119 ) ; glVertex3d ( -0.61803398875, 0.0, 1.61803398875 ) ; glVertex3d ( -1.0, 1.0, 1.0 ) ; glVertex3d ( -1.61803398875, 0.61803398875, 0.0 ) ; glVertex3d ( -1.61803398875, -0.61803398875, 0.0 ) ; glVertex3d ( -1.0, -1.0, 1.0 ) ;
849 glBegin ( GL_POLYGON ) ;
850 glNormal3d ( 0.850650808354, 0.0, -0.525731112119 ) ; glVertex3d ( 0.61803398875, 0.0, -1.61803398875 ) ; glVertex3d ( 1.0, 1.0, -1.0 ) ; glVertex3d ( 1.61803398875, 0.61803398875, 0.0 ) ; glVertex3d ( 1.61803398875, -0.61803398875, 0.0 ) ; glVertex3d ( 1.0, -1.0, -1.0 ) ;
852 glBegin ( GL_POLYGON ) ;
853 glNormal3d ( -0.850650808354, 0.0, -0.525731112119 ) ; glVertex3d ( -0.61803398875, 0.0, -1.61803398875 ) ; glVertex3d ( -1.0, -1.0, -1.0 ) ; glVertex3d ( -1.61803398875, -0.61803398875, 0.0 ) ; glVertex3d ( -1.61803398875, 0.61803398875, 0.0 ) ; glVertex3d ( -1.0, 1.0, -1.0 ) ;
856 glBegin ( GL_POLYGON ) ;
857 glNormal3d ( 0.525731112119, 0.850650808354, 0.0 ) ; glVertex3d ( 1.61803398875, 0.61803398875, 0.0 ) ; glVertex3d ( 1.0, 1.0, -1.0 ) ; glVertex3d ( 0.0, 1.61803398875, -0.61803398875 ) ; glVertex3d ( 0.0, 1.61803398875, 0.61803398875 ) ; glVertex3d ( 1.0, 1.0, 1.0 ) ;
859 glBegin ( GL_POLYGON ) ;
860 glNormal3d ( 0.525731112119, -0.850650808354, 0.0 ) ; glVertex3d ( 1.61803398875, -0.61803398875, 0.0 ) ; glVertex3d ( 1.0, -1.0, 1.0 ) ; glVertex3d ( 0.0, -1.61803398875, 0.61803398875 ) ; glVertex3d ( 0.0, -1.61803398875, -0.61803398875 ) ; glVertex3d ( 1.0, -1.0, -1.0 ) ;
862 glBegin ( GL_POLYGON ) ;
863 glNormal3d ( -0.525731112119, 0.850650808354, 0.0 ) ; glVertex3d ( -1.61803398875, 0.61803398875, 0.0 ) ; glVertex3d ( -1.0, 1.0, 1.0 ) ; glVertex3d ( 0.0, 1.61803398875, 0.61803398875 ) ; glVertex3d ( 0.0, 1.61803398875, -0.61803398875 ) ; glVertex3d ( -1.0, 1.0, -1.0 ) ;
865 glBegin ( GL_POLYGON ) ;
866 glNormal3d ( -0.525731112119, -0.850650808354, 0.0 ) ; glVertex3d ( -1.61803398875, -0.61803398875, 0.0 ) ; glVertex3d ( -1.0, -1.0, -1.0 ) ; glVertex3d ( 0.0, -1.61803398875, -0.61803398875 ) ; glVertex3d ( 0.0, -1.61803398875, 0.61803398875 ) ; glVertex3d ( -1.0, -1.0, 1.0 ) ;
873 void FGAPIENTRY glutWireOctahedron( void )
875 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireOctahedron" );
878 glBegin( GL_LINE_LOOP );
879 glNormal3d( 0.577350269189, 0.577350269189, 0.577350269189); glVertex3d( RADIUS, 0.0, 0.0 ); glVertex3d( 0.0, RADIUS, 0.0 ); glVertex3d( 0.0, 0.0, RADIUS );
880 glNormal3d( 0.577350269189, 0.577350269189,-0.577350269189); glVertex3d( RADIUS, 0.0, 0.0 ); glVertex3d( 0.0, 0.0,-RADIUS ); glVertex3d( 0.0, RADIUS, 0.0 );
881 glNormal3d( 0.577350269189,-0.577350269189, 0.577350269189); glVertex3d( RADIUS, 0.0, 0.0 ); glVertex3d( 0.0, 0.0, RADIUS ); glVertex3d( 0.0,-RADIUS, 0.0 );
882 glNormal3d( 0.577350269189,-0.577350269189,-0.577350269189); glVertex3d( RADIUS, 0.0, 0.0 ); glVertex3d( 0.0,-RADIUS, 0.0 ); glVertex3d( 0.0, 0.0,-RADIUS );
883 glNormal3d(-0.577350269189, 0.577350269189, 0.577350269189); glVertex3d(-RADIUS, 0.0, 0.0 ); glVertex3d( 0.0, 0.0, RADIUS ); glVertex3d( 0.0, RADIUS, 0.0 );
884 glNormal3d(-0.577350269189, 0.577350269189,-0.577350269189); glVertex3d(-RADIUS, 0.0, 0.0 ); glVertex3d( 0.0, RADIUS, 0.0 ); glVertex3d( 0.0, 0.0,-RADIUS );
885 glNormal3d(-0.577350269189,-0.577350269189, 0.577350269189); glVertex3d(-RADIUS, 0.0, 0.0 ); glVertex3d( 0.0,-RADIUS, 0.0 ); glVertex3d( 0.0, 0.0, RADIUS );
886 glNormal3d(-0.577350269189,-0.577350269189,-0.577350269189); glVertex3d(-RADIUS, 0.0, 0.0 ); glVertex3d( 0.0, 0.0,-RADIUS ); glVertex3d( 0.0,-RADIUS, 0.0 );
894 void FGAPIENTRY glutSolidOctahedron( void )
896 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidOctahedron" );
899 glBegin( GL_TRIANGLES );
900 glNormal3d( 0.577350269189, 0.577350269189, 0.577350269189); glVertex3d( RADIUS, 0.0, 0.0 ); glVertex3d( 0.0, RADIUS, 0.0 ); glVertex3d( 0.0, 0.0, RADIUS );
901 glNormal3d( 0.577350269189, 0.577350269189,-0.577350269189); glVertex3d( RADIUS, 0.0, 0.0 ); glVertex3d( 0.0, 0.0,-RADIUS ); glVertex3d( 0.0, RADIUS, 0.0 );
902 glNormal3d( 0.577350269189,-0.577350269189, 0.577350269189); glVertex3d( RADIUS, 0.0, 0.0 ); glVertex3d( 0.0, 0.0, RADIUS ); glVertex3d( 0.0,-RADIUS, 0.0 );
903 glNormal3d( 0.577350269189,-0.577350269189,-0.577350269189); glVertex3d( RADIUS, 0.0, 0.0 ); glVertex3d( 0.0,-RADIUS, 0.0 ); glVertex3d( 0.0, 0.0,-RADIUS );
904 glNormal3d(-0.577350269189, 0.577350269189, 0.577350269189); glVertex3d(-RADIUS, 0.0, 0.0 ); glVertex3d( 0.0, 0.0, RADIUS ); glVertex3d( 0.0, RADIUS, 0.0 );
905 glNormal3d(-0.577350269189, 0.577350269189,-0.577350269189); glVertex3d(-RADIUS, 0.0, 0.0 ); glVertex3d( 0.0, RADIUS, 0.0 ); glVertex3d( 0.0, 0.0,-RADIUS );
906 glNormal3d(-0.577350269189,-0.577350269189, 0.577350269189); glVertex3d(-RADIUS, 0.0, 0.0 ); glVertex3d( 0.0,-RADIUS, 0.0 ); glVertex3d( 0.0, 0.0, RADIUS );
907 glNormal3d(-0.577350269189,-0.577350269189,-0.577350269189); glVertex3d(-RADIUS, 0.0, 0.0 ); glVertex3d( 0.0, 0.0,-RADIUS ); glVertex3d( 0.0,-RADIUS, 0.0 );
912 /* Magic Numbers: r0 = ( 1, 0, 0 )
913 * r1 = ( -1/3, 2 sqrt(2) / 3, 0 )
914 * r2 = ( -1/3, -sqrt(2) / 3, sqrt(6) / 3 )
915 * r3 = ( -1/3, -sqrt(2) / 3, -sqrt(6) / 3 )
916 * |r0| = |r1| = |r2| = |r3| = 1
917 * Distance between any two points is 2 sqrt(6) / 3
919 * Normals: The unit normals are simply the negative of the coordinates of the point not on the surface.
922 #define NUM_TETR_FACES 4
924 static GLdouble tet_r[4][3] = { { 1.0, 0.0, 0.0 },
925 { -0.333333333333, 0.942809041582, 0.0 },
926 { -0.333333333333, -0.471404520791, 0.816496580928 },
927 { -0.333333333333, -0.471404520791, -0.816496580928 } } ;
929 static GLint tet_i[4][3] = /* Vertex indices */
931 { 1, 3, 2 }, { 0, 2, 3 }, { 0, 3, 1 }, { 0, 1, 2 }
937 void FGAPIENTRY glutWireTetrahedron( void )
939 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireTetrahedron" );
941 glBegin( GL_LINE_LOOP ) ;
942 glNormal3d ( -tet_r[0][0], -tet_r[0][1], -tet_r[0][2] ) ; glVertex3dv ( tet_r[1] ) ; glVertex3dv ( tet_r[3] ) ; glVertex3dv ( tet_r[2] ) ;
943 glNormal3d ( -tet_r[1][0], -tet_r[1][1], -tet_r[1][2] ) ; glVertex3dv ( tet_r[0] ) ; glVertex3dv ( tet_r[2] ) ; glVertex3dv ( tet_r[3] ) ;
944 glNormal3d ( -tet_r[2][0], -tet_r[2][1], -tet_r[2][2] ) ; glVertex3dv ( tet_r[0] ) ; glVertex3dv ( tet_r[3] ) ; glVertex3dv ( tet_r[1] ) ;
945 glNormal3d ( -tet_r[3][0], -tet_r[3][1], -tet_r[3][2] ) ; glVertex3dv ( tet_r[0] ) ; glVertex3dv ( tet_r[1] ) ; glVertex3dv ( tet_r[2] ) ;
952 void FGAPIENTRY glutSolidTetrahedron( void )
954 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidTetrahedron" );
956 glBegin( GL_TRIANGLES ) ;
957 glNormal3d ( -tet_r[0][0], -tet_r[0][1], -tet_r[0][2] ) ; glVertex3dv ( tet_r[1] ) ; glVertex3dv ( tet_r[3] ) ; glVertex3dv ( tet_r[2] ) ;
958 glNormal3d ( -tet_r[1][0], -tet_r[1][1], -tet_r[1][2] ) ; glVertex3dv ( tet_r[0] ) ; glVertex3dv ( tet_r[2] ) ; glVertex3dv ( tet_r[3] ) ;
959 glNormal3d ( -tet_r[2][0], -tet_r[2][1], -tet_r[2][2] ) ; glVertex3dv ( tet_r[0] ) ; glVertex3dv ( tet_r[3] ) ; glVertex3dv ( tet_r[1] ) ;
960 glNormal3d ( -tet_r[3][0], -tet_r[3][1], -tet_r[3][2] ) ; glVertex3dv ( tet_r[0] ) ; glVertex3dv ( tet_r[1] ) ; glVertex3dv ( tet_r[2] ) ;
967 double icos_r[12][3] = { { 1.0, 0.0, 0.0 },
968 { 0.447213595500, 0.894427191000, 0.0 }, { 0.447213595500, 0.276393202252, 0.850650808354 }, { 0.447213595500, -0.723606797748, 0.525731112119 }, { 0.447213595500, -0.723606797748, -0.525731112119 }, { 0.447213595500, 0.276393202252, -0.850650808354 },
969 { -0.447213595500, -0.894427191000, 0.0 }, { -0.447213595500, -0.276393202252, 0.850650808354 }, { -0.447213595500, 0.723606797748, 0.525731112119 }, { -0.447213595500, 0.723606797748, -0.525731112119 }, { -0.447213595500, -0.276393202252, -0.850650808354 },
970 { -1.0, 0.0, 0.0 } } ;
971 int icos_v [20][3] = { { 0, 1, 2 }, { 0, 2, 3 }, { 0, 3, 4 }, { 0, 4, 5 }, { 0, 5, 1 },
972 { 1, 8, 2 }, { 2, 7, 3 }, { 3, 6, 4 }, { 4, 10, 5 }, { 5, 9, 1 },
973 { 1, 9, 8 }, { 2, 8, 7 }, { 3, 7, 6 }, { 4, 6, 10 }, { 5, 10, 9 },
974 { 11, 9, 10 }, { 11, 8, 9 }, { 11, 7, 8 }, { 11, 6, 7 }, { 11, 10, 6 } } ;
976 void FGAPIENTRY glutWireIcosahedron( void )
980 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireIcosahedron" );
982 for ( i = 0; i < 20; i++ )
985 normal[0] = ( icos_r[icos_v[i][1]][1] - icos_r[icos_v[i][0]][1] ) * ( icos_r[icos_v[i][2]][2] - icos_r[icos_v[i][0]][2] ) - ( icos_r[icos_v[i][1]][2] - icos_r[icos_v[i][0]][2] ) * ( icos_r[icos_v[i][2]][1] - icos_r[icos_v[i][0]][1] ) ;
986 normal[1] = ( icos_r[icos_v[i][1]][2] - icos_r[icos_v[i][0]][2] ) * ( icos_r[icos_v[i][2]][0] - icos_r[icos_v[i][0]][0] ) - ( icos_r[icos_v[i][1]][0] - icos_r[icos_v[i][0]][0] ) * ( icos_r[icos_v[i][2]][2] - icos_r[icos_v[i][0]][2] ) ;
987 normal[2] = ( icos_r[icos_v[i][1]][0] - icos_r[icos_v[i][0]][0] ) * ( icos_r[icos_v[i][2]][1] - icos_r[icos_v[i][0]][1] ) - ( icos_r[icos_v[i][1]][1] - icos_r[icos_v[i][0]][1] ) * ( icos_r[icos_v[i][2]][0] - icos_r[icos_v[i][0]][0] ) ;
988 glBegin ( GL_LINE_LOOP ) ;
989 glNormal3dv ( normal ) ;
990 glVertex3dv ( icos_r[icos_v[i][0]] ) ;
991 glVertex3dv ( icos_r[icos_v[i][1]] ) ;
992 glVertex3dv ( icos_r[icos_v[i][2]] ) ;
1000 void FGAPIENTRY glutSolidIcosahedron( void )
1004 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidIcosahedron" );
1006 glBegin ( GL_TRIANGLES ) ;
1007 for ( i = 0; i < 20; i++ )
1010 normal[0] = ( icos_r[icos_v[i][1]][1] - icos_r[icos_v[i][0]][1] ) * ( icos_r[icos_v[i][2]][2] - icos_r[icos_v[i][0]][2] ) - ( icos_r[icos_v[i][1]][2] - icos_r[icos_v[i][0]][2] ) * ( icos_r[icos_v[i][2]][1] - icos_r[icos_v[i][0]][1] ) ;
1011 normal[1] = ( icos_r[icos_v[i][1]][2] - icos_r[icos_v[i][0]][2] ) * ( icos_r[icos_v[i][2]][0] - icos_r[icos_v[i][0]][0] ) - ( icos_r[icos_v[i][1]][0] - icos_r[icos_v[i][0]][0] ) * ( icos_r[icos_v[i][2]][2] - icos_r[icos_v[i][0]][2] ) ;
1012 normal[2] = ( icos_r[icos_v[i][1]][0] - icos_r[icos_v[i][0]][0] ) * ( icos_r[icos_v[i][2]][1] - icos_r[icos_v[i][0]][1] ) - ( icos_r[icos_v[i][1]][1] - icos_r[icos_v[i][0]][1] ) * ( icos_r[icos_v[i][2]][0] - icos_r[icos_v[i][0]][0] ) ;
1013 glNormal3dv ( normal ) ;
1014 glVertex3dv ( icos_r[icos_v[i][0]] ) ;
1015 glVertex3dv ( icos_r[icos_v[i][1]] ) ;
1016 glVertex3dv ( icos_r[icos_v[i][2]] ) ;
1025 double rdod_r[14][3] = { { 0.0, 0.0, 1.0 },
1026 { 0.707106781187, 0.000000000000, 0.5 }, { 0.000000000000, 0.707106781187, 0.5 }, { -0.707106781187, 0.000000000000, 0.5 }, { 0.000000000000, -0.707106781187, 0.5 },
1027 { 0.707106781187, 0.707106781187, 0.0 }, { -0.707106781187, 0.707106781187, 0.0 }, { -0.707106781187, -0.707106781187, 0.0 }, { 0.707106781187, -0.707106781187, 0.0 },
1028 { 0.707106781187, 0.000000000000, -0.5 }, { 0.000000000000, 0.707106781187, -0.5 }, { -0.707106781187, 0.000000000000, -0.5 }, { 0.000000000000, -0.707106781187, -0.5 },
1029 { 0.0, 0.0, -1.0 } } ;
1030 int rdod_v [12][4] = { { 0, 1, 5, 2 }, { 0, 2, 6, 3 }, { 0, 3, 7, 4 }, { 0, 4, 8, 1 },
1031 { 5, 10, 6, 2 }, { 6, 11, 7, 3 }, { 7, 12, 8, 4 }, { 8, 9, 5, 1 },
1032 { 5, 9, 13, 10 }, { 6, 10, 13, 11 }, { 7, 11, 13, 12 }, { 8, 12, 13, 9 } } ;
1033 double rdod_n[12][3] = {
1034 { 0.353553390594, 0.353553390594, 0.5 }, { -0.353553390594, 0.353553390594, 0.5 }, { -0.353553390594, -0.353553390594, 0.5 }, { 0.353553390594, -0.353553390594, 0.5 },
1035 { 0.000000000000, 1.000000000000, 0.0 }, { -1.000000000000, 0.000000000000, 0.0 }, { 0.000000000000, -1.000000000000, 0.0 }, { 1.000000000000, 0.000000000000, 0.0 },
1036 { 0.353553390594, 0.353553390594, -0.5 }, { -0.353553390594, 0.353553390594, -0.5 }, { -0.353553390594, -0.353553390594, -0.5 }, { 0.353553390594, -0.353553390594, -0.5 }
1039 void FGAPIENTRY glutWireRhombicDodecahedron( void )
1043 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireRhombicDodecahedron" );
1045 for ( i = 0; i < 12; i++ )
1047 glBegin ( GL_LINE_LOOP ) ;
1048 glNormal3dv ( rdod_n[i] ) ;
1049 glVertex3dv ( rdod_r[rdod_v[i][0]] ) ;
1050 glVertex3dv ( rdod_r[rdod_v[i][1]] ) ;
1051 glVertex3dv ( rdod_r[rdod_v[i][2]] ) ;
1052 glVertex3dv ( rdod_r[rdod_v[i][3]] ) ;
1060 void FGAPIENTRY glutSolidRhombicDodecahedron( void )
1064 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidRhombicDodecahedron" );
1066 glBegin ( GL_QUADS ) ;
1067 for ( i = 0; i < 12; i++ )
1069 glNormal3dv ( rdod_n[i] ) ;
1070 glVertex3dv ( rdod_r[rdod_v[i][0]] ) ;
1071 glVertex3dv ( rdod_r[rdod_v[i][1]] ) ;
1072 glVertex3dv ( rdod_r[rdod_v[i][2]] ) ;
1073 glVertex3dv ( rdod_r[rdod_v[i][3]] ) ;
1079 void FGAPIENTRY glutWireSierpinskiSponge ( int num_levels, GLdouble offset[3], GLdouble scale )
1083 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireSierpinskiSponge" );
1085 if ( num_levels == 0 )
1088 for ( i = 0 ; i < NUM_TETR_FACES ; i++ )
1090 glBegin ( GL_LINE_LOOP ) ;
1091 glNormal3d ( -tet_r[i][0], -tet_r[i][1], -tet_r[i][2] ) ;
1092 for ( j = 0; j < 3; j++ )
1094 double x = offset[0] + scale * tet_r[tet_i[i][j]][0] ;
1095 double y = offset[1] + scale * tet_r[tet_i[i][j]][1] ;
1096 double z = offset[2] + scale * tet_r[tet_i[i][j]][2] ;
1097 glVertex3d ( x, y, z ) ;
1105 GLdouble local_offset[3] ; /* Use a local variable to avoid buildup of roundoff errors */
1108 for ( i = 0 ; i < NUM_TETR_FACES ; i++ )
1110 local_offset[0] = offset[0] + scale * tet_r[i][0] ;
1111 local_offset[1] = offset[1] + scale * tet_r[i][1] ;
1112 local_offset[2] = offset[2] + scale * tet_r[i][2] ;
1113 glutWireSierpinskiSponge ( num_levels, local_offset, scale ) ;
1118 void FGAPIENTRY glutSolidSierpinskiSponge ( int num_levels, GLdouble offset[3], GLdouble scale )
1122 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidSierpinskiSponge" );
1124 if ( num_levels == 0 )
1126 glBegin ( GL_TRIANGLES ) ;
1128 for ( i = 0 ; i < NUM_TETR_FACES ; i++ )
1130 glNormal3d ( -tet_r[i][0], -tet_r[i][1], -tet_r[i][2] ) ;
1131 for ( j = 0; j < 3; j++ )
1133 double x = offset[0] + scale * tet_r[tet_i[i][j]][0] ;
1134 double y = offset[1] + scale * tet_r[tet_i[i][j]][1] ;
1135 double z = offset[2] + scale * tet_r[tet_i[i][j]][2] ;
1136 glVertex3d ( x, y, z ) ;
1144 GLdouble local_offset[3] ; /* Use a local variable to avoid buildup of roundoff errors */
1147 for ( i = 0 ; i < NUM_TETR_FACES ; i++ )
1149 local_offset[0] = offset[0] + scale * tet_r[i][0] ;
1150 local_offset[1] = offset[1] + scale * tet_r[i][1] ;
1151 local_offset[2] = offset[2] + scale * tet_r[i][2] ;
1152 glutSolidSierpinskiSponge ( num_levels, local_offset, scale ) ;
1157 /*** END OF FILE ***/