I thought it would be a nice experiment to log my progress on implementing suggestive contours for my thesis on a minute-by-minute basis.
Whether this turns out to be an interesting log or a boring concatenation of my sloppy coding adventures, we’ll see. I might discover what’s eating the most of my time …
I need to re-read the suggestive contours paper, since I didn’t pay much attention to implementation details uptil now.
The object-space algorithm is based on finding the points where the radial curvature (K_r) is zero. It searches over the entire mesh. It then “trims” the solution using the directional derivative. So at the end, I’ll have a reduced set of points. How to connect them then? We’ll see.
Computing the radial curvature is done using this formula:
K_r(point) = K_1(point)cos²(phi) + K_2(point)cos²(phi)
So, first things first, what are K_1 and K_2?
Thanks to Wikipedia, I now know that K_1 and K_2 of a certain point p depict the principal curvatures in that point. Now, I hope that TriMesh2 already has some magic functionality to compute these, since it involves stuff like Taubin Smoothing and something called the T-algorithm – never heard of.
Since TriMesh2 doesn’t offer any kind of documentation, it’s looking-at-the-source time again. In TriMesh.h I discover that the standard mesh has the principal directions and the principal curvatures stored in a vector. All I need to do is call need_curvatures. The file TriMesh_curvature.cc contains the implementation, but I suppose this will Just Work ™.
I wonder whether I could compute the radial curvatures just one time (as a pre-process).
This turns out to be a silly thought, since the formula also contains the factor phi, which is the angle between the view vector (pointing to the camera) in that vertex and the first principal direction.
I had to compute the view vector for regular contours too, so I’ve got that part covered. Computing the angle between the view vector and the first principal direction vertex probably can be done using the dot product.
Realized the current code I’m adding to mesh_viewer.cc is getting a bit messy. I’m going to try and clean it up a bit by moving my contour-related functions to seperate files. Might have to browse through my C++ book to find out how to do that the clean way.
Reading parts of Accelerated C++ by A. Koenig again. And …
dinner break time
Had to work on something else first, so it was a rather long break.
Succesfully created some header files which allow me to use mesh_viewer global variables in other files.
I noticed all facenormals get recomputed at every draw. Going to write normals caching.
Got facenormals caching working. Rendering speed has improved. Might work this into the TriMesh2 library itself, in order to reduce ugly code …
Worked facenormals vector into TriMesh2 and recompiled library. Now I’ve got TriMesh2-JeroenRemix ;) Never done this before, but it seems to work. I somehow feel those were 3 hours well spent, although it didn’t really have anything to do with suggestive contours.
Time for a break. After that, I’ll implement compute_radial_curvature (*vertex)