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 "../include/GL/freeglut.h"
35 #include "freeglut_internal.h"
38 * TODO BEFORE THE STABLE RELEASE:
40 * Following functions have been contributed by Andreas Umbach.
42 * glutWireCube() -- looks OK
43 * glutSolidCube() -- OK
45 * Those functions have been implemented by John Fay.
47 * glutWireTorus() -- looks OK
48 * glutSolidTorus() -- looks OK
49 * glutWireDodecahedron() -- looks OK
50 * glutSolidDodecahedron() -- looks OK
51 * glutWireOctahedron() -- looks OK
52 * glutSolidOctahedron() -- looks OK
53 * glutWireTetrahedron() -- looks OK
54 * glutSolidTetrahedron() -- looks OK
55 * glutWireIcosahedron() -- looks OK
56 * glutSolidIcosahedron() -- looks OK
58 * The Following functions have been updated by Nigel Stewart, based
59 * on FreeGLUT 2.0.0 implementations:
61 * glutWireSphere() -- looks OK
62 * glutSolidSphere() -- looks OK
63 * glutWireCone() -- looks OK
64 * glutSolidCone() -- looks OK
68 /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
71 * Draws a wireframed cube. Code contributed by Andreas Umbach <marvin@dataway.ch>
73 void FGAPIENTRY glutWireCube( GLdouble dSize )
75 double size = dSize * 0.5;
77 # define V(a,b,c) glVertex3d( a size, b size, c size );
78 # define N(a,b,c) glNormal3d( a, b, c );
81 * PWO: I dared to convert the code to use macros...
83 glBegin( GL_LINE_LOOP ); N( 1.0, 0.0, 0.0); V(+,-,+); V(+,-,-); V(+,+,-); V(+,+,+); glEnd();
84 glBegin( GL_LINE_LOOP ); N( 0.0, 1.0, 0.0); V(+,+,+); V(+,+,-); V(-,+,-); V(-,+,+); glEnd();
85 glBegin( GL_LINE_LOOP ); N( 0.0, 0.0, 1.0); V(+,+,+); V(-,+,+); V(-,-,+); V(+,-,+); glEnd();
86 glBegin( GL_LINE_LOOP ); N(-1.0, 0.0, 0.0); V(-,-,+); V(-,+,+); V(-,+,-); V(-,-,-); glEnd();
87 glBegin( GL_LINE_LOOP ); N( 0.0,-1.0, 0.0); V(-,-,+); V(-,-,-); V(+,-,-); V(+,-,+); glEnd();
88 glBegin( GL_LINE_LOOP ); N( 0.0, 0.0,-1.0); V(-,-,-); V(-,+,-); V(+,+,-); V(+,-,-); glEnd();
95 * Draws a solid cube. Code contributed by Andreas Umbach <marvin@dataway.ch>
97 void FGAPIENTRY glutSolidCube( GLdouble dSize )
99 double size = dSize * 0.5;
101 # define V(a,b,c) glVertex3d( a size, b size, c size );
102 # define N(a,b,c) glNormal3d( a, b, c );
105 * PWO: Again, I dared to convert the code to use macros...
108 N( 1.0, 0.0, 0.0); V(+,-,+); V(+,-,-); V(+,+,-); V(+,+,+);
109 N( 0.0, 1.0, 0.0); V(+,+,+); V(+,+,-); V(-,+,-); V(-,+,+);
110 N( 0.0, 0.0, 1.0); V(+,+,+); V(-,+,+); V(-,-,+); V(+,-,+);
111 N(-1.0, 0.0, 0.0); V(-,-,+); V(-,+,+); V(-,+,-); V(-,-,-);
112 N( 0.0,-1.0, 0.0); V(-,-,+); V(-,-,-); V(+,-,-); V(+,-,+);
113 N( 0.0, 0.0,-1.0); V(-,-,-); V(-,+,-); V(+,+,-); V(+,-,-);
121 * Compute lookup table of cos and sin values forming a cirle
124 * It is the responsibility of the caller to free these tables
125 * The size of the table is (n+1) to form a connected loop
126 * The last entry is exactly the same as the first
127 * The sign of n can be flipped to get the reverse loop
130 static void circleTable(double **sint,double **cost,const int n)
134 /* Table size, the sign of n flips the circle direction */
136 const int size = abs(n);
138 /* Determine the angle between samples */
140 const double angle = 2*M_PI/(double)n;
142 /* Allocate memory for n samples, plus duplicate of first entry at the end */
144 *sint = (double *) calloc(sizeof(double), size+1);
145 *cost = (double *) calloc(sizeof(double), size+1);
147 /* Bail out if memory allocation fails, fgError never returns */
149 if (!(*sint) || !(*cost))
153 fgError("Failed to allocate memory in circleTable");
156 /* Compute cos and sin around the circle */
158 for (i=0; i<size; i++)
160 (*sint)[i] = sin(angle*i);
161 (*cost)[i] = cos(angle*i);
164 /* Last sample is duplicate of the first */
166 (*sint)[size] = (*sint)[0];
167 (*cost)[size] = (*cost)[0];
171 * Draws a solid sphere
173 void FGAPIENTRY glutSolidSphere(GLdouble radius, GLint slices, GLint stacks)
177 /* Adjust z and radius as stacks are drawn. */
182 /* Pre-computed circle */
184 double *sint1,*cost1;
185 double *sint2,*cost2;
186 circleTable(&sint1,&cost1,-slices);
187 circleTable(&sint2,&cost2,stacks*2);
189 /* The top stack is covered with a triangle fan */
196 glBegin(GL_TRIANGLE_FAN);
199 glVertex3d(0,0,radius);
201 for (j=slices; j>=0; j--)
203 glNormal3d(cost1[j]*r1, sint1[j]*r1, z1 );
204 glVertex3d(cost1[j]*r1*radius, sint1[j]*r1*radius, z1*radius);
209 /* Cover each stack with a quad strip, except the top and bottom stacks */
211 for( i=1; i<stacks-1; i++ )
213 z0 = z1; z1 = cost2[i+1];
214 r0 = r1; r1 = sint2[i+1];
216 glBegin(GL_QUAD_STRIP);
218 for(j=0; j<=slices; j++)
220 glNormal3d(cost1[j]*r1, sint1[j]*r1, z1 );
221 glVertex3d(cost1[j]*r1*radius, sint1[j]*r1*radius, z1*radius);
222 glNormal3d(cost1[j]*r0, sint1[j]*r0, z0 );
223 glVertex3d(cost1[j]*r0*radius, sint1[j]*r0*radius, z0*radius);
229 /* The bottom stack is covered with a triangle fan */
234 glBegin(GL_TRIANGLE_FAN);
237 glVertex3d(0,0,-radius);
239 for (j=0; j<=slices; j++)
241 glNormal3d(cost1[j]*r0, sint1[j]*r0, z0 );
242 glVertex3d(cost1[j]*r0*radius, sint1[j]*r0*radius, z0*radius);
247 /* Release sin and cos tables */
256 * Draws a solid sphere
258 void FGAPIENTRY glutWireSphere(GLdouble radius, GLint slices, GLint stacks)
262 /* Adjust z and radius as stacks and slices are drawn. */
267 /* Pre-computed circle */
269 double *sint1,*cost1;
270 double *sint2,*cost2;
271 circleTable(&sint1,&cost1,-slices );
272 circleTable(&sint2,&cost2, stacks*2);
274 /* Draw a line loop for each stack */
276 for (i=1; i<stacks; i++)
281 glBegin(GL_LINE_LOOP);
283 for(j=0; j<=slices; j++)
289 glVertex3d(x*r*radius,y*r*radius,z*radius);
295 /* Draw a line loop for each slice */
297 for (i=0; i<slices; i++)
299 glBegin(GL_LINE_STRIP);
301 for(j=0; j<=stacks; j++)
303 x = cost1[i]*sint2[j];
304 y = sint1[i]*sint2[j];
308 glVertex3d(x*radius,y*radius,z*radius);
314 /* Release sin and cos tables */
325 void FGAPIENTRY glutSolidCone( GLdouble base, GLdouble height, GLint slices, GLint stacks )
329 /* Step in z and radius as stacks are drawn. */
334 const double zStep = height/stacks;
335 const double rStep = base/stacks;
337 /* Scaling factors for vertex normals */
339 const double cosn = ( height / sqrt ( height * height + base * base ));
340 const double sinn = ( base / sqrt ( height * height + base * base ));
342 /* Pre-computed circle */
345 circleTable(&sint,&cost,-slices);
347 /* Cover the circular base with a triangle fan... */
355 glBegin(GL_TRIANGLE_FAN);
357 glNormal3d(0.0,0.0,-1.0);
358 glVertex3d(0.0,0.0, z0 );
360 for (j=0; j<=slices; j++)
361 glVertex3d(cost[j]*r0, sint[j]*r0, z0);
365 /* Cover each stack with a quad strip, except the top stack */
367 for( i=0; i<stacks-1; i++ )
369 glBegin(GL_QUAD_STRIP);
371 for(j=0; j<=slices; j++)
373 glNormal3d(cost[j]*sinn, sint[j]*sinn, cosn);
374 glVertex3d(cost[j]*r0, sint[j]*r0, z0 );
375 glVertex3d(cost[j]*r1, sint[j]*r1, z1 );
378 z0 = z1; z1 += zStep;
379 r0 = r1; r1 -= rStep;
384 /* The top stack is covered with individual triangles */
386 glBegin(GL_TRIANGLES);
388 glNormal3d(cost[0]*sinn, sint[0]*sinn, cosn);
390 for (j=0; j<slices; j++)
392 glVertex3d(cost[j+0]*r0, sint[j+0]*r0, z0 );
393 glVertex3d(0, 0, height);
394 glNormal3d(cost[j+1]*sinn, sint[j+1]*sinn, cosn );
395 glVertex3d(cost[j+1]*r0, sint[j+1]*r0, z0 );
400 /* Release sin and cos tables */
409 void FGAPIENTRY glutWireCone( GLdouble base, GLdouble height, GLint slices, GLint stacks)
413 /* Step in z and radius as stacks are drawn. */
418 const double zStep = height/stacks;
419 const double rStep = base/stacks;
421 /* Scaling factors for vertex normals */
423 const double cosn = ( height / sqrt ( height * height + base * base ));
424 const double sinn = ( base / sqrt ( height * height + base * base ));
426 /* Pre-computed circle */
429 circleTable(&sint,&cost,-slices);
431 /* Draw the stacks... */
433 for (i=0; i<stacks; i++)
435 glBegin(GL_LINE_LOOP);
437 for( j=0; j<slices; j++ )
439 glNormal3d(cost[j]*sinn, sint[j]*sinn, cosn);
440 glVertex3d(cost[j]*r, sint[j]*r, z );
449 /* Draw the slices */
455 for (j=0; j<slices; j++)
457 glNormal3d(cost[j]*sinn, sint[j]*sinn, cosn );
458 glVertex3d(cost[j]*r, sint[j]*r, 0.0 );
459 glVertex3d(0.0, 0.0, height);
464 /* Release sin and cos tables */
472 * Draws a solid cylinder
474 void FGAPIENTRY glutSolidCylinder(GLdouble radius, GLdouble height, GLint slices, GLint stacks)
478 /* Step in z and radius as stacks are drawn. */
481 const double zStep = height/stacks;
483 /* Pre-computed circle */
486 circleTable(&sint,&cost,-slices);
488 /* Cover the base and top */
490 glBegin(GL_TRIANGLE_FAN);
491 glNormal3d(0.0, 0.0, -1.0 );
492 glVertex3d(0.0, 0.0, 0.0 );
493 for (j=0; j<=slices; j++)
494 glVertex3d(cost[j]*radius, sint[j]*radius, 0.0);
497 glBegin(GL_TRIANGLE_FAN);
498 glNormal3d(0.0, 0.0, 1.0 );
499 glVertex3d(0.0, 0.0, height);
500 for (j=slices; j>=0; j--)
501 glVertex3d(cost[j]*radius, sint[j]*radius, height);
509 for (i=1; i<=stacks; i++)
514 glBegin(GL_QUAD_STRIP);
515 for (j=0; j<=slices; j++ )
517 glNormal3d(cost[j], sint[j], 0.0 );
518 glVertex3d(cost[j]*radius, sint[j]*radius, z0 );
519 glVertex3d(cost[j]*radius, sint[j]*radius, z1 );
523 z0 = z1; z1 += zStep;
526 /* Release sin and cos tables */
533 * Draws a wire cylinder
535 void FGAPIENTRY glutWireCylinder(GLdouble radius, GLdouble height, GLint slices, GLint stacks)
539 /* Step in z and radius as stacks are drawn. */
542 const double zStep = height/stacks;
544 /* Pre-computed circle */
547 circleTable(&sint,&cost,-slices);
549 /* Draw the stacks... */
551 for (i=0; i<=stacks; i++)
556 glBegin(GL_LINE_LOOP);
558 for( j=0; j<slices; j++ )
560 glNormal3d(cost[j], sint[j], 0.0);
561 glVertex3d(cost[j]*radius, sint[j]*radius, z );
569 /* Draw the slices */
573 for (j=0; j<slices; j++)
575 glNormal3d(cost[j], sint[j], 0.0 );
576 glVertex3d(cost[j]*radius, sint[j]*radius, 0.0 );
577 glVertex3d(cost[j]*radius, sint[j]*radius, height);
582 /* Release sin and cos tables */
591 void FGAPIENTRY glutWireTorus( GLdouble dInnerRadius, GLdouble dOuterRadius, GLint nSides, GLint nRings )
593 double iradius = dInnerRadius, oradius = dOuterRadius, phi, psi, dpsi, dphi;
594 double *vertex, *normal;
596 double spsi, cpsi, sphi, cphi ;
599 * Allocate the vertices array
601 vertex = (double *)calloc( sizeof(double), 3 * nSides * nRings );
602 normal = (double *)calloc( sizeof(double), 3 * nSides * nRings );
606 dpsi = 2.0 * M_PI / (double)nRings ;
607 dphi = -2.0 * M_PI / (double)nSides ;
610 for( j=0; j<nRings; j++ )
616 for( i=0; i<nSides; i++ )
618 int offset = 3 * ( j * nSides + i ) ;
621 *(vertex + offset + 0) = cpsi * ( oradius + cphi * iradius ) ;
622 *(vertex + offset + 1) = spsi * ( oradius + cphi * iradius ) ;
623 *(vertex + offset + 2) = sphi * iradius ;
624 *(normal + offset + 0) = cpsi * cphi ;
625 *(normal + offset + 1) = spsi * cphi ;
626 *(normal + offset + 2) = sphi ;
633 for( i=0; i<nSides; i++ )
635 glBegin( GL_LINE_LOOP );
637 for( j=0; j<nRings; j++ )
639 int offset = 3 * ( j * nSides + i ) ;
640 glNormal3dv( normal + offset );
641 glVertex3dv( vertex + offset );
647 for( j=0; j<nRings; j++ )
649 glBegin(GL_LINE_LOOP);
651 for( i=0; i<nSides; i++ )
653 int offset = 3 * ( j * nSides + i ) ;
654 glNormal3dv( normal + offset );
655 glVertex3dv( vertex + offset );
669 void FGAPIENTRY glutSolidTorus( GLdouble dInnerRadius, GLdouble dOuterRadius, GLint nSides, GLint nRings )
671 double iradius = dInnerRadius, oradius = dOuterRadius, phi, psi, dpsi, dphi;
672 double *vertex, *normal;
674 double spsi, cpsi, sphi, cphi ;
677 * Increment the number of sides and rings to allow for one more point than surface
683 * Allocate the vertices array
685 vertex = (double *)calloc( sizeof(double), 3 * nSides * nRings );
686 normal = (double *)calloc( sizeof(double), 3 * nSides * nRings );
690 dpsi = 2.0 * M_PI / (double)(nRings - 1) ;
691 dphi = -2.0 * M_PI / (double)(nSides - 1) ;
694 for( j=0; j<nRings; j++ )
700 for( i=0; i<nSides; i++ )
702 int offset = 3 * ( j * nSides + i ) ;
705 *(vertex + offset + 0) = cpsi * ( oradius + cphi * iradius ) ;
706 *(vertex + offset + 1) = spsi * ( oradius + cphi * iradius ) ;
707 *(vertex + offset + 2) = sphi * iradius ;
708 *(normal + offset + 0) = cpsi * cphi ;
709 *(normal + offset + 1) = spsi * cphi ;
710 *(normal + offset + 2) = sphi ;
718 for( i=0; i<nSides-1; i++ )
720 for( j=0; j<nRings-1; j++ )
722 int offset = 3 * ( j * nSides + i ) ;
723 glNormal3dv( normal + offset );
724 glVertex3dv( vertex + offset );
725 glNormal3dv( normal + offset + 3 );
726 glVertex3dv( vertex + offset + 3 );
727 glNormal3dv( normal + offset + 3 * nSides + 3 );
728 glVertex3dv( vertex + offset + 3 * nSides + 3 );
729 glNormal3dv( normal + offset + 3 * nSides );
730 glVertex3dv( vertex + offset + 3 * nSides );
744 void FGAPIENTRY glutWireDodecahedron( void )
746 /* Magic Numbers: It is possible to create a dodecahedron by attaching two pentagons to each face of
747 * of a cube. The coordinates of the points are:
748 * (+-x,0, z); (+-1, 1, 1); (0, z, x )
749 * where x = 0.61803398875 and z = 1.61803398875.
751 glBegin ( GL_LINE_LOOP ) ;
752 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 ) ;
754 glBegin ( GL_LINE_LOOP ) ;
755 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 ) ;
757 glBegin ( GL_LINE_LOOP ) ;
758 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 ) ;
760 glBegin ( GL_LINE_LOOP ) ;
761 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 ) ;
764 glBegin ( GL_LINE_LOOP ) ;
765 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 ) ;
767 glBegin ( GL_LINE_LOOP ) ;
768 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 ) ;
770 glBegin ( GL_LINE_LOOP ) ;
771 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 ) ;
773 glBegin ( GL_LINE_LOOP ) ;
774 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 ) ;
777 glBegin ( GL_LINE_LOOP ) ;
778 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 ) ;
780 glBegin ( GL_LINE_LOOP ) ;
781 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 ) ;
783 glBegin ( GL_LINE_LOOP ) ;
784 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 ) ;
786 glBegin ( GL_LINE_LOOP ) ;
787 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 ) ;
794 void FGAPIENTRY glutSolidDodecahedron( void )
796 /* Magic Numbers: It is possible to create a dodecahedron by attaching two pentagons to each face of
797 * of a cube. The coordinates of the points are:
798 * (+-x,0, z); (+-1, 1, 1); (0, z, x )
799 * where x = 0.61803398875 and z = 1.61803398875.
801 glBegin ( GL_POLYGON ) ;
802 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 ) ;
804 glBegin ( GL_POLYGON ) ;
805 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 ) ;
807 glBegin ( GL_POLYGON ) ;
808 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 ) ;
810 glBegin ( GL_POLYGON ) ;
811 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 ) ;
814 glBegin ( GL_POLYGON ) ;
815 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 ) ;
817 glBegin ( GL_POLYGON ) ;
818 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 ) ;
820 glBegin ( GL_POLYGON ) ;
821 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 ) ;
823 glBegin ( GL_POLYGON ) ;
824 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 ) ;
827 glBegin ( GL_POLYGON ) ;
828 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 ) ;
830 glBegin ( GL_POLYGON ) ;
831 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 ) ;
833 glBegin ( GL_POLYGON ) ;
834 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 ) ;
836 glBegin ( GL_POLYGON ) ;
837 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 ) ;
844 void FGAPIENTRY glutWireOctahedron( void )
847 glBegin( GL_LINE_LOOP );
848 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 );
849 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 );
850 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 );
851 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 );
852 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 );
853 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 );
854 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 );
855 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 );
863 void FGAPIENTRY glutSolidOctahedron( void )
866 glBegin( GL_TRIANGLES );
867 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 );
868 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 );
869 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 );
870 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 );
871 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 );
872 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 );
873 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 );
874 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 );
882 void FGAPIENTRY glutWireTetrahedron( void )
884 /* Magic Numbers: r0 = ( 1, 0, 0 )
885 * r1 = ( -1/3, 2 sqrt(2) / 3, 0 )
886 * r2 = ( -1/3, -sqrt(2) / 3, sqrt(6) / 3 )
887 * r3 = ( -1/3, -sqrt(2) / 3, -sqrt(6) / 3 )
888 * |r0| = |r1| = |r2| = |r3| = 1
889 * Distance between any two points is 2 sqrt(6) / 3
891 * Normals: The unit normals are simply the negative of the coordinates of the point not on the surface.
894 double r0[3] = { 1.0, 0.0, 0.0 } ;
895 double r1[3] = { -0.333333333333, 0.942809041582, 0.0 } ;
896 double r2[3] = { -0.333333333333, -0.471404520791, 0.816496580928 } ;
897 double r3[3] = { -0.333333333333, -0.471404520791, -0.816496580928 } ;
899 glBegin( GL_LINE_LOOP ) ;
900 glNormal3d ( -1.0, 0.0, 0.0 ) ; glVertex3dv ( r1 ) ; glVertex3dv ( r3 ) ; glVertex3dv ( r2 ) ;
901 glNormal3d ( 0.333333333333, -0.942809041582, 0.0 ) ; glVertex3dv ( r0 ) ; glVertex3dv ( r2 ) ; glVertex3dv ( r3 ) ;
902 glNormal3d ( 0.333333333333, 0.471404520791, -0.816496580928 ) ; glVertex3dv ( r0 ) ; glVertex3dv ( r3 ) ; glVertex3dv ( r1 ) ;
903 glNormal3d ( 0.333333333333, 0.471404520791, 0.816496580928 ) ; glVertex3dv ( r0 ) ; glVertex3dv ( r1 ) ; glVertex3dv ( r2 ) ;
910 void FGAPIENTRY glutSolidTetrahedron( void )
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 double r0[3] = { 1.0, 0.0, 0.0 } ;
923 double r1[3] = { -0.333333333333, 0.942809041582, 0.0 } ;
924 double r2[3] = { -0.333333333333, -0.471404520791, 0.816496580928 } ;
925 double r3[3] = { -0.333333333333, -0.471404520791, -0.816496580928 } ;
927 glBegin( GL_TRIANGLES ) ;
928 glNormal3d ( -1.0, 0.0, 0.0 ) ; glVertex3dv ( r1 ) ; glVertex3dv ( r3 ) ; glVertex3dv ( r2 ) ;
929 glNormal3d ( 0.333333333333, -0.942809041582, 0.0 ) ; glVertex3dv ( r0 ) ; glVertex3dv ( r2 ) ; glVertex3dv ( r3 ) ;
930 glNormal3d ( 0.333333333333, 0.471404520791, -0.816496580928 ) ; glVertex3dv ( r0 ) ; glVertex3dv ( r3 ) ; glVertex3dv ( r1 ) ;
931 glNormal3d ( 0.333333333333, 0.471404520791, 0.816496580928 ) ; glVertex3dv ( r0 ) ; glVertex3dv ( r1 ) ; glVertex3dv ( r2 ) ;
938 double icos_r[12][3] = { { 1.0, 0.0, 0.0 },
939 { 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 },
940 { -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 },
941 { -1.0, 0.0, 0.0 } } ;
942 int icos_v [20][3] = { { 0, 1, 2 }, { 0, 2, 3 }, { 0, 3, 4 }, { 0, 4, 5 }, { 0, 5, 1 },
943 { 1, 8, 2 }, { 2, 7, 3 }, { 3, 6, 4 }, { 4, 10, 5 }, { 5, 9, 1 },
944 { 1, 9, 8 }, { 2, 8, 7 }, { 3, 7, 6 }, { 4, 6, 10 }, { 5, 10, 9 },
945 { 11, 9, 10 }, { 11, 8, 9 }, { 11, 7, 8 }, { 11, 6, 7 }, { 11, 10, 6 } } ;
947 void FGAPIENTRY glutWireIcosahedron( void )
950 for ( i = 0; i < 20; i++ )
953 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] ) ;
954 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] ) ;
955 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] ) ;
956 glBegin ( GL_LINE_LOOP ) ;
957 glNormal3dv ( normal ) ;
958 glVertex3dv ( icos_r[icos_v[i][0]] ) ;
959 glVertex3dv ( icos_r[icos_v[i][1]] ) ;
960 glVertex3dv ( icos_r[icos_v[i][2]] ) ;
968 void FGAPIENTRY glutSolidIcosahedron( void )
972 glBegin ( GL_TRIANGLES ) ;
973 for ( i = 0; i < 20; i++ )
976 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] ) ;
977 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] ) ;
978 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] ) ;
979 glNormal3dv ( normal ) ;
980 glVertex3dv ( icos_r[icos_v[i][0]] ) ;
981 glVertex3dv ( icos_r[icos_v[i][1]] ) ;
982 glVertex3dv ( icos_r[icos_v[i][2]] ) ;
991 double rdod_r[14][3] = { { 0.0, 0.0, 1.0 },
992 { 0.707106781187, 0.000000000000, 0.5 }, { 0.000000000000, 0.707106781187, 0.5 }, { -0.707106781187, 0.000000000000, 0.5 }, { 0.000000000000, -0.707106781187, 0.5 },
993 { 0.707106781187, 0.707106781187, 0.0 }, { -0.707106781187, 0.707106781187, 0.0 }, { -0.707106781187, -0.707106781187, 0.0 }, { 0.707106781187, -0.707106781187, 0.0 },
994 { 0.707106781187, 0.000000000000, -0.5 }, { 0.000000000000, 0.707106781187, -0.5 }, { -0.707106781187, 0.000000000000, -0.5 }, { 0.000000000000, -0.707106781187, -0.5 },
995 { 0.0, 0.0, -1.0 } } ;
996 int rdod_v [12][4] = { { 0, 1, 5, 2 }, { 0, 2, 6, 3 }, { 0, 3, 7, 4 }, { 0, 4, 8, 1 },
997 { 5, 10, 6, 2 }, { 6, 11, 7, 3 }, { 7, 12, 8, 4 }, { 8, 9, 5, 1 },
998 { 5, 9, 13, 10 }, { 6, 10, 13, 11 }, { 7, 11, 13, 12 }, { 8, 12, 13, 9 } } ;
999 double rdod_n[12][3] = {
1000 { 0.353553390594, 0.353553390594, 0.5 }, { -0.353553390594, 0.353553390594, 0.5 }, { -0.353553390594, -0.353553390594, 0.5 }, { 0.353553390594, -0.353553390594, 0.5 },
1001 { 0.000000000000, 1.000000000000, 0.0 }, { -1.000000000000, 0.000000000000, 0.0 }, { 0.000000000000, -1.000000000000, 0.0 }, { 1.000000000000, 0.000000000000, 0.0 },
1002 { 0.353553390594, 0.353553390594, -0.5 }, { -0.353553390594, 0.353553390594, -0.5 }, { -0.353553390594, -0.353553390594, -0.5 }, { 0.353553390594, -0.353553390594, -0.5 }
1005 void FGAPIENTRY glutWireRhombicDodecahedron( void )
1008 for ( i = 0; i < 12; i++ )
1010 glBegin ( GL_LINE_LOOP ) ;
1011 glNormal3dv ( rdod_n[i] ) ;
1012 glVertex3dv ( rdod_r[rdod_v[i][0]] ) ;
1013 glVertex3dv ( rdod_r[rdod_v[i][1]] ) ;
1014 glVertex3dv ( rdod_r[rdod_v[i][2]] ) ;
1015 glVertex3dv ( rdod_r[rdod_v[i][3]] ) ;
1023 void FGAPIENTRY glutSolidRhombicDodecahedron( void )
1027 glBegin ( GL_QUADS ) ;
1028 for ( i = 0; i < 12; i++ )
1030 glNormal3dv ( rdod_n[i] ) ;
1031 glVertex3dv ( rdod_r[rdod_v[i][0]] ) ;
1032 glVertex3dv ( rdod_r[rdod_v[i][1]] ) ;
1033 glVertex3dv ( rdod_r[rdod_v[i][2]] ) ;
1034 glVertex3dv ( rdod_r[rdod_v[i][3]] ) ;
1042 static GLdouble tetrahedron_v[4][3] = /* Vertices */
1044 { -0.5, -0.288675134595, -0.144337567297 },
1045 { 0.5, -0.288675134595, -0.144337567297 },
1046 { 0.0, 0.577350269189, -0.144337567297 },
1047 { 0.0, 0.0, 0.672159013631 }
1050 static GLint tetrahedron_i[4][3] = /* Vertex indices */
1052 { 0, 1, 2 }, { 0, 2, 3 }, { 0, 3, 1 }, { 1, 3, 2 }
1055 static GLdouble tetrahedron_n[4][3] = /* Normals */
1058 { -0.816496580928, 0.471404520791, 0.333333333333 },
1059 { 0.0, -0.942809041582, 0.333333333333 },
1060 { 0.816496580928, 0.471404520791, 0.333333333333 }
1063 void FGAPIENTRY glutWireSierpinskiSponge ( int num_levels, GLdouble offset[3], GLdouble scale )
1067 if ( num_levels == 0 )
1070 for ( i = 0 ; i < NUM_FACES ; i++ )
1072 glBegin ( GL_LINE_LOOP ) ;
1073 glNormal3dv ( tetrahedron_n[i] ) ;
1074 for ( j = 0; j < 3; j++ )
1076 double x = offset[0] + scale * tetrahedron_v[tetrahedron_i[i][j]][0] ;
1077 double y = offset[1] + scale * tetrahedron_v[tetrahedron_i[i][j]][1] ;
1078 double z = offset[2] + scale * tetrahedron_v[tetrahedron_i[i][j]][2] ;
1079 glVertex3d ( x, y, z ) ;
1087 GLdouble local_offset[3] ; /* Use a local variable to avoid buildup of roundoff errors */
1090 local_offset[0] = offset[0] + scale * tetrahedron_v[0][0] ;
1091 local_offset[1] = offset[1] + scale * tetrahedron_v[0][1] ;
1092 local_offset[2] = offset[2] + scale * tetrahedron_v[0][2] ;
1093 glutWireSierpinskiSponge ( num_levels, local_offset, scale ) ;
1094 local_offset[0] += scale ;
1095 glutWireSierpinskiSponge ( num_levels, local_offset, scale ) ;
1096 local_offset[0] -= 0.5 * scale ;
1097 local_offset[1] += 0.866025403784 * scale ;
1098 glutWireSierpinskiSponge ( num_levels, local_offset, scale ) ;
1099 local_offset[1] -= 0.577350269189 * scale ;
1100 local_offset[2] += 0.816496580928 * scale ;
1101 glutWireSierpinskiSponge ( num_levels, local_offset, scale ) ;
1105 void FGAPIENTRY glutSolidSierpinskiSponge ( int num_levels, GLdouble offset[3], GLdouble scale )
1109 if ( num_levels == 0 )
1111 glBegin ( GL_TRIANGLES ) ;
1113 for ( i = 0 ; i < NUM_FACES ; i++ )
1115 glNormal3dv ( tetrahedron_n[i] ) ;
1116 for ( j = 0; j < 3; j++ )
1118 double x = offset[0] + scale * tetrahedron_v[tetrahedron_i[i][j]][0] ;
1119 double y = offset[1] + scale * tetrahedron_v[tetrahedron_i[i][j]][1] ;
1120 double z = offset[2] + scale * tetrahedron_v[tetrahedron_i[i][j]][2] ;
1121 glVertex3d ( x, y, z ) ;
1129 GLdouble local_offset[3] ; /* Use a local variable to avoid buildup of roundoff errors */
1132 local_offset[0] = offset[0] + scale * tetrahedron_v[0][0] ;
1133 local_offset[1] = offset[1] + scale * tetrahedron_v[0][1] ;
1134 local_offset[2] = offset[2] + scale * tetrahedron_v[0][2] ;
1135 glutSolidSierpinskiSponge ( num_levels, local_offset, scale ) ;
1136 local_offset[0] += scale ;
1137 glutSolidSierpinskiSponge ( num_levels, local_offset, scale ) ;
1138 local_offset[0] -= 0.5 * scale ;
1139 local_offset[1] += 0.866025403784 * scale ;
1140 glutSolidSierpinskiSponge ( num_levels, local_offset, scale ) ;
1141 local_offset[1] -= 0.577350269189 * scale ;
1142 local_offset[2] += 0.816496580928 * scale ;
1143 glutSolidSierpinskiSponge ( num_levels, local_offset, scale ) ;
1149 /*** END OF FILE ***/