public static Vector3 CalcExpectedCameraPosition(SimulatedHead head, SimulatedBody body)
        {
            Vector3 vector = body.position;

            vector.y += body.height - 1.776f;
            vector.y -= head.diameter / 2f;
            vector.y += 0.115999952f;
            Vector3 eulerAngles = head.eulerAngles;

            eulerAngles.y += body.rotation;
            Quaternion rotation = Quaternion.Euler(eulerAngles);

            vector += rotation * (0.0985f * Vector3.forward);
            return(vector);
        }
Esempio n. 2
0
        // this method uses the experimentally-found constants above to adjust
        // transform data in order to account for an emulator with different
        // settings for height, head size, and offset from the center of the head
        // to where the eyes are actually located (the respective constants are
        // defined above)
        public static Vector3 CalcExpectedCameraPosition(SimulatedHead head, SimulatedBody body)
        {
            Vector3 adjustedCameraPosition = body.position;

            // account for body height difference and offset for head size
            adjustedCameraPosition.y += body.height - k_DefaultBodyHeight;

            adjustedCameraPosition.y -= head.diameter / 2f;
            adjustedCameraPosition.y += k_DefaultHeadDiameter / 2f;

            // get total effective head rotation and convert to quaternion...
            var angles = head.eulerAngles;

            angles.y += body.rotation;
            var rotation = Quaternion.Euler(angles);

            // ...to account for the experimentally found forward-offset between the
            // center of the simulated head and average position of the eyes
            adjustedCameraPosition += rotation * (k_ForwardOffset * Vector3.forward);

            return(adjustedCameraPosition);
        }