X-Git-Url: https://git.lukelau.me/?p=opengl.git;a=blobdiff_plain;f=main.cpp;fp=main.cpp;h=e4cc81a2d79846c9a8e3028cfb85a2b2b42899ab;hp=c65e8d249e74f101f31f3ee3b2db817fb609304f;hb=ad77a970429c9c5e9cf8d513d0469d03ad82e622;hpb=671418e7effc7cbbb7e05df216291406d2b82dd7 diff --git a/main.cpp b/main.cpp index c65e8d2..e4cc81a 100644 --- a/main.cpp +++ b/main.cpp @@ -168,41 +168,19 @@ void display() { glUniform3fv(glGetUniformLocation(pbrProg->progId, "lightPositions"), numLights, glm::value_ptr(lightPositions[0])); glUniform3fv(glGetUniformLocation(pbrProg->progId, "lightColors"), numLights, glm::value_ptr(lightColors[0])); - glm::vec3 targetPos(sin(d) * 2 - 2, 2, 0); +#ifdef COWEDBOY_IK + { + glm::vec3 targetPos(sin(d) * 2 + 3, -2, 1); Light targetLight = { glm::translate(glm::mat4(1), targetPos), {0.5, 1, 1} }; drawLight(targetLight); - inverseKinematic(*sceneModel->find("Bottom Bone"), *sceneModel->find("Toppest Bone"), targetPos); + inverseKinematics(*sceneModel->find("Shoulder.L"), *sceneModel->find("Finger.L"), targetPos); - /* std::array jointPositions; std::array jointDistances; */ - - /* std::array jointNames = { "Bottom Bone", "Middle Bone", "Top Bone" }; */ - /* for (int i = 0; i < 3; i++) { */ - /* glm::mat4 trans; */ - /* findNodeTrans(&sceneModel->getRoot()->ai, aiString(jointNames[i]), &trans); */ - /* jointPositions[i] = glm::vec3(trans[3]); */ - - /* if (i > 0) */ - /* jointDistances[i - 1] = glm::distance(jointPositions[i], jointPositions[i - 1]); */ - /* } */ - - /* glm::vec3 targetPos(sin(d * 10.f), cos(d * 10.f), 0); */ - /* auto newPositions = fabrik(targetPos, jointPositions, jointDistances); */ - - /* for (int i = 0; i < 3; i++) { */ - /* glm::mat4 absTrans(1); */ - /* findNodeTrans(&sceneModel->getRoot()->ai, aiString(jointNames[i]), */ - /* &absTrans); */ - /* glm::mat4 newAbsTrans = absTrans; */ - /* newAbsTrans[3] = glm::vec4(newPositions[i], newAbsTrans[3][3]); */ - - /* auto node = sceneModel->getRoot()->ai.FindNode(jointNames[i].c_str()); */ - - /* auto newTrans = worldSpaceToModelSpace(node->mParent, newAbsTrans); */ - - /* node->mTransformation = mat4ToaiMatrix(newTrans); */ - /* } */ - /* sceneModel->find("Top Bone")->transform = glm::rotate(glm::mat4(1), d / 5.f, { 1, 0, 0}); */ - /* sceneModel->find("Bottom Bone")->transform = glm::rotate(glm::mat4(1), d / 3.f, { 1, 0, 0}); */ + targetPos = { sin(d * 2) * 2 - 5, 2.5, 0 }; + targetLight = { glm::translate(glm::mat4(1), targetPos), {1, 1, 0.5} }; + drawLight(targetLight); + inverseKinematics(*sceneModel->find("Shoulder.R"), *sceneModel->find("Finger.R"), targetPos); + } +#endif sceneModel->draw(skyboxes[activeSkybox], d * 1000); @@ -254,7 +232,7 @@ void init() { pbrProg = new Program("pbrvert.glsl", "pbrfrag.glsl"); glUseProgram(pbrProg->progId); - const std::string scenePath = "models/ik.glb"; + 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; @@ -312,7 +290,7 @@ void keyboardUp(unsigned char key, int x, int y) { keyStates[key] = false; } -#define ENABLE_MOVEMENT +/* #define ENABLE_MOVEMENT */ void timer(int _) { #ifdef ENABLE_MOVEMENT