mesh is wrong positioned

Hi,

i have a problem with some wrong placed models.
As you can see on the picture below, the head and leg addon are wrong placed. You cannot see very good the head addon, it is inside the body. If you compare carefully both the original and my displayed model. you notice that these models are not just wrong placed, they are wrong turned by 180°, too. All other parts, like the backpack, or the tubes,… are all correctly displayed.

[ATTACH=CONFIG]1411[/ATTACH]

I’m calculating the model’s individual translation matrices here: MshViewer/Source/Object.cpp · master · C-Fu / OpenGL · GitLab

Notice the conversion between quaternion and Euler: MshViewer/Source/Object.cpp · master · C-Fu / OpenGL · GitLab

in the update function i call for every model part the getMVP function: MshViewer/Source/OpenGlController.cpp · master · C-Fu / OpenGL · GitLab
In there i calculate

m4x4Projection * m4x4View * m4x4ModelRot * m4x4Normalize * m4x4ModelCenter * getModelMatrix(index);

So in words: get the Model’s individual matrix (MshViewer/Source/OpenGlController.cpp · master · C-Fu / OpenGL · GitLab), move to Center, scale down to 1, rotate everything the way the user want it, move the camera in place and finally adjust the projection to fit the window size.

I don’t understand why there are only 2 parts wrong placed and why they are wrong placed. Maybe you can help me to find the problem.

My two cents: aren’t they related to any parent ? If so, they should be placed torward their parent coordinate system, not the global one.

Yes that’s right, everything can have a parent. In this case all models have the same parent (as you can see on the picture)
In my code i’m calling getModelMatrix(index); here. And the function is defined here. So i get every parent matrix

  1. if you first resize all the parts to 1 (as i suggested a few days ago), you also are resizing the “center” position
  2. if you re-center your model, you have to keep in mind that the center position has been resized, too

example:

you have a cube: [0; 5] x [0; 5] x [0; 5]
center = (2.5 | 2.5 | 2.5)

  1. resize to 1:
    scale factor = 0.2
    center --> (0.5 | 0.5 | 0.5) = scale factor x old center position

  2. re-center the cube:
    –> move all the vertices: -(0.5 | 0.5 | 0.5) instead of -(2.5 | 2.5 | 2.5)

that means you have to move all the parts belonging to that model with -(0.5 | 0.5 | 0.5)
you also have to scale all the parts with 0.2

Ah, i see. I’ll see if i find that in my code.

==EDIT==

i looked in the code, but i move everything to Center first and scale it then and i have the same problem without scaling and centering

btw i think i’m gonna switch from glm, glut, glew, glfw,… to Qt. Because i can get everything with just one very nice and powerful library. Already setup everything for Visual Studio and i already got my first Example code from the internet running :smiley:

I hope i can easily switch my whole project to Qt now :smiley: Do you know OpenGL with Qt, too? And do you have a nice tutorial??

[QUOTE=3DPrgmer;1284927]btw i think i’m gonna switch from glm, glut, glew, glfw,… to Qt. Because i can get everything with just one very nice and powerful library. Already setup everything for Visual Studio and i already got my first Example code from the internet running :smiley:

I hope i can easily switch my whole project to Qt now :smiley: Do you know OpenGL with Qt, too? And do you have a nice tutorial??[/QUOTE]

if you install Qt as “stand-alone” IDE, there are already simple / advanced examples included
i’m currently trying (struggling) to install the addin to Visual Studio 2015 (because the Qt IDE isnt that good imho)

If you need any help with that, let me know. I compiled the qt source multiple times with MinGW for static linking. And I already compiled them for VS with OpenGL Desktop. But I think I forgot exception handling, so I may need to recompile them.