Esempio n. 1
0
        public static MatrixRecargada operator *(MatrixRecargada lhs, MatrixRecargada rhs)
        {
            MatrixRecargada matXMat = zero;

            matXMat.m00 = (lhs.m00 * rhs.m00) + (lhs.m01 * rhs.m10) + (lhs.m02 * rhs.m20) + (lhs.m03 * rhs.m30);
            matXMat.m01 = (lhs.m00 * rhs.m01) + (lhs.m01 * rhs.m11) + (lhs.m02 * rhs.m21) + (lhs.m03 * rhs.m31);
            matXMat.m02 = (lhs.m00 * rhs.m02) + (lhs.m01 * rhs.m12) + (lhs.m02 * rhs.m22) + (lhs.m03 * rhs.m32);
            matXMat.m03 = (lhs.m00 * rhs.m03) + (lhs.m01 * rhs.m13) + (lhs.m02 * rhs.m23) + (lhs.m03 * rhs.m33);

            matXMat.m10 = (lhs.m10 * rhs.m00) + (lhs.m11 * rhs.m10) + (lhs.m12 * rhs.m20) + (lhs.m13 * rhs.m30);
            matXMat.m11 = (lhs.m10 * rhs.m01) + (lhs.m11 * rhs.m11) + (lhs.m12 * rhs.m21) + (lhs.m13 * rhs.m31);
            matXMat.m12 = (lhs.m10 * rhs.m02) + (lhs.m11 * rhs.m12) + (lhs.m12 * rhs.m22) + (lhs.m13 * rhs.m32);
            matXMat.m13 = (lhs.m10 * rhs.m03) + (lhs.m11 * rhs.m13) + (lhs.m12 * rhs.m23) + (lhs.m13 * rhs.m33);

            matXMat.m20 = (lhs.m20 * rhs.m00) + (lhs.m21 * rhs.m10) + (lhs.m22 * rhs.m20) + (lhs.m23 * rhs.m30);
            matXMat.m21 = (lhs.m20 * rhs.m01) + (lhs.m21 * rhs.m11) + (lhs.m22 * rhs.m21) + (lhs.m23 * rhs.m31);
            matXMat.m22 = (lhs.m20 * rhs.m02) + (lhs.m21 * rhs.m12) + (lhs.m22 * rhs.m22) + (lhs.m23 * rhs.m32);
            matXMat.m23 = (lhs.m20 * rhs.m03) + (lhs.m21 * rhs.m13) + (lhs.m22 * rhs.m23) + (lhs.m23 * rhs.m33);

            matXMat.m30 = (lhs.m30 * rhs.m00) + (lhs.m31 * rhs.m10) + (lhs.m32 * rhs.m20) + (lhs.m33 * rhs.m30);
            matXMat.m31 = (lhs.m30 * rhs.m01) + (lhs.m31 * rhs.m11) + (lhs.m32 * rhs.m21) + (lhs.m33 * rhs.m31);
            matXMat.m32 = (lhs.m30 * rhs.m02) + (lhs.m31 * rhs.m12) + (lhs.m32 * rhs.m22) + (lhs.m33 * rhs.m32);
            matXMat.m33 = (lhs.m30 * rhs.m03) + (lhs.m31 * rhs.m13) + (lhs.m32 * rhs.m23) + (lhs.m33 * rhs.m33);
            return(matXMat);
        }
Esempio n. 2
0
        public static MatrixRecargada TRS(Vec3 pos, Quarentenion q, Vec3 s)
        {
            MatrixRecargada matTrans = Translate(pos);
            MatrixRecargada matRot   = Rotate(q);
            MatrixRecargada matScale = Scale(s);
            MatrixRecargada trs      = matTrans * matRot * matScale;

            return(trs);
        }
Esempio n. 3
0
        //
        // Resumen:
        //     Creates a scaling matrix.
        //
        // Parámetros:
        //   vector:
        public static MatrixRecargada Scale(Vec3 vector)
        {
            MatrixRecargada mScale = zero;

            mScale.m00 = vector.x;
            mScale.m11 = vector.y;
            mScale.m22 = vector.z;
            mScale.m33 = 1.0f;

            return(mScale);
        }
Esempio n. 4
0
        //
        // Resumen:
        //     Creates a translation matrix.
        //
        // Parámetros:
        //   vector:
        public static MatrixRecargada Translate(Vec3 vector)
        {
            MatrixRecargada mTrans = identity;

            mTrans.m03 = vector.x;
            mTrans.m13 = vector.y;
            mTrans.m23 = vector.z;
            mTrans.m33 = 1.0f;

            return(mTrans);
        }
Esempio n. 5
0
        public static MatrixRecargada Rotate(Quarentenion q)
        {
            MatrixRecargada mRot = identity;

            mRot.m00 = 1 - 2.0f * (q.y * q.y) - 2.0f * (q.z * q.z);
            mRot.m01 = 2.0f * (q.x * q.y) - 2.0f * (q.z * q.w);
            mRot.m02 = 2.0f * (q.x * q.z) + 2.0f * (q.y * q.w);
            mRot.m10 = 2.0f * (q.x * q.y) + 2.0f * (q.z * q.w);
            mRot.m11 = 1 - 2.0f * (q.x * q.x) - 2.0f * (q.z * q.z);
            mRot.m12 = 2.0f * (q.y * q.z) - 2.0f * (q.x * q.w);
            mRot.m20 = 2.0f * (q.x * q.z) - 2.0f * (q.y * q.w);
            mRot.m21 = 2.0f * (q.y * q.z) + 2.0f * (q.x * q.w);
            mRot.m22 = 1 - 2.0f * (q.x * q.x) - 2.0f * (q.y * q.y);

            return(mRot);
        }