Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

glut_teapot.c

Go to the documentation of this file.
00001 
00002 /* Copyright (c) Mark J. Kilgard, 1994. */
00003 
00004 /**
00005 (c) Copyright 1993, Silicon Graphics, Inc.
00006 
00007 ALL RIGHTS RESERVED
00008 
00009 Permission to use, copy, modify, and distribute this software
00010 for any purpose and without fee is hereby granted, provided
00011 that the above copyright notice appear in all copies and that
00012 both the copyright notice and this permission notice appear in
00013 supporting documentation, and that the name of Silicon
00014 Graphics, Inc. not be used in advertising or publicity
00015 pertaining to distribution of the software without specific,
00016 written prior permission.
00017 
00018 THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU
00019 "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR
00020 OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
00021 MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  IN NO
00022 EVENT SHALL SILICON GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE
00023 ELSE FOR ANY DIRECT, SPECIAL, INCIDENTAL, INDIRECT OR
00024 CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER,
00025 INCLUDING WITHOUT LIMITATION, LOSS OF PROFIT, LOSS OF USE,
00026 SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD PARTIES, WHETHER OR
00027 NOT SILICON GRAPHICS, INC.  HAS BEEN ADVISED OF THE POSSIBILITY
00028 OF SUCH LOSS, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00029 ARISING OUT OF OR IN CONNECTION WITH THE POSSESSION, USE OR
00030 PERFORMANCE OF THIS SOFTWARE.
00031 
00032 US Government Users Restricted Rights
00033 
00034 Use, duplication, or disclosure by the Government is subject to
00035 restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
00036 (c)(1)(ii) of the Rights in Technical Data and Computer
00037 Software clause at DFARS 252.227-7013 and/or in similar or
00038 successor clauses in the FAR or the DOD or NASA FAR
00039 Supplement.  Unpublished-- rights reserved under the copyright
00040 laws of the United States.  Contractor/manufacturer is Silicon
00041 Graphics, Inc., 2011 N.  Shoreline Blvd., Mountain View, CA
00042 94039-7311.
00043 
00044 OpenGL(TM) is a trademark of Silicon Graphics, Inc.
00045 */
00046 
00047 #include <GL/gl.h>
00048 #include <GL/glut.h>
00049 
00050 /* Rim, body, lid, and bottom data must be reflected in x
00051    and y; handle and spout data across the y axis only.  */
00052 
00053 long patchdata[][16] =
00054 {
00055     /* rim */
00056   {102, 103, 104, 105, 4, 5, 6, 7, 8, 9, 10, 11,
00057     12, 13, 14, 15},
00058     /* body */
00059   {12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
00060     24, 25, 26, 27},
00061   {24, 25, 26, 27, 29, 30, 31, 32, 33, 34, 35, 36,
00062     37, 38, 39, 40},
00063     /* lid */
00064   {96, 96, 96, 96, 97, 98, 99, 100, 101, 101, 101,
00065     101, 0, 1, 2, 3,},
00066   {0, 1, 2, 3, 106, 107, 108, 109, 110, 111, 112,
00067     113, 114, 115, 116, 117},
00068     /* bottom */
00069   {118, 118, 118, 118, 124, 122, 119, 121, 123, 126,
00070     125, 120, 40, 39, 38, 37},
00071     /* handle */
00072   {41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
00073     53, 54, 55, 56},
00074   {53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
00075     28, 65, 66, 67},
00076     /* spout */
00077   {68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
00078     80, 81, 82, 83},
00079   {80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
00080     92, 93, 94, 95}
00081 };
00082 
00083 float cpdata[][3] =
00084 {
00085     {0.2, 0, 2.7}, {0.2, -0.112, 2.7}, {0.112, -0.2, 2.7}, {0,
00086     -0.2, 2.7}, {1.3375, 0, 2.53125}, {1.3375, -0.749, 2.53125},
00087     {0.749, -1.3375, 2.53125}, {0, -1.3375, 2.53125}, {1.4375,
00088     0, 2.53125}, {1.4375, -0.805, 2.53125}, {0.805, -1.4375,
00089     2.53125}, {0, -1.4375, 2.53125}, {1.5, 0, 2.4}, {1.5, -0.84,
00090     2.4}, {0.84, -1.5, 2.4}, {0, -1.5, 2.4}, {1.75, 0, 1.875},
00091     {1.75, -0.98, 1.875}, {0.98, -1.75, 1.875}, {0, -1.75,
00092     1.875}, {2, 0, 1.35}, {2, -1.12, 1.35}, {1.12, -2, 1.35},
00093     {0, -2, 1.35}, {2, 0, 0.9}, {2, -1.12, 0.9}, {1.12, -2,
00094     0.9}, {0, -2, 0.9}, {-2, 0, 0.9}, {2, 0, 0.45}, {2, -1.12,
00095     0.45}, {1.12, -2, 0.45}, {0, -2, 0.45}, {1.5, 0, 0.225},
00096     {1.5, -0.84, 0.225}, {0.84, -1.5, 0.225}, {0, -1.5, 0.225},
00097     {1.5, 0, 0.15}, {1.5, -0.84, 0.15}, {0.84, -1.5, 0.15}, {0,
00098     -1.5, 0.15}, {-1.6, 0, 2.025}, {-1.6, -0.3, 2.025}, {-1.5,
00099     -0.3, 2.25}, {-1.5, 0, 2.25}, {-2.3, 0, 2.025}, {-2.3, -0.3,
00100     2.025}, {-2.5, -0.3, 2.25}, {-2.5, 0, 2.25}, {-2.7, 0,
00101     2.025}, {-2.7, -0.3, 2.025}, {-3, -0.3, 2.25}, {-3, 0,
00102     2.25}, {-2.7, 0, 1.8}, {-2.7, -0.3, 1.8}, {-3, -0.3, 1.8},
00103     {-3, 0, 1.8}, {-2.7, 0, 1.575}, {-2.7, -0.3, 1.575}, {-3,
00104     -0.3, 1.35}, {-3, 0, 1.35}, {-2.5, 0, 1.125}, {-2.5, -0.3,
00105     1.125}, {-2.65, -0.3, 0.9375}, {-2.65, 0, 0.9375}, {-2,
00106     -0.3, 0.9}, {-1.9, -0.3, 0.6}, {-1.9, 0, 0.6}, {1.7, 0,
00107     1.425}, {1.7, -0.66, 1.425}, {1.7, -0.66, 0.6}, {1.7, 0,
00108     0.6}, {2.6, 0, 1.425}, {2.6, -0.66, 1.425}, {3.1, -0.66,
00109     0.825}, {3.1, 0, 0.825}, {2.3, 0, 2.1}, {2.3, -0.25, 2.1},
00110     {2.4, -0.25, 2.025}, {2.4, 0, 2.025}, {2.7, 0, 2.4}, {2.7,
00111     -0.25, 2.4}, {3.3, -0.25, 2.4}, {3.3, 0, 2.4}, {2.8, 0,
00112     2.475}, {2.8, -0.25, 2.475}, {3.525, -0.25, 2.49375},
00113     {3.525, 0, 2.49375}, {2.9, 0, 2.475}, {2.9, -0.15, 2.475},
00114     {3.45, -0.15, 2.5125}, {3.45, 0, 2.5125}, {2.8, 0, 2.4},
00115     {2.8, -0.15, 2.4}, {3.2, -0.15, 2.4}, {3.2, 0, 2.4}, {0, 0,
00116     3.15}, {0.8, 0, 3.15}, {0.8, -0.45, 3.15}, {0.45, -0.8,
00117     3.15}, {0, -0.8, 3.15}, {0, 0, 2.85}, {1.4, 0, 2.4}, {1.4,
00118     -0.784, 2.4}, {0.784, -1.4, 2.4}, {0, -1.4, 2.4}, {0.4, 0,
00119     2.55}, {0.4, -0.224, 2.55}, {0.224, -0.4, 2.55}, {0, -0.4,
00120     2.55}, {1.3, 0, 2.55}, {1.3, -0.728, 2.55}, {0.728, -1.3,
00121     2.55}, {0, -1.3, 2.55}, {1.3, 0, 2.4}, {1.3, -0.728, 2.4},
00122     {0.728, -1.3, 2.4}, {0, -1.3, 2.4}, {0, 0, 0}, {1.425,
00123     -0.798, 0}, {1.5, 0, 0.075}, {1.425, 0, 0}, {0.798, -1.425,
00124     0}, {0, -1.5, 0.075}, {0, -1.425, 0}, {1.5, -0.84, 0.075},
00125     {0.84, -1.5, 0.075}
00126 };
00127 
00128 static float tex[2][2][2] =
00129 {
00130   { {0, 0},
00131     {1, 0}},
00132   { {0, 1},
00133     {1, 1}}
00134 };
00135 
00136 static void
00137 teapot(GLint grid, GLdouble scale, GLenum type)
00138 {
00139   float p[4][4][3], q[4][4][3], r[4][4][3], s[4][4][3];
00140   long i, j, k, l;
00141 
00142   glPushAttrib(GL_ENABLE_BIT | GL_EVAL_BIT);
00143   glEnable(GL_AUTO_NORMAL);
00144   glEnable(GL_NORMALIZE);
00145   glEnable(GL_MAP2_VERTEX_3);
00146   glEnable(GL_MAP2_TEXTURE_COORD_2);
00147   glPushMatrix();
00148   glRotatef(270.0, 1.0, 0.0, 0.0);
00149   glScalef(0.5 * scale, 0.5 * scale, 0.5 * scale);
00150   glTranslatef(0.0, 0.0, -1.5);
00151   for (i = 0; i < 10; i++) {
00152     for (j = 0; j < 4; j++) {
00153       for (k = 0; k < 4; k++) {
00154         for (l = 0; l < 3; l++) {
00155           p[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l];
00156           q[j][k][l] = cpdata[patchdata[i][j * 4 + (3 - k)]][l];
00157           if (l == 1)
00158             q[j][k][l] *= -1.0;
00159           if (i < 6) {
00160             r[j][k][l] =
00161               cpdata[patchdata[i][j * 4 + (3 - k)]][l];
00162             if (l == 0)
00163               r[j][k][l] *= -1.0;
00164             s[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l];
00165             if (l == 0)
00166               s[j][k][l] *= -1.0;
00167             if (l == 1)
00168               s[j][k][l] *= -1.0;
00169           }
00170         }
00171       }
00172     }
00173     glMap2f(GL_MAP2_TEXTURE_COORD_2, 0, 1, 2, 2, 0, 1, 4, 2,
00174       &tex[0][0][0]);
00175     glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,
00176       &p[0][0][0]);
00177     glMapGrid2f(grid, 0.0, 1.0, grid, 0.0, 1.0);
00178     glEvalMesh2(type, 0, grid, 0, grid);
00179     glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,
00180       &q[0][0][0]);
00181     glEvalMesh2(type, 0, grid, 0, grid);
00182     if (i < 6) {
00183       glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,
00184         &r[0][0][0]);
00185       glEvalMesh2(type, 0, grid, 0, grid);
00186       glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,
00187         &s[0][0][0]);
00188       glEvalMesh2(type, 0, grid, 0, grid);
00189     }
00190   }
00191   glPopMatrix();
00192   glPopAttrib();
00193 }
00194 
00195 void
00196 glutSolidTeapot(GLdouble scale)
00197 {
00198   teapot(14, scale, GL_FILL);
00199 }
00200 
00201 void
00202 glutWireTeapot(GLdouble scale)
00203 {
00204   teapot(10, scale, GL_LINE);
00205 }
00206 
 

Powered by Plone

This site conforms to the following standards: