rotate opengl mesh relative to camera
        Posted  
        
            by 
                shuall
            
        on Game Development
        
        See other posts from Game Development
        
            or by shuall
        
        
        
        Published on 2012-08-07T20:31:02Z
        Indexed on 
            2012/09/10
            21:50 UTC
        
        
        Read the original article
        Hit count: 302
        
I have a cube in opengl. It's position is determined by multiplying it's specific model matrix, the view matrix, and the projection matrix and then passing that to the shader as per this tutorial (http://www.opengl-tutorial.org/beginners-tutorials/tutorial-3-matrices/). I want to rotate it relative to the camera.
The only way I can think of getting the correct axis is by multiplying the inverse of the model matrix (because that's where all the previous rotations and tranforms are stored) times the view matrix times the axis of rotation (x or y).
I feel like there's got to be a better way to do this like use something other than model, view and projection matrices, or maybe I'm doing something wrong. That's what all the tutorials I've seen use.
PS I'm also trying to keep with opengl 4 core stuff.
edit: If quaternions would fix my problems, could someone point me to a good tutorial/example for switching from 4x4 matrices to quaternions. I'm a little daunted by the task.
© Game Development or respective owner