FinalData.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. // Magica Cloth.
  2. // Copyright (c) MagicaSoft, 2020-2022.
  3. // https://magicasoft.jp
  4. using System.Collections.Generic;
  5. using UnityEngine;
  6. namespace MagicaReductionMesh
  7. {
  8. /// <summary>
  9. /// 最終メッシュデータ
  10. /// ※シリアライズ設定していますが基本的には使い捨てを想定して作成されています
  11. /// </summary>
  12. [System.Serializable]
  13. public class FinalData
  14. {
  15. //=========================================================================================
  16. // マージメッシュ情報
  17. public List<Vector3> vertices = new List<Vector3>();
  18. public List<Vector3> normals = new List<Vector3>();
  19. public List<Vector4> tangents = new List<Vector4>();
  20. public List<Vector2> uvs = new List<Vector2>();
  21. public List<BoneWeight> boneWeights = new List<BoneWeight>();
  22. public List<Matrix4x4> bindPoses = new List<Matrix4x4>();
  23. public List<Transform> bones = new List<Transform>();
  24. public List<int> lines = new List<int>();
  25. public List<int> triangles = new List<int>();
  26. public List<int> tetras = new List<int>();
  27. public List<float> tetraSizes = new List<float>();
  28. /// <summary>
  29. /// マージ頂点ごとのバインドポーズ
  30. /// </summary>
  31. public List<Matrix4x4> vertexBindPoses = new List<Matrix4x4>();
  32. /// <summary>
  33. /// マージ頂点が影響を与える子メッシュ頂点リスト
  34. /// データはuintでパッキングされ、上位16bitが[子メッシュインデックス]、下位16bitが[子頂点インデックス]
  35. /// </summary>
  36. [System.Serializable]
  37. public class MeshIndexData
  38. {
  39. public List<uint> meshIndexPackList = new List<uint>();
  40. }
  41. public List<MeshIndexData> vertexToMeshIndexList = new List<MeshIndexData>();
  42. /// <summary>
  43. /// マージ頂点が所属するトライアングル情報リスト
  44. /// </summary>
  45. public List<int> vertexToTriangleCountList = new List<int>(); // 所属トライアングルの数
  46. public List<int> vertexToTriangleStartList = new List<int>(); // vertexToTriangleIndexListの開始位置
  47. public List<int> vertexToTriangleIndexList = new List<int>(); // 所属トライアングルインデックスリスト(これは頂点数とは一致しない)
  48. //=========================================================================================
  49. /// <summary>
  50. /// 子メッシュ情報
  51. /// </summary>
  52. [System.Serializable]
  53. public class MeshInfo
  54. {
  55. public int meshIndex;
  56. public Mesh mesh;
  57. public List<Vector3> vertices = new List<Vector3>();
  58. public List<Vector3> normals = new List<Vector3>();
  59. public List<Vector4> tangents = new List<Vector4>();
  60. public List<BoneWeight> boneWeights = new List<BoneWeight>();
  61. /// <summary>
  62. /// 元々属していた親マージ頂点インデックス
  63. /// </summary>
  64. public List<int> parents = new List<int>();
  65. /// <summary>
  66. /// 頂点数
  67. /// </summary>
  68. public int VertexCount
  69. {
  70. get
  71. {
  72. return vertices.Count;
  73. }
  74. }
  75. }
  76. public List<MeshInfo> meshList = new List<MeshInfo>();
  77. //=========================================================================================
  78. /// <summary>
  79. /// データが有効か判定する
  80. /// </summary>
  81. public bool IsValid
  82. {
  83. get
  84. {
  85. return vertices.Count > 0;
  86. }
  87. }
  88. /// <summary>
  89. /// 頂点数
  90. /// </summary>
  91. public int VertexCount
  92. {
  93. get
  94. {
  95. return vertices.Count;
  96. }
  97. }
  98. /// <summary>
  99. /// ライン数
  100. /// </summary>
  101. public int LineCount
  102. {
  103. get
  104. {
  105. return lines.Count / 2;
  106. }
  107. }
  108. /// <summary>
  109. /// トライアングル数
  110. /// </summary>
  111. public int TriangleCount
  112. {
  113. get
  114. {
  115. return triangles.Count / 3;
  116. }
  117. }
  118. /// <summary>
  119. /// テトラ数
  120. /// </summary>
  121. public int TetraCount
  122. {
  123. get
  124. {
  125. return tetras.Count / 4;
  126. }
  127. }
  128. /// <summary>
  129. /// ボーン数
  130. /// </summary>
  131. public int BoneCount
  132. {
  133. get
  134. {
  135. return bones.Count;
  136. }
  137. }
  138. /// <summary>
  139. /// スキンメッシュかどうか
  140. /// </summary>
  141. public bool IsSkinning
  142. {
  143. get
  144. {
  145. //return bones.Count > 1;
  146. return true; // 基本的にすべてスキニング
  147. }
  148. }
  149. /// <summary>
  150. /// 子メッシュ数
  151. /// </summary>
  152. public int MeshCount
  153. {
  154. get
  155. {
  156. return meshList.Count;
  157. }
  158. }
  159. }
  160. }