Index of /courses/cse418/project3/

NameLast ModifiedSize
UpParent Directory
[TXT]alloc.h2020-10-17 18:01 2k
[TXT]alloc.h.html2020-10-17 18:01 4k
Fileani.rgb2020-10-17 18:01 51k
Filebezier.inp2020-10-17 18:01 2k
Filebezier.out2020-10-17 18:01 2k
[TXT]color.cc2020-10-17 18:01 4k
[TXT]color.cc.html2020-10-17 18:01 8k
[TXT]color.h2020-10-17 18:01 2k
[TXT]color.h.html2020-10-17 18:01 4k
[TXT]draw.cc2020-10-17 18:01 12k
[TXT]draw.cc.html2020-10-17 18:01 30k
[TXT]draw.h2020-10-17 18:01 1k
[TXT]draw.h.html2020-10-17 18:01 1k
Fileglut32.dll2020-10-17 18:01 216k
[TXT]hash.cc2020-10-17 18:01 5k
[TXT]hash.cc.html2020-10-17 18:01 9k
[TXT]hash.h2020-10-17 18:01 2k
[TXT]hash.h.html2020-10-17 18:01 4k
[TXT]main.cc2020-10-17 18:01 20k
[TXT]main.cc.html2020-10-17 18:01 45k
FileMakefile2020-10-17 18:01 1k
[TXT]Makefile.html2020-10-17 18:01 3k
FileMakefile.LINUX2020-10-17 18:01 1k
Filemandrill.rgb2020-10-17 18:01 53k
[BIN]project3-windows.exe2020-10-17 18:01 176k
[CMP]project3.tar.gz2020-10-17 18:01 546k
[TXT]readrgb.cc2020-10-17 18:01 6k
[TXT]readrgb.cc.html2020-10-17 18:01 16k
[TXT]readrgb.h2020-10-17 18:01 1k
[TXT]readrgb.h.html2020-10-17 18:01 1k
Filesample1.inp2020-10-17 18:01 1k
Filesample2.inp2020-10-17 18:01 2k
Filesample3.inp2020-10-17 18:01 2k
[TXT]spline.cc2020-10-17 18:01 20k
[TXT]spline.cc.html2020-10-17 18:01 47k
[TXT]spline.h2020-10-17 18:01 5k
[TXT]spline.h.html2020-10-17 18:01 10k
Filesurf1.rgb2020-10-17 18:01 31k
Filesurf2.rgb2020-10-17 18:01 67k
Filesurf3.rgb2020-10-17 18:01 31k
Filetags2020-10-17 18:01 20k
Filetext1.rgb2020-10-17 18:01 94k
Filetext2.rgb2020-10-17 18:01 96k
Filetext3.rgb2020-10-17 18:01 50k
Filetext4.rgb2020-10-17 18:01 92k
Filetext5.rgb2020-10-17 18:01 50k
CSE 418, HW #3 ============== Spline Manipulation Program Group #15: Anirudh Modi modi@cse.psu.edu Brian T Bialek bialek@cse.psu.edu Christine A Reindl reindl@cse.psu.edu 18 November 1999 ************************************************************************************************* * QUICK NOTES: This is an C++/STL implementation. (Extra Credit) * * This program does contain texture mapping feature. (Extra Credit) (see Spec#15) * * This program also contains bump mapping feature. (Extra Credit) (see Spec#16) * ************************************************************************************************* PURPOSE: This is the README file for the spline editor program designed for modeling 3D objects with B�zier spline patches. USAGE: to complile type make. to run type project3 <optional args> -specifies a previously generated spline file to read from. If not supplied reads from default, bezier.inp. FILES: [This code was primarily developed and tested on a Linux machine with MesaGL] CODE: Makefile - makefile using gcc main.cc - contains main source code. spline.h - contains Spline class source code including all drawing routines. spline.cc draw.h - contains the routines for the evaluation of the spline curve, see notes draw.cc below for how spline is evaluated. color.h - contains color class source code, creates a color database for use in color.cc the programi. hash.cc - contains hash table for color functions, sets up the color database in hash.h hash table.<F12> readrgb.h - contains source code for texture mapping feature, reads in rgb texture readrgb.cc mapping information from rgb data files. INPUT/OUTPUT FILES: BEZIER.DAT - data file saved to when F2 pressed or save is selected from menu. Saves current scene. bezier.out - spline information is written here when program exits. bezier.inp - initial spline display is read in from this file upon starting the program (if this file exists). *.rgb - rgb format texture files. Program cycles through them when pressing F5. INSTRUCTIONS: README - instructions and documentation (this file) KEYBOARD COMMANDS: F1: HELP- brings up command menu that is displayed at beginning of program. F2: Save data to file - saves data to default data file: BEZIER.DAT. F3: Load data from file "BEZIER.DAT" arrow keys: Rotate +/-: Zoom in/out" 1: Increase mesh density 2: Decrease mesh density T: Toggle Select/View mode - toggles between moving about the scene (rotating and zooming) and picking control points for operations S: Toggle Flat/Smooth shading W: Toggle Wireframe/surface C: Toggle C1/C0 continuity - toggles join type for joined splines J: Join two splines M: Move a spline A: Add a spline D: Delete current spline U: Last undo/redo F5: Cycle/toggle texture mapping B: Toggle bump-mapping X: Clear screen Q: Quit Esc: Go to view mode MENU COMMANDS: The same commands listed above are also available from a menu that pops up when the user right clicks with the mouse. SPEC: 1. A new spline can be created and added to the model based on the position of the user's mouse. It is always added on the x,y plane - z is 0. (choose "Add a spline" from the menu) 2. A spline can be deleted by selecting a control point contained in it and selecting delete from the menu or pressing D on the keyboard. 3. The program has a select mode (entered by keyboard command or choice from menu) where the user can select any spline that exists in the current model by using the left mouse button. By default, when selected mode is enabled the program goes into move spline mode. By toggling the Move Spline/Cp menu option or pressing M on the keyboard will toggle between the move spline mode and the move CP mode. 4. For a selected spline surface, the program has an individual spline surface modeling mode (when user selects move CP mode). To get in this mode the user needs to be in select mode and select move CP mode, then is able to modify a specific spline from the model by clicking on control points and moving them around. 5. The user can do any of the following to a spline: delete, rotate, move, or modify it (using keyboard commands or choice from menu). a. To delete: 1. Select the desired spline to delete by selecting one if its control points 2. Select delete from the menu or press D on the keyboard to delete the current spline 3. After deleting a spline the mode is returned to select mode. b. To Rotate: 1. User must be in select mode and uses the middle mouse button to rotate the selected spline. 2. The user need not be on one of the control points to rotate. The user selects a spline by clicking a control point, then can be anywhere on screen to rotate spline around. c. To Move: 1. User must be in select mode, this is the default select mode. 2. To move a spline select move spline menu option or press M on the keyboard when in select mode. 3. Select one of the control points on the spline you want to move and drag the mouse. 4. Exit this mode by selecting a different mode to go into or move another spline d. In the modify mode: 1. User must be in select mode, and press M or select toggle move spline/CP mode from the menu. 2. The user is able to view the control points and select any control point and move it to another (x,y,z) location. (left click on the control point and move the mouse around) 3. The control point that has been selected is highlighted and the beginning and final, modified coordinates of this control point are displayed on the screen. 6. The program allows the user to "undo" the last modification to a control point or a spline. (choose "Undo" from the menu or use keyboard command "U") 7. The program also allows the user to "redo" after an "undo". (repeatedly pressing "U" will cycle through undo's and redo's). 8. The user is able to move the control point in a "click-and-drag" mode and the spline surface is continuously updated given the current position of the control point as it is being moved. 9. The spline surface is directly evaluated by a written routine. (see Spline Evaluation Routine below) 10. The user can adjust the level of spline subdivision.(entered by keyboard command 1 or 2, or choice from menu) 11. The program allows the user to rotate the complete object being modeled (while in view mode, use the mouse to rotation the object). 12. The user is able to select any two spline edges and ensure that the the spline surface will join along that edge (C0 continuity between two splines at that edge). (choose the join option from the menu, then choose the first spline, upon choosing the first spline you will be prompted to choose another one. choose the second spline and the two splines will be connected.) 13. The user is able to select a joined edge and set or (unset) the continuity of the parametric derivative across that edge (C1 continuity between two splines at that edge). 14. The program is able to read and write a file specifying the spline model. The defualt file used for reading and writing is "BEZIER.DAT". *** 15. The program contains a texture mapping feature with several built-in textures. To enable/cycle through textures and plain surface the user presses F5. All the relevant code is present in Spline::setTexture() in file "draw.cc". The texture mapping code for reading the rgb data files is in "readrgb.cc". *** 16. The program also contains a bump mapping feature generated using a random bump-mapping function defined in Spline::bumpMapFunction(u,v) in file "draw.cc". To toggle bump-mapping, press B or select the option from Rendering menu. SPLINE EVALUATION NOTES: The blending functions and tangents are evaluated once. Then they are stored in a table (s->data[][][3], s->normal[][][3]) and used to generate the spline surface mesh (all of this can be found in the Splines IV packet). This is accomplished with the following code which can be found in the "draw.cc" file: //*************************************************************************** // The direct evaluation of the Bezier Surface is done here Spline::MapCurrentGrid(theSpline *s, int nx, int ny) { allocData(s,nx,ny); float b[CP_NX][nx]; // assuming CP_NX = CP_NY and nx = ny float b2[CP_NX][nx]; // For the derivatives for (int i = 0; i < CP_NX; i++) b[i][0] = b[i][nx-1] = 0.0; b[0][0] = 1.0; b[CP_NX-1][nx-1] = 1.0; for (int j = 1; j < nx-1; j++) { b[0][j] = pow(1.0-j*1.0/(nx-1),CP_NX-1); for (int i = 1; i < CP_NX; i++) b[i][j] = b[i-1][j]*((CP_NX-i)*1.0/i)*(j*1.0/(nx-j-1)); } // Initialize the coefficients for the derivatives b2[0][0] = b2[CP_NX-2][nx-1] = -(CP_NX-1)*1.0; b2[1][0] = b2[CP_NX-1][nx-1] = (CP_NX-1)*1.0; for (int j = 1; j < nx-1; j++) for (int i = 0; i < CP_NX; i++) b2[i][j] = b[i][j]*(nx-1)*(i*1.0/j-(CP_NX-1-i)*1.0/(nx-1-j)); for (int i = 2; i < CP_NX; i++) b2[i][0] = b2[CP_NX-1-i][nx-1] = 0.0; float ddu[nx][ny][3]; // dQ/du float ddv[nx][ny][3]; // dQ/dv for (int i = 0; i < nx; i++) for (int j = 0; j < ny; j++) for (int k = 0; k < 3; k++) { s->data[i][j][k] = 0.0; ddu[i][j][k] = 0.0; ddv[i][j][k] = 0.0; } for (int i = 0; i < nx; i++) for (int j = 0; j < ny; j++) for (int m = 0; m < CP_NX; m++) for (int n = 0; n < CP_NY; n++) for (int k = 0; k < 3; k++) { s->data[i][j][k] += b[m][i]*b[n][j]* s->cp[m][n][k]; ddu[i][j][k] += b2[m][i]*b[n][j]* s->cp[m][n][k]; ddv[i][j][k] += b[m][i]*b2[n][j]* s->cp[m][n][k]; } if (bumpMappingEnabled) { srand(1); // Initialize seed for bumpMapFunction(u,v) for (int i = 0; i < nx; i++) for (int j = 0; j < ny; j++) computeBumpMapNormal(i*1.0/(nx-1),j*1.0/(ny-1), ddu[i][j],ddv[i][j],s->normal[i][j]); } else { for (int i = 0; i < nx; i++) for (int j = 0; j < ny; j++) unitCrossProd(ddu[i][j],ddv[i][j],s->normal[i][j]); } } //***************************************************************************
Proudly Served by LiteSpeed Web Server at www.anirudh.net Port 80