예제 #1
0
 public static MmdMatrix[] createArray(int i_length)
 {
     MmdMatrix[] ret = new MmdMatrix[i_length];
     for (int i = 0; i < i_length; i++)
     {
         ret[i] = new MmdMatrix();
     }
     return(ret);
 }
예제 #2
0
        public void Vector3Rotate(MmdVector3 pVec3In, MmdMatrix matRotate)
        {
            double vx = pVec3In.x;
            double vy = pVec3In.y;
            double vz = pVec3In.z;

            this.x = (float)(vx * matRotate.m[0, 0] + vy * matRotate.m[1, 0] + vz * matRotate.m[2, 0]);
            this.y = (float)(vx * matRotate.m[0, 1] + vy * matRotate.m[1, 1] + vz * matRotate.m[2, 1]);
            this.z = (float)(vx * matRotate.m[0, 2] + vy * matRotate.m[1, 2] + vz * matRotate.m[2, 2]);
            return;
        }
예제 #3
0
        public void Vector3Transform(MmdVector3 pVec3In, MmdMatrix matTransform)
        {
            double vx = pVec3In.x;
            double vy = pVec3In.y;
            double vz = pVec3In.z;

            this.x = (float)(vx * matTransform.m[0, 0] + vy * matTransform.m[1, 0] + vz * matTransform.m[2, 0] + matTransform.m[3, 0]);
            this.y = (float)(vx * matTransform.m[0, 1] + vy * matTransform.m[1, 1] + vz * matTransform.m[2, 1] + matTransform.m[3, 1]);
            this.z = (float)(vx * matTransform.m[0, 2] + vy * matTransform.m[1, 2] + vz * matTransform.m[2, 2] + matTransform.m[3, 2]);
            return;
        }
예제 #4
0
        public void MatrixLerp(MmdMatrix matSrc1, MmdMatrix matSrc2, float fLerpValue)
        {
            double[,] sm1 = matSrc1.m;
            double[,] sm2 = matSrc2.m;
            double[,] dm  = this.m;
            double fT = 1.0 - fLerpValue;

            for (int i = 0; i < 4; i++)
            {
                dm[i, 0] = sm1[i, 0] * fLerpValue + sm2[i, 0] * fT;
                dm[i, 1] = sm1[i, 1] * fLerpValue + sm2[i, 1] * fT;
                dm[i, 2] = sm1[i, 2] * fLerpValue + sm2[i, 2] * fT;
                dm[i, 3] = sm1[i, 3] * fLerpValue + sm2[i, 3] * fT;
            }
            return;
        }
예제 #5
0
        public void MatrixMultiply(MmdMatrix matSrc1, MmdMatrix matSrc2)
        {
            double[,] matTemp = this._array_temp;
            int i;

            for (i = 0; i < 4; i++)
            {
                matTemp[i, 0] = matSrc1.m[i, 0] * matSrc2.m[0, 0] + matSrc1.m[i, 1] * matSrc2.m[1, 0] + matSrc1.m[i, 2] * matSrc2.m[2, 0] + matSrc1.m[i, 3] * matSrc2.m[3, 0];
                matTemp[i, 1] = matSrc1.m[i, 0] * matSrc2.m[0, 1] + matSrc1.m[i, 1] * matSrc2.m[1, 1] + matSrc1.m[i, 2] * matSrc2.m[2, 1] + matSrc1.m[i, 3] * matSrc2.m[3, 1];
                matTemp[i, 2] = matSrc1.m[i, 0] * matSrc2.m[0, 2] + matSrc1.m[i, 1] * matSrc2.m[1, 2] + matSrc1.m[i, 2] * matSrc2.m[2, 2] + matSrc1.m[i, 3] * matSrc2.m[3, 2];
                matTemp[i, 3] = matSrc1.m[i, 0] * matSrc2.m[0, 3] + matSrc1.m[i, 1] * matSrc2.m[1, 3] + matSrc1.m[i, 2] * matSrc2.m[2, 3] + matSrc1.m[i, 3] * matSrc2.m[3, 3];
            }

            for (i = 0; i < 4; i++)
            {
                this.m[i, 0] = matTemp[i, 0];
                this.m[i, 1] = matTemp[i, 1];
                this.m[i, 2] = matTemp[i, 2];
                this.m[i, 3] = matTemp[i, 3];
            }
        }
예제 #6
0
        public void MatrixInverse(MmdMatrix matSrc)
        {
            double[,] matTemp = this._array_temp;
            for (int i = 0; i < 4; i++)
            {
                for (int i2 = 0; i2 < 4; i2++)
                {
                    matTemp[i, i2] = matSrc.m[i, i2];
                }
            }
            this.MatrixIdentity();

            //掃き出し法
            for (int i = 0; i < 4; i++)
            {
                double buf = 1.0 / matTemp[i, i];
                for (int j = 0; j < 4; j++)
                {
                    matTemp[i, j] *= buf;
                    this.m[i, j]  *= buf;
                }
                for (int j = 0; j < 4; j++)
                {
                    if (i != j)
                    {
                        buf = matTemp[j, i];
                        for (int k = 0; k < 4; k++)
                        {
                            matTemp[j, k] -= matTemp[i, k] * buf;
                            this.m[j, k]  -= this.m[i, k] * buf;
                        }
                    }
                }
            }
            return;
        }