Jump to content
  • Sign Up

How to get the character's orientation from MumbleLink?


River.8964

Recommended Posts

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 :p ).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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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#:

public static int Get_Orientation(float fAvatarFront){float radian = (float)Math.Atan2(fAvatarFront[0], fAvatarFront[2]);float angle = radian * 180.0f / (float)Math.PI;return (int)((angle + 360.0f) % 360.0f);
}

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.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...