aw_t
object, e.g., a simple cube, in this assignment
add in the capability to rotate the object.
aw_t
object three float
variables, rotx
, roty
,
and rotz
.
rotate(float rx, float ry, float rz)
which adds each of the three arguments to each of the
rotx
, roty
,
and rotz
variables—these store the amount
of rotation the object currently is subject to.
s
: rotate left about x-axis
d
: rotate left about y-axis
f
: rotate left about z-axis
S
: rotate right about x-axis
D
: rotate right about y-axis
F
: rotate right about z-axis
glRotatef
three times,
one for each of the rotations about the
x-
y- and
z-axes, e.g.,
glRotatef(the_objects[i]->rotx,1,0,0)
and similarly for the other axes.
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.
GL: 2.1 NVIDIA-10.2.1 310.41.15f01 NVIDIA Corporation
number of verts read in: 8
number of faces read in: 5
*** printing object list
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
it is a good idea to print out the object parsed in, to make
sure you can read the object data and then reproduce it by
iterating through the vertex and face lists.
Makefile
that you can use to compile the project:
.SUFFIXES: .c .o .cpp .cc .cxx .C
UNAME = $(shell uname)
PLATFORM = $(shell uname -p)
CC = g++
COPTS = -g -Wall
INCDIR =
LIBDIR =
ifeq ("$(shell uname)", "Linux")
INC = \
-I/usr/lib/glut-3.7/include
LIBDIR = \
-L/usr/lib -L/usr/X11R6/lib -L/usr/lib/glut-3.7/lib/glut
LIBS = \
-lglut -lGLU -lGL -lXmu -lXi -lXext -lX11 -lm
else
ifeq ("$(shell uname)", "Darwin")
LIBS = \
-framework OpenGL -framework GLUT -framework Foundation -lstdc++
endif
endif
.c.o:
$(CC) -c $(INCDIR) $(COPTS) -o $@ $<
.cpp.o:
$(CC) -c $(INCDIR) $(COPTS) -o $@ $<
all : main
OBJECTS = \
point.o \
face.o \
vertex.o \
aw.o \
camera.o
main : $(OBJECTS) main.o
$(CC) -o $@ $(INCDIR) $(COPTS) $(OBJECTS) $@.o $(LIBDIR) $(LIBS)
point.o: point.h point.cpp
clean :
rm -f *.o
rm -rf main
tar.gz
archive of your asg##/ directory, including:
README
file containing
Makefile
.h
headers and .cpp
source)
make clean
before tar
)
handin
notes