|
From: Keith W. <kw...@cs...> - 2004-06-21 14:40:38
|
The camera view in my program will reflect a first-person perspective of a person's body and head in a world. The person can move their "body" by going forward and backward or rotating left and right (yaw). The person can also individually move their head around their neck by "pitching" up and down. I want this system to do some specific things, some of which I have figured out, others of which I haven't. Moving forward and backward is easy, since I can get the forward vector of the object, discard the Y axis and just translate by a distance or speed scalar of X and Z to move over horizontal ground (discarding Y because looking up shouldn't make a person fly up into the sky when they move forward). Rotating around Y isn't too hard. I tried using yaw but of course that makes it yaw around the local Y axis which gets funky when the head is pitched up or down. However, this is fairly easy by just orienting around the Y Euler angle. I have found that is works properly even when the camera is pitched away from a horizontal viewing axis. However, I have the following problem. I would like to make the head "snap" back to 0 vertical (no pitch) when I move the body forward or backward (so instead of wandering around with one's head pointed an arbitrary pitch the head should snap back to horizontal as soon as the body and camera are moved forward or backward). I can't figure out how to take the present orientation (a quaternion of course) and remove the vertical component of this orientation to flatten it to 0 without affecting the horizontal orientation (so the body is still looking along the same vertical azimuthal equator of the world but at 0 degree altitude). How do I do this? Thanks. ________________________________________________________________________ Keith Wiley kw...@cs... http://www.unm.edu/~keithw http://www.mp3.com/KeithWiley "Yet mark his perfect self-contentment, and hence learn his lesson, that to be self-contented is to be vile and ignorant, and that to aspire is better than to be blindly and impotently happy." -- Edwin A. Abbott, Flatland ________________________________________________________________________ |