コード例 #1
0
        public static mat4x4 SetTranslatePart(Vector3 pos)
        {
            mat4x4 mat = identity;

            mat[0]  = 1; mat[1] = 0; mat[2] = 0; mat[3] = pos.x;
            mat[4]  = 0; mat[5] = 1; mat[6] = 0; mat[7] = pos.y;
            mat[8]  = 0; mat[9] = 0; mat[10] = 1; mat[11] = pos.z;
            mat[12] = 0; mat[13] = 0; mat[14] = 0; mat[15] = 1;

            Debug.Log("Position: " + mat.ToString());

            return(mat);
        }
コード例 #2
0
        public static mat4x4 SetScalePart(Vector3 scale)
        {
            mat4x4 mat = identity;

            mat[0]  = scale.x; mat[1] = 0; mat[2] = 0; mat[3] = 0;
            mat[4]  = 0; mat[5] = scale.y; mat[6] = 0; mat[7] = 0;
            mat[8]  = 0; mat[9] = 0; mat[10] = scale.z; mat[11] = 0;
            mat[12] = 0; mat[13] = 0; mat[14] = 0; mat[15] = 1;

            Debug.Log("Scale: " + mat.ToString());


            return(mat);
        }
コード例 #3
0
        public static mat4x4 SetRotatePart(Quaternion rot)
        {
            mat4x4 mat = identity;

            float x = rot.x;
            float y = rot.y;
            float z = rot.z;
            float w = rot.w;

            mat[0]  = 1 - 2 * (y * y + z * z); mat[1] = 2 * (x * y - z * w); mat[2] = 2 * (x * z + y * w); mat[3] = 0;
            mat[4]  = 2 * (x * y + z * w); mat[5] = 1 - 2 * (x * x + z * z); mat[6] = 2 * (y * z - x * w); mat[7] = 0;
            mat[8]  = 2 * (x * z - y * w); mat[9] = 2 * (y * z + x * w); mat[10] = 1 - 2 * (x * x + y * y); mat[11] = 0;
            mat[12] = 0; mat[13] = 0; mat[14] = 0; mat[15] = 1;

            Debug.Log("Rotation: " + mat.ToString());

            return(mat);
        }