Closed kaaass closed 3 years ago
The code looks fine.
The drawing result is like this snapshot.
I tried to disable VMD by commenting these lines, but it seems helpless.
auto anim = std::make_unique<saba::VMDAnimation>();
anim->Create(m_mmdModel);
// saba::VMDFile vmdFile;
// saba::ReadVMDFile(&vmdFile, animPath.c_str());
// anim->Add(vmdFile);
anim->SyncPhysics(0.0f);
m_vmdAnim = std::move(anim);
However, as I extracted the logic about MMD model to a single project, the way of model twists got changed. And it works properly as I commented these lines.
void MmdModel::draw(Shader *shader) {
Lighting::getDefault()->useShader(shader);
// Model, view, projection matrix
glm::mat4 projection;
auto &screen = Game::getInstance()->screen;
auto camera = Game::curStage()->getCamera();
projection = glm::perspective(glm::radians(camera->zoom), (float) screen.width / (float) screen.height, 0.1f,
100.0f);
glm::mat4 view = camera->getViewMatrix();
glm::mat4 modelMat = glm::mat4(1.0f);
// modelMat = glm::translate(modelMat, glm::vec3{0, 0, 3});
// modelMat = glm::scale(modelMat, glm::vec3(1.0 / 6));
// ...
}
But this solution doesn't work in my full project. I had no idea with the problem and its solution. I guess it might relate to some weird memory issues, but valgrind gives nothing helped.
Here is the extracted code, tested under Linux kaaass-pc 5.4.80-1-MANJARO #1 SMP PREEMPT Tue Nov 24 18:57:09 UTC 2020 x86_64 GNU/Linux
.
3dg_demo.tar.gz
Anyway, thanks to your reply. Sorry for the long content.
I also built and tested it and had no problems. Commenting out the following line did not cause any problems.
// modelMat = glm::translate(modelMat, glm::vec3{0, 0, 3});
// modelMat = glm::scale(modelMat, glm::vec3(1.0 / 6));
Environment:
Is the version of glm the same as the saba library?
I tried to compile using the glm under saba/external/glm
, and every problem got solved.
Thanks again for your help.
Hi, I'm trying importing saba to my own OpenGL project. I followed the instruction in wiki, and the code in simple_mmd_viewer_glfw.cpp. But I could only get a twisted model, which I had no idea why.
Here is my model class: pastebin The rest program is like:
I also noticed that changing
m_mmdModel->GetUpdatePositions()
tom_mmdModel->GetPositions()
would make the model renderred properly but with no animation.Any help will be appreciated. And thanks for developing this fantastic repo since assimp only support poor pmx feature.