Herein lies: 1) the prototype skeleton code for the second assignment. 2) some sample scenes (in the scenes directory), it has: the blender file; the rendered blender image; the exported text file that can be read by the raytracer. the ppm files generated by my solution. 0: circletest -- is an empty scene, useful if using the added 'circle test' (appears at the bottom of main.c) 1: triangle -- is a triangle sitting on the view plane 2: viewplane -- has two "rectangles" that are just inside the blender viewplane height and width 3: light test -- is three triangles (red, blue, purple) on the viewplane 4: complex -- is an icosohedron in front of a mirrored triangle (note the differences between the images) 3) a file to add to the blender scripts that will export a blender scene in a format that can be read by the raytracer. -- place this file in your ~/.blender/scripts directory Once this has been done, you will be able to export any blender scene to the raytracer format, ... except ... -- all lights are 'converted' to point lights. -- it only exports one material per mesh. It will 'happily' export quad faces ... but the raytracer will spit the dummy when you try to read it. #### Note: you do **not** need to use blender to create your scenes. you can write your own text scene files (in fact, this is how the marking test scenes will be created -- a well thought out simple test scene is much more useful than an elaborate design exported from blender ) #### 4) after you compile the code, you can run it like ./raytracer scenes/test01.txt (assuming you've created a test scene called test01.txt in the scenes directory). When you run the program, it creates the image on the screen, and it quietly saves a ppm version of the image (as the file out.ppm) in the directory from which you ran the raytracer. NOTES ON SKELETON CODE: ======================= The skeleton code reads in the camera, lights, and mesh information. The default camera is positioned at the origin (0, 0, 0, 1); and it is looking at a viewplane with top left corner at (-16, 16, -lens, 1), and bottom right corner (16, -16, -lens, 1) (In fact blender uses (16, -12, -lens, 1) and (-16, 12, -lens, 1); but I think it's easier to code for a square image. It will mean we see a little more of the scene than blender generates). This information is needed for creating the primary rays. No information about the face normals is given, so that will need to be generated somewhere, somehow. Because of this, each face will have its own normal -- rather than each vertex having a different 'normal' -- and you will be doing flat shading, rather than smooth shading. Rather than encapsulating all the information about a mesh in a mesh structure, the mesh structure references a general list of faces - with each face referencing a general list of vertices. So, for instance, you might have a scene with 50 faces in the face list, and mesh 1 might be faces 0..24, mesh 2 might be faces 25..48, and the third mesh may be the final face 49 (ie - a triangle). NOTES ON THE BLENDER SCENE: =========================== For a reasonable comparison between the blender scene and the raytraced version it is good to set up the lights as in the sample scenes. -- set the radius to maximum (5000) -- set the attenuation values (linear and quad) both to 0 -- keep the energy at 1.0 (Aside: I was worried about the different images for test scene 2, ... until I 'energised' the blender light to be comparable!) Note -- blender scenes can produce shadows, if you tell it to do Raytracing, and that the light and object can have shadows. (ie - there are a few buttons to make sure you have selected). There are several settings that affect the object's colour. -- there are the three colour setters RGB for 'Col', 'Spe', and 'Mir' -- in shaders there are settings for 'Amb', 'Ref', 'Spec', 'Hard', and 'RayMir' -- the 'standard' raytracing coefficients are: ambient = the same Amb value for RGB coefficients. diffuse = Ref * (1 - RayMir) * (Col_RGB) specular = Spec * (Spe_RGB) with the phong coefficient being the Hard mirror = RayMir * (Mir_RGB) The scene exporter outputs the same blender 'ambient' value for the three ambient coefficients. It also outputs the phong coefficient, and uses the above (assumptions) to calculate the three colour coefficients for diffuse, specular, and mirror. Note -- blender can produce mirror surfaces, if all the correct buttons have been selected, and sliders set (cf, shadows). The blender scene has no 'background' colour, so I have used its 'horizon' value (and ignored its zenith). -- Let me know of any problems!!! raymond.