예제 #1
0
        public void LoadHairAsset(string path_to_apx, bool reset_params = true)
        {
            // release existing instance & asset
            if (m_hinstance)
            {
                hwi.hwInstanceRelease(m_hinstance);
                m_hinstance = hwi.HInstance.NullHandle;
            }

            if (m_hasset)
            {
                hwi.hwAssetRelease(m_hasset);
                m_hasset = hwi.HAsset.NullHandle;
            }

            // load & create instance
            m_hasset = hwi.hwAssetLoadFromFile(HairResourcesPath() + path_to_apx);
            if (m_hasset.id == hwi.HAsset.NullHandle)
            {
                return;
            }

            if (m_hasset)
            {
                m_hair_asset = path_to_apx;
                m_hinstance  = hwi.hwInstanceCreate(m_hasset);
                if (reset_params)
                {
                    hwi.hwAssetGetDefaultDescriptor(m_hasset, ref m_params);
                }
            }

            // update bone structure
            if (reset_params)
            {
                m_bones                 = null;
                m_skinning_matrices     = null;
                m_skinning_matrices_ptr = IntPtr.Zero;
            }

            // update the bones
            UpdateBones();

            // get the names for the hair textures used by this asset
            GetHairTextureNames();

            // prepare all the needed textures
            LoadHairTextures(Path.GetDirectoryName(path_to_apx));

#if UNITY_EDITOR
            RepaintWindow();
#endif
        }
예제 #2
0
        public void LoadHairAsset(string path_to_apx, bool reset_params = true)
        {
            // release existing instance & asset
            if (m_hinstance)
            {
                hwi.hwInstanceRelease(m_hinstance);
                m_hinstance = hwi.HInstance.NullHandle;
            }
            if (m_hasset)
            {
                hwi.hwAssetRelease(m_hasset);
                m_hasset = hwi.HAsset.NullHandle;
            }

            // load & create instance
            if (m_hasset = hwi.hwAssetLoadFromFile(Application.streamingAssetsPath + "/" + path_to_apx, scaleFactor * 100f))
            {
                m_hair_asset = path_to_apx;
                m_hinstance  = hwi.hwInstanceCreate(m_hasset);
                if (reset_params)
                {
                    hwi.hwAssetGetDefaultDescriptor(m_hasset, ref m_params);
                }
            }

            // update bone structure
            if (reset_params)
            {
                m_bones                 = null;
                m_skinning_matrices     = null;
                m_skinning_matrices_ptr = IntPtr.Zero;
            }
            UpdateBones();

#if UNITY_EDITOR
            Update();
            RepaintWindow();
#endif
        }