Example #1
0
        public static PositionVector operator *(PositionVector v, float n)
        {
            PositionVector matrix = new PositionVector();

            for (int i = 0; i < matrix.Rows; i++)
            {
                for (int j = 0; j < matrix.Columns; j++)
                {
                    matrix[i, j] = v[i, j] * n;
                }
            }
            return(matrix);
        }
Example #2
0
        public static PositionVector operator +(PositionVector v1, PositionVector v2)
        {
            PositionVector matrix = new PositionVector();

            for (int i = 0; i < matrix.Rows; i++)
            {
                for (int j = 0; j < matrix.Columns; j++)
                {
                    matrix[i, j] = v1[i, j] + v2[i, j];
                }
            }
            return(matrix);
        }
Example #3
0
        public static PositionVector operator *(TransformationMatrix m, PositionVector v)
        {
            PositionVector vector = new PositionVector();

            vector.Zero();
            for (int i = 0; i < vector.Rows; i++)
            {
                for (int j = 0; j < m.Columns; j++)
                {
                    vector[i, 0] += m[i, j] * v[j, 0];
                }
            }
            return(vector);
        }
Example #4
0
        static void TransformBones()
        {
            PositionVector bone;

            for (int i = 0; i < model.Bones.Length; i++)
            {
                bone = new PositionVector(new Vector3D(model.Bones[i].Position.x, model.Bones[i].Position.y, model.Bones[i].Position.z));
                bone = matrices[i] * bone;
                model.Bones[i].Position = new ModelBonePosition
                {
                    x = bone[0, 0],
                    y = bone[2, 0],
                    z = -bone[1, 0]
                };
                Quaternion quaternion = matrices[i].ToQuaterion();
                model.Bones[i].Rotation = new ModelBoneRotation
                {
                    x = (float)quaternion.X,
                    y = (float)quaternion.Z,
                    z = -(float)quaternion.Y,
                    w = (float)quaternion.W
                };
            }
        }