Subject: Linux install workshops (This message is being sent to CPSC 215 Students and TA's) The Clemson Linux Users Group (CLUG) is a student organization whose mission is to encourage the use of the Linux flavor of Unix and to assist new users in installing and using Linux. Their home page is: http://clemsonlinux.org/ They will be assisting students this week who wish to create dual boot Windows/Linux environments upon their computers. # Dual-boot Workshop Location: Martin M104 Date: 2005-08-22, 13:00:00 - 15:00:00 Help incoming freshmen get started with the dual-boot images. # Dual-boot Workshop Location: Martin M104 Date: 2005-08-23, 11:00:00 - 13:00:00 Help incoming freshmen get started with the dual-boot images. While this is NOT required for CPSC 215, if you do not already have an operational Unix/Linux computer it WILL significantly facilitate your work in the class. I highly recommend that you take advantage of this opportunity if you have not already done so. If you choose to participate, I suspect that you should ensure that you have at least 10 GB of available hard disk space and that you defragment your disk in advance. jmw Subject: Short programming assignment 1 available (This message is being sent to CPSC 215 Students and TA's) The assignment description is available in assns/sp1.f05.pdf in the class directory. It's due at midnight friday so I wouldn't delay in getting started. Subject: Short programming assignment 1 clarification (This message is being sent to CPSC 215 Students and TA's) The output produced by your program MUST be in the existing format of sp1.c. Any additions, deletions, or re-ordering in the output of the program you submit WILL lead to deductions. Subject: Short programming assignment 1 clarification(s) (This message is being sent to CPSC 215 Students and TA's) 1 - In the turn in procedure the id wjsmith is used as an EXAMPLE ONLY. Everywhere the word "wjsmith" appears you should supply your personal userid. For another example, if I personally were to turn in a program I would supply the word "westall" since it is my personal userid everywhere the word "wjsmith" appears. However, YOU shouldn't specify either "wjsmith" nor "westall" you should specify whatever your personal userid happens to be. 2 - If you try to use the gc script to compile sp1.c and get class/215/assns ==> gc sp1.c Error: sp1.c:9: syntax error near line 9 context: >>> int <<< main() class/215/assns ==> That means you are running the graph count (gc) program instead of your gc script!! You can fix that by always remembering to put ./ in front of any command you run out of one of your private directories (e.g: ./gc sp1 and ./sp1 < a2t4.ppm) or by putting a . at the start of your path environment variable -- The latter approach is discouraged by the sysadmin but thats the way I do it. 3 - For input to sp1 you may use any of the .ppm files in either the images or the examples subdirectories of the class directory. You can (and should) also build bogo .ppm files containing only a valid header by using your favorite <<<<>>>>> (NOT M$) text editor and creating something like: P6 600 # test comment 800 ## another ## more 255 Subject: Unix help for AP and xfer students (This message is being sent to CPSC 215 Students and TA's) Some students (transfers and AP in particular) may have limited or no experience working on the Departmental systems or Unix systems in general. Mr. Duckworth will be conducting "Unix Bootcamp" in the 110D lab at 1:25 on Friday. If you feel that your Unix skills are not quite up to par, please e-mail Mr. Duckworth (duckwos@clemson.edu) that you plan to attend. Subject: Hint on sp1 (This message is being sent to CPSC 215 Students and TA's) The value returned by sscanf() with %d format codes can be viewed separate cases: -1 => there was nothing but whitespace characters between the start of buffer pointer and the NULL at the end of the string 0 => there was some non-whitespace but the first field encountered was not a decimal number >0 => one or more numeric fields was successfully obtained. Therefore, if your .ppm header looks like P6 1024 768 255 and you use count = sscanf(buf + 2, "....") you will set count to -1 which is a BAD THING!!!!!!!!!! Thus it is advisable to do something along the lines of status = sscanf(...); if (status > 0) count += status; Subject: sp1 grades (This message is being sent to CPSC 215 Students and TA's) I will be sending out evaluation for sp1 shortly. The test data and a solution may be found in the assns/sp1data subdirectory of the 215 class directory. These programs were evaluated by me.. not the TA so you should see or email me if you have questions. ----------- The sp2 assignment is also available now. See sp2.f05.pdf in the assns subdirectory of the 215 class directory. It is due Friday. Subject: Additional sp2 requirments (This message is being sent to CPSC 215 Students and TA's) A student asks: >> You didn't mention anything about style/commenting of the code. >> It varies from teacher to teacher, and I would appreciate it if >> you could clarify your policies for future reference. I have no requirements regarding things like format of variables names and location of { characters. Variable names should be reasonably indicative of their use in the program though. More detailed standards will be announced for the raytracer. For the short programs please use these: 1 - All programs when compiled with -Wall must produce NO WARNINGs. 2 - Source code lines must not exceed 75 characters in length. 3 - Reasonable commenting must be provided. The sp1.c solution is an example of what I consider reasonable. 4 - For sp2.c pointer notation (instead of array notation) must be used to read/write pixel data. (You may leave the array notation in the .ppm header reading code). Subject: Example sp2 data (This message is being sent to CPSC 215 Students and TA's) Example input and output images for sp2 are in assns/sp2data Subject: sp2 notes (This message is being sent to CPSC 215 Students and TA's) If you are logged into a departmental machine using ssh, the xv image viewer WILL NOT WORK. If you are unable to physically locate yourself in front of a departmental machine and wish to view image data on your not-so-user-friendly MS-Window$ system you will need to do ONE of the following (solution 3 is recommended): (1) (a) find a freeware .ppm viewer for Window$ (there are plenty) (b) hope it contains minimal spyware and viri (c) download and install it upon your Window$ system (d) install the ssh family of tools from the W: (whatever) disk and figure out how to download the .ppm file from a CS departmental system. (e) Use your new ppm viewer to view it. (2) Find a Window$ Xserver program. There used to be one available at Clemson. I don't know if its still exists and/or is free. I recommend you see the fine folks in the basement of Martin Hall if you wish to pursue this (painful) option. But I definitely CAN"T HELP YOU on this route. (3) See the fine folks at CLUG and let them convert your computer into a dual boot Window$/Linux system. You can DO ALL of your programming for this course on the Linux side. And Linux contains xv! Furthermore, I am an EXPERT Linux sysadmin and will be happy to help you with download / upload problems. =================================================================== How to create a .tar file cd to the directory containing your sp2 code and do tar cvf ../sp2.tar * The file sp2.tar (which will live in the directory ABOVE the directory containing your source) should be sent to me. If you run into trouble with that you can just attach the source (this time). Subject: sp2 sample image (This message is being sent to CPSC 215 Students and TA's) If your output image looks VERY similar to the one in sp2data but yours is VERY slightly but perceptibly lighter than the one I placed in the sp2data directory, yours is likely CORRECT! If yours has three visible copies of the original, big bands of black, or great clouds of strange unrecognizable fuzz then you have other problems. The following defective code was present in my solution sum += 0.56 * *im1++; Simple typos such as this one in which I had a finger spasm and typed 0.56 instead of 0.59 -- can be frustratingly hard to find. Fortunately this one didn't cost my employer millions of $$$$s (unless one of you can successfully sue Clemson). As an act of penitence I will forgive all errors IN ENTERING THE WEIGHTS on this assignment. Thanks to Thomas Davidson for helping me find the error of my ways! mw Subject: reminder on collaboration (This message is being sent to CPSC 215 Students and TA's) Four people turned in programs that ignored identical aspects of the spec and contained other identical bugs that produced identical defective images. Its AMAZINGLY hard to work independently and produce identical BROKEN images. All four of these are now inexorably headed toward an appearance at the student honor court. The may get an F for the course, the may get a 0 for the assignment, or they may get off altogether. I don't know. What I DO KNOW is that they clearly ignored my no collaboration rule and that they are in for a VERY unpleasant next couple of weeks.. When tempted -- THINK about this --- and just say NO! Subject: sp3 available (This message is being sent to CPSC 215 Students and TA's) The sp3 specification is now available in the assns directory. A solution for sp2 which may be used as a starting point is available in sp2data Due date is Friday. My solution required 11 lines of new code beyond sp2.c Subject: sp3 typo (This message is being sent to CPSC 215 Students and TA's) In the "corresponding column" discussion I had accidentally entered 944 where I meant 914's. I think its fixed now. Subject: Procedure for requesting help on programs (This message is being sent to CPSC 215 Students and TA's) If you get stuck on a program, I strongly encourage you to ask me for help. I'm generally available about 14 hrs / day and 7 days a week. Requests submitted after 9 or 10 pm may not be answered until the next morning though. If your question involves a problem with your program, it is important that you send (1) everything I need to build your program (2) the input that causes the problem and (3) a brief description of the problem. The first two items should be included in a .tar file See msg.010 in the msgs directory if you have forgotten how to build one. Please avoid doing either of the following: (1) sending me only defective OUTPUT and asking me how your program might have come to create this defective output. I honestly can't tell without source code. (2) Students for some reason, often seem to think they are doing me a favor by sending me a snippet rather than the WHOLE program. This is NOT TRUE. If you knew what the problem was you would solve it yourself. Thus, by very definition, you don't really know what parts of the program contain hints to the nature of the problem. Furthermore, even if you don't use gdb, I OFTEN use it. If you send a snippet, you have just disarmed me! Thanks for helping me help you! Subject: sp4 available (This message is being sent to CPSC 215 Students and TA's) See sp4.f05.pdf in the assns directory. Auxilliary materials are in the sp4data subdirectory Subject: sp2/3 logs (This message is being sent to CPSC 215 Students and TA's) sp2 and sp3 logs will be distributed shortly. For sp2 grades are conditional and assume that no finding of unauthorized collaboration occurs. For sp3 two tests were made: a.out 500 200 < mike.ppm > newmike.1.ppm a.out 200 500 < mike.ppm > newmike.2.ppm If I reported your program as broken and you can properly produce these two images tell me what machine you used and I'll test again. If I report minor problems that you don't understand you should stop by some time and let me show you -- as the old saying goes: a picture is worth 1000 e-mail words of description. Subject: sp4 correction (This message is being sent to CPSC 215 Students and TA's) The x-coord mapping from pixel to world space should actually look like: *(world + 0) = x / (proj->win_size_pixel[0] - 1) * proj->win_size_world[0]; *(world + 0) -= proj->win_size_world[0] / 2.0; The -1 is needed because, for example, a pixmap that is 5 pixels in width consists of pixels 0, 1, 2, 3, 4 and thus has a width of 4 (instead of 5) in pixel space. The sample output in sp4data has been updated to reflect this correction. mw Subject: Further sp4 clarifications (This message is being sent to CPSC 215 Students and TA's) (1) It is mandatory that all arithmetic in the map_pix.. function be done in the floating point domain. You can achieve that by casting the first element in the expression to a double. e.g. (double) x / (proj->win...) (2) The -1 correction needs to be applied to the "y" coordinate too. (3) In Java and C++ class methods refer to class data elements directly by name without qualfication. So a statement such as fscanf(in,"%lf %lf", &win_size_world[0], &win_size_world[1]); will work correctly in C++ if proj_t is a class and projection_init() is a class method. The C language has neither classes nor class methods!! Therefore any attempt to use a statement such as the one above will yield: projection.c:21: `win_size_world' undeclared (first use in this function) projection.c:21: (Each undeclared identifier is reported only once projection.c:21: for each function it appears in.) In C, EVERY reference to an element of a structure must be prefaced by xxx. or xxx-> where xxx represents the name of an instance of or a pointer to the structure of which win_size_world is a member! Subject: Another excellent question reg'd sp4 (This message is being sent to CPSC 215 Students and TA's) >> Dr. Westall, >> >> I'm having complications with my map_pix_to_world function. I'm >> using a method similar to the one in your notes on page 61: >> >> map_pix_to_world(proj_t proj*, int x, int y, double *world) >> >> However, the one defined in rayhdrs.h is as follows: >> >> map_pix_to_world(int x, int y, double *world) >> >> Do I need to change my function so that it doesn't take proj_t >> *proj as a parameter or is this an issue with rayhdrs.h? Thank >> you for you time. This little dilemma is one that is commonly encountered in C programming -- whether to trade off good design principles for a bit of extra performance. The notes reflect good design. The sample "rayhdrs.h" came from my own raytracer in which I decided to try to make it run a bit faster. There is no "right" answer here and either way is fine. The only thing that is not fine here is compiler warnings! So if you use the notes approach you MUST change rayhdrs.h. If you use the Westall implementation approach you obviously still need access to the proj_t data structure that defines the projection. So how do you do that? The way I did it was to define static proj_t *proj = NULL; // static variable where we keep proj ptr at the top of my projection.c module outside the body of all functions... Some might say eeeewwwwwwwwweee "global variable". But because its static its global ONLY to the functions in projection.c --- more on this later in the course. Anyhow, in projection_init() I do proj = malloc(sizeof(proj_t)); but I DON"T create a local variable named proj in projection_init. Thus when map_pix...() later refers to proj (it also DOESN"T declare a local proj) it will get the value safely stored there by projection_init() mw Subject: Still more good questions on sp4 (This message is being sent to CPSC 215 Students and TA's) >> A quick question on your ray.h... is there a particular reason >> why you did the include "rayhdrs.h" after the struct definitions? Just >> wondering. Thank you. Yes! -------------------- (just kidding) The longer answer is that the function prototypes in rayhdrs.h, for example 11 void projection_dump( 12 FILE *out, 13 proj_t *proj); include references to user defined and/or structured types such as proj_t. So if you #include "rayhdrs.h" at the TOP of "ray.h" then you will get all manner of nastygrams from gcc reminding you that gcc doesn't know what a proj_t is yet. As mentioned in class and as you might encounter in a compiler class one day it WOULD be possible to build a compiler that made multiple passes over the input and could deal with this situation. However, the C standard doesn't expect this. ------------- Its an EXCELLENT sign when questions such as these pop into your heads. It happens to me all the time and when it happens, I always just TRY IT and see what happens. That is, I will make a new testing directory so I don't destroy my good stuff, copy my working directory over there, move the #include, compile and just see what happens. If I can then understand what just happened, I have new knowledge and THIS IS GOOD. If I can't understand, I know there is something I don't know that I should and THIS IS GOOD too. Subject: sp4 (This message is being sent to CPSC 215 Students and TA's) >> Dr. Westall, >> >> It was not specified in the sp4.f05.pdf file whether or not you would >> take off points if we used arrays instead of pointers to access the >> buffer. Will you take off points if we use arrays this time? You should use pointer notation to access dynamically allocated data structures. You may use array notation to access specific elements declared as arrays within structures definitions provided by me. . When in doubt, try to use pointer notation. Here is an example of acceptable usage of array notation: fscanf(in, "%lf %lf", &proj->win_size_world[0], &proj->win_size_world[1]); Subject: link time errors (This message is being sent to CPSC 215 Students and TA's) /var/tmp//ccfz83ip.o(.text+0x70): In function `vl_length3': : undefined reference to `sqrt' collect2: ld returned 1 exit status If your program contains references to math functions such sqrt() even if you don't actually call the function you must use the following to the command line: gcc -Wall -g main.c projection.c veclib.c -lm The character preceding the "m" in the -lm flag is a lower case L and NOT the numeral 1. The -lm instructs the linker to use the mathematical function library. Subject: including .c files in other .c files (This message is being sent to CPSC 215 Students and TA's) This is such a bad practice that unfortunately it never pops into my mind to tell you DON'T DO IT. (This reminds me of the book Coach Hatfield allegedly gave to the football players in which he attempted to enumerate all the things they weren't supposed to do. Rumor had it that it grew to over 400 pages but that he gave up after two players, who were apparently quite diligent students in CPSC 120 back when we taught how to use scanners and color printers, started printing their own money, were arrested for counterfeiting, and then pointed out: "but Coach... it wasn't in the book!". Anyhow, its in the book now. DON"T INCLUDE .c files in other .c files. I will compile your submission using the command shown in the previous e-mail and if you include the .c files in each other, THAT WON"T WORK. mw Subject: Ambiguous redirection (This message is being sent to CPSC 215 Students and TA's) > When I run > ./a.out 4 3 proj.mapp 2> proj.err > I got a error saying ambiguous redirection. As discussed in lab 1 and in class last week there are two common families of command shell in Unix. The sh/bash family supports this form of redirection but the csh/tcsh family does not. You can start up the bash shell by simply entering bash So if you get the ambiguous redirection message, the solution is: bash ./a.out 4 3 proj.mapp 2> proj.err Subject: sp5 now available (This message is being sent to CPSC 215 Students and TA's) The sp5 description is now available in the assns directory. Other resources are in the sp5data subdirectory. WARNINGs: (1) This assignment requires more code be written than the previous ones. (2) It will also present more component integration and interoperation issues than previous ones. So starting on the due date is NOT ADVISABLE. Using the incremental build an test procedure is ESSENTIAL. Subject: grades (This message is being sent to CPSC 215 Students and TA's) I'll be sending out sp4 reports shortly. I will also send out a complete report of your program grades to date. Based on prior experience teaching this and other courses, if your average is in the 40 to 60 range, you need to change your way of doing business SOON or you will likely find yourself on the receiving end of a grade or D or worse. If your average is worse that, I recommend that you drop the course and try again when you find yourself in a position in which you might have enough time to put in the effort necessary for success. If you don't have any drop hours left and also don't have time to put in the effort necessary for success in this course, I recommend that you NOT SPEND ANY MORE TIME at all on THIS course. Instead spend the time you have on courses where you DO have a reasonable chance for success. Shown below are the sorted program averages to date: About half the class has program average of 80 or better and 3/4 are in no particular danger at this point. 0 1 19 24 35 43 44 52 55 69 71 73 73 73 76 76 77 81 83 87 88 89 90 91 94 99 100 100 100 100 100 100 Subject: sp5 resources / sample output (This message is being sent to CPSC 215 Students and TA's) > I was reading the description again and you say that we should > be putting the function prototypes in rayhdrs.h. Well I tried > doing that for the material.c ones... but that didn't goto well > because in rayhdrs it didn't know what material_init was I'm not especially clear on what this problem was but the "ray.h" in the sp5data directory WAS SCREWED UP. In cutting and pasting it together the author (me) failed to put the #include "rayhdrs.h" at the end. The necessity of doing this was described earlier. I believe I have corrected this now. If there are other troubles please let me know ASAP. > Also, in writing the output to sp5.2 on your example, I noticed > that the sphere_dump and the plane_dump place the line "Sphere > data" or "Plane data" in different locations. This was a nasty slackism committed by the author (me) it would be nice to have a consistent output format. I encourage everyone to do better than I did. Subject: sp5 -- You MUST submit all .c's and .h's needed > On the assignment at the top of the page you say create object.c, > sphere.c, plane.c, and material.c. However at the bottom of the page > you say turn in model.c, plane.c, object.c, and list.c. Not sure if I > am reading it wrong or if this is an actual discrepancy. The bottom line is that in this assignment and FROM NOW ON you will be be expected to turn in ALL .c's and .h's that are required to build your programs. Hence sphere.c and other previously written components should have been included in the inventory. model.c and main.c are freebies provided by me. The list.c and veclib.c modules should have been written by you but if yours didn't work there should be one available in the sol directory of the relevant lab. Bottom line: gcc -Wall -g main.c model.c sphere.c plane.c material.c object.c list.c veclib.c -lm MUST build your program. Be sure to submit all .h files that your program requires. I don't really care if you create one big ray.h or submit ray.h rayhdrs.h and veclib.h After you copy your files to the submission directory, you MUST ensure that the "gcc" command shown above will successfully build your program! ---------------------------------------------------------------- And as was pointed out in class today, e-mails such as this DO override the original specs that were posted. In the "real" world changes such as these are the rule not the exception. Subject: The material_t structure (This message is being sent to CPSC 215 Students and TA's) Note that within the obj_t the material is defined as material_t mat; and NOT material_t *mat; That is the material structure is embedded within (is a substructure of) the obj_t. Thus you don't need nor want to separately malloc it. To pass a pointer to it you pass &obj->mat where obj points to the obj_t Subject: Submitting sp5 (This message is being sent to CPSC 215 Students and TA's) Prof. Madison pointed out that I failed to include material.c and sphere.c in the list of source files you should submit. They MUST be submitted. A good way to tell if you have submitted EXACTLY the correct stuff is after you copy to the submission directory do: gcc -g -Wall *.c This command should build your a.out and produce no compiler warnings. Subject: Last question on today's quiz (This message is being sent to CPSC 215 Students and TA's) The point on the plane is: Q = (0, 0, -6) which means its 6 units BEHIND the screen The viewpoint is at: V = (4, 2, 2) Which means its 2 units in FRONT of the screen. (and offset 4 to the left and 2 above the origin) Since the ray direction is (0, 0, -1) the x and y coordinates of points on the ray are the SAME as at the viewpoint so the hitpoint is H = (4, 2, -6) and the distance is t = 8 Subject: sp5 and sp6 (This message is being sent to CPSC 215 Students and TA's) Turn in directories for sp5 and sp6 are available. The sp6 spec is available in the assns directory. -- It will be due next WEDNESDAY -- (Its only one function though -- sphere_hits()) Subject: warnings in model.c (This message is being sent to CPSC 215 Students and TA's) The sample model.c does produce 2 or 3 compiler warnings when compiled with -Wall The sample model.c is now YOUR model.c so you should fix those. From now on you are responsible for turning in ALL components needed to build your program. You are free to "adopt" sample code provided by me or write your own, but from now on its YOUR program. --------------- Be careful in the components you write NOT TO VIOLATE THE 72 characters per line of source code rule. If you feed your source program to the following test program it will tell you if you have a problem. It will also tell ME if you have a problem, so its a good idea to run it before turning in stuff. /* linecheck.c */ #include main() { int count = 0; int val; while ((val = fgetc(stdin)) > 0) { count += 1; if (val == 10) { if (count > 72) { printf("%d\n", count); } count = 0; } } } --------------- The objid element is simply a serial number that should start with some arbitrary value and be incremented by 1 for each object created. Subject: proper use of NULL (This message is being sent to CPSC 215 Students and TA's) The defined constant NULL should be used ONLY to initialize POINTER values. It should NOT be used to initialize floating point values or ints as this will produce a nastygram from gcc: double dis = NULL; The proper way to initialize a floating point values is: double dis = 0.0; and int should be done int ival = 0; Subject: bug in sp6main.c (This message is being sent to CPSC 215 Students and TA's) The original version of sp6main.c had a bug in it. The call to vl_unitvec3() should have been BEFORE the call to sphere_hits(). Thus the sample output was also not correct. I think I have corrected all this now. Subject: implicit declaration messages (This message is being sent to CPSC 215 Students and TA's) Warning messages such as this mean that you FAILED TO ADD A PROPER PROTOTYPE for the function to rayhdrs.h main.c:18: warning: implicit declaration of function `model_init' main.c:19: warning: implicit declaration of function `model_dump' model.c: In function `model_init': model.c:35: warning: implicit declaration of function `model_dump' model.c:40: warning: implicit declaration of function `list_add' Here is an example of a proper prototype: void vl_scale3( double fact, double *v1, double *v2); Basically you just copy your function header and REMEMBER TO ADD ; when you put it in rayhdrs.h Subject: completing version 1 of the raytracer (This message is being sent to CPSC 215 Students and TA's) A couple of students have already finished sp6 and have asked for a roadmap to complete the raytracer. The references below to the notes refer to a new version just updated TODAY. Here is the "roadmap". 1 - Implement the make_image() and make_pixel() functions described on page 74 and 75 of the current notes 2 - Implement the ray_trace() function as described on page 77 of the notes 3 - Read page 94 - 101 regarding the use of make in conjuction with conditional compilation of diagnostic fprintfs() to be used in debugging the program. Be sure to include AT LEAST those given as examples. 4 - Implement the find_closest_object() function as described on page 105 of the notes. 5 - Before attempting to create a viewable image, copy the a2t1.txt file from assn2data and run: ray 5 3 < a2t1.txt 1> a2t1.ppm 2> a2p1.log Make sure the output in a2p1.log agrees with the output on page 101 of the notes. 6 - When it does agree, then remake your program with the debugging code disabled and rerun will ray 800 600 < a2t1.txt > a2t1.ppm 2> a2p1.log Admire the ugly mustard colored wall you have rendered. If you don't see an ugly mustard colored wall, add a DBG_UCP (Unsigned char pixel) which will print out the unsigned char values of the R, G, B components stored by make_pixel() in the pixmap and go back to step 5 7. When all of this works add a green sphere with radius 1 and center at (0, 2, -3) and go back to step 5. When the step 5 output looks sensible, create an image. 8. When the sphere appears in the bottom half of the image (as it probably will), figure out why your image is upside down and fix that. The ambient only full raytracer will be due Oct 12. Subject: sp5 evaluations (This message is being sent to CPSC 215 Students and TA's) I'll be sending those out shortly. The test input files were sp5a.txt sp5b.txt and sp5c.txt which are now all in sp5data. The files are LOGICALLY identical but have differences in the presence of comments and blank lines. Your model parser MUST be insensitive to blank lines and comments. If its not, your raytracer will fail in weird and wonderous ways when presented correct input. So please correct those problems ASAP. See me if you can't figure it out. ------------------------------------------------- I don't like like surprises and I would think being surprised with a grade of D or F would be a particularly unpleasant surprise. A few students seem to be operating in a state of denial in which they appear to be thinking that if they can come up with a 65 average on quizzes and tests they will magically be awarded a C- at the end of the semster. That would be false. Students who submit functionally complete programs that compile cleanly but fail miserably in execution will generally earn a grade in the neighborhood of 60 and thus MAY BE ABLE to make a C- in the course. Students who continually submit nothing or programs that are grossly incomplete from a functional perspective should EXPECT to make an F in the course and should not be surprised when they do. As it states in the syllabus: Grading: The final grade for the course will be computed based upon the following distribution (To earn a grade of C or better in the course it is necessary to make at least a C in the Lab and to have at least a 50 average in the project component of the course). Subject: input format (This message is being sent to CPSC 215 Students and TA's) Here are some general guidelines: 1 - values belonging to a single logical entity (e.g. ambient reflectivity or plane normal or plane point) will always appear together on a single line with no comments in between them so they can always be read using a "%lf %lf %lf" format. 2 - comments are optional 3 - comments will always appear on the same line with the logical entity they describe and will follow the entity they describe 4 - each logical entity will start on a new line 5 - zero or more blank lines may appear between any lines containing data. ------------------------------------------------------- Although seemingly complicated these rules are actually set up to make it as EASY as possible to read the input data. The bottom line For each logical entity: (1) use a SINGLE fscanf(in, (with the appropriate number of "%lf" descriptors, e.g. 3 for a plane normal, 1 for a sphere radius) to read the entity (2) use A SINGLE fgets(buf, 256, in); to consume any comment info This approach will always work for data files structured as described above. Subject: sp6 / raytracer / logging / dbug output (This message is being sent to CPSC 215 Students and TA's) > Sorry one other question, in the sp6main.c you are using stderr > in your fprintf.... I had to change it to stdout to get it to > dump into sp6.out, should I keep it that way or am I doing > something else wrong? In the Unix environment it is standard to send the primary output (namely the .ppm image you will be building) to stdout and EVERYTHING else (e.g. model description, debug output) to the stderr. Hopefully it should be obvious that a .ppm file that also contained debug or log output would not be a very pretty picture. In sp5.c some folks who had apparently forgotten the discussion regarding the need to use the bash shell and how to redirect output as: ray 400 300 < test1.txt 1> test1.ppm 2> test1.log changed the main program and made all logging output go to the stdout. I initially "fined" these folks 5 points but when one of them pointed out that I had not adequately identified the problem I rescinded the fine. I feel that I have now provided adequate notification and am DOUBLING the fine for anyone who changes my main program! Subject: sp5 solution components (This message is being sent to CPSC 215 Students and TA's) I have placed 3 components of the solution to sp5 in the sp5data directory. sp5sphere.c - contains the complete code for sphere_init() and sphere_dump() sp5vec.c - contains vl_get3() and vl_vecprn3() readers and writers of three component vectors sp5mat.c - material loader and dumper sp5obj.c - object constructor -------------------------------------------------------------- as far as I can tell that leaves only the plane_init() and plane_dump() functions which are clones of their sphere counterparts to be written. I believe almost EVERYTHING else is available as a solution. (You will have to write vl_get1() and vl_vecprn1() if you use my sphere initializer. --------------------------------------------------------------- So if you still don't have a working sp5 here is what to do: (1) assemble the components from the various solution directories into an sp5 directory (2) comment out the plane_init() and plane_dump() calls in model.c (3) add vl_get1() and vl_vecprn1() to veclib() (4) make sure prototypes of ALL FUNCTIONS are in rayhdrs.h (5) try to build (6) delete the planes from sp5.txt and try to run (7) using the sphere as a guide, write the plane functions (8) run sp5a.txt sp5b.txt and sp7c.txt If you get stuck at ANY POINT in this process, contact me or the TA SOONER rather than LATER. ---------------------------------------------------------------- It should be obvious that until you can come up with an operational model loader NOTHING ELSE WILL WORK! Thus the ONLY choices are: (1) get it working (2) drop the course (3) take an F Subject: Raytracer version 1 assignment (This message is being sent to CPSC 215 Students and TA's) The requirements for this program are now available in mp1.f05.pdf in the assns directory. Subject: table driven model loader (This message is being sent to CPSC 215 Students and TA's) There were a couple of bugs and one compiler warning producer in the notes on p.111. These have now been update so as to be possibly (closer to) correct! Thanks to Webb Brown for identifying the problems there. Subject: memory leaks (This message is being sent to CPSC 215 Students and TA's) I have noticed that many sp6 programs are leaking memory in a big way. Since only 4 rays are fired in sp6, there is no ill effect of the leak and since we haven't discussed this much in class, I will not penalize it on sp6. These leaks MUST be corrected in the ray tracer. The basic rules that should be followed are: (1) things malloc'ed in projection_init/model_init need to exist until the program ends and should NOT BE FREED (2) for every other instance of malloc() there MUST be a corresponding free() IN THE FUNCTION in which the malloc() occurs. (3) a better option is to change all malloc() EXCEPT THOSE in projection_init/model_init to alloca() The alloca() function allocates small amounts of storage on the stack and it does not require the use of free() to release the storage. In fact attempting to free() storage allocated with alloca() is a FATAL ERROR. More on this in class monday. Subject: more memory management woes / testing strategy (This message is being sent to CPSC 215 Students and TA's) Whilst failure to free() is bad, freeing memory that was NOT ALLOCATED with malloc() is EVEN WORSE. This WILL cause an instant segfault in one of my test environments. An example of this error is: double unitvec[3]; : : free(unitvec); return; Trying to be EXTRA SURE that you free stuff by freeing the SAME MEMORY MORE THAN ONE TIME is equally fatal. I found two instances of this first error in a program of a student who had reported to me that his program was now working "perfectly". Thus I strongly recommend a detailed inventory of every free() in every module to insure that you haven't accidentally put in one of these high-penalty errors!!! ------------------------------------------------------------ Also be sure to test your programs with some spheres and some planes other than "back walls" Ceilings, floors, and intersecting diagonal walls would be good choices. Subject: prototype for find_closest_object (This message is being sent to CPSC 215 Students and TA's) It has been pointed out that the notes provide an example of a call to find_closest_object don't provide a prototype. Here is one: obj_t *find_closest_object( list_t *lst, /* Visible Object list */ double *base, /* Base of ray */ double *dir, /* direction of ray */ obj_t *last_hit, /* -> object last hit (or NULL) */ double *closest_dist); /* return dist to hitloc here */ The last_hit pointer WILL have a reason for existence in diffuse and specular lighting. It should be set to NULL as shown in the example call for this assignment. If the last_hit object is NOT NULL, then the object it points to should be EXCLUDED from the test for closest object hit. Subject: "nastygram" regarding help requests (This message is being sent to CPSC 215 Students and TA's) You will help me help you if you make sure that you comply with requirements specified in the assignment and be sure that your program is not suffering from errors that were previously identified. Tonight I received a ray tracer that included a double x = NULL; and for which tmp/?? ==> grep DBG *.c yielded NOTHING tmp/?? ==> I'm more than glad to help, but I'm NOT more than glad to add debug statements previously defined as pre-reqs to your code. (If you don't need my help that's EXCELLENT, but you still MUST include it because we are trying to learn how to produce professional quality code instead of bad habits here!) Subject: random black pixels near edge of image (This message is being sent to CPSC 215 Students and TA's) A student writes: > I've found that when I have planes (walls) intersecting the edges of the screen, > some pixels along that edge are black (or show through to something behind that > plane if applicable). Is this normal? As far as I can tell, it's a math precision > issue where the Z coordinate of the hitpoint is very near zero. That is indeed related to math precision. I won't deduct for it but if you want to get rid of it that can generally be accommplished in plane_hits by changing: if (hitloc[2] >= 0) return (-1.0); to if (hitloc[2] >= 0.0001) return (-1.0); Subject: Name of the executable raytracer (This message is being sent to CPSC 215 Students and TA's) > In the mp1.pdf file you tell us to name our executable a.out... but in the > specification you gave by e-mail you wrote.. > > 5 - Before attempting to create a viewable image, copy the > a2t1.txt file from assn2data and run: > > ray 5 3 < a2t1.txt 1> a2t1.ppm 2> a2p1.log > > Which one should we put in our makefile? Please use a.out as the name of the executable, but because I was ambiguous on the subject, I won't deduct for using "ray" (that one is easy to correct in the grading script) if test -e ray then mv ray a.out fi Other choices will earn that aggrevating 5 point charge for me having to manually fix your make file so that it doesn't break my automated build and run system! Subject: Perspective distortion (This message is being sent to CPSC 215 Students and TA's) Raytracing constructs images using a technique commonly called "perspective projection". This is basically the same technique used by a standard camera. If you have ever used a wide-angle (a.k.a. fisheye) lens you have probably noticed that objects near the edge of the photograph tend to be distorted. This is one form of what is known as perspective distortion and can be observed in a ray tracing system when the viewpoint is near the screen (effectively creating a wide angle lens). Sphere located near the edge of the screen appear elliptical. You can see how this happens in the following way. Let V represent the viewpoint and the horizontal line represent the screen. Draw two circles of the same size in the positions indicated below. These circles represent spheres whose centers lie in the y=0 plane and we are looking down at the situation from above. Make sure the distance from the center of the two circles to V is the same. Now draw tangents from V to both sides of each circle. The "width" of the sphere that you would see in a raytrace is the distance between the intersections of the tangents with the screen. If you have drawn carefully it should be obvious that the circle on the right will appear wider. It will also appear taller but the height distortion will be smaller. An example of perspective distortion may be found in the pdist.jpg / pdist.txt files in the examples directory. Circle Circle ------------------------------------------ V Subject: Midterm exam (This message is being sent to CPSC 215 Students and TA's) The midterm exam will be given in class next Wednesday, Oct 19 Approx 70% will be old quiz questions. Approx 30% will be programming problems requiring the programming techniques used so far in the assignments. I placed an all.f05 file containing all of the quizzes given this semester in the quizzes directory. The mid-terms from last year are also in the quizzes directory in test1.f04 and test1key.s05 Subject: Dr. Westall's debug services (This message is being sent to CPSC 215 Students and TA's) (prescript: Don't forget the midterm is Wed 19 OCT) This message is intended to clarify any misconceptions regarding the scope of my debugging services, it is being sent because I received a couple of "nastygrams" from one student who expressed concerns that my methods were unfair. I don't really think my methods differ in substance from those of other faculty, but just to ensure everybody is aware of what they are I provide this description: Specifically, the student asserted: > I don't think it's fair for you to tell me that my program is working > and then fail to tell me that you didn't check it with images that > you would be likely to test it on, then wait for me to find out about > that after the due date. I understand that it is only one point, and > that I have the rest of the day to fix it, but it's not a matter of > points anymore. It's a matter of principle. I find that this is > completely unfair. This assertion seems to based upon the following two messages that I DID SEND to the student along with a copy of the a2t1.txt on which I tested. >> OK, this last one is MUCH better! It compiles >> without warning, the DBG output looks correct, >> and so does the a2t1.txt image." and later: >> I'm not sure why you can't make an >> image with a2t1.txt. I ran it this >> way and a2t1.ppm seemed to be correct >> to me. I guess you could have a platform >> dependent bug. Those messages were intended to tell the student that his/her program did indeed APPEAR to render the mustard yellow back wall correctly on the machine on which I tested. Having programmed for 40 years I am extremely careful NEVER to state that any program is CORRECT (as in: WILL NOT FAIL ON ANY INPUT). I fully expect that over half of the programs that receive 100 COULD BE BROKEN with more extensive testing. The student went on to imply that I KNEW his/her program was broken but deliberately withheld said info. > I'm just hurt at the fact > that I asked you a question, and > you almost practically did refrain from > telling me the complete truth. This on hurt MY feelings! I have been BUSTING MY TAIL trying to do the best I can to find/solve your problems. And when I find a bug, all but one of you know I'm NOT SHY when it comes to telling you about it. I have been in the business of teaching programming for 30 years now and I would NEVER EVER WITHHOLD KNOWLEDGE of errors in a student program for ANY REASON!!! The student also seemed to assume that I would test his/her program using all possible inputs or at least all inputs that would be used in evaluating the program before commenting on its correctness. I regret if somehow I conveyed that expectation to that student or anyone else. I definitely didn't mean to do that. -------------------------------------- Here are the proper expectations regarding debug help. 1 - If include an input file, provide its name in your e-mail and request that I test on that file, I will do so and report the results of testing ON THAT FILE. 2 - If you wish for me to test on ONE specific machine on which I have a login ID, I will do that IF YOU SEND ME THE MACHINE NAME. 3 - If you send me a tar ball and no input file or don't identify a specific input file, I will test on a single "minimal standard" input file that I use for ALL students. 4 - Under NO circumstances do I "guarantee" that I can find all the bugs in your submission (or my OWN PROGRAMS) for that matter. 5 - I DO NOT promise to pre-test your programs on all inputs that will be used in evaluating them. In the "real world" they don't do that either. 6 - If I tell you that your program appeared to work correctly on input blah.txt, it does NOT MEAN that your program is CORRECT! A correct program works correctly on all possible inputs. Basically it is IMPOSSIBLE to prove in ANY rational way that a program of this size is correct. mw Subject: labs this week (This message is being sent to CPSC 215 Students and TA's) Wed and Thursday labs WILL MEET as scheduled this week. This will cause the labs to get "out of sync" with respect to the week and they will remain so until the Tuesday lab "catches up" the week of Thanksgiving break when it will meet and the other two will not. Subject: Assignment sp7 is now available (This message is being sent to CPSC 215 Students and TA's) Its time to get back into the programming business. Assignment sp7.f05.pdf is now in the assns directory. I will be sending out evaulations of mp1 shortly. If you have a major problem there, you will also need to be sure to fix that. In a few cases it wasn't too hard for me to see the problem (and if i know what it is i have told you what it is). In other cases I don't know what it is, but as usual I will be pleased to TRY to help you find it if you can't identify the problem. The test cases and correct output are available in the mp1data directory. The a2t7 and a2t8 test cases are student submitted model.txt files and these tests were successful in identifying several broken programs that mine did not. GOOD JOB! In the grading of mp1 a few particularly meritorious model.txt submissions were awarded with extra credit ranging from 3 to 6 points. Some model.txt files placed objects on the wrong side (+z) side of the screen. There was no deduction for this but since such objects are invisible in a correct raytracer such submissions were D-Q'ed from receiving extra credit. mw Subject: missing theta in the notes (This message is being sent to CPSC 215 Students and TA's) It was pointed out in class that due to a problem with OpenOffice the greek letter theta disappeared in both the diffuse diagram and in the illumination formula. theta is the angle between the object normal at the hitloc and the vector pointing from the hitloc to the center of the light. Therefore cos(theta) is just the dot product of the UNIT normal and a UNIT vector pointing from the hitloc to the light. Subject: sp7.out (This message is being sent to CPSC 215 Students and TA's) Some students have asked how / why / what is the meaning in sp7.out of: 11 Diffuse reflectivity 3.465 0.000 0.000 12 Current ivec 3.465 0.000 0.000 The value of Diffuse reflectivity here should be the illumination associated with the CURRENT LIGHT and NOT the input value material.diffuse (which was 5.0 0.0 0.0! Current ivec should be the sum of the contributions of ALL lights. Since sp7main has ONLY ONE LIGHT, the values should be equal here, but would NOT be equal IF there had been multiple lights that illuminated the hitloc. Subject: mp2 test data (This message is being sent to CPSC 215 Students and TA's) I have placed some test model descriptions, images and diffuse lighting log files in assns/mp2data The images are built using (where x is in {1, 2, 5, 7}) a.out 800 600 < a3tx.txt > a3tx.ppm The log files are built using a.out 8 6 < a3tx.txt 2> a3tx.log with DBG_DIFFUSE enabled. ------------------------------------------------------------ These are designed to provide a reasonable starting point for debugging, and will be used in grading your programs, but just because your program works correctly on these models DOESN"T GUARANTEE YOU HAVE A CORRECT PROGRAM. As with mp1 I will use particularly meritorious student submitted model.txt files in addition to these as test input files in grading! ----------------------------------------------------------- Step one is to make sure you can duplicate my log files. (or possibly convince me that my log files are broken). Until that happens I don't want to see any defective images (but I will be happy to look at defective log files). If the log file is correct but the image is still broken, then I will look at defective images. Subject: MP2 + Latent buggies (This message is being sent to CPSC 215 Students and TA's) A description of what is required in mp2 is now available in the mp2.f05.pdf file in the assns directory. ------------ In helping a student who is working on mp2 it would appear that despite my best efforts to identify bugs in your programs as early and reliably as possible, I DON'T find them all. Thus on mp2 or mp3 you MAY WELL be bitten by an old leftover bug or you may also be afflicted by the "you touched it you broke it" syndrome whilst trying to add new functionality. Anyhow, this message is intended to once again remind you that EVEN IF I could find NO ERROR in mp1, that doesn't mean there wasn't one hiding in there somewhere and IF IT SURFACES in mp2, you will get a penalty!!! Being the nice guy that I am, I will NOT retroactively penalize you on mp1 though! --------------------------------- Here is my response to the student working on diffuse lighting. It looks as though that EITHER her/his DBG is defective or his/her ray firing mechanism is broken, because row 2 and row 3 hitlocs and hit distances are equal! But either this bug was not present or I failed to detect it in the students mp1. > I think you have a latent bug leftover from MP1 (or possibly way before > that). Note that row 2 and row 3 yield the SAME distance and > hitloc. Something seems broken here. > I get this when I run with DBG_PIX, DBG_HIT and DBG_AMB PIX 0 2 - HIT 1: 18.5 (-14.7, 2.2, -8.0) - AMB ( 0.092, 0.092, PIX 1 2 - HIT 1: 15.3 (-10.5, 2.2, -8.0) - AMB ( 0.175, 0.175, PIX 2 2 - HIT 1: 12.9 ( -6.3, 2.2, -8.0) - AMB ( 0.345, 0.345, PIX 3 2 - HIT 1: 11.4 ( -2.1, 2.2, -8.0) - AMB ( 0.574, 0.574, PIX 4 2 - HIT 1: 11.4 ( 2.1, 2.2, -8.0) - AMB ( 0.574, 0.574, PIX 5 2 - HIT 1: 12.9 ( 6.3, 2.2, -8.0) - AMB ( 0.345, 0.345, PIX 6 2 - HIT 1: 15.3 ( 10.5, 2.2, -8.0) - AMB ( 0.175, 0.175, PIX 7 2 - HIT 1: 18.5 ( 14.7, 2.2, -8.0) - AMB ( 0.092, 0.092, PIX 0 3 - HIT 1: 18.5 (-14.7, -2.2, -8.0) - AMB ( 0.092, 0.092, PIX 1 3 - HIT 1: 15.3 (-10.5, -2.2, -8.0) - AMB ( 0.175, 0.175, PIX 2 3 - HIT 1: 12.9 ( -6.3, -2.2, -8.0) - AMB ( 0.345, 0.345, PIX 3 3 - HIT 1: 11.4 ( -2.1, -2.2, -8.0) - AMB ( 0.574, 0.574, PIX 4 3 - HIT 1: 11.4 ( 2.1, -2.2, -8.0) - AMB ( 0.574, 0.574, PIX 5 3 - HIT 1: 12.9 ( 6.3, -2.2, -8.0) - AMB ( 0.345, 0.345, PIX 6 3 - HIT 1: 15.3 ( 10.5, -2.2, -8.0) - AMB ( 0.175, 0.175, PIX 7 3 - HIT 1: 18.5 ( 14.7, -2.2, -8.0) - AMB ( 0.092, 0.092, Subject: Use of the last_hit parameter is find_closest_object (This message is being sent to CPSC 215 Students and TA's) obj_t *find_closest_object( list_t *lst, /* Visible Object list */ double *base, /* Base of ray */ double *dir, /* direction of ray */ obj_t *last_hit, /* -> object last hit (or NULL) */ double *closest_dist); /* return dist to hitloc here */ For diffuse illumination to work it is necessary to use set the last_hit parameter to the "hitobj" when calling find_closest_object(). Inside find_closest_object() you MUST NOT test the last_hit object (because if you do you will find that the ray fired from the hitobj toward the light hits the hitobj at a distance 0.0 and you will mistakenly conclude the hitobj is occluded)! Subject: The finite plane rotation matrix (This message is being sent to CPSC 215 Students and TA's) The projection mechanism described in class will generally NOT produce a unit vector. Rows of the rotation matrix MUST BE unit vectors. Therefore, you must unitize the RESULT of the projection operation AND the plane normal vector BEFORE using them to construct the rotation matrix