예제 #1
0
TVector CCharacterCamera::GetThirdPersonCameraPosition()
{
	CCharacter* pCharacter = m_hCharacter;
	if (!pCharacter)
		return TVector(10, 0, 0);

	TVector vecEyeHeight = pCharacter->GetUpVector() * pCharacter->EyeHeight();

	TMatrix mView = TMatrix(pCharacter->GetThirdPersonCameraAngles(), TVector());
	TVector vecThird = pCharacter->GetGlobalTransform().GetTranslation() + vecEyeHeight;
	vecThird -= Vector(mView.GetForwardVector()) * m_flBack;
	vecThird += Vector(mView.GetUpVector()) * m_flUp;
	vecThird += Vector(mView.GetLeftVector()) * m_flSide;

	return vecThird;
}
예제 #2
0
void CCharacterCamera::CameraThink()
{
	BaseClass::CameraThink();

	CCharacter* pCharacter = m_hCharacter;
	if (!pCharacter)
		return;

	if (GetThirdPerson())
	{
		SetGlobalOrigin(GetThirdPersonCameraPosition());
		SetGlobalAngles(VectorAngles(GetThirdPersonCameraDirection()));
	}
	else
	{
		SetGlobalOrigin(pCharacter->GetGlobalOrigin() + pCharacter->GetUpVector() * (TFloat)pCharacter->EyeHeight());
		SetGlobalAngles(pCharacter->GetViewAngles());
	}
}