コード例 #1
0
        public static void game_tilt_init(game_tilt tilt)
        {
            tilt.x[0] = 1.0f;
            tilt.x[1] = 0.0f;
            tilt.x[2] = 0.0f;

            tilt.rx = 0.0f;

            tilt.z[0] = 0.0f;
            tilt.z[1] = 0.0f;
            tilt.z[2] = 1.0f;

            tilt.rz = 0.0f;
        }
コード例 #2
0
        public static void game_tilt_grav(float[] h,
                                          float[] g,
                                          game_tilt tilt)
        {
            float[] X = new float[16];
            float[] Z = new float[16];
            float[] M = new float[16];

            /* Compute the gravity vector from the given world rotations. */

            Vec3.m_rot(Z, tilt.z, MathHelper.DegreesToRadians(tilt.rz));
            Vec3.m_rot(X, tilt.x, MathHelper.DegreesToRadians(tilt.rx));
            Vec3.m_mult(M, Z, X);
            Vec3.m_vxfm(h, M, g);
        }
コード例 #3
0
        /*
         * Compute appropriate tilt axes from the view basis.
         */
        public static void game_tilt_axes(game_tilt tilt, float[][] view_e)
        {
            float[] Y = new float[3] {
                0.0f, 1.0f, 0.0f
            };

            Vec3.v_cpy(tilt.x, view_e[0]);
            Vec3.v_cpy(tilt.z, view_e[2]);

            /* Handle possible top-down view. */

            if (System.Math.Abs(Vec3.v_dot(view_e[1], Y)) < System.Math.Abs(Vec3.v_dot(view_e[2], Y)))
            {
                Vec3.v_inv(tilt.z, view_e[1]);
            }
        }