Discussion1F16
Contents |
Overview
For those of you who couldn't make it to discussion today (09/26), here's a recap of what went on. The discussion slides for today can be viewed here
Homework projects
The first homework project is listed under the Homeworks section on the course webpage. You have about two weeks, but get started as soon as possible; This project is not something you can finish in one or two days. There will be 5 homework projects this quarter, each 2 weeks long (with the exception of the final project being 3 weeks long). On all homework projects, you can score up to 110% (100% + 10% extra credit).
Please note that the extra credit is meant for you to challenge yourself using what was taught in class. We do not provide help with extra credit - you're entirely on your own.
Homework 1
You will be able to download the starter code from the course webpage in the Basecode page.
When you run the program successfully for the first time, you will see a spinning pink cube. The project is configured to run on Visual Studio on Windows systems. You will need to create an XCode project if you work on Macs, using the installation instructions provided on the basecode page.
The first homework project is aimed at getting you familiar with the tools and libraries that will be your friends throughout the quarter. These will include GLFW and GLew. You are free to use any other graphics or window management library, however you must contact us first for approval, as we want to make sure that you are not using a library that does too much of the homework for you. For the first homework project, you will be:
- Writing a parser for the .obj file extension (more info to come)
- Rendering the 3D object defined by the .obj file
- Manipulating the object (translation (moving), scaling, rotating (orbiting), etc.) using the keyboard, and
- Implementing a way to switch between immediate mode (which is the code that we provide) and your own software rasterizer (just so you can know and appreciate what the GPU does for you), which will be discussed next week.
The OBJ file format
For the purposes of keeping your sanity intact, all .obj files we provide will have only information of vertices (lines starting with a v), normals (lines starting with a vn), and faces (lines starting with an f). You won't need to worry about normals and faces until project 2, but for those curious, this is very important when dealing with shading (lighting, colors, that kind of stuff). The general format for vertex lines is:
v v_x v_y v_z r g b
Where v_x, v_y, v_z are the vertex x, y, and z coordinates and are strictly floats. The values r, g, b define the color of the vertex, and are optional (i.e. they will be missing from many files). Like the vertex coordinates, they are strictly floats, but can only take on values between 0.0 and 1.0. All values are delimited by a single whitespace character.
The general format for normal is the same as for vertices, minus the color info—the r, g, b.
You can find more info about the .obj file format on Wikipedia. Again, you are only responsible for the v and vn lines in project 1, so don't worry too much about the face lines, which start with 'f'.
Linear Algebra
For the purposes of displaying and manipulating your objects in 3D space, there will be a lot of linear algebra involved. More specifically, lots and lots of matrices and matrix multiplication! We will not review linear algebra, as all the necessary information will be explained in lecture tomorrow (09/27). One thing you should remember, however, is that the order of multiplication matters! Matrix multiplication is not commutative, so AB won't yield the same result as BA.
In order to manipulate objects, we recommend creating transformation matrices using glm::translate, glm::rotate, and/or glm::scale, with the identity matrix derived by glm::mat4(1.0f) passed in as the first argument. The resulting transformation matrix can be multiplied by the OBJObject's toWorld matrix in order to perform the desired transformation. Once again, the multiplication order matters! Try switching around the operands and see what happens if you multiply in the wrong order.