Loop's Subdivision README
loop.c, loop.h, object.c, print.c
This program implements Loop's subdivision scheme for a mesh composed of triangular faces (at the risk of trademark violation, we'll call them "doritos"). The object viewer has been modified to read *.obj files into a winged edge data structure. Unfortunately, this means that the other models such as the Porsche and Al the Gangster are no longer supported. In addition, I've disabled the ability to print models to postscript files, although you can now e[x]port your subdivided model to an *.obj file.
Using the modified object viewer
The object viewer should be pretty easy to use. All of the supported keyboard commands are listed in the window - feel free to play around with them. In particular, a few of commands warrant some description:
[L] Loop's |
Apply Loop's subdivision algorithm.
In the first pass, new vertices are added at the midpoints of the edges of the triangle. New edge pointers are added and old pointers are updated to accommodate the new vertices (see figure 1). Since the face of the triangle is defined by it's initial edge, it is scaled to one corner.
In the second pass, edges are added to complete the subdivision into 4 triangles (see figure 2).
In the third pass, Loop's mask is applied. Vertices are "averaged" or "refined" to create a smoothing effect. For each vertex v, it's new position is defined by the number and relative positions of it's neighbors. The function alpha applies weights to each vertex based on the number of it's neighbors. |
| |
Figure 1: Subdivision - after the first pass |
Figure 2: Subdivision - after the second pass |
| |  |
|
[S] subdivide |
Apply only the first two passes of Loop's subdivision algorithm. That is, subdivide without applying Loop's mask. You won't see any effect if you are viewing the flat-shaded model. Press 'W' to see the subdivided wireframe. |
|    |
[A] average |
Apply Loop's mask without subdividing. Since this doesn't increase the number of doritos displayed, you can apply this function arbitrarily often. Eventually, the positions of the vertices will approach a limit. |
[1] firstpass |
Apply only the first pass of the subdivision (see figure 1). This is a bit of a hack to create some really cool models by applying Loop's mesh before the subdivision is complete. Doing only this will of course "break" the data structure (press [V] to see the complaints), but you can fix it again by subdividing with [S] (the program can recognize that the first pass has already been completed and will proceed with the second pass). But that won't do anything interesting unless you apply Loop's mask before completing the subdivision. Apply Loop's mask a number of times with [A]. Since edges are missing, the new vertices added in the subdivision will have fewer neighbors and be weighted differently during the averaging scheme. When you've applied Loop's mask a few times, press [S] to restore the model. Note: after pressing [1] once, pressing it again won't do anything until you've "fixed" your model with [S]. |
[X] export |
Save your modified model in a file called output.obj. Note: If your object file is over thousands of lines long, don't try to open it up again with my object viewer. Unfortunately, reading object files into a winged edge data structure takes O(n^2) (at least when I do it...). The original object viewer reads files in linear time, so you might want to use that instead. I've included the old executable under the filename oldobject. Note that this method can also be used to create postscript files from your models since oldobject still has this feature. |
I'd suggest just playing around with some of the models for a while. There are some pre-defined objects you can play with, or you can generate some new ones using the shape program (from project 1). See the readme for instructions. Or you could just fire up pico and type in some of your own. Just remember that the object needs to be some kind of closed surface, otherwise the winged edge data structure will break (in the style of a seg fault).
More pretty pictures
This project was obviously lots of fun.
|
|
Want to drop me a note? Do so: 
|
|
|