I am attempting to solve a problem involving Quaternions and 3D rotation.
I am using a games engine (Torque 3D) for a project that I am developing. I have modified the gravity system so that the player is pulled in three dimensions towards a central point (the center of a spherical world).
I would like the player to also turn so that their feet are facing this central point, regardless of their position or initial orientation. I want the player to be able to stand on the spherical world, and currently, even though they are being pulled to the center of the world correctly, the orientation doesn't change.
The orientation is held in a Quaternion called "mOrient".
I know that the solution will involve rotation matrices, and probably world/local space translations, but I am not sure how to put all this together.
I am currently attempting this, unsuccessfully: Assume (0,0,0) is the center point, getPosition() is the position of the player. mOrient is the players 3D rotation quaternion, this is what I need to change.
Point3F gravityvec = Point3F(0, 0, 0) - getPosition();
gravityvec.normalize();
QuatF q = QuatF(gravityvec);
mOrient = q;
Does anyone have a solution for this?
I'm programming in C++ inside a games engine, but Pseudocode would be fine, I just need some assistance with the mathematical side.