public void Link(apBone parentBone, apMeshGroup meshGroup, apPortrait portrait) { _parentBone = parentBone; if (_effectorBoneID < 0) { _effectorBone = null; } else { _effectorBone = meshGroup.GetBone(_effectorBoneID); if (_effectorBone == null) { _effectorBoneID = -1; } } //추가 : Control Param으로 Weight를 제어할 수 있다. if (_isWeightByControlParam) { _weightControlParam = null; if (_weightControlParamID >= 0) { _weightControlParam = portrait.GetControlParam(_weightControlParamID); } if (_weightControlParam == null) { _weightControlParamID = -1; } } else { _weightControlParam = null; } #region [미사용 코드 : Bone Chain으로 대체한다] //if(_startBoneID < 0) //{ // _startBone = null; //} //else //{ // _startBone = meshGroup.GetBone(_startBoneID); // if(_startBone == null) // { // _startBoneID = -1; // } //} //if(_subChainedBones == null) //{ // _subChainedBones = new List<SubChainedBone>(); //} //if(_effectorBone == null) //{ // _subChainedBones.Clear(); //} ////Child > Parent 순으로 순회한다. //apBone curChildBone = _parentBone;//<<현재 본이 가장 Child //for (int i = 0; i < _subChainedBones.Count; i++) //{ // _subChainedBones[i]._subBone = meshGroup.GetBone(_subChainedBones[i]._subBoneID); // _subChainedBones[i]._childBone = curChildBone; // if(i - 1 >= 0) // { // _subChainedBones[i]._childChainedBone = _subChainedBones[i - 1]; // } // else // { // _subChainedBones[i]._childChainedBone = null; // } // if(i + 1 < _subChainedBones.Count) // { // _subChainedBones[i]._parentChainedBone = _subChainedBones[i + 1]; // } // else // { // _subChainedBones[i]._parentChainedBone = null; // } // curChildBone = _subChainedBones[i]._subBone; //} #endregion //_childChainBone }
/// <summary> /// Link를 해준다. 소속되는 MeshGroup은 물론이고, ParentBone도 링크해준다. /// ParentBone이 있다면 해당 Bone의 Child 리스트에 이 Bone을 체크 후 추가한다. /// (Link는 Child -> Parent 로 참조를 한다. Add와 반대) /// </summary> /// <param name="meshGroup"></param> /// <param name="parentBone"></param> public void Link(apMeshGroup meshGroup, apBone parentBone) { _meshGroup = meshGroup; _parentBone = parentBone; if (_childBones == null) { _childBones = new List <apBone>(); } //일단 ID가 있는 Bone들은 meshGroup으로부터 값을 받아서 연결을 해준다. if (_IKTargetBoneID >= 0) { _IKTargetBone = _meshGroup.GetBone(_IKTargetBoneID); if (_IKTargetBone == null) { _IKTargetBoneID = -1; } } if (_IKNextChainedBoneID >= 0) { _IKNextChainedBone = _meshGroup.GetBone(_IKNextChainedBoneID); if (_IKNextChainedBone == null) { _IKNextChainedBoneID = -1; } } if (_IKHeaderBoneID >= 0) { _IKHeaderBone = _meshGroup.GetBone(_IKHeaderBoneID); if (_IKHeaderBone == null) { _IKHeaderBoneID = -1; } } if (_parentBone != null) { //호출 순서가 잘못되어서 parent의 List가 초기화가 안된 경우가 있다. if (_parentBone._childBones == null) { _parentBone._childBones = new List <apBone>(); } if (!_parentBone._childBones.Contains(this)) { _parentBone._childBones.Add(this); } if (!_parentBone._childBoneIDs.Contains(_uniqueID)) { _parentBone._childBoneIDs.Add(_uniqueID); } _parentBoneID = _parentBone._uniqueID; } else { _parentBone = null; _parentBoneID = -1; } if (_rigTestMatrix == null) { _rigTestMatrix = new apMatrix(); } _isRigTestPosing = false; if (_localMatrix == null) { _localMatrix = new apMatrix(); } if (_worldMatrix == null) { _worldMatrix = new apMatrix(); } if (_worldMatrix_NonModified == null) { _worldMatrix_NonModified = new apMatrix(); } //if(_invWorldMatrix == null) //{ // _invWorldMatrix = new apMatrix(); //} //if(_invWorldMatrix_NonModified == null) //{ // _invWorldMatrix_NonModified = new apMatrix(); //} //Default Angle이 제대로 적용되지 않는 경우가 있다. //Default는 -180 ~ 180 안에 들어간다 }