I've been working on a 6DOF camera that I want to be able to "align" to any walls orientation to make it feel like I'm standing on that wall.

I'm thinking it's a simple matter of finding the right amount needed between the current cameras rotation and the ground orientation and apply the difference in roll, but I'm terrible at vector math. Any help?

I use C# XNA Quaternion/Matrix/Vector3, but any pesudo math can do as thats what I'm struggling with.

Edit: I would also like this to work on spheres & cylinders, so I'd also need a way calculate the difference in pitch from changing from one vector to avoid making the camera feel like it looking upward if walking a step forward on top of a sphere for example.

  • \$\begingroup\$ What does "standing on that wall" mean? \$\endgroup\$
    – Steve H
    Commented Oct 12, 2016 at 12:22
  • \$\begingroup\$ To align the bottom of the camera to a wall/cylinder/sphere direction. \$\endgroup\$
    – jsmars
    Commented Oct 12, 2016 at 13:49

1 Answer 1


Turns out this was both easier and hard than I first realized. The simple answer to my question, of "rolling" a 6DOF cameras feet onto any normal, was quite simple. It can be aligned to any planar/spherical/cylindrical vector as follorws:

Roll(Vector3.Dot(currentDirection, alignmentVector));

But to achieve a camera that can truly latch on to any of these types of surfaces, we'd also need to make sure movement went along these planes as well as move the Yaw and Pitch to compensate for the movement, and this is something that requires quite a bit more calculations, which I found an answer to here. I've yet to implement this solution in my C# XNA environment tho, so if anyone has any help om this that would be greatly appreciated.

This does in a way answer my own question, however it doesn't solve my greater problem, so if anyone has a better solution or an implementation of DMGregory's suggestion for C#, I will mark that as the answer instead of this.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .