## Archive for March, 2015

### Extract full resolution (original) gif image (or other media) from a power point file

Sunday, March 29th, 2015

I’d lost the original to an animated gif that I’d embedded in a previous talk’s powerpoint slide. I tried clicking “Save image as…” but this gave me a lower resolution, scaled version without the animation. Seems there is a well known trick to finding original media in modern Microsoft office files. The .*x files are actually zipped directories. So unzip them to a folder using something like:

unzip myfile.pptx -d myfile/


Then you should find your media files somewhere in this directory. I found mine in: myfile/ppt/media/.

source

### Two-sided material in matlab

Monday, March 23rd, 2015

Unfortunately there seems to be no builtin support for two-sided surfaces in matlab. There’s some rudimentary control over back-face lighting, but that’s all. At least you can determine the back-facing triangles for a given camera position:

N = normals(V,F);
BC = barycenter(V,F);
back_facing = sum(N.*bsxfun(@minus,BC,campos),2)<=0;


Here’s an example for an armadillo mesh:

t = tsurf(F,V,'EdgeColor','none','FaceLighting','phong');view(2);
axis equal;
camproj('persp')
t.FaceVertexCData = 1*(sum(N.*bsxfun(@minus,BC,campos),2)<=0)
apply_ambient_occlusion();


Of course, if you change the view, the coloring is no longer valid:

So you need to recompute the coloring:

You can also insert nans to achieve back-face culling:

t.FaceVertexCData(sum(N.*bsxfun(@minus,BC,campos),2)>0) = nan;


### EZproxy bookmarklet

Friday, March 20th, 2015

The columbia proxy/vpn never worked super well for me. Or at least I didn’t try very hard to set it up. I really only need it for viewing academic articles off campus. So usually I just search for it via the columbia library’s website, log in, and retrieve the article. Doing this I noticed that the library is just feeding me the usual link (e.g. from acm dl) but via an “ezproxy”. So

http://dl.acm.org/citation.cfm?id=2185544 becomes

http://dl.acm.org.ezproxy.cul.columbia.edu/citation.cfm?id=2185544.

I wrapped this replacement into a javascript bookmarklet.

javascript:(function(){window.location.href=window.location.href.replace(/http:\/\/[^\/]*/,"\$&.ezproxy.cul.columbia.edu");})()


### Parse a list of numbers without hard coding size

Thursday, March 19th, 2015

I’ve been used to parsing numbers from strings with the c-style sscanf function. So if I need to read in 3 floats into a vector I’d use something like:

vector<float> v(3);
sscanf(string_to_parse,"%f %f %f",&v[0],&v[1],&v[2]);


This is fine if you know at compile time that the vector will be size 3. But if the number isn’t known at compile time, the c-style gets messy with loops.

Here’s a c++-style solution. Admittedly there are also some messy-looking loops, but I still prefer it. It also makes it easy to have a richer delimiter set.

// http://stackoverflow.com/a/1894955
#include <vector>
#include <string>
#include <sstream>
...
using namespace std;
vector<double> vect;
string delimeters = ", ";
stringstream ss(string_to_parse);
double v;
while(ss >> v)
{
vect.push_back(v);
while(string::npos != delimeters.find(ss.peek()))
{
ss.ignore();
}
}


### Skinning Course at SGP Grad School

Monday, March 16th, 2015

I’ll be teaching a version our of SIGGRAPH 2014 course Skinning: Real-time Shape Deformation at this years SGP. Looking at the grad school line up this yea, it seems I’ll be in very good company.

### Compiling OpenSubDiv on mac os x with gcc

Monday, March 16th, 2015

I had a bit of trouble compiling OpenSubDiv on Mac OS X Yosemite with gcc. I could at least manage to compile the cpu library with:

mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DNO_EXAMPLES=1 -DNO_GCD=1 -DNO_CUDA=1 ..
make osd_static_cpu


This creates lib/libosdCPU.a. It seems -DNO_GCD=1 is the most critical option as grand central dispatch uses apple’s “blocks” extension C which is only supported by clang.

### Skinning Subdivision Surfaces

Monday, March 16th, 2015

Songrun and Yotam have wrapped up the little 3D demo of our Siggraph Asia 2014 paper Skinning Cubic Bézier Splines and Catmull-Clark Subdivision Surfaces. Build the demo from source on github.

### gluUnProject buggy for canonical views

Sunday, March 15th, 2015

I just ran into a very frustrating bug in gluUnProject. It seems that if the model view matrix is rotated to align the view axis with the y-axis then gluUnProject is unreliable. Here’s a little example:

Set up you model view, projection and viewport with:

MV = [1 0 0 0;0 0 -1 0;0 1 0 -4.3;0 0 0 1];
P = [1.81066 0 0 0;0 2.41421 0 0; 0 0 -1.00019 -0.0200019; 0 0 -1 0];
VP = [0 0 960 720];


Then given a point in the scene

p = [1.66667 0 0];


project it using gluProject (this seems to work OK):

proj_p = [816.867 360 0.99777];


move it one pixel up (as if with the mouse):

proj_p = [816.867 361 0.99777];


then unproject with gluUnProject:

wrong = [1.80114 -0.345327 -0.00534674];


Where did that movement in the y-direction come from? My guess is the implementation of gluUnProject is doing a bad job inverting the scene matrix in terms of floating point error. Luckily, libigl has an implementation of igl::unproject which uses Eigen’s robust inverse() function. This solved my problem and gives the correct unprojection:

correct = [1.66667 0 -0.00494755];