CS 184: Computer Graphics and Imaging, Spring 2020

Project 2: Mesh Editor

Mie Haga, CS184-mie-h

Part1

        I start with a number of control points and a t value. Then, for each pair of control points next to each other, I calculate the location for a new point in between these two control points using the linear interpolation formula given. Finally, I repeat the process recursively multiple times until it arrives at a single point. This is the point that lies on the Bezier curve for the given t value.

Part2

        For Bezier surfaces, there are now two parameter values u and v, instead of just a t value. To do Bezier surfaces, I used the de Casteljau algorithm for Bezier curves multiple times, first to determine a point on the Bezier curve for each set of control points given, with respect to the u value. Then, I use the points determined, along with the v value, to calculate the final point on the Bezier surface.

        

Part3

        Given a vertex, I got the halfedges of the surrounding triangles, by calling the halfedge() and twin() functions. Then I used these halfedges to get the normals of each triangle. Then, I calculated the area of the triangle by first getting the length of each edge and using heron’s formula. Then, I weighed the normals of these triangles with their area, and normalized them by dividing the total area afterwards.

Flat shading

Phong Shading

Part4

        The first part was to define all of the halfedges, edges, vertexes, and faces that would be used for the flip. Then, each of those were set manually to their new value. I drew them out to make it easier to manually define their new positions.

Before flips

After flipping

        Drawing it out first really helps when you have to go back and manually check each halfedge, edge, vertex, and face to check for any typos. There were also some things that needed to be added, not for part 4, but for part 6, so I had to come back and add it into the function.

Part5

        Similar to how part 4 was implemented, I first defined all the halfedges, vertexes, edges, and faces that already existed and drew them out. Then I added in the new halfedges, vertexes, edges, and faces that would be needed. Finally, I put them into their proper new positions.

Before splits

After splits

After both splits and flips

        Same as part 4, drawing out all the pieces beforehand does help in making sure all the pieces are put together properly. I had to go back and change some things, since even with the drawing, there were some mistakes. I also had to go back and add stuff that we needed for part 6 as well.

Part6

        First, I calculated the new positions of the vertexes, and set those aside for now. Then, I did the same thing with the edges, to save the positions of new vertexes. Then, I split the edges and flipped the edges. Finally, I replaced the old positions of the vertexes with the new positions that were set aside later.

Some interesting tricks I used was to first calculated the positions of the old vertexes, and set them aside until after the splitting and flipping. Another interesting trick was to first save the positions for new vertexes into the edge that it eventually splits. Then, it can be saved in the vertex after it is created.    

icosahedron/input.dae:

Looping makes the sharp corner and sharp edges rounded. Pre-splitting has no effect on the sharp corner and sharp edges since they become smoother and rounded as a whole anyways.

Pre-processing to make it more symmetrical

Before split :

After split :

If I start by splitting the front diagonal edge before looping, it ends up more symmetrical. The main reason that it wasn’t symmetrical in the first place is because the starting face was not symmetrical, so no matter how many times it is looped, it won’t become symmetrical.