I'm playing with the MumbleLink API at the moment and I'm trying to get the character's orientation relative to the game map's orientation.
There's a struct fAvatarFront in LinkedMem. This struct changes when the character rotates around itself.
And there's another struct compassRotation in MumbleContext but it's always 0 no matter which way the character turns afaik even though the wiki said that it's radians (I have a high hope for it but turned out it didn't worked or I missed something big time ).
Does anyone figure out how to get this information? My best observation is the clue relates to the struct fAvatarFront.
It would be nice if someone already created some sort of formula to convert these numbers into the angle number relative to the map's orientation.
Thanks in advance
fAvatarFront and fAvatarUp are unit vectors out of which you can calculate the character's yaw and pitch with a bit of trigonometry - see https://wiki.mumble.info/wiki/Link
I think compassRotation would change only if you enable your minimap to rotate automatically depending on your character's orientation.
Does this help?
Answers
Thanks for tips about the minimap and the link. It has been a long time since I touched the triangles, lines, points and stuffs. I think it's time for me to refresh them.
Assuming that in GW2 the character model cannot stare at the zenith or the nadir, I think that you can simplify the math and use only the projection of the front vector onto the horizontal plane: yaw = atan2(frontvector.z, frontvector.x). See the Mumble coordinate system if you're wondering why we take z and x. This yields the anticlockwise angle from the positive x axis. Ref: https://en.wikipedia.org/wiki/Atan2 . Give it a try and let us know, I'm interested in the result
If you're interested in how to handle unit vectors with a complete freedom of rotation, have a look at https://en.wikipedia.org/wiki/Rotation_matrix#In_three_dimensions
The Legend of Gnash Gnarlsson
Here is what I came up with:
I use fAvatarFront from struct LinkedMem and like you said we take only X and Z values so they are fAvatarFront[0] and fAvatarFront[2] respectively.
This is the code written in C#:
This will return an integer value from 0 to 359. It starts at true North equals to 0 and goes clockwise.
Thanks again for the infos.
Glad it worked! Nice trick to do atan2(x,z) instead of atan2(z,x) to get the origin axis rotated and the angle flipped as you describe (north clockwise instead of east anticlockwise).
Are you planning to develop a game tool?
The Legend of Gnash Gnarlsson
Maybe in the near future but for now, I'm just trying to test my capability and get familiar with the APIs.