Exemplo n.º 1
0
        /// <summary>
        /// Loads / imports hair from the given file with given format.
        /// </summary>
        /// <param name="format"></param>
        /// <param name="path"></param>
        public static Hair Import(HairFormat format, string path, HairImportSettings importSettings = null)
        {
            if (importSettings == null)
            {
                importSettings = HairImportSettings.standard;
            }

            // Get hair format impl
            IHairFormat formatImpl = format.GetFormatImplementation();

            // Create new hair object
            Hair hair = new Hair();

            // Open the binary reader
            BinaryReader reader = new BinaryReader(File.Open(path, FileMode.Open));

            // Import the hair data
            HairMesh[] hairMeshes = null;
            try
            {
                hairMeshes = formatImpl.Import(reader, path, hair, importSettings);
            }
            finally
            {
                reader.Close();
            }
            reader.Close();

            // Validity check
            if (hairMeshes.Length > 4)
            {
                throw new IndexOutOfRangeException("TressFX only supports up to 4 hair meshes, the file you tried to import had " + hairMeshes.Length);
            }

            // Set all meshes
            for (int i = 0; i < hairMeshes.Length; i++)
            {
                hair.SetHairMesh(i, hairMeshes[i]);
            }

            hair.CreateBoundingSphere();

            // We're done :>
            return(hair);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Loads / imports hair from the given file with given format.
        /// </summary>
        /// <param name="format"></param>
        /// <param name="path"></param>
        public static Hair Import(HairFormat format, string path, HairImportSettings importSettings = null)
        {
            if (importSettings == null)
                importSettings = HairImportSettings.standard;

            // Get hair format impl
            IHairFormat formatImpl = format.GetFormatImplementation();

            // Create new hair object
            Hair hair = new Hair();

            // Open the binary reader
            BinaryReader reader = new BinaryReader(File.Open(path, FileMode.Open));

            // Import the hair data
            HairMesh[] hairMeshes = null;
            try
            {
                hairMeshes = formatImpl.Import(reader, path, hair, importSettings);
            }
            finally
            {
                reader.Close();
            }
            reader.Close();

            // Validity check
            if (hairMeshes.Length > 4)
                throw new IndexOutOfRangeException("TressFX only supports up to 4 hair meshes, the file you tried to import had " + hairMeshes.Length);

            // Set all meshes
            for (int i = 0; i < hairMeshes.Length; i++)
                hair.SetHairMesh(i, hairMeshes[i]);

            // We're done :>
            return hair;
        }
Exemplo n.º 3
0
 /// <summary>
 /// Exports this hair to the given file format output.
 /// </summary>
 public void Export(HairFormat format, string path)
 {
     IHairFormat formatImpl = format.GetFormatImplementation();
     this.Export(formatImpl, path);
 }
Exemplo n.º 4
0
        /// <summary>
        /// Exports this hair to the given file format output.
        /// </summary>
        public void Export(HairFormat format, string path)
        {
            IHairFormat formatImpl = format.GetFormatImplementation();

            this.Export(formatImpl, path);
        }