| 789 | } |
| 790 | |
| 791 | int CScriptBind_Entity::GetBoneLocal(IFunctionHandler* pH, const char* boneName, Vec3 trgDir) |
| 792 | { |
| 793 | GET_ENTITY; |
| 794 | |
| 795 | const char* sBoneName; |
| 796 | if (!pH->GetParams(sBoneName)) |
| 797 | return pH->EndFunction(); |
| 798 | |
| 799 | ICharacterInstance* pCharacter = pEntity->GetCharacter(0); |
| 800 | if (!pCharacter) |
| 801 | return pH->EndFunction(); |
| 802 | |
| 803 | int16 pBone_id = pCharacter->GetIDefaultSkeleton().GetJointIDByName(sBoneName); |
| 804 | if (pBone_id == -1) |
| 805 | { |
| 806 | gEnv->pLog->Log("ERROR: CScriptObjectWeapon::GetBoneLocal: Bone not found: %s", sBoneName); |
| 807 | return pH->EndFunction(); |
| 808 | } |
| 809 | Matrix33 trgMat(Matrix33::CreateRotationVDir(trgDir)); |
| 810 | // Matrix33 boneMat(pEntity->GetSlotWorldTM(0)*pCharacter->GetISkeleton()->GetAbsJMatrixByID(pBone_id)); |
| 811 | Matrix33 boneMat(pEntity->GetSlotWorldTM(0) * Matrix34(pCharacter->GetISkeletonPose()->GetAbsJointByID(pBone_id))); |
| 812 | Matrix33 localMat(boneMat.GetTransposed() * trgMat); |
| 813 | |
| 814 | Matrix33 m = boneMat * localMat; |
| 815 | |
| 816 | // Vec3 p((pEntity->GetSlotWorldTM(0)*pCharacter->GetISkeleton()->GetAbsJMatrixByID(pBone_id)).GetTranslation()); |
| 817 | Vec3 p((pEntity->GetSlotWorldTM(0) * Matrix34(pCharacter->GetISkeletonPose()->GetAbsJointByID(pBone_id))).GetTranslation()); |
| 818 | |
| 819 | //gEnv->pRenderer->GetIRenderAuxGeom()->DrawLine(p, ColorB(255, 255, 0, 255), p-(m.GetColumn(1)*100), ColorB(128, 0, 255, 255)); |
| 820 | //return pH->EndFunction(Ang3::GetAnglesXYZ(Quat(localMat))); |
| 821 | return pH->EndFunction(localMat.GetColumn(1).normalized()); |
| 822 | } |
| 823 | |
| 824 | ////////////////////////////////////////////////////////////////////////// |
| 825 |
nothing calls this directly
no test coverage detected