Syllabus  Blank  Homework  Quizzes  
Notes  Labs  Scores  Blank 
Mesh examples:

Elements of Polygonal mesh modeling:
see http://en.wikipedia.org/wiki/Polygon_mesh


A large class of 3D shapes can be generated by extruding or sweeping a 2D shape through space.
Creating Prisms
if ( j == N  1 ) next = 0; else next = j + 1; 
Extrusions with a "Twist"
e.g. scaling factor = 0.7, translation = H along z
e.g. the cap has been rotated through an angle θ about zaxis before translation.
Building Segmented Extrusions  Tubes and Snakes
M_{0}P_{0}, M_{0}P_{1}, M_{0}P_{2}, M_{0}P_{3}, M_{1}P_{0}, M_{1}P_{1}, M_{1}P_{2}, M_{1}P_{3}, M_{2}P_{0}, ...., M_{3}P_{3}
represent the body and head of a snake. 
Designing Tubes using 3D Curves
x(t) = cos ( t )
y(t) = sin ( t ) z(t) = b*t i.e. C(t) = ( cos(t), sin(t), b*t ) for some constant b 

Tangents to the helix. 
Frenet frames for the helix. 
See programs in /pool/u/class/cs520/labs/lab4
cse5204b.avi (3D Objects by Extrusion)a) p = 2, q = 5; b) p = 1, q = 7
Produce 3D objects by
A surface can be obtained by
Details:
Example
/* sweep1.cpp * Construct surfaces of revolution using wireframe but have not considered lighting. * Surface is generated by revolving a curve around xaxis. * A curve f(x) is generated by polynomial interpolation from some control points * or by some interested functions. * * @Author: T.L. Yu, Fall 2008 */ #include <GL/glut.h> #include <stdlib.h> #include <stdio.h> #include <math.h> #include <stdlib.h> using namespace std; const double PI = 3.14159265389; int anglex= 0, angley = 0, anglez = 0; //rotation angles int window; //control points GLfloat ctrlpoints[4][3] = { { 0.0, 0.0, 0.0}, { 1.0, 0.5, 0.0}, {2.0, 1.2, 0.0}, {3.0, 3, 0.0}}; void init(void) { glClearColor(1.0, 1.0, 1.0, 1.0); glPolygonMode( GL_FRONT, GL_LINE ) ; glPolygonMode( GL_BACK, GL_LINE ) ; glShadeModel(GL_FLAT); } //polynomial interpretation for N points float polyint ( float points[][3], float x, int N ) { float y; float num = 1.0, den = 1.0; float sum = 0.0; for ( int i = 0; i < N; ++i ) { num = den = 1.0; for ( int j = 0; j < N; ++j ) { if ( j == i ) continue; num = num * ( x  points[j][0] ); //x  xj } for ( int j = 0; j < N; ++j ) { if ( j == i ) continue; den = den * ( points[i][0]  points[j][0] ); //xi  xj } sum += num / den * points[i][1]; } y = sum; return y; } float aLine ( float x ) { return x + 2.5; } void display(void) { int i, j; float x, y, z, r; //current coordinates float x1, y1, z1, r1; //next coordinates float theta; glClear(GL_COLOR_BUFFER_BIT); glColor3f(0.0, 1.0, 1.0); const float startx = 0, endx = 3; const int nx = 20; //number of slices along xdirection const int ntheta = 20; //number of angular slices const float dx = (endx  startx) / nx; //x step size const float dtheta = 2*PI / ntheta; //angular step size x = startx; //r = aLine ( x ); r = polyint( ctrlpoints, x, 4); glPushMatrix(); glRotatef( anglex, 1.0, 0.0, 0.0); //rotate the object about xaxis glRotatef( angley, 0.0, 1.0, 0.0); //rotate about yaxis glRotatef( anglez, 0.0, 0.0, 1.0); //rotate about zaxis for ( i = 0; i < nx; ++i ) { //step through x theta = 0; x1 = x + dx; //next x //r1 = aLine ( x1 ); //next f(x) r1 = polyint( ctrlpoints, x1, 4); //next f(x) //draw the surface composed of quadrilaterals by sweeping theta glBegin( GL_QUAD_STRIP ); for ( j = 0; j <= ntheta; ++j ) { theta += dtheta; double cosa = cos( theta ); double sina = sin ( theta ); y = r * cosa; y1 = r1 * cosa; //current and next y z = r * sina; z1 = r1 * sina; //current and next z //edge from point at x to point at next x glVertex3f (x, y, z); glVertex3f (x1, y1, z1); //forms quad with next pair of points with incremented theta value } glEnd(); x = x1; r = r1; } //for i /* The following code displays the control points as dots. */ glPointSize(5.0); glColor3f(1.0, 0.0, 1.0); glBegin(GL_POINTS); for (i = 0; i < 4; i++) glVertex3fv(&ctrlpoints[i][0]); glEnd(); glPopMatrix(); glFlush(); } void reshape(int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); if (w <= h) glOrtho(5.0, 5.0, 5.0*(GLfloat)h/(GLfloat)w, 5.0*(GLfloat)h/(GLfloat)w, 5.0, 5.0); else glOrtho(5.0*(GLfloat)w/(GLfloat)h, 5.0*(GLfloat)w/(GLfloat)h, 5.0, 5.0, 5.0, 5.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } void keyboard(unsigned char key, int x, int y) { switch(key) { case 'x': anglex = ( anglex + 3 ) % 360; break; case 'X': anglex = ( anglex  3 ) % 360; break; case 'y': angley = ( angley + 3 ) % 360; break; case 'Y': angley = ( angley  3 ) % 360; break; case 'z': anglez = ( anglez + 3 ) % 360; break; case 'Z': anglez = ( anglez  3 ) % 360; break; case 'r': //reset anglez = angley = anglex = 0; glLoadIdentity(); break; case 27: /* escape */ glutDestroyWindow(window); exit(0); } glutPostRedisplay(); } int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode (GLUT_SINGLE  GLUT_RGB); glutInitWindowSize (500, 500); glutInitWindowPosition (100, 100); glutCreateWindow (argv[0]); init (); glutDisplayFunc(display); glutReshapeFunc(reshape); glutKeyboardFunc (keyboard); glutMainLoop(); return 0; } 
Area of a Surface of Revolution
e.g. f(x) = √x 1 ≤ x ≤ 4
S = π/6 ( 17√(17)  5√5 ) 
Volume of a Surface of Revolution
e.g.
Version 2008 interface with a dark theme 
3ds max living room rendered with VRay 
In addition to its modeling and animation tools, the latest version of 3ds Max also features advanced shaders (such as ambient occlusion and subsurface scattering), dynamic simulation, particle systems, radiosity, normal map creation and rendering, and global illumination.
MAIN3DS
EDIT3DS
EDIT_OBJECT
OBJ_TRIMESH
TRI_VERTEXL
TRI_FACEL1
TRI_TEXCOORD
Header of "knot.3ds"
[ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0123456789012345] 00000: 4D 4D 29 D2 00 00 02 00 0A 00 00 00 03 00 00 00 MM)............. 00016: 3D 3D 39 D1 00 00 3E 3D 0A 00 00 00 03 00 00 00 ==9...>=........ 00032: 00 01 0A 00 00 00 00 00 80 3F 00 40 1F D1 00 00 .........?.@.... 00048: 54 6F 72 75 73 20 4B 6E 6F 74 00 00 41 0E D1 00 Torus Knot..A... 00064: 00 10 41 C4 49 00 00 25 06 3D 09 61 42 40 3E 05 ..A.I..%.=.aB@>. 00080: C0 E7 75 01 42 6A 93 6D 42 F2 1F 0E C1 38 E3 1C ..u.Bj.mB....8.. 00096: 42 C5 E3 67 42 40 BC 5D C1 D5 D4 3F 42 59 80 51 B..gB@.]...?BY.Q 00112: 42 97 CF 7A C1 C6 ED 60 42 DF 68 30 42 87 8F 5D B..z...`B.h0B..] 00128: C1 BA 4F 77 42 46 7B 0D 42 7C D2 0D C1 5C FB 7C ..OwBF{.B...\. 00144: 42 E2 26 E4 41 81 D8 03 C0 B3 6B 70 42 88 12 CB B.&.A.....kpB... 00160: 41 81 B4 97 40 64 FE 54 42 D0 71 D6 41 8F 76 1B A...@d.TB.q.A.v. 00176: 41 C7 0C 32 42 53 9C 01 42 E9 89 38 41 D6 F3 10 A..2BS..B..8A... 00192: 42 CC B3 22 42 DD 49 1B 41 C1 23 F5 41 66 A1 45 B.."B.I.A.#.Af.E 00208: 42 AC 19 97 40 7C CC E9 41 3B 09 61 42 13 3E 05 B...@..A;.aB.>. 00224: C0 E5 75 01 42 AD 0E 6E 42 04 51 AA 3F 38 97 0D ..u.B..nB.Q.?8.. 00240: 42 BA 90 7B 42 F4 63 84 C0 C9 08 2D 42 A6 99 76 B..{B.c....B..v [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0123456789012345] 
00000: 4D 4D 29 D2 00 00 MAIN3DS chunk length 02 00 0A 00 00 00 BOTTOM subchunk length 03 00 00 00 LEFT 00016: 3D 3D 39 D1 00 00 3E 3D EDIT3DS sibling chunk length 0A 00 00 00 03 00 00 00 00032: 00 01 0A 00 00 00 00 00 80 3F 00 40 1F D1 00 00 .........?.@.... 00048: 54 6F 72 75 73 20 4B 6E 6F 74 00 00 41 0E D1 00 Torus Knot..A... 00064: 00 10 41 C4 49 00 00 25 06 3D 09 61 42 40 3E 05 ..A.I..%.=.aB@>. 00080: C0 E7 75 01 42 6A 93 6D 42 F2 1F 0E C1 38 E3 1C ..u.Bj.mB....8.. 00096: 42 C5 E3 67 42 40 BC 5D C1 D5 D4 3F 42 59 80 51 B..gB@.]...?BY.Q 00112: 42 97 CF 7A C1 C6 ED 60 42 DF 68 30 42 87 8F 5D B..z...`B.h0B..] 00128: C1 BA 4F 77 42 46 7B 0D 42 7C D2 0D C1 5C FB 7C ..OwBF{.B...\. 00144: 42 E2 26 E4 41 81 D8 03 C0 B3 6B 70 42 88 12 CB B.&.A.....kpB... 00160: 41 81 B4 97 40 64 FE 54 42 D0 71 D6 41 8F 76 1B A...@d.TB.q.A.v. 00176: 41 C7 0C 32 42 53 9C 01 42 E9 89 38 41 D6 F3 10 A..2BS..B..8A... 00192: 42 CC B3 22 42 DD 49 1B 41 C1 23 F5 41 66 A1 45 B.."B.I.A.#.Af.E 00208: 42 AC 19 97 40 7C CC E9 41 3B 09 61 42 13 3E 05 B...@..A;.aB.>. 00224: C0 E5 75 01 42 AD 0E 6E 42 04 51 AA 3F 38 97 0D ..u.B..nB.Q.?8.. 00240: 42 BA 90 7B 42 F4 63 84 C0 C9 08 2D 42 A6 99 76 B..{B.c....B..v [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0123456789012345]
....
For details, see sepcifications.
Opensource library: http://www.lib3ds.org/
struct Vertex { float x, y, z; }; void display_meshes ( Lib3dsFile *f ) { struct Vertex *vs, v; Lib3dsMesh *mesh; Lib3dsMaterial *mat=0; //mesh materials init_texture(); //initialize texture features glEnable( GL_CULL_FACE ); glCullFace ( GL_BACK ); Lib3dsNode *node; //3DS node for ( int k = 0; k < f>nmeshes; ++k ) { mesh = f>meshes[k]; vs = getVertices(f>meshes[k]);//get a vertice of mesh //calculate normal float (*normals)[3] = (float (*)[3]) malloc (3*3*sizeof(float) * mesh>nfaces); lib3ds_mesh_calculate_face_normals ( mesh, normals ); for ( int i = 0; i < mesh>nfaces; ++i ) { if (mat) { //set material properties float s; glMaterialfv(GL_FRONT, GL_AMBIENT, mat>ambient ); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat>diffuse); glMaterialfv(GL_FRONT, GL_SPECULAR, mat>specular); s = pow(2, 10.0*mat>shininess); if (s>128.0) s=128.0; glMaterialf(GL_FRONT, GL_SHININESS, s); } //if ( mat ) //display the mesh glBegin ( GL_TRIANGLES ); for ( int j = 0; j < 3; ++ j ) { glNormal3fv(normals[3*i+j]); int ii = mesh>faces[i].index[j]; v = vs[ii]; if ( mesh>texcos ) //texture coordinates glTexCoord2f(mesh>texcos[ii][0], mesh>texcos[ii][1]); glVertex3fv( ( float*)&v ); } glEnd(); } //for i free ( normals ); } //for k free ( vs ); } void display() { Lib3dsCamera *camera; Lib3dsFile *f = get3dsFile ( (char *) filename ); if ( f>ncameras > 0 ) { camera = f>cameras[0]; glMatrixMode ( GL_PROJECTION ); glLoadIdentity(); gluPerspective ( camera>fov, 1.0, camera>near_range, camera>far_range ); glMatrixMode ( GL_MODELVIEW ); glLoadIdentity(); gluLookAt(camera>position[0], camera>position[1], camera>position[2], camera>target[0], camera>target[1], camera>target[2], 0, 1, 0 ); } display_meshes ( f ); glFlush(); glutSwapBuffers(); } 
Opensource software:
Blender
Blender Tutorial