|
|
CS 176 (Winter 2009) |
|
|
|
|
|
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. Lily will be supervising this assignment and she has a simple framework 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, but Lily's is available. Don't bang your head against the wall on getting things such as texture transformation matrices right... |