public PmdIK(PMD_IK pPMDIKData, PmdBone[] i_ref_bone_array) { // IKターゲットボーン this.m_pTargetBone = i_ref_bone_array[pPMDIKData.nTargetNo]; // IK先端ボーン this.m_pEffBone = i_ref_bone_array[pPMDIKData.nEffNo]; this.m_unCount = pPMDIKData.unCount; this.m_fFact = pPMDIKData.fFact * Math.PI; this.m_nSortVal = pPMDIKData.punLinkNo[0]; // IKリンク配列の作成 int number_of_ik_link = pPMDIKData.cbNumLink; this.m_ppBoneList = new PmdBone[number_of_ik_link];//参照 for (int i = 0; i < number_of_ik_link; i++) { this.m_ppBoneList[i] = i_ref_bone_array[pPMDIKData.punLinkNo[i]]; // ボーン番号は降順で格納されている if (this.m_ppBoneList[i].getName().Equals("左ひざ") || this.m_ppBoneList[i].getName().Equals("右ひざ")) { this.m_ppBoneList[i].setIKLimitAngle(true); } } }
public PmdBone(PMD_Bone pPMDBoneData, PmdBone[] pBoneArray) { // ボーン名のコピー this._name = pPMDBoneData.szName; // 位置のコピー this._pmd_bone_position.setValue(pPMDBoneData.vec3Position); // 親ボーンの設定 if (pPMDBoneData.nParentNo != -1) { this._parent_bone = pBoneArray[pPMDBoneData.nParentNo]; m_vec3Offset.Vector3Sub(this._pmd_bone_position, this._parent_bone._pmd_bone_position); } else { // 親なし this._parent_bone = null; this.m_vec3Offset.setValue(this._pmd_bone_position); } // 子ボーンの設定 if (pPMDBoneData.nChildNo != -1) { this.m_pChildBone = pBoneArray[pPMDBoneData.nChildNo]; } this.m_matInvTransform.MatrixIdentity(); this.m_matInvTransform.m[3, 0] = -this._pmd_bone_position.x; this.m_matInvTransform.m[3, 1] = -this._pmd_bone_position.y; this.m_matInvTransform.m[3, 2] = -this._pmd_bone_position.z; this.m_bIKLimitAngle = false; // 各変数の初期値を設定 reset(); }