Log in to reply



    I have this class where I don't want to use natives, so I'm trying to re-implement this. Brain says no though.

    I thought it should be possible with a few Vector3's:

    • base position in world coords
    • base rotation
    • offset position in world coords

    I can't figure it out though. Can anybody help?

    Edit - Never mind. I took ScriptHookVDotNet's Camera::GetOffsetInWorldCoords and adapted it for my own, and it seems to work:

        Vector3 GetOffsetInWorldCoords(Vector3 baseP, Vector3 rotation, Vector3 direction, Vector3 offset)
            Vector3 forward = direction;
            const double d2R = 0.01745329251994329576923690768489;
            double num1 = System.Math.Cos(rotation.Y * d2R);
            double x = num1 * System.Math.Cos(-rotation.Z * d2R);
            double y = num1 * System.Math.Sin(rotation.Z * d2R);
            double z = System.Math.Sin(-rotation.Y * d2R);
            Vector3 right = new Vector3((float)x, (float)y, (float)z);
            Vector3 up = Vector3.Cross(right, forward);
            return baseP + (right * offset.X) + (forward * offset.Y) + (up * offset.Z);

    Blah, cross products. I never quite understood algebra with vectors.

Log in to reply

Looks like your connection to GTA5-Mods.com Forums was lost, please wait while we try to reconnect.