Sources/CryGame C++/Solution1/CryGame/ScriptObjectWeaponClass.cpp
//////////////////////////////////////////////////////////////////////
/*! Obtains the position of a bone in the weapon object while taking into account
that weapons are rendered with a different FOV
@param sBoneName Name of the bone
*/
Obtains the position of a bone in the weapon object while taking into account
that weapons are rendered with a different FOV
Obtains the position of a bone in the weapon object while taking into account that weapons are rendered with a different FOV
int CScriptObjectWeaponClass::GetBonePos(IFunctionHandler *pH)
{
	CHECK_PARAMETERS(1);
	const char * sBoneName = "wt";
	pH->GetParam(1,sBoneName);
	ICryCharInstance * cmodel = m_pWeaponClass->GetCharacter();    
	if (!cmodel) 
		return pH->EndFunctionNull();
	ICryBone * pBone = cmodel->GetBoneByName(sBoneName);
	if(!pBone)
	{
		return pH->EndFunctionNull();
	}
	Vec3d vBonePos = pBone->GetBonePosition();
	Vec3d angles = m_pWeaponClass->GetAngles();
	Matrix44 m=Matrix34::CreateRotationXYZ( Deg2Rad(angles), m_pWeaponClass->GetPos() );	
	m	=	GetTransposed44(m); 
	Vec3 vec = m.TransformPointOLD(vBonePos);
	m_pMemberBonePos->BeginSetGetChain();
	m_pMemberBonePos->SetValueChain("x",vec.x);
	m_pMemberBonePos->SetValueChain("y",vec.y);
	m_pMemberBonePos->SetValueChain("z",vec.z);
	m_pMemberBonePos->EndSetGetChain();
	return pH->EndFunction(m_pMemberBonePos);
}
int CScriptObjectWeaponClass :: GetBonePos ( IFunctionHandler * pH ) { CHECK_PARAMETERS ( 1 ) ; const char * sBoneName = " " ; pH -> GetParam ( 1 , sBoneName ) ; ICryCharInstance * cmodel = m_pWeaponClass -> GetCharacter ( ) ; if ( ! cmodel ) return pH -> EndFunctionNull ( ) ; ICryBone * pBone = cmodel -> GetBoneByName ( sBoneName ) ; if ( ! pBone ) { return pH -> EndFunctionNull ( ) ; } Vec3d vBonePos = pBone -> GetBonePosition ( ) ; Vec3d angles = m_pWeaponClass -> GetAngles ( ) ; Matrix44 m = Matrix34 :: CreateRotationXYZ ( Deg2Rad ( angles ) , m_pWeaponClass -> GetPos ( ) ) ; m = GetTransposed44 ( m ) ; Vec3 vec = m . TransformPointOLD ( vBonePos ) ; m_pMemberBonePos -> BeginSetGetChain ( ) ; m_pMemberBonePos -> SetValueChain ( " " , vec . x ) ; m_pMemberBonePos -> SetValueChain ( " " , vec . y ) ; m_pMemberBonePos -> SetValueChain ( " " , vec . z ) ; m_pMemberBonePos -> EndSetGetChain ( ) ; return pH -> EndFunction ( m_pMemberBonePos ) ; }
Obtains the position of a bone in the weapon object while taking into account
that weapons are rendered with a different FOV
Obtains the position of a bone in the weapon object while taking into account that weapons are rendered with a different FOV
//set rotation and translation in one function call
 //TODO: remove this after E3 and use Matrix34 instead of Matrix44
 // get result
