Exemplo n.º 1
0
//------------------------------------------------------------------------
const Matrix33 &CItem::GetSlotHelperRotation(int slot, const char *helper, bool worldSpace, bool relative)
{
    static Matrix33 rotation;
    rotation.SetIdentity();

    IEntity* pEntity = GetEntity();
    if(!pEntity)
        return rotation;

    SEntitySlotInfo info;
    if (pEntity->GetSlotInfo(slot, info))
        {
            if (info.pStatObj)
                {
                    IStatObj *pStatObj = info.pStatObj;
                    rotation = Matrix33(pStatObj->GetHelperTM(helper));
                    rotation.OrthonormalizeFast();
                    rotation = Matrix33(GetEntity()->GetSlotLocalTM(slot, false))*rotation;
                }
            else if (info.pCharacter)
                {
                    ICharacterInstance *pCharacter = info.pCharacter;
                    if(!pCharacter)
                        return rotation;

                    IAttachment* pAttachment = pCharacter->GetIAttachmentManager()->GetInterfaceByName(helper);
                    if(pAttachment)
                        {
                            rotation = Matrix33(worldSpace ? pAttachment->GetAttWorldAbsolute().q : pAttachment->GetAttModelRelative().q);
                            return rotation;
                        }
                    else
                        {
                            ISkeletonPose* pSkeletonPose = pCharacter->GetISkeletonPose();
                            int16 id = pSkeletonPose->GetJointIDByName(helper);
                            if (id > -1)
                                {
                                    rotation = relative ? Matrix33(pSkeletonPose->GetRelJointByID(id).q) : Matrix33(pSkeletonPose->GetAbsJointByID(id).q);
                                }
                        }

                    if (!relative)
                        {
                            rotation = Matrix33(pEntity->GetSlotLocalTM(slot, false)) * rotation;
                        }
                }
        }

    if (worldSpace)
        {
            rotation = Matrix33(pEntity->GetWorldTM()) * rotation;
        }

    return rotation;
}
Exemplo n.º 2
0
//------------------------------------------------------------------------
Vec3 CItem::GetSlotHelperPos(int slot, const char *helper, bool worldSpace, bool relative) const
{
    Vec3 position(0,0,0);

    SEntitySlotInfo info;
    if (GetEntity()->GetSlotInfo(slot, info))
        {
            if (info.pStatObj)
                {
                    IStatObj *pStatsObj = info.pStatObj;
                    position = pStatsObj->GetHelperPos(helper);
                    position = GetEntity()->GetSlotLocalTM(slot, false).TransformPoint(position);
                }
            else if (info.pCharacter)
                {
                    ICharacterInstance *pCharacter = info.pCharacter;
                    IAttachment* pAttachment = pCharacter->GetIAttachmentManager()->GetInterfaceByName(helper);
                    if (pAttachment)
                        {
                            position = worldSpace ? pAttachment->GetAttWorldAbsolute().t : pAttachment->GetAttModelRelative().t;
                            return position;
                        }
                    else
                        {
                            ISkeletonPose* pSkeletonPose = pCharacter->GetISkeletonPose();
                            int16 id = pSkeletonPose->GetJointIDByName(helper);
                            if (id > -1)
                                {
                                    position = relative ? pSkeletonPose->GetRelJointByID(id).t : pSkeletonPose->GetAbsJointByID(id).t;
                                }
                        }

                    if (!relative)
                        {
                            position = GetEntity()->GetSlotLocalTM(slot, false).TransformPoint(position);
                        }
                }
        }

    if (worldSpace)
        {
            position = GetWorldTM().TransformPoint(position);
        }

    return position;
}
Exemplo n.º 3
0
void CHUDTagNames::DrawTagName(IActor *pActor,bool bLocalVehicle)
{
	CRY_ASSERT(pActor);
	if(!pActor)
		return;

	IActor *pClientActor = g_pGame->GetIGameFramework()->GetClientActor();
	CGameRules *pGameRules = g_pGame->GetGameRules();
	int iClientTeam = pGameRules->GetTeam(pClientActor->GetEntityId());

	if(!bLocalVehicle && pActor->GetLinkedVehicle())
		return;
	
	const char *szRank = GetPlayerRank(pActor->GetEntityId());

	IEntity *pEntity = pActor->GetEntity();
	if(!pEntity)
		return;

	char szText[HUD_MAX_STRING_SIZE];
	if(szRank)
	{
		sprintf(szText,"%s %s",szRank,pEntity->GetName());
	}
	else
	{
		sprintf(szText,"%s",pEntity->GetName());
	}

	ICharacterInstance *pCharacterInstance = pEntity->GetCharacter(0);
	if(!pCharacterInstance)
		return;

	ISkeletonPose *pSkeletonPose = pCharacterInstance->GetISkeletonPose();
	if(!pSkeletonPose)
		return;

	int16 sHeadID = pSkeletonPose->GetJointIDByName("Bip01 Head");
	if(-1 == sHeadID)
		return;

	Matrix34 matWorld = pEntity->GetWorldTM() * Matrix34(pSkeletonPose->GetAbsJointByID(sHeadID));

	Vec3 vWorldPos = matWorld.GetTranslation();

	// Who has a bigger head? :)
	vWorldPos.z += 0.4f;

	AABB box; 
	pEntity->GetWorldBounds(box);

	bool bDrawOnTop = bLocalVehicle;

	if(ProjectOnSphere(vWorldPos,box))
	{
		bDrawOnTop = true;
	}

	ColorF rgbTagName = COLOR_ENEMY;

	if(0 == iClientTeam)
	{
		if(IsFriendlyToClient(pActor->GetEntityId()))
		{
			rgbTagName = COLOR_FRIEND;
		}
	}
	else if(pGameRules->GetTeam(pActor->GetEntityId()) == iClientTeam)
	{
		rgbTagName = COLOR_FRIEND;
	}

	if(pActor->GetHealth() <= 0)
	{
		rgbTagName = COLOR_DEAD;
	}

	m_tagNamesVector.resize(1);

	for(std::vector<EntityId>::iterator iter=SAFE_HUD_FUNC_RET(GetRadar()->GetSelectedTeamMates())->begin(); iter!=SAFE_HUD_FUNC_RET(GetRadar()->GetSelectedTeamMates())->end(); ++iter)
	{
		if(pActor->GetEntityId() == *iter)
		{
			// Teammate is selected in radar, force the visibility of that name					
			bDrawOnTop = true;
			break;
		}
	}

	STagName *pTagName = &m_tagNamesVector[0];

	pTagName->strName			= szText;
	pTagName->vWorld			= vWorldPos;
	pTagName->bDrawOnTop	= bDrawOnTop;
	pTagName->rgb					= rgbTagName;

	DrawTagNames();
}