This is an old assignment. Do not use.

CSCI 480 Programming Assignment 1: Height Fields

Due Monday Feb 6th 2012 by 11:59pm

An Overview

Height fields may be found in many applications of computer graphics. They are used to represent terrain in video games and simulations, and also often utilized to represent data in three dimensions. This assignment asks you to create a height field based on the data from an image which the user specifies at the command line, and to allow the user to manipulate the height field in three dimensions by rotating, translating, or scaling it. After the completion of your program, you will use it to create an animation.

Why?

This assignment is intended as a hands-on introduction to OpenGL and programming in three dimensions. The starter code we provide is minimal, giving only the functionality to read and write a JPEG image and handle mouse and keyboard input. You must write the code to create a window, handle camera transformations, perform rendering, and handle any other functionality you may desire. We highly recommend the use of GLUT--please see the OpenGL Programming Guide for information, or, OpenGL.org and a page of OpenGL tutors or the on-line red book .

Background Information

A height field is a visual representation of a function which takes as input a two-dimensional point and returns a scalar value ("height") as output. In other words, a function f takes x and y coordinates and returns a z coordinate.

Rendering a height field over arbitrary coordinates is somewhat tricky--we will simplify the problem by making our function piece-wise. Visually, the domain of our function is a two-dimensional grid of points, and a height value is defined at each point. We can render this data using only a point at each defined value, or use it to approximate a surface by connecting the points with triangles in 3D.

Your Implementation

You will be using image data from a grayscale JPEG file to create your height field, such that the two dimensions of the grid correspond to the two dimensions of the image and the height value is a function of the image grayscale level. Since you will be working with grayscale image, the bytes per pixel (i.e. Pic->bpp) is always 1 and you don't have to worry about the case where bpp is 3 (i.e. RGB images).

Starter code in Visual Studio 2010 can be obtained here.

For Linux users, the starter code is here, and you will also need the pic image library which is used to read/write JPEG images. The makefile of the starter code assumes that the pic library locates one level above (i.e. if the starter code is in /home/tom/code/assign1, then the pic library should be in /home/tom/code/pic). You have to compile the pic library before the starter code. Please make sure you have libjpeg before compiling pic. The libjpeg can be obtained by "sudo apt-get install libjpeg62-dev". Here is a sample sequence of Ubuntu commands that get everything compiled:

> tar -xvf pic.tar.gz
> tar -xvf assign1_starterCode_linux.tar.gz
> cd pic
> make
> cd ..
> cd assign1
> make
> ./assign1 spiral.jpg

For Mac OS X, starter code is here, and you will also need the pic image library. The makefile of the starter code assumes that the pic library locates one level above (i.e. if starter code == /Users/tom/code/assign1, then pic library should be in /Users/tom/code/pic). Please compile the pic library before compiling the starter code. Here is a sample sequence of commands that get everything compiled:

> unzip pic_MacOS.zip
> unzip assign1_starterCode_macOS.zip
> cd pic
> make
> cd ..
> cd assign1
> make
> ./assign1 spiral.jpg

Please email the TA if you have trouble compiling the starter code. Note that the starter code includes an "exit" function call in the middle of the main function. On MS Visual Studio, you will see a console window appear briefly and then close right after that. Regardless of what operating system and platform you use to solve the assignment, you need to remove the exit function call and replace it with proper OpenGL initialization.

Grading Criteria

Your program must:

Animation Requirement

After finishing your program, you are required to submit a series of JPEG images which are screenshots from your program. Functionality to output a screenshot is included in the starter code, and assumes you are using a window size of 640x480--your JPEG images must be this size. Please name your JPEG frames 000.jpg, 001.jpg, and so on, where 000.jpg is the first frame of your animation, and please do not exceed 300 frames. Expect a framerate of 15 frames per second, which corresponds to 20 seconds of animation running time maximum.

There is a large amount of room for creavitiy in terms of how you choose to show your results in the animation. You can use our provided input images, or modify them with any software you wish, or use your own input images. You may also use your animation to show off any extra features you choose to implement. Your animation will receive credit based on its artistic content, whether pretty, funny, or just interesting in some manner.

We will compile a video of all student submissions and show it in class. Optional: If you would like to convert your frames to a video by yourself, you can use Adobe Premiere, ffmpeg, QuickTime Pro, or Windows Movie Maker.

Submission

Please zip your code and JPEG images into a single file and submit it to Blackboard. After submission, please verify that your zip file has been successfully uploaded. You may submit as many times as you like. If you submit the assignment multiple times, we will grade your LAST submission only. Your submission time is the time of your LAST submission; if this time is after the deadline, late policy will apply to it.

Tips

Extras

You may choose to implement any combination of the following for extra credit.

Please note that the amount of extra credit awarded will not exceed 10% of the assignment's total value.

Examples and Inputs

Input (Source Image)

Output (Height Field)

More inputs (real-world data):



[128] [256] [512] [768]

Santa Monica Mountains
Min elevation: 0m / 0ft
Max elevation: 638m / 2093.17ft
Image size: 15.9km x 15.9km / 9.8miles x 9.8miles


[128] [256] [512] [768]

Grand Teton National Park
Min elevation: 1936m / 6351.71ft
Max elevation: 4200m / 13779.52ft
Image size: 27.8km x 27.8km / 17.2miles x 17.2miles


[128] [256] [512] [768]

Ohiopyle State Park
Min elevation: 326m / 1069.55ft
Max elevation: 712m / 2335.95ft
Image size: 7.1km x 7.1km / 4.4miles x 4.4miles

Data available from U.S. Geological Survey, Earth Resources
Observation and Science (EROS) Center, Sioux Falls, SD.