MCPcopy Create free account
hub / github.com/MergHQ/CRYENGINE / GetBoneLocal

Method GetBoneLocal

Code/CryEngine/CryEntitySystem/ScriptBind_Entity.cpp:791–822  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

789}
790
791int 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

Callers

nothing calls this directly

Calls 10

GetISkeletonPoseMethod · 0.80
normalizedMethod · 0.80
GetParamsMethod · 0.45
EndFunctionMethod · 0.45
GetCharacterMethod · 0.45
GetJointIDByNameMethod · 0.45
LogMethod · 0.45
GetTransposedMethod · 0.45
GetTranslationMethod · 0.45
GetColumnMethod · 0.45

Tested by

no test coverage detected