! Retrieves the world direction of a bone - direction of Y axis of the bone @param bone Name of the helper object in the model @return Three component vector cotaining the direction in degrees */
| 3412 | @return Three component vector cotaining the direction in degrees |
| 3413 | */ |
| 3414 | int CScriptObjectEntity::GetBoneDir(IFunctionHandler *pH) |
| 3415 | { |
| 3416 | CHECK_PARAMETERS(1); |
| 3417 | const char * sBoneName = "wt"; |
| 3418 | pH->GetParam(1,sBoneName); |
| 3419 | |
| 3420 | IEntityCharacter *pIChar = m_pEntity->GetCharInterface(); |
| 3421 | ICryCharInstance * cmodel = pIChar->GetCharacter(0); |
| 3422 | |
| 3423 | if (!cmodel) |
| 3424 | return pH->EndFunctionNull(); |
| 3425 | |
| 3426 | ICryBone * pBone = cmodel->GetBoneByName(sBoneName); |
| 3427 | if(!pBone) |
| 3428 | { |
| 3429 | m_pISystem->GetILog()->Log("ERROR: CScriptObjectWeapon::GetBonePos: Bone not found: %s", sBoneName); |
| 3430 | return pH->EndFunctionNull(); |
| 3431 | } |
| 3432 | |
| 3433 | |
| 3434 | Vec3 vBoneDir = pBone->GetBoneAxis('z'); |
| 3435 | // vBoneDir = vBoneDir*(-1.0f); |
| 3436 | Vec3 angles = m_pEntity->GetAngles(); |
| 3437 | Vec3 worldAngles; |
| 3438 | Matrix44 m; |
| 3439 | |
| 3440 | // transform into entity space |
| 3441 | m.SetIdentity(); |
| 3442 | //m.RotateMatrix_fix(angles); |
| 3443 | m=Matrix44::CreateRotationZYX(-angles*gf_DEGTORAD)*m; //NOTE: angles in radians and negated |
| 3444 | |
| 3445 | // get result |
| 3446 | //CHANGED_BY_IVO |
| 3447 | //worldAngles = m.TransformVector(vBoneDir); |
| 3448 | worldAngles = GetTransposed44(m)*vBoneDir; |
| 3449 | |
| 3450 | |
| 3451 | worldAngles=ConvertVectorToCameraAngles(worldAngles); |
| 3452 | SetMemberVector( SOE_MEMBER_BONE_DIR,worldAngles ); |
| 3453 | return pH->EndFunction( m_memberSO[SOE_MEMBER_BONE_DIR] ); |
| 3454 | } |
| 3455 | |
| 3456 | |
| 3457 |
nothing calls this directly
no test coverage detected