Beispiel #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);
        }
Beispiel #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;
        }
		/// <summary>
		/// Gets the import settings for the current settings.
		/// </summary>
		/// <returns>The import settings.</returns>
		public static HairImportSettings GetImportSettings()
		{
			HairImportSettings importSettings = new HairImportSettings ();
			importSettings.scale = new TressFXLib.Numerics.Vector3(importScale.x, importScale.y, importScale.z);
			return importSettings;
		}