Пример #1
0
        /// <summary>
        /// Correctly adjust the position in accordance with the fruit element's rotation and rotationOrigin  (compare ShapeTesselator.TesselateShapeElements())
        /// </summary>
        private double[] Rotate(double[] pos, ShapeElement element, double[] matrix, double[] triple)
        {
            Mat4d.Identity(matrix);
            Mat4d.Translate(matrix, matrix, (element.RotationOrigin[0]) / 16, (element.RotationOrigin[1]) / 16, (element.RotationOrigin[2]) / 16);

            if (element.RotationX != 0)
            {
                triple[0] = 1;
                triple[1] = 0;
                triple[2] = 0;
                Mat4d.Rotate(matrix, matrix, element.RotationX * GameMath.DEG2RAD, triple);
            }
            if (element.RotationY != 0)
            {
                triple[0] = 0;
                triple[1] = 1;
                triple[2] = 0;
                Mat4d.Rotate(matrix, matrix, element.RotationY * GameMath.DEG2RAD, triple);
            }
            if (element.RotationZ != 0)
            {
                triple[0] = 0;
                triple[1] = 0;
                triple[2] = 1;
                Mat4d.Rotate(matrix, matrix, element.RotationZ * GameMath.DEG2RAD, triple);
            }

            Mat4d.Translate(matrix, matrix, (element.From[0] - element.RotationOrigin[0]) / 16, (element.From[1] - element.RotationOrigin[1]) / 16, (element.From[2] - element.RotationOrigin[2]) / 16);

            return Mat4d.MulWithVec4(matrix, pos);
        }
Пример #2
0
        public void Rotate(double rad, double x, double y, double z)
        {
            triple[0] = x;
            triple[1] = y;
            triple[2] = z;

            Mat4d.Rotate(Top, Top, rad, triple);
        }