setupCube()
function by an
inputCube()
that reads in a simple
rgbcube.obj
file, an Alias|Wavefront object, e.g., a simple cube.
inputCube()
function, read in the data for the
verteces and faces as they are encountered. The program should
contain two global lists:
std::vector<point_t *> points
a list of vertices,
std::vector<face_t *> faces
a list of faces, and
std::string group
an unused string to store the group
designation
face_t
object that will be used to store the
integer vertex indeces that index into the object's vertex list,
basically a list of integers.
The face_t
object contains the following data objects:
std::vector<int> vin
a list of integers
face.h
and implementation
face.cpp
files.
std::vector
, are indexed 0..n-1.
point_t
object and follow that pattern.
This time, when looping through the input, you will have to
decide what is being read in: a point_t
object,
a face_t
object, or the std::string
object. Each of these is identified by the leading character,
i.e., v
, g
, or f
,
respectively. Therefore, your parsing loop should read in a
single character and then switch
on that character
to decide what to read in, e.g., with
std::istream& s
,
while( s.get(c) && !s.eof() ) {
switch(c) {
case 'v':
// read in vertex_t object
break;
case 'g':
// read in group string
break;
case 'f':
// read in face_t object
break;
}
glVertex3f
.
To do the above, you will need to
glVertex3f
.
(*the_points[i])[0]
syntax).
cube-ccw.obj
file used to test the above program is:
v 1.0 1.0 1.0
v 1.0 1.0 -1.0
v 1.0 -1.0 1.0
v 1.0 -1.0 -1.0
v -1.0 1.0 1.0
v -1.0 1.0 -1.0
v -1.0 -1.0 1.0
v -1.0 -1.0 -1.0
g cube
f 1 5 7 3
f 2 1 3 4
f 5 6 8 7
f 6 2 4 8
f 2 6 5 1
f 8 4 3 7
std::vector
containers, which keep track
of the size of the list.
tar.gz
archive of your asg##/ directory, including:
README
file containing
Makefile
.h
headers and .cpp
source)
make clean
before tar
)
handin
notes