public void AddModMeshSet(apOptModifiedMeshSet modMeshSet) { if (_requestType == REQUEST_TYPE.VertLocal) { _modWeightPairs.Add(new ModWeightPair(modMeshSet.SubModMesh_Vertex)); _nModWeightPairs = _modWeightPairs.Count; } else if (_requestType == REQUEST_TYPE.Rigging) { apOptModifiedMesh_VertexRig modMesh_Rigging = modMeshSet.SubModMesh_Rigging; if (_rigBoneWeightTables != null) { //?? //Rigging은 Static 타입이어서 ModMesh가 하나만 생성된다. Debug.LogError("Overwritten Mod Mesh To Rigging"); return; } //_totalRiggingWeight = 0.0f; _rigBoneWeightTables = new VertRigWeightTable[modMesh_Rigging._vertRigs.Length]; for (int i = 0; i < modMesh_Rigging._vertRigs.Length; i++) { _rigBoneWeightTables[i] = new VertRigWeightTable(i, modMeshSet, modMesh_Rigging); } } }
// Link //--------------------------------------------------------------------------------- public void Link(apPortrait portrait) { _portrait = portrait; if (IsVertex) { apOptModifiedMesh_Vertex sub_Vertex = SubModMesh_Vertex; if (sub_Vertex != null) { sub_Vertex.Link(this); } } if (IsTransform) { apOptModifiedMesh_Transform sub_Transform = SubModMesh_Transform; if (sub_Transform != null) { sub_Transform.Link(this); } } if (IsRigging) { apOptModifiedMesh_VertexRig sub_Rigging = SubModMesh_Rigging; if (sub_Rigging != null) { sub_Rigging.Link(portrait, this); } } if (IsPhysics) { apOptModifiedMesh_Physics sub_Physics = SubModMesh_Physics; if (sub_Physics != null) { sub_Physics.Link(portrait, this); } } if (IsColor) { apOptModifiedMesh_Color sub_Color = SubModMesh_Color; if (sub_Color != null) { sub_Color.Link(this); } } if (IsExtra) { apOptModifiedMesh_Extra sub_Extra = SubModMesh_Extra; if (sub_Extra != null) { sub_Extra.Link(portrait, this); } } }
public void Bake_VertexRigs(List <apModifiedVertexRig> modVertRigs) { _dataType |= DATA_TYPE.Rigging; _subModMesh_Rigging = new apOptModifiedMesh_VertexRig[1]; _subModMesh_Rigging[0] = new apOptModifiedMesh_VertexRig(); apOptModifiedMesh_VertexRig subMod_Riggingm = _subModMesh_Rigging[0]; subMod_Riggingm.Bake(modVertRigs); }
//추가 : ModMeshSet으로 RigWeightTable을 만드는 기능도 추가 public VertRigWeightTable(int vertIndex, apOptModifiedMeshSet modMeshSet, apOptModifiedMesh_VertexRig modMeshSet_Rigging) { apOptModifiedMesh_VertexRig.VertexRig.WeightPair[] weightPairs = modMeshSet_Rigging._vertRigs[vertIndex]._weightPairs; _rigTable = new RigBoneWeightPair[weightPairs.Length]; //float totalWeight = 0.0f; _totalRiggingWeight = 0.0f; for (int i = 0; i < weightPairs.Length; i++) { _rigTable[i] = new RigBoneWeightPair(modMeshSet._targetTransform, weightPairs[i]._bone, weightPairs[i]._weight); _totalRiggingWeight += weightPairs[i]._weight; } //Debug.Log("VertRigWeightTable : " + totalWeight); //RiggingMatrix를 위해서는 무조건 Normalize를 해야한다. //주의 : _totalRiggingWeight이 값은 1이 아닌 원래의 Weight 합을 유지해야한다. 보간시 필요 if (_totalRiggingWeight > 0.0f) { for (int i = 0; i < _rigTable.Length; i++) { _rigTable[i]._weight /= _totalRiggingWeight; } } _nRigTable = _rigTable.Length; }