I make a FPS game with OpenGL (C++). I want to align a weapon like a gun to the camera, so that she moves and rotates with the camera.
I have accomplished that the weapon moves with the camera by removing the translation part from the view-matrix so that the weapon is always at the same position.
So I have removed the translation part (I work with OpenGL Mathematics (GLM)):
view = glm::mat4(glm::mat3(view));
The problem is that the weapon does not rotate with the camera. That means when I start the program the gun is aligned correctly but if I turn around the weapon don't turns with me so I cam't see her anymore.
Can anybody help to accomplish that the weapon is fixed to the camera?