+
+ if (curMode == Default) {
+ const std::string scenePath = "models/cowedboy.glb";
+ const aiScene *scene = importer.ReadFile(
+ scenePath, aiProcess_Triangulate | aiProcess_CalcTangentSpace |
+ aiProcess_GenNormals | aiProcess_FlipUVs);
+ if (!scene) {
+ std::cerr << importer.GetErrorString() << std::endl;
+ exit(1);
+ }
+
+ if (scene->mNumCameras > 0) {
+ aiCamera *cam = scene->mCameras[0];
+ glm::mat4 camTrans;
+ if (findNodeTrans(scene->mRootNode, cam->mName, &camTrans) != 0)
+ abort(); // there must be a node with the same name as camera
+
+ camPos = {camTrans[3][0], camTrans[3][1], camTrans[3][2]};
+
+ glm::vec3 camLookAt =
+ glm::vec3(cam->mLookAt.x, cam->mLookAt.y, cam->mLookAt.z);
+ camFront = camLookAt - camPos;
+
+ camUp = glm::vec3(cam->mUp.x, cam->mUp.y, cam->mUp.z);
+
+ fov = cam->mHorizontalFOV;
+ // TODO: aspectRatio = cam->mAspect;
+ znear = cam->mClipPlaneNear;
+ zfar = cam->mClipPlaneFar;
+ }
+
+ for (int i = 0; i < scene->mNumLights; i++) {
+ aiLight *light = scene->mLights[i];
+ glm::mat4 trans;
+ findNodeTrans(scene->mRootNode, light->mName, &trans);
+ glm::vec3 col = {light->mColorAmbient.r, light->mColorAmbient.g,
+ light->mColorAmbient.b};
+ Light l = {trans, col};
+ lights.push_back(l);
+ }
+
+ sceneModel = new Model(scene, *pbrProg);
+ }
+
+ if (curMode == Blendshapes) {
+ loadBlendshapes("models/high-res-blendshapes/", *pbrProg, &bsModel);
+ targetModel = bsModel.model;
+
+ size_t numBlends = bsModel.blendshapes.size();
+ std::vector<std::string> names(numBlends);
+ for (int i = 0; i < numBlends; i++) names[i] = bsModel.blendshapes[i].name;
+ controlWindow = createControlWindow(names, &cwDelegate);
+
+ camPos = { 0, 18, 81 };
+ camFront = { 0, 0, -1 };
+ camUp = { 0, 1, 0 };
+ zfar = 10000;
+ znear = 0.1f;
+ }