CISC 829 - Homework 2 Programming Assignment
Bryan Youse, Yuqi Wang, Christopher Thorpe
I. Brief description of solution in (hopefully) plain language:
Our solution uses OpenGL for rendering its graphics and is written in C++. As described below, it uses a simple interface for adding segments to the screen area, along with a way to specify an eye or camera location with a viewing direction. The program makes use of a doubly-connected edge list-like data structure (DCEL) to store information about the partitioning of the plane into faces. Additionally, a BSP tree is created that allows the program to create an ordering of line segment fragments from back to front, with regards to the view point. The program initializes a BSP cell with its face as the entire program window. The first line segment drawn will partition this cell into two new cells, each with their own faces. Each subsequent line segment drawn will partition one or more bsp cells in half, creating new faces as necessary. There are simple recursive algorithms in place to both determine the cell that the eye point is in, AND obtain the back to front ordering of line segment fragments to draw.
See below to learn some of the program's features, along with how to use the program.
II. Download
Our solution is available in various formats:
Runnables:
bspx86 - a pre-compiled version of our program for x86 GNU/Linux
bsp.zip - a zipped folder with a running win32 executable build of our program inside (dynamically linked with glut32.dll - included)
(if neither of these run or are otherwise unsuitable for you, please contact us)
More:
BSP.tar.gz - a gzipped tarfile containing our program's source files and a makefile for GNU/Linux (needs GL and glut libraries to build)
BSPVS.zip - a zipped folder with a Visual Studio C++ project containing our program inside (needs GL and glut libraries to build)
Source directly linked from this directory:
src/
III. Features/Instructions for using our application:
Segments are added by LEFT-clicking anywhere on the "canvas", holding down the button to drag out the segment, then releasing the mouse button to finalize the segment. If the user fails to drag out a segment, i.e. if he just left clicks, no segment (which would be of length 0) will be created and the BSP tree will not be affected. For consistency and simplicity's sake, the first six points are always colored red, gree, blue, yellow, cyan, magenta, respectively. After that, the segments are given a random color. The eye point is positioned by RIGHT-clicking. Instead of dragging it around, it can simply be put anywhere on the canvas with another RIGHT click. The viewing direction from the eye point will be created by holding the RIGHT-click after placing the eye point and dragging in a direction. A small white line segment will stem from the eye point indicating the direction chosen. If the user neglects to drag out a direction, the default viewing direction is straight up (in the y direction). Using the 'f' key toggles between the eye point being fixed and the eye point being able to be moved with another RIGHT-click. The default mode is non-fixed, meaning the eye point can be repeatedly placed anywhere with a RIGHT click. Enabling the eyepoint-fixed-mode using the 'f' key allows right click to only drag the viewing angle around the eye point. This is useful for adjusting your view without accidentally moving around.
There are two windows where drawing happens. The main window is where the user drags out his segments and moves his eye point and direction. The "output" window is the thin window that pops up below the main window. This is where a pseudo-3d representation of the viewing line, as seen from the view-point in the view-direction. Only the segments closest to the viewpoint (that is, those that aren't blocked by closer segments) are seen, as intended by the BSP algorithm! Also, as specified in the homework outline, the BSPCell in which the current eye point lies is highlighted in grey, standing out from the typically black background.
Commands
- 'w' key - Toggles wire-frame mode (just for fun). The polygons in the view-line window will be displayed by their outlines instead of being filled in. This is useful for seeing that the segments in the back DO get drawn despite not being able to be seen normally. If there are too many segments crossing each other however, this view can get messy.
- 'p' key - You can keep hitting 'w' to toggle wireframe, but hitting 'p' will ALWAYS return you to polygon mode, meaning filled in polygons on the view-line window.
- 'f' key - Toggles the eye point being fixed or not as explained above. The eye point being green means not fixed, white means fixed. When the eye point is white, it cannot be moved: only the viewing angle can be changed with the right mouse button.
- 'q' or ESC - exits the program
That's it! We hope you find our program as easy-to-use and full-featured as I do!. If there are any questions, please contact us.