Archive for October, 2011

julio le parc at bugada and cargnel

Saturday, October 29th, 2011


Mosek, matlab and mac ox x 10.7

Wednesday, October 19th, 2011

I recently got a new work machine with mac os x 10.7. Already having visions of last summer when I had a laptop with 10.5 and a desktop with 10.6. We’ll see how this goes…

My first issue is a simple one. I installed mosek and as per the instructions I changed the ~/.MacOSX/environment.plist file to contain:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">

But when I restarted matlab and issued


I saw that it was not finding the mosek binaries correctly:

??? Invalid MEX-file '/opt/local/mosek/6/toolbox/r2009b/mosekopt.mexmaci64':
dlopen(/opt/local/mosek/6/toolbox/r2009b/mosekopt.mexmaci64, 1): Library not loaded:
  Referenced from: /opt/local/mosek/6/toolbox/r2009b/mosekopt.mexmaci64
  Reason: image not found

The solution: Log out and back in.

BBW alligator demo

Wednesday, October 19th, 2011

alligator demo

I posted a small “bonus” demo that I’ve been distributing as a supplement for the Bounded Biharmonic Weights for Real-Time Deformation MATLAB demo. This shows a full pipeline for the alligator example in Figure 5 of our paper and in our videos. The example uses point, bone, and cages on the sample 2D character. The demo is now included in the folder of matlab code and can be called by issuing:

>> alligator_demo


Wednesday, October 19th, 2011


Eigen gotcha, sparse matrix inneriterator type

Sunday, October 9th, 2011

I just experienced a really annoying Eigen gotcha. If I have a sparsematrix A, defined as:

SparseMatrix<double> A;
// ... filled in somehow

then I can loop over the values with:

for(int k=0; k<A.outerSize(); ++k)
  // Iterate over inside
  for(SparseMatrix<double>::InnerIterator it (A,k); it; ++it)
      // it.row(),  it.col(), it.value()

This works fine. But if instead I use the wrong type for the InnerIterator, say int, I get no complaint from the compiler, just occasional garbage when I use it.col(), it.row(), or it.value():

for(int k=0; k<A.outerSize(); ++k)
  // Iterate over inside
  for(SparseMatrix<int>::InnerIterator it (A,k); it; ++it)
      // it.row(),  it.col(), it.value() produce occasional garbage


Wednesday, October 5th, 2011


glUniform invalid operation mystery

Sunday, October 2nd, 2011

I burned way too many hours tracking down a foolish bug I had in my GLSL/OpenGL code. The bug had to do with setting uniform variables in my GLSL vertex shader. My shader code looked something like:

uniform mat4 my_matrices[100];
uniform int my_int;
void main()
  // ... something using my_int and my_matrices
 I would then try to set them in my C++ OpenGL code with: 


This should work as long as my_matrices_location and my_int_location are set properly. Here’s I was setting them


// get number of active uniforms
GLint n = 200;
// get max uniform name length
GLint max_name_length;
// buffer for name
GLchar * name = new GLchar[max_name_length];
// buffer for length
GLsizei length = 100;
// Type of variable
GLenum type;
// Count of variables
GLint size;
// loop over active uniforms getting each's name
for(GLuint u = 0;u < n;u++)
  if(string(name) == "my_matrices[0]")
    my_matrices_location = u;
  }else if(string(name) == "my_int")
    my_int_location = u;

The mistake is that I’m confusing the variable’s index which I pass to glGetActiveUniform with it’s location which cannot be retrieved by glGetActiveUniform. Instead I need to retrieve the variable’s location with glGetUniformLocation. Here’s how I’m now setting my uniform variable locations CORRECTLY:

my_matrices_location = glGetUniformLocation(my_prog_id,"my_matrices[0]");
my_int_location = glGetUniformLocation(my_prog_id,"my_int");