Meido.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. using System;
  2. using System.IO;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Xml.Linq;
  7. using UnityEngine;
  8. using static TBody;
  9. namespace COM3D2.MeidoPhotoStudio.Plugin
  10. {
  11. internal class Meido : ISerializable
  12. {
  13. public const int meidoDataVersion = 1000;
  14. public static readonly PoseInfo DefaultPose =
  15. new PoseInfo(Constants.PoseGroupList[0], Constants.PoseDict[Constants.PoseGroupList[0]][0]);
  16. public static readonly string defaultFaceBlendSet = "通常";
  17. public static readonly string[] faceKeys = new string[24]
  18. {
  19. "eyeclose", "eyeclose2", "eyeclose3", "eyebig", "eyeclose6", "eyeclose5", "hitomih",
  20. "hitomis", "mayuha", "mayuw", "mayuup", "mayuv", "mayuvhalf", "moutha", "mouths",
  21. "mouthc", "mouthi", "mouthup", "mouthdw", "mouthhe", "mouthuphalf", "tangout",
  22. "tangup", "tangopen"
  23. };
  24. public static readonly string[] faceToggleKeys = new string[12]
  25. {
  26. // blush, shade, nose up, tears, drool, teeth
  27. "hoho2", "shock", "nosefook", "namida", "yodare", "toothoff",
  28. // cry 1, cry 2, cry 3, blush 1, blush 2, blush 3
  29. "tear1", "tear2", "tear3", "hohos", "hoho", "hohol"
  30. };
  31. public enum Curl
  32. {
  33. front, back, shift
  34. }
  35. private bool initialized;
  36. public event EventHandler<MeidoUpdateEventArgs> UpdateMeido;
  37. public int StockNo { get; }
  38. public Maid Maid { get; private set; }
  39. public TBody Body => Maid.body0;
  40. public MeidoDragPointManager IKManager { get; private set; }
  41. public Texture2D Portrait { get; private set; }
  42. public PoseInfo CachedPose { get; private set; } = DefaultPose;
  43. public string FaceBlendSet { get; private set; } = defaultFaceBlendSet;
  44. public int Slot { get; private set; }
  45. public bool Loading { get; private set; }
  46. public string FirstName => Maid.status.firstName;
  47. public string LastName => Maid.status.lastName;
  48. public bool Busy => Maid.IsBusy && Loading;
  49. public bool CurlingFront => Maid.IsItemChange("skirt", "めくれスカート")
  50. || Maid.IsItemChange("onepiece", "めくれスカート");
  51. public bool CurlingBack => Maid.IsItemChange("skirt", "めくれスカート後ろ")
  52. || Maid.IsItemChange("onepiece", "めくれスカート後ろ");
  53. public bool PantsuShift => Maid.IsItemChange("panz", "パンツずらし")
  54. || Maid.IsItemChange("mizugi", "パンツずらし");
  55. private bool freeLook;
  56. public bool FreeLook
  57. {
  58. get => freeLook;
  59. set
  60. {
  61. if (this.freeLook == value) return;
  62. this.freeLook = value;
  63. Body.trsLookTarget = this.freeLook ? null : GameMain.Instance.MainCamera.transform;
  64. OnUpdateMeido();
  65. }
  66. }
  67. public bool Stop
  68. {
  69. get
  70. {
  71. if (!Body.isLoadedBody) return true;
  72. else return !Maid.GetAnimation().isPlaying;
  73. }
  74. set
  75. {
  76. if (!Body.isLoadedBody || value == Stop) return;
  77. else
  78. {
  79. if (value) Maid.GetAnimation().Stop();
  80. else this.SetPose(this.CachedPose.Pose);
  81. OnUpdateMeido();
  82. }
  83. }
  84. }
  85. public bool IK
  86. {
  87. get => IKManager.Active;
  88. set
  89. {
  90. if (value == IKManager.Active) return;
  91. else IKManager.Active = value;
  92. }
  93. }
  94. public bool Bone
  95. {
  96. get => IKManager.IsBone;
  97. set
  98. {
  99. if (value == Bone) return;
  100. else IKManager.IsBone = value;
  101. OnUpdateMeido();
  102. }
  103. }
  104. public float[] BlendValuesBackup { get; private set; }
  105. public float[] BlendValues { get; private set; }
  106. public Quaternion DefaultEyeRotL { get; private set; }
  107. public Quaternion DefaultEyeRotR { get; private set; }
  108. public Meido(int stockMaidIndex)
  109. {
  110. this.StockNo = stockMaidIndex;
  111. this.Maid = GameMain.Instance.CharacterMgr.GetStockMaid(stockMaidIndex);
  112. this.Portrait = Maid.GetThumIcon();
  113. IKManager = new MeidoDragPointManager(this);
  114. IKManager.SelectMaid += (s, args) => OnUpdateMeido((MeidoUpdateEventArgs)args);
  115. }
  116. public void BeginLoad()
  117. {
  118. FreeLook = false;
  119. Maid.Visible = true;
  120. Body.boHeadToCam = true;
  121. Body.boEyeToCam = true;
  122. Body.SetBoneHitHeightY(-1000f);
  123. }
  124. public void Load(int slot)
  125. {
  126. Slot = slot;
  127. Loading = true;
  128. if (!Body.isLoadedBody)
  129. {
  130. Maid.DutPropAll();
  131. Maid.AllProcPropSeqStart();
  132. }
  133. GameMain.Instance.StartCoroutine(Load());
  134. }
  135. private IEnumerator Load()
  136. {
  137. while (Maid.IsBusy) yield return null;
  138. yield return new WaitForEndOfFrame();
  139. OnBodyLoad();
  140. }
  141. public void Unload()
  142. {
  143. if (Body.isLoadedBody)
  144. {
  145. DetachAllMpnAttach();
  146. Body.jbMuneL.enabled = true;
  147. Body.jbMuneR.enabled = true;
  148. Body.quaDefEyeL = DefaultEyeRotL;
  149. Body.quaDefEyeR = DefaultEyeRotR;
  150. }
  151. Body.MuneYureL(1f);
  152. Body.MuneYureR(1f);
  153. Body.SetMaskMode(MaskMode.None);
  154. Body.SetBoneHitHeightY(0f);
  155. Maid.Visible = false;
  156. IKManager.Destroy();
  157. }
  158. public void Deactivate()
  159. {
  160. Unload();
  161. Maid.SetPos(Vector3.zero);
  162. Maid.SetRot(Vector3.zero);
  163. Maid.SetPosOffset(Vector3.zero);
  164. Body.transform.localScale = Vector3.one;
  165. Maid.ResetAll();
  166. Maid.ActiveSlotNo = -1;
  167. }
  168. public void SetPose(PoseInfo poseInfo)
  169. {
  170. CachedPose = poseInfo;
  171. SetPose(poseInfo.Pose);
  172. }
  173. public void SetPose(string pose)
  174. {
  175. if (!Body.isLoadedBody) return;
  176. if (pose.StartsWith(Constants.customPosePath))
  177. {
  178. byte[] poseBuffer = File.ReadAllBytes(pose);
  179. string hash = Path.GetFileName(pose).GetHashCode().ToString();
  180. Body.CrossFade(hash, poseBuffer, loop: true, fade: 0f);
  181. }
  182. else
  183. {
  184. string[] poseComponents = pose.Split(',');
  185. pose = poseComponents[0] + ".anm";
  186. Maid.CrossFade(pose, loop: true, val: 0f);
  187. Maid.GetAnimation().Play();
  188. if (poseComponents.Length > 1)
  189. {
  190. Maid.GetAnimation()[pose].time = float.Parse(poseComponents[1]);
  191. Maid.GetAnimation()[pose].speed = 0f;
  192. }
  193. }
  194. Maid.SetAutoTwistAll(true);
  195. SetMune();
  196. }
  197. public void CopyPose(Meido fromMeido)
  198. {
  199. byte[] poseBinary = fromMeido.SerializePose();
  200. string tag = $"copy_{fromMeido.Maid.status.guid}";
  201. Body.CrossFade(tag, poseBinary, false, true, false, 0f);
  202. Maid.SetAutoTwistAll(true);
  203. Maid.transform.rotation = fromMeido.Maid.transform.rotation;
  204. SetMune();
  205. }
  206. public void SetMune(bool drag = false)
  207. {
  208. bool momiOrPaizuri = CachedPose.Pose.Contains("_momi") || CachedPose.Pose.Contains("paizuri_");
  209. float onL = (drag || momiOrPaizuri) ? 0f : 1f;
  210. Body.MuneYureL(onL);
  211. Body.MuneYureR(onL);
  212. Body.jbMuneL.enabled = !drag;
  213. Body.jbMuneR.enabled = !drag;
  214. }
  215. public void SetHandPreset(string filename, bool right)
  216. {
  217. XDocument handDocument = XDocument.Load(filename);
  218. XElement handElement = handDocument.Element("FingerData");
  219. if (handElement.IsEmpty || handElement.Element("GameVersion").IsEmpty
  220. || handElement.Element("RightData").IsEmpty || handElement.Element("BinaryData").IsEmpty
  221. ) return;
  222. Stop = true;
  223. bool rightData = bool.Parse(handElement.Element("RightData").Value);
  224. string base64Data = handElement.Element("BinaryData").Value;
  225. byte[] handData = Convert.FromBase64String(base64Data);
  226. IKManager.DeserializeHand(handData, right, rightData != right);
  227. }
  228. public byte[] SerializePose(bool frameBinary = false)
  229. {
  230. CacheBoneDataArray cache = GetCacheBoneData();
  231. return frameBinary ? cache.GetFrameBinary(true, true) : cache.GetAnmBinary(true, true);
  232. }
  233. public void SetFaceBlendSet(string blendSet)
  234. {
  235. FaceBlendSet = blendSet;
  236. Maid.boMabataki = false;
  237. TMorph morph = Body.Face.morph;
  238. morph.EyeMabataki = 0f;
  239. morph.MulBlendValues(blendSet, 1f);
  240. morph.FixBlendValues_Face();
  241. OnUpdateMeido();
  242. }
  243. public void SetFaceBlendValue(string hash, float value)
  244. {
  245. TMorph morph = Body.Face.morph;
  246. if (hash == "nosefook")
  247. {
  248. morph.boNoseFook = value > 0f;
  249. Maid.boNoseFook = morph.boNoseFook;
  250. }
  251. else
  252. {
  253. bool gp01FBFace = morph.bodyskin.PartsVersion >= 120;
  254. float[] blendValues = hash.StartsWith("eyeclose") && !(gp01FBFace && (hash == "eyeclose3"))
  255. ? this.BlendValuesBackup
  256. : this.BlendValues;
  257. hash = Utility.GP01FbFaceHash(morph, hash);
  258. try
  259. {
  260. blendValues[(int)morph.hash[hash]] = value;
  261. }
  262. catch { }
  263. }
  264. Maid.boMabataki = false;
  265. morph.EyeMabataki = 0f;
  266. morph.FixBlendValues_Face();
  267. }
  268. public void SetMaskMode(MaskMode maskMode)
  269. {
  270. bool invisibleBody = !Body.GetMask(SlotID.body);
  271. Body.SetMaskMode(maskMode);
  272. if (invisibleBody) SetBodyMask(false);
  273. }
  274. public void SetBodyMask(bool enabled)
  275. {
  276. Hashtable table = Utility.GetFieldValue<TBody, Hashtable>(Body, "m_hFoceHide");
  277. foreach (SlotID bodySlot in MaidDressingPane.bodySlots)
  278. {
  279. table[bodySlot] = enabled;
  280. }
  281. if (Body.goSlot[19].m_strModelFileName.Contains("melala_body"))
  282. {
  283. table[SlotID.accHana] = enabled;
  284. }
  285. Body.FixMaskFlag();
  286. Body.FixVisibleFlag(false);
  287. }
  288. public void SetCurling(Curl curling, bool enabled)
  289. {
  290. string[] name = curling == Curl.shift
  291. ? new[] { "panz", "mizugi" }
  292. : new[] { "skirt", "onepiece" };
  293. if (enabled)
  294. {
  295. string action = curling == Curl.shift
  296. ? "パンツずらし" : curling == Curl.front
  297. ? "めくれスカート" : "めくれスカート後ろ";
  298. Maid.ItemChangeTemp(name[0], action);
  299. Maid.ItemChangeTemp(name[1], action);
  300. }
  301. else
  302. {
  303. Maid.ResetProp(name[0]);
  304. Maid.ResetProp(name[1]);
  305. }
  306. Maid.AllProcProp();
  307. }
  308. public void SetMpnProp(MpnAttachProp prop, bool detach)
  309. {
  310. if (detach) Maid.ResetProp(prop.Tag, false);
  311. else Maid.SetProp(prop.Tag, prop.MenuFile, 0, true);
  312. Maid.AllProcProp();
  313. }
  314. public void DetachAllMpnAttach(bool unload = false)
  315. {
  316. Maid.ResetProp(MPN.kousoku_lower, false);
  317. Maid.ResetProp(MPN.kousoku_upper, false);
  318. Maid.AllProcProp();
  319. }
  320. private CacheBoneDataArray GetCacheBoneData()
  321. {
  322. CacheBoneDataArray cache = this.Maid.gameObject.GetComponent<CacheBoneDataArray>();
  323. if (cache == null)
  324. {
  325. cache = this.Maid.gameObject.AddComponent<CacheBoneDataArray>();
  326. cache.CreateCache(this.Maid.body0.GetBone("Bip01"));
  327. }
  328. return cache;
  329. }
  330. private void OnBodyLoad()
  331. {
  332. if (!initialized)
  333. {
  334. TMorph faceMorph = Body.Face.morph;
  335. BlendValuesBackup = Utility.GetFieldValue<TMorph, float[]>(faceMorph, "BlendValuesBackup");
  336. BlendValues = Utility.GetFieldValue<TMorph, float[]>(faceMorph, "BlendValues");
  337. DefaultEyeRotL = Body.quaDefEyeL;
  338. DefaultEyeRotR = Body.quaDefEyeR;
  339. initialized = true;
  340. }
  341. IKManager.Initialize();
  342. IK = true;
  343. Stop = false;
  344. Bone = false;
  345. Loading = false;
  346. }
  347. public void OnUpdateMeido(MeidoUpdateEventArgs args = null)
  348. {
  349. this.UpdateMeido?.Invoke(this, args ?? MeidoUpdateEventArgs.Empty);
  350. }
  351. public void Serialize(BinaryWriter binaryWriter)
  352. {
  353. using (MemoryStream memoryStream = new MemoryStream())
  354. using (BinaryWriter tempWriter = new BinaryWriter(memoryStream))
  355. {
  356. // transform
  357. tempWriter.WriteVector3(Maid.transform.position);
  358. tempWriter.WriteQuaternion(Maid.transform.rotation);
  359. tempWriter.WriteVector3(Maid.transform.localScale);
  360. // pose
  361. byte[] poseBuffer = SerializePose(true);
  362. tempWriter.Write(poseBuffer.Length);
  363. tempWriter.Write(poseBuffer);
  364. CachedPose.Serialize(tempWriter);
  365. // eye direction
  366. tempWriter.WriteQuaternion(Body.quaDefEyeL * Quaternion.Inverse(DefaultEyeRotL));
  367. tempWriter.WriteQuaternion(Body.quaDefEyeR * Quaternion.Inverse(DefaultEyeRotR));
  368. // free look
  369. tempWriter.Write(FreeLook);
  370. if (FreeLook)
  371. {
  372. tempWriter.WriteVector3(Body.offsetLookTarget);
  373. tempWriter.WriteVector3(Utility.GetFieldValue<TBody, Vector3>(Body, "HeadEulerAngle"));
  374. }
  375. // face
  376. SerializeFace(tempWriter);
  377. // body visible
  378. tempWriter.Write(Body.GetMask(SlotID.body));
  379. // clothing
  380. foreach (SlotID clothingSlot in MaidDressingPane.clothingSlots)
  381. {
  382. bool value = true;
  383. if (clothingSlot == SlotID.wear)
  384. {
  385. if (MaidDressingPane.wearSlots.Any(slot => Body.GetSlotLoaded(slot)))
  386. {
  387. value = MaidDressingPane.wearSlots.Any(slot => Body.GetMask(slot));
  388. }
  389. }
  390. else if (clothingSlot == SlotID.megane)
  391. {
  392. SlotID[] slots = new[] { SlotID.megane, SlotID.accHead };
  393. if (slots.Any(slot => Body.GetSlotLoaded(slot)))
  394. {
  395. value = slots.Any(slot => Body.GetMask(slot));
  396. }
  397. }
  398. else if (Body.GetSlotLoaded(clothingSlot))
  399. {
  400. value = Body.GetMask(clothingSlot);
  401. }
  402. tempWriter.Write(value);
  403. }
  404. // zurashi and mekure
  405. tempWriter.Write(CurlingFront);
  406. tempWriter.Write(CurlingBack);
  407. tempWriter.Write(PantsuShift);
  408. bool hasKousokuUpper = Body.GetSlotLoaded(SlotID.kousoku_upper);
  409. tempWriter.Write(hasKousokuUpper);
  410. if (hasKousokuUpper) tempWriter.Write(Maid.GetProp(MPN.kousoku_upper).strTempFileName);
  411. bool hasKousokuLower = Body.GetSlotLoaded(SlotID.kousoku_lower);
  412. tempWriter.Write(hasKousokuLower);
  413. if (hasKousokuLower) tempWriter.Write(Maid.GetProp(MPN.kousoku_lower).strTempFileName);
  414. binaryWriter.Write(memoryStream.Length);
  415. binaryWriter.Write(memoryStream.ToArray());
  416. }
  417. }
  418. private void SerializeFace(BinaryWriter binaryWriter)
  419. {
  420. binaryWriter.Write("MPS_FACE");
  421. TMorph morph = Maid.body0.Face.morph;
  422. bool gp01FBFace = morph.bodyskin.PartsVersion >= 120;
  423. foreach (string hash in faceKeys)
  424. {
  425. float[] blendValues = hash.StartsWith("eyeclose") && !(gp01FBFace && (hash == "eyeclose3"))
  426. ? this.BlendValuesBackup
  427. : this.BlendValues;
  428. string faceKey = Utility.GP01FbFaceHash(morph, hash);
  429. try
  430. {
  431. float value = blendValues[(int)morph.hash[faceKey]];
  432. binaryWriter.Write(hash);
  433. binaryWriter.Write(value);
  434. }
  435. catch { }
  436. }
  437. foreach (string hash in faceToggleKeys)
  438. {
  439. bool value = this.BlendValues[(int)morph.hash[hash]] > 0f;
  440. if (hash == "nosefook") value = morph.boNoseFook;
  441. binaryWriter.Write(hash);
  442. binaryWriter.Write(value);
  443. }
  444. binaryWriter.Write("END_FACE");
  445. }
  446. public void Deserialize(BinaryReader binaryReader) => Deserialize(binaryReader, meidoDataVersion, false);
  447. public void Deserialize(BinaryReader binaryReader, int dataVersion, bool mmScene)
  448. {
  449. Maid.GetAnimation().Stop();
  450. DetachAllMpnAttach();
  451. binaryReader.ReadInt64(); // meido buffer length
  452. // transform
  453. Maid.transform.position = binaryReader.ReadVector3();
  454. Maid.transform.rotation = binaryReader.ReadQuaternion();
  455. Maid.transform.localScale = binaryReader.ReadVector3();
  456. // pose
  457. if (mmScene) IKManager.Deserialize(binaryReader);
  458. else
  459. {
  460. int poseBufferLength = binaryReader.ReadInt32();
  461. byte[] poseBuffer = binaryReader.ReadBytes(poseBufferLength);
  462. GetCacheBoneData().SetFrameBinary(poseBuffer);
  463. }
  464. Body.MuneYureL(0f);
  465. Body.MuneYureR(0f);
  466. Body.jbMuneL.enabled = false;
  467. Body.jbMuneR.enabled = false;
  468. CachedPose = PoseInfo.Deserialize(binaryReader);
  469. // eye direction
  470. Body.quaDefEyeL = binaryReader.ReadQuaternion() * DefaultEyeRotL;
  471. Body.quaDefEyeR = binaryReader.ReadQuaternion() * DefaultEyeRotR;
  472. // free look
  473. FreeLook = binaryReader.ReadBoolean();
  474. if (FreeLook)
  475. {
  476. Body.offsetLookTarget = binaryReader.ReadVector3();
  477. Utility.SetFieldValue<TBody, Vector3>(Body, "HeadEulerAngleG", Vector3.zero);
  478. Utility.SetFieldValue<TBody, Vector3>(Body, "HeadEulerAngle", binaryReader.ReadVector3());
  479. }
  480. // face
  481. DeserializeFace(binaryReader);
  482. // body visible
  483. SetBodyMask(binaryReader.ReadBoolean());
  484. // clothing
  485. foreach (SlotID clothingSlot in MaidDressingPane.clothingSlots)
  486. {
  487. bool value = binaryReader.ReadBoolean();
  488. if (clothingSlot == SlotID.wear)
  489. {
  490. Body.SetMask(SlotID.wear, value);
  491. Body.SetMask(SlotID.mizugi, value);
  492. Body.SetMask(SlotID.onepiece, value);
  493. }
  494. else if (clothingSlot == SlotID.megane)
  495. {
  496. Body.SetMask(SlotID.megane, value);
  497. Body.SetMask(SlotID.accHead, value);
  498. }
  499. else if (Body.GetSlotLoaded(clothingSlot))
  500. {
  501. Body.SetMask(clothingSlot, value);
  502. }
  503. }
  504. // zurashi and mekure
  505. bool curlingFront = binaryReader.ReadBoolean();
  506. bool curlingBack = binaryReader.ReadBoolean();
  507. if (CurlingFront != curlingFront) SetCurling(Curl.front, curlingFront);
  508. if (CurlingBack != curlingBack) SetCurling(Curl.back, curlingBack);
  509. SetCurling(Curl.shift, binaryReader.ReadBoolean());
  510. bool hasKousokuUpper = binaryReader.ReadBoolean();
  511. if (hasKousokuUpper)
  512. {
  513. try
  514. {
  515. SetMpnProp(new MpnAttachProp(MPN.kousoku_upper, binaryReader.ReadString()), false);
  516. }
  517. catch { }
  518. }
  519. bool hasKousokuLower = binaryReader.ReadBoolean();
  520. if (hasKousokuLower)
  521. {
  522. try
  523. {
  524. SetMpnProp(new MpnAttachProp(MPN.kousoku_lower, binaryReader.ReadString()), false);
  525. }
  526. catch { }
  527. }
  528. // OnUpdateMeido();
  529. }
  530. private void DeserializeFace(BinaryReader binaryReader)
  531. {
  532. binaryReader.ReadString(); // read face header
  533. TMorph morph = Maid.body0.Face.morph;
  534. bool gp01FBFace = morph.bodyskin.PartsVersion >= 120;
  535. HashSet<string> faceKeys = new HashSet<string>(Meido.faceKeys);
  536. string header;
  537. while ((header = binaryReader.ReadString()) != "END_FACE")
  538. {
  539. if (faceKeys.Contains(header))
  540. {
  541. float[] blendValues = header.StartsWith("eyeclose") && !(gp01FBFace && (header == "eyeclose3"))
  542. ? this.BlendValuesBackup
  543. : this.BlendValues;
  544. string hash = Utility.GP01FbFaceHash(morph, header);
  545. try
  546. {
  547. float value = binaryReader.ReadSingle();
  548. blendValues[(int)morph.hash[hash]] = value;
  549. }
  550. catch { }
  551. }
  552. else
  553. {
  554. bool value = binaryReader.ReadBoolean();
  555. if (header == "nosefook") this.Maid.boNoseFook = value;
  556. else this.BlendValues[(int)morph.hash[header]] = value ? 1f : 0f;
  557. }
  558. }
  559. Maid.boMabataki = false;
  560. morph.EyeMabataki = 0f;
  561. morph.FixBlendValues_Face();
  562. }
  563. }
  564. public struct PoseInfo
  565. {
  566. public string PoseGroup { get; }
  567. public string Pose { get; }
  568. public bool CustomPose { get; }
  569. public PoseInfo(string poseGroup, string pose, bool customPose = false)
  570. {
  571. this.PoseGroup = poseGroup;
  572. this.Pose = pose;
  573. this.CustomPose = customPose;
  574. }
  575. public void Serialize(BinaryWriter binaryWriter)
  576. {
  577. binaryWriter.Write(PoseGroup);
  578. binaryWriter.Write(Pose);
  579. binaryWriter.Write(CustomPose);
  580. }
  581. public static PoseInfo Deserialize(BinaryReader binaryReader)
  582. {
  583. return new PoseInfo
  584. (
  585. binaryReader.ReadString(),
  586. binaryReader.ReadString(),
  587. binaryReader.ReadBoolean()
  588. );
  589. }
  590. }
  591. }