Esempio n. 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);
        }
Esempio n. 2
0
        /// <summary>
        ///     Apply a matrix only affecting the xyz values.
        /// </summary>
        /// <param name="xyz">The matrix to apply.</param>
        /// <returns>The new quad.</returns>
        public Quad ApplyTranslationMatrix(Matrix4 xyz)
        {
            Vert0 = Vert0.ApplyTranslationMatrix(xyz);
            Vert1 = Vert1.ApplyTranslationMatrix(xyz);
            Vert2 = Vert2.ApplyTranslationMatrix(xyz);
            Vert3 = Vert3.ApplyTranslationMatrix(xyz);

            return(this);
        }
Esempio n. 3
0
        /// <summary>
        ///     Rotate the texture coordinates.
        /// </summary>
        public Quad RotateTextureCoordinates(Vector3 axis, int rotations)
        {
            if (new Vector3(Vert0.N, Vert0.O, Vert0.P).Absolute().Rounded(digits: 2) != axis)
            {
                return(this);
            }

            for (var r = 0; r < rotations; r++)
            {
                Vert0 = Vert0.RotateUV();
                Vert1 = Vert1.RotateUV();
                Vert2 = Vert2.RotateUV();
                Vert3 = Vert3.RotateUV();
            }

            return(this);
        }
Esempio n. 4
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);
        }