Exemple #1
0
        /// <summary>
        ///     Apply a matrix to this quad.
        /// </summary>
        /// <param name="xyz">The matrix to apply to the position.</param>
        /// <param name="nop">The matrix to apply to the normals.</param>
        /// <returns>The quad with the matrices applied.</returns>
        public Quad ApplyMatrix(Matrix4 xyz, Matrix4 nop)
        {
            Vert0 = Vert0.ApplyMatrix(xyz, nop);
            Vert1 = Vert1.ApplyMatrix(xyz, nop);
            Vert2 = Vert2.ApplyMatrix(xyz, nop);
            Vert3 = Vert3.ApplyMatrix(xyz, nop);

            return(this);
        }
Exemple #2
0
        /// <summary>
        ///     Apply a rotation matrix to this quad.
        /// </summary>
        public Quad ApplyRotationMatrixY(Matrix4 xyz, Matrix4 nop, int rotations)
        {
            // Rotate positions and normals.
            Vert0 = Vert0.ApplyMatrix(xyz, nop);
            Vert1 = Vert1.ApplyMatrix(xyz, nop);
            Vert2 = Vert2.ApplyMatrix(xyz, nop);
            Vert3 = Vert3.ApplyMatrix(xyz, nop);

            // Rotate UVs for top and bottom sides.
            if (new Vector3(Vert0.N, Vert0.O, Vert0.P).Absolute().Rounded(digits: 2) == Vector3.UnitY)
            {
                for (var r = 0; r < rotations; r++)
                {
                    Vert0 = Vert0.RotateUV();
                    Vert1 = Vert1.RotateUV();
                    Vert2 = Vert2.RotateUV();
                    Vert3 = Vert3.RotateUV();
                }
            }

            return(this);
        }