+void weightsChanged(int blendshape, float weight) {
+ blendshapeWeights[blendshape] = weight;
+ std::vector<float> weights;
+ weights.assign(blendshapeWeights, blendshapeWeights + blendshapes.deltas.size());
+ interpolateBlendshapes(&blendshapes, weights);
+}
+
+void loadBlendshapes() {
+
+ // get all the obj files
+ std::vector<std::string> blends;
+ const std::string modelDir = "models/high-res-blendshapes/";
+ DIR *blendDir = opendir(modelDir.c_str());
+ while (dirent *e = readdir(blendDir)) {
+ if (e->d_type & DT_DIR) continue;
+ const std::string name(e->d_name);
+ if (name == "neutral.obj") continue;
+ blends.push_back(name);
+ }
+ closedir(blendDir);
+
+ std::vector<std::string> blendFps;
+ for (auto blend: blends) blendFps.push_back(modelDir + blend);
+ createBlendshapes(blendFps, modelDir + "neutral.obj", *pbrProg, &blendshapes);
+ targetModel = blendshapes.model;
+
+ size_t numBlends = blends.size();
+ blendshapeWeights = new float[numBlends];
+ for (int i = 0; i < numBlends; i++) blendshapeWeights[i] = 0;
+ const char *names[numBlends];
+ for (int i = 0; i < numBlends; i++) names[i] = blends[i].c_str();
+ createControlWindow(numBlends, names, weightsChanged);
+
+ camPos = { 0, 22, 81 };
+ camFront = { 0, 0, -1 };
+ camUp = { 0, 1, 0 };
+ zfar = 10000;
+ znear = 0.1f;
+}