+void drawLight(Light &light) {
+ drawPlainProg(plainProg, lightVao, light.trans, light.color);
+}
+
+int findNodeTrans(const struct aiNode *n, const struct aiString name, glm::mat4 *dest) {
+ if (strcmp(n->mName.data, name.data) == 0) {
+ *dest = aiMatrixToMat4(n->mTransformation);
+ return 0;
+ }
+ for (int i = 0; i < n->mNumChildren; i++) {
+ if (findNodeTrans(n->mChildren[i], name, dest) == 0) {
+ glm::mat4 t = aiMatrixToMat4(n->mTransformation);
+ *dest = t * *dest;
+ return 0;
+ }
+ }
+ return 1;
+}
+
+glm::mat4 worldSpaceToModelSpace(aiNode *node, glm::mat4 m) {
+ aiNode *parent = node;
+ glm::mat4 res = m;
+ std::vector<glm::mat4> trans;
+ while (parent != nullptr) {
+ /* res = res * glm::inverse(aiMatrixToMat4(parent->mTransformation)); */
+ trans.push_back(glm::inverse(aiMatrixToMat4(parent->mTransformation)));
+ parent = parent->mParent;
+ }
+ while (!trans.empty()) { res = trans.back() * res; trans.pop_back(); }
+ return res;
+}
+
+void drawCursor(glm::vec3 pos, glm::vec3 color, float scale = 1) {
+ glUseProgram(cursorProg->progId);
+ glBindVertexArray(cursorVao);
+ setProjectionAndViewUniforms(cursorProg->progId);
+ glm::mat4 model = glm::scale(glm::translate(glm::mat4(1), pos), glm::vec3(scale * 0.4));
+ GLuint modelLoc = glGetUniformLocation(cursorProg->progId, "model");
+ glUniformMatrix4fv(modelLoc, 1, GL_FALSE, glm::value_ptr(model));
+
+ GLuint colorLoc = glGetUniformLocation(cursorProg->progId, "color");
+ glUniform4fv(colorLoc, 1, glm::value_ptr(color));
+
+ glDrawElements(GL_TRIANGLES, cursorNumIndices, GL_UNSIGNED_INT, 0);
+}