I'm working on making a 3rd person camera (in lwjgl) and I simply cannot get the math concepts straight in my head. I've worked through the positioning stuff in the arcsynthesis tutorials but I'm still having some trouble thinking in quaternions. I really don't like Euler angles (yaw, pitch, roll) so I'd like to stay away from them.

Right now I have a player class that has its own camera object as well as player position and camera target vectors and an orientation quaternion. I can update the player's orientation with a quat but I'm having trouble figuring out how to move the camera's target and position properly.

Should that be done with quats/position vectors as in the left half of my pic? Would it be better to do it with a pair of spherical position vectors like in the right? And if so, isn't that subject to gimbal lock?

I'm using an offset target point so as to avoid the irritating player-always-in-the-way effect like in minecraft.

You can always view a rotation in 3D as taking 3 orthogonal unit vectors and performing a parallel projection (dot product) of the point into them to form the rotation. So if you have a lookat direction, you already have one. Having a rough desired 'up' direction gives you a way to generate the other 2. It looks like you're asking for the classic lookat formulation. It's degenerate as lookat approaches either straight up or down but it a reasonable starting point.

Actually I have the lookat formula but I wanted to do the same thing with quats because they don't degenerate. I roughly understand the lookat formula but I can't figure how to properly position the camera and target point relative to the player while working with quats. I appreciate the note about dot product though, it's been a few years since I did calc or trig.

Using quaternions is fine, but you still need to decide how you want to parametrize the orientation. You have to figure out how you want camera 'up' (or right or left) to behave. Quaternions will help for smoothly transitioning from the current camera orientation toward your new target orientation but don't seem useful for making the target. You effectively have an axis-of-rotation embedded in the quat and you still need to figure out what it is.

Ok that helps a lot! The arcball thing makes sense now, my final problem is that I can't imaging how to make the camera rotate about the player (as in the dark circle in my pic) but look at another point without screwing up the arcball. Mathematically how can I account for rotating around a center that is not my camera target?

Ok, here's what I'm thinking, (I'm at work so I'll test it later if I can) I should have two orientation quats, one pointing the camera at the player (center of arcball) and one pointing it at the target point. I use the first one while rotating the camera around the player (ie camToPlayerQuat.tomatrix ()) then set the cameras orientation to camToTargetQuat before rendering. Does that make sense to anyone?

Ok that helps a lot! The arcball thing makes sense now, my final problem is that I can't imaging how to make the camera rotate about the player (as in the dark circle in my pic) but look at another point without screwing up the arcball. Mathematically how can I account for rotating around a center that is not my camera target?

Two different issues. Rotation about the player defines the local coordinate frame of the camera...we're more talking about how the camera is oriented in that frame.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org