Program 4 - Interactively Building Objects
Abstract
For this problem you produce a program that add faces to an object.
Outline
This system has a file representation, an interactive interface.
It is a way to create more complex 3D objects.
Goals
A goal of this project is to expose you to a number of issues
in developing interactive code.
These issues include programming issues such as:
how you use the pointer to get work done,
what pointer driven code does,
and how you show the user the current state of the system.
It also includes issues such as: how can you design an interface
to allow a user to easily get work done.
This program also has a goal of allowing you to see some ways
of representing objects in a file.
Objectives
You will be able to write interactive code.
You will determine a mapping from file descriptions to internal objects
and back to a file description.
You will make internal states visible to the user so he/she can get
work done.
Prerequisite Background
You need to be able to write an OpenGL program, display objects,
and control the viewpoint and select items in the view.
Content
Interactive Object Builder
Write a program to interactively build objects.
The program starts by reading in a prototype file with an object specification
in it.
Faces on the object can be selected.
Once selected, a point on the face can be selected, this will form a
pyramid of the new point and the vertices of the selected face.
Basically a face, once selected is removed and is replaced by the pyramid.
When you are done you are to save the file so it can be loaded
later by the program.
Program modes:
-
NORMAL:
after loading the file, display in current orientation.
Display is stationary.
-
TRACKBALL:
Left mouse click outside of the object will use trackball to orientate the
object. When the button is released, return to NORMAL state.
-
FACE_SELECT:
Left mouse click on a face will select the face.
This will be shown by highlighting the selected face.
The system will then go to SELECT_XY.
-
SELECT_XY:
A cursor will move around the XY of the face (the face's coordinate system).
If the mouse is clicked in the face, the x,y point of the face is selected
and the mode changes to SELECT_Z.
You may or may not keep the cursor in the face.
If the mouse is clicked outside of the face,
the system goes back to NORMAL.
If the right mouse button is clicked return to NORMAL.
-
SELECT_Z:
The cursor will move on the surface normal until a mouse click.
When the mouse is clicked, the z value is selected and the mode
changes to BUILD_PYRAMID.
If the right mouse button is clicked, return to NORMAL.
-
BUILD_PYRAMID:
Delete the selected face and replace it with a pyramid formed by
the new point and edges to the original face vertices.
The system changes to NORMAL state.
File format:
OBJECT_FILE ::= DESCRIPTION FACES
DESCRTIPTION ::= line of text CR
FACES ::= NUM_OF_FACES CR FACE*
FACE ::= NUM_OF_VETICES CR VERTEX*
VERTEX ::= X Y Z CR
Prime the system by hand building a file for a cube.
You will probably want menu options for file save and exit.
Above is a way of getting the desired results, of interactively
building an object.
If you have a better way, feel free to change the specifications.
If it is a large change please check with the instructor.
Also, since you are trying to improve the system, you will need to
explain how your system is better in your report.
You also need to address, better for whom and why.
Posttest
Read and understand an ASCII file defining objects.
Design a interactive interface to build hierarchies of objects.
Program an interactive interface for a first person shooter (FPS) game.