Exemplo n.º 1
0
// Camera update function
void CameraObject::Update(float dT)
{
	bool bUpdateViewProj = false;

	if(bTransformDirty)
	{
		Matrix4x4::ConstructLookAtMatrix(&cachedViewMatrix, GetLocation(), GetOrientationQuat());
		bTransformDirty = false;
		bUpdateViewProj = true;
	}

	if(bProjectionDirty)
	{
		switch(projectionType)
		{
		case CameraObject::CLT_Perspective:	Matrix4x4::ConstructPerspectiveMatrix(&cachedProjectionMatrix, pParams.FOV, pParams.Aspect, pParams.Near, pParams.Far); break;
		case CameraObject::CLT_Orthographic:	Matrix4x4::ConstructOrthographicMatrix(&cachedProjectionMatrix, oParams.Width, oParams.Height, oParams.Near, oParams.Far); break;
		default: assert(false && "Unknown projection type");
		}

		bProjectionDirty = false;
		bUpdateViewProj = true;
	}

	if(bUpdateViewProj)
	{
		cachedViewProjectionMatrix = cachedViewMatrix * cachedProjectionMatrix;
	}
}
Exemplo n.º 2
0
Quat Util_L::GetOrientationQuat(const Vec3f &_nodePos, const Vec3f &_viewPos, const Vec3f &_baseUp, S32 _order[3], Float *_pDist)
{
	Vec3f	vFrontDir = _viewPos - _nodePos;
	if (_pDist)
	{
		(*_pDist) = vFrontDir.GetNorm();
	}
	vFrontDir.CNormalize();	
	return GetOrientationQuat(vFrontDir, _baseUp, _order);
}