Recent Changes - Search:

CS559-2006 Web

Staff Login

TutorialGLExample

OpenGL Example

This page provides some example code to suggest some ideas on how to do the 3D user interfaces. It is a good starting point for Programming Assignment 3 and Project 2.

The idea here is not to show off great user interfaces, but rather to show you that some simple and easy to implement things are workable (and good enough for the assignments and projects).

Also, we'll provide you with some example code to implement some User Interfaces that require some techniques a little beyond what we talk about in class.

From this page are three versions of a program called "CubeIt." Each program creates a set of cubes and allows the user to move them around (fullfilling the requirements of Programming Assignment 3).

CubeIt1

CubeIt1 provides the very most basic interface. A set of sliders is used to control the camera parameters and the cube position. Clicking the left mouse button cycles through the cubes.

CubeIt2

Cubeit2 uses a technique called "ArcBall " to control the viewpoint. The right mouse button is used to move the viewpoint. This is a simplified version of the arcball and can be a little bit hard to control. However, it provides a fast way to look around the world.

CubeIt3

CubeIt3 adds a better interface for moving the cubes. A cube is selected by clicking on it with the left mouse button. Cubes can be dragged with the left mouse button. Normally, dragging happens in the XZ plane (the height of the cube stays the same, but it follows the mouse around). If you hold down the control key, the movement of the cube will be in the XY or YZ plane, so it will move up and down to follow the mouse movement.

The programs were written to show how small and simple they can be. In your own programs, I'd recommend taking a little bit more of an object-oriented approach (for example, creating a class for 3D points rather than passing around 3 floats to every function).

The programs do not make any attempt to draw the cubes nicely. They do not even use lighting. The one fancy display thing they do is "drop" shadows. This was done to show you how to do drop shadows yourself (they will make your programs much nicer). Drop shadows are useful not only because they look nice, but also because they help to convey depth.

The files of Interest:

History - Print - Recent Changes - Search
Page last modified on October 11, 2006, at 12:52 PM