CS 176 (Winter 2011)

 

Project 3 Description

 

 


In this homework we are asking you to implement the complex barycentric coordinates as discussed in class. All equations necessary are in the paper.

Your program should read in an image and display it by texture mapping it onto a triangle mesh. The easiest way to do this is to use n x m grid of vertices in the unit square and put in the diagonals in each small square to make n x m x 2 triangles. How large n and m? So it looks good. :) Showing the image then is a matter of issuing triangle drawing calls with appropriate z coordinates for each vertex to be used as texture coordinate referencing the input image as a texture.

You will need to catch mouse events to first have the user put down a boundary for the region of interest. This should be a singly connected sequence of vertices to make the boundary "S" (as it is called in the paper). Because editing of the boundary is hard to do well when there are many vertices on the boundary we ask you to only implement the P2P version of morphing. In other words you need to be able to change mode in the interface (and indicate the mode you are in, else this will get confusing) to "put down marker" mode. This will allow the user to place some landmark points. When the user is finished you have the "r_i" as they are called in the paper. Now starts the fun. The user now enters "edit marker mode" and can drag a marker (you'll need to have some reasonably robust way to figure out which one of the markers the user is grabbing) around to affect a deformation.

What happens under the hood? You need to compute the value of each of the P_i basis functions at each of the vertices of you mesh. With this stored any motion of a marker point will require recomputation of the sum over the P_i with the marker vertex positions as coefficients to arrive at the final texture coordinate for a given vertex in the mesh. Then issue the triangle drawing call again.

It's worth in this assignment to think a little bit about separating precomputation and "in loop" computations so that you can get quick update speeds. For the drawing you should probably consider a drawing mode which is not "immediate." I.e., display lists or vertex array type constructions.

Here's a simple framework code (Visual C++) and matrix inversion code that will give you a head start on the interface. Those who already have a nice textured mesh drawing code and have something that catches mouse events may well chose to stick with their own code. If you are a Linux person, here's a linux version of the same framework code with a Makefile that uses libpng in lieu of QT to load textures. This version includes the matrix library. Also, the framework is slightly modified to read in textures with alpha channel, and the cute froggy png is also updated to have transparent background. Even if you are not using this framework, you might still want to use the transparent version of the test image. If you are on linux and still want to use Qt, you can download the updated Qt code implementing transparency here: baryCoords_qt.tgz.