Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // даю рут ноду
- void Mesh::DrawNode(aiNode * node, glm::mat4 prtr)
- {
- aiMatrix4x4 m = node->mTransformation;
- aiTransposeMatrix4(&m);
- glm::mat4 node_tr = glm::make_mat4(&m.a1);
- glm::mat4 new_node_tr = node_tr * prtr;
- glm::mat4 pMatrices[MAXBONES];
- for (unsigned int i = 0; i < node->mNumMeshes; i++) {
- const aiMesh* pCurrentMesh = m_scene->mMeshes[node->mMeshes[i]];
- if ((pCurrentMesh->HasBones()) && (animController != nullptr)) {
- const std::vector<aiMatrix4x4>& vBoneMatrices = animController->GetBoneMatrices(node, i);
- if (vBoneMatrices.size() != pCurrentMesh->mNumBones) {
- continue;
- }
- for (unsigned int j = 0; j < pCurrentMesh->mNumBones; j++) {
- if (j < MAXBONES) {
- pMatrices[j][0][0] = vBoneMatrices[j].a1;
- pMatrices[j][0][1] = vBoneMatrices[j].b1;
- pMatrices[j][0][2] = vBoneMatrices[j].c1;
- pMatrices[j][0][3] = vBoneMatrices[j].d1;
- pMatrices[j][1][0] = vBoneMatrices[j].a2;
- pMatrices[j][1][1] = vBoneMatrices[j].b2;
- pMatrices[j][1][2] = vBoneMatrices[j].c2;
- pMatrices[j][1][3] = vBoneMatrices[j].d2;
- pMatrices[j][2][0] = vBoneMatrices[j].a3;
- pMatrices[j][2][1] = vBoneMatrices[j].b3;
- pMatrices[j][2][2] = vBoneMatrices[j].c3;
- pMatrices[j][2][3] = vBoneMatrices[j].d3;
- pMatrices[j][3][0] = vBoneMatrices[j].a4;
- pMatrices[j][3][1] = vBoneMatrices[j].b4;
- pMatrices[j][3][2] = vBoneMatrices[j].c4;
- pMatrices[j][3][3] = vBoneMatrices[j].d4;
- }
- }
- }
- GLCHECK(glUniformMatrix4fv(program->GetUniformLocation("bones"), pCurrentMesh->mNumBones, GL_FALSE, (float*)pMatrices));
- DrawChunk(node->mMeshes[i], new_node_tr);
- }
- for (unsigned int i = 0; i < node->mNumChildren; i++)
- {
- DrawNode(node->mChildren[i], new_node_tr);
- }
- }
- void Mesh::DrawChunk(int index, glm::mat4 tr)
- {
- //program->UseProgram();
- auto i = meshes[index];
- tr = ModelMatrix * tr;
- program->SetUniform("MVPm", tr);
- ................
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement