point_t
object is used to read a file of points into
a list (std::vector
) and drawn in a 3D GLUT window, set up
GLUT callbacks to translate and rotate the camera.
camera_t
object that contains the following
data objects:
std::vector<float> pos
position of the camera,
std::vector<float> ref
ref point position, and
std::vector<float> vup
the camera's tilt vector.
h
: truck left
j
: pedestal down
k
: pedestal up
l
: truck right
i
: dolly forward
m
: dolly back
H
: pan left
J
: pitch down
K
: pitch up
L
: pan right
I
: tilt right
M
: tilt left
gluPerspective(90,1.0,1.0,1000.0);
glLoadIdentity();
gluLookAt()
, starting with:
0.0,0.0,-10.0
,
0.0,0.0,1000.0
,
0.0,1.0,0.0
.
j
to translate left, the camera object is
called so that "the camera moves itself", e.g.,
the_camera.truck(-0.1);
.
camera_t the_camera;
at the top of main.cpp
just like std::vector<point_t* > the_points
.
new
point_t*
each
time data is read in (this gets added to the list).
delete
ing each point pointer as you erase each one
from the list (i.e., when the program exits).
pointdata.txt
file used to test the above program is:
1.0 -1.0 1.0
-1.0 -1.0 1.0
-1.0 -1.0 -1.0
1.0 -1.0 -1.0
*** printing list
1.00, -1.00, 1.00
-1.00, -1.00, 1.00
-1.00, -1.00, -1.00
1.00, -1.00, -1.00
and a window showing something like what appears below:
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
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