   [XNA] Matrix.CreateLookAt not behaving as expected when changing the Up vector...
  For the past while I have been unsuccessful in implementing camera roll.  I've got yaw and pitch working just fine, but roll has proven to be considerably more difficult.Here's more or less what I am doing:Each frame I'm capturing mouse (and keyboard) input to get the yaw, pitch, and roll.  Using the yaw, pitch, and roll I create a rotation matrix to rotate three points around the origin (representing the camera's target, 'up', and 'right' vectors).  I then translate that into place to the camera's real position and create a view matrix using Matrix.CreateLookAt(), passing in the camera's position, target, and up vectors.Now before you jump on this and say it is a gimbal lock problem, I don't think it is.  The only thing that I am keeping between frames is the yaw, pitch and roll.  I'm regenerating the rotation matrix from scratch each frame, so I'm pretty sure it isn't a gimbal lock problem.For the curious, here's the bit of code that I am using to do the aforementioned://boring bits of getting the input have been ignored.  At this point yaw, pitch, and roll contain the yaw, pitch, and roll of the camera, as they should.  //update the rotation matrix according to the yaw/pitch/roll.  Rotate the lookat point  rotationMatrix = Matrix.CreateFromYawPitchRoll(yaw, pitch, roll);  initialTarget = Vector3.Forward;  initialUp = Vector3.Up;  initialRight = Vector3.Right;  initialPosition = Vector3.Zero;  //rotate the target   initialTarget = Vector3.Transform(initialTarget, rotationMatrix);  initialUp = Vector3.Transform(initialUp, rotationMatrix);  initialRight = Vector3.Transform(initialRight, rotationMatrix);  target = initialTarget + position;  up = initialUp + position;  right = initialRight + position;  //move forward  if (currentKeyboardState.IsKeyDown(Keys.W))  { position += initialTarget * 0.05f;target += initialTarget * 0.05f;right += initialTarget * 0.05f;up += initialTarget * 0.05f;  }  //move backward  if (currentKeyboardState.IsKeyDown(Keys.S))  { position -= initialTarget * 0.05f;target -= initialTarget * 0.05f;right -= initialTarget * 0.05f;up -= initialTarget * 0.05f;  }  //strafe left  if (currentKeyboardState.IsKeyDown(Keys.A))  { position -= initialRight * 0.05f; target -= initialRight * 0.05f;right -= initialRight * 0.05f;up -= initialRight * 0.05f;  }  //strafe right  if (currentKeyboardState.IsKeyDown(Keys.D))  { position += initialRight * 0.05f; target += initialRight * 0.05f;right += initialRight * 0.05f;up += initialRight * 0.05f;  }    UpdateProjectionMatrix();    //This doesn't seem to work as expected...  viewMatrix = Matrix.CreateLookAt(position, target, up);  //I then draw some things using the view matrix...Here's the kicker: the only things that I am drawing right now are four points - one at the world's origin, and three more at the camera's initial target, up, and right vectors.  The points behave just as they should.  The initial target point rotates around the origin just like it should, as does the initial up and initial right vectors.  It's when I plug things into the Matrix.CreateLookAt function that everything breaks down.  Rather than rolling like it should, the camera behaves very strangely.  When I look side to side (just changing the yaw), the camera rolls side to side as well as looks side to side.  If I plug a value of (0.0, 1.0, 0.0) in for the Up vector on Matrix.CreateLookAt, it behaves just fine, but without any sort of camera roll.I can't for the life of me figure out what is causing this strange behavior.  All the rotations seem correct when I render out the initial points.  Is there something that I don't know and should know about Matrix.CreateLookAt?  Shouldn't the Up vector in Matrix.CreateLookAt cause the world to roll around?I've got a thread over on the XNA forums, but haven't found a proper answer yet, so I figured I'd try asking the brains around here to see if any of you have any ideas on why it isn't working as it should.   
  There's no need to use CreateLookAt if you already have a matrix representing your camera's position.  Just use CreateFromYawPitchRoll, set the position of the camera in the Translation property of the resulting matrix, and then invert it.  Voila, you have a view matrix.   ;  Hmm, good call.  I guess I was thinking that Matrix.CreateLookAt did something special.  I'll have to play around with this more when I get home.   ;Quote:Original post by MoeHmm, good call.  I guess I was thinking that Matrix.CreateLookAt did something special.  I'll have to play around with this more when I get home.Yeah it's not extremely obvious, but a view matrix is just the inverse of a "world" transformation.  If you think about it makes sense: a world matrix takes something and transforms it from its local space to it's actual world position and orientation.  A view matrix takes things that are in their world position and orientation, and transforms them to a coordinate space local to the camera.;  Matt, you are totally right - it worked like a charm.  Thanks a bunch!   