Hi, under the code directory for the course page I've added some demos
http://www.mat.ucsb.edu/594cm/2011/mat594cm/code/
There's no problem set this week, rather I want you to look at and use/modify the code in two of the demos (as described below). Also, brush up on your C programming (e.g, via http://www.cprogramming.com/tutorial.html#ctutorial).
I've added some sample code for reading an .OBJ file under the glutLoadObjFile directory. We'll go over it in class when we discuss C programming in more detail next week, but if you look at the main.c and main.h files you should be able to make more sense of how to use structs and how to use pointers and arrays in C, and how to allocate (and reallocate) memory. For your homework this week, simply create your own OBJ mesh and display it using something similar to this demo. Add lighting and a texture. The code in my demo only supports triangular faces. Try and modify it so that works with quadrilateral faces as well.
Also in the computeNormalsDemo directory I wrote a quick example of how to calculate the normals from a face. In the example, I have an array with 4 points (x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4). I create 2 vectors (from p1 - p0 and p2 - p0) and then use the cross product to get the normal vector, which is then normalized to be unit length. For your homework, see if you can use this code (or your own version of it) to add correct lighting to a simple 3D shape.
After next week's class we'll start working on some more ambitious and creative projects...
-Angus
glut code demo & homework
Jump to
- Courses
- ↳ MAT 594CM
- ↳ Spring 2010
- ↳ Winter 2011
- ↳ MAT 200A
- ↳ Fall 2010
- ↳ Art 130
- ↳ Fall 2010
- ↳ Winter 2012
- ↳ Fall 2012
- ↳ MAT 201B
- ↳ Fall 2010
- ↳ MAT 259
- ↳ Winter 2011
- ↳ Winter 2012
- ↳ Winter 2013
- ↳ Winter 2014
- ↳ Winter 2015
- ↳ Winter 2016
- ↳ Winter 2017
- ↳ Winter 2018
- ↳ Winter 2019
- ↳ Winter 2020
- ↳ Winter 2021
- ↳ Winter 2022
- ↳ Winter 2023
- ↳ Winter 2024
- ↳ ART 102
- ↳ Winter 2011
- ↳ Spring 2012
- ↳ Winter 2013
- ↳ NMDS 551
- ↳ MAT 594CR
- ↳ Spring 2012
- ↳ MAT 254
- ↳ Fall 2013
- ↳ Fall 2014
- ↳ MAT 265
- ↳ Spring 2016
- ↳ Fall 2022
- ↳ Winter 2023
- ↳ ART 185GL
- ↳ Spring 2017
- ↳ Spring 2018
- ↳ MAT 594G
- ↳ Fall 2020
- ↳ MAT 255
- ↳ Spring 2021
- ↳ Spring 2022
- ↳ Fall 2022
- ↳ Fall 2023