I was trying to make a camera similar to Maya and having trouble with the rotation
The camera flips when looking down the yaxis, does a Z rotation when I only want x,y like maya
and when I translate and then rotate does some really funky things when not at the origin
Can anyone help me debug this?
if( Buttons[0] )
{
roty = -(float) 1.0f * diffx;
rotx = -(float) 1.0f * diffy;
float phi = (rotx);
float theta = (roty);
glm::vec3 cameraW = glm::normalize(myCamera.getLookAtPosition()-myCamera.getCameraPosition());
glm::vec3 cameraU = glm::normalize(glm::cross( myCamera.getupVector(), cameraW ) );
glm::quat myQuat = glm::normalize(glm::angleAxis(theta, glm::vec3(myCamera.getupVector().x, myCamera.getupVector().y, myCamera.getupVector().z)) *glm::angleAxis(phi, glm::vec3(cameraU.x, cameraU.y, cameraU.z)) );
glm::mat4 rotmat = glm::toMat4( myQuat );
glm::vec4 myPoint(myCamera.getCameraPosition().x,myCamera.getCameraPosition().y,myCamera.getCameraPosition().z,1.0f);
glm::vec4 myVector(0.0, 1.0, 0.0, 0.0f);
glm::vec4 newPosition = rotmat * myPoint;
glm::vec4 newUpVector = myQuat* myVector ;//* glm::conjugate(glm::angleAxis(phi, glm::vec3(1.0f, 0.0f, 0.0f))) );
myCamera.setCameraPosition(newPosition.x,newPosition.y,newPosition.z);
myCamera.setupVector(newUpVector.x, newUpVector.y, newUpVector.z);
myCamera.setViewMatrix(myCamera.getCameraPosition(),myCamera.getLookAtPosition(),myCamera.getupVector());