tailieunhanh - Microsoft XNA Game Studio Creator’s Guide- P11

Microsoft XNA Game Studio Creator’s Guide- P11:The release of the XNA platform and specifically the ability for anyone to write Xbox 360 console games was truly a major progression in the game-programming world. Before XNA, it was simply too complicated and costly for a student, software hobbyist, or independent game developer to gain access to a decent development kit for a major console platform. | 278 MICROSOFT XNA GAME STUDIO CREATOR S GUIDE vector that stores a rotation around an axis. Quaternion math is used to calculate an increment to update the camera s Look vector. We can express the value of the Look vector like this Look View - Position By rearranging this equation we can say the following View Look Position If the quaternion represents the updated Look vector then Updated View Updated Look Vector Position Updated Look Vector The formula for calculating the updated Look vector is qRotation qLook qRotation qRotation is the conjugate of qRotation Each of the three operands will be discussed next. Local Rotation Quaternion The first quaternion that is used to calculate the updated Look vector qRotation is a local rotation. Quaternion theory provides a formula for computing the local rotation. In this case the local rotation is generated using a direction vector for X Y and Z. Rotations about the X axis are applied using the Look vector. Rotations about the Y axis are applied using the Right direction vector. The rotation angle stored in the W component is obtained from the deviation of the mouse or thumbstick from the center of the window. With this information we can generate the local rotation by writing the following cos MouseDeviationFromCenter 2 sin MouseDeviationFromCenter 2 sin MouseDeviationFromCenter 2 sin MouseDeviationFromCenter 2 Using the Look Vector as a Quaternion The next quaternion used in the formula for the updated Look vector is based on the Look direction 0 CHAPTER 17 Conjugate Quaternion A conjugate quaternion is used to calculate the updated Look vector. The conjugate is created by negating a quaternion vector s X Y and Z components Quaternion conjugate Quaternion Product The equation for multiplying two quaternion is as follows