Example #1
0
// Get the animated parameters of a camera contained in the scene
// and store them in the associated member variables contained in
// the camera.
void Scene::getCameraAnimatedParameters(KFbxNode* pNode, KTime time)
{
    KFbxCamera* lCamera = (KFbxCamera*) pNode->GetNodeAttribute();
    lCamera->Position.Set(getGlobalPosition(pNode, time).GetT());

    KFbxAnimCurve* fc = lCamera->Roll.GetCurve<KFbxAnimCurve>(currentAnimationLayer);
    if (fc)
        lCamera->Roll.Set(fc->Evaluate(time));

    if (lCamera->GetApertureMode() == KFbxCamera::eHORIZONTAL ||
            lCamera->GetApertureMode() == KFbxCamera::eVERTICAL)
    {
        fc = lCamera->FieldOfView.GetCurve<KFbxAnimCurve>(currentAnimationLayer);
        if (fc)
            lCamera->FieldOfView.Set(fc->Evaluate(time));
    }
    else if (lCamera->GetApertureMode() == KFbxCamera::eHORIZONTAL_AND_VERTICAL)
    {
        // In this aperture mode, the squeeze ratio is not relevant
        // because the fields of view in X and Y are independent.
        // It's value is set to retrieve the proper aspect in function SetCamera().
        //
        // if:
        //
        // aspect = field of view X / field of view Y = aperture width * squeeze ratio / aperture height
        //
        // then:
        //
        // squeeze ratio = (field of view X * aperture height) / (field of view Y * aperture width)
        //
        double lFieldOfViewX = lCamera->FieldOfViewX.Get();
        double lFieldOfViewY = lCamera->FieldOfViewY.Get();
        fc = lCamera->FieldOfViewX.GetCurve<KFbxAnimCurve>(currentAnimationLayer);
        if (fc)
            lFieldOfViewX = fc->Evaluate(time);

        fc = lCamera->FieldOfViewY.GetCurve<KFbxAnimCurve>(currentAnimationLayer);
        if (fc)
            lFieldOfViewY = fc->Evaluate(time);

        double lSqueezeRatio = (lFieldOfViewX * lCamera->GetApertureHeight()) / (lFieldOfViewY * lCamera->GetApertureWidth());

        lCamera->FieldOfViewX.Set(lFieldOfViewX);
        lCamera->FieldOfViewY.Set(lFieldOfViewY);
        lCamera->SetSqueezeRatio(lSqueezeRatio);
    }
    else if (lCamera->GetApertureMode() == KFbxCamera::eFOCAL_LENGTH)
    {
        double lFocalLength = lCamera->FocalLength.Get();
        fc = lCamera->FocalLength.GetCurve<KFbxAnimCurve>(currentAnimationLayer);
        if (fc && fc ->Evaluate(time))
            lCamera->FocalLength.Set(lFocalLength);
    }
}
Example #2
0
void GetCameraAnimatedParameters(KFbxNode* pNode, KTime& pTime)
{
	KFbxCamera* lCamera = (KFbxCamera*) pNode->GetNodeAttribute();
	lCamera->Position.Set(GetGlobalPosition(pNode, pTime).GetT());

	KFbxAnimCurve* fc = lCamera->Roll.GetCurve<KFbxAnimCurve>(gCurrentAnimationLayer);
	if (fc)
		lCamera->Roll.Set(fc->Evaluate(pTime));

	if (lCamera->GetApertureMode() == KFbxCamera::eHORIZONTAL || 
			lCamera->GetApertureMode() == KFbxCamera::eVERTICAL) 
	{
		fc = lCamera->FieldOfView.GetCurve<KFbxAnimCurve>(gCurrentAnimationLayer);
		if (fc)
			lCamera->FieldOfView.Set(fc->Evaluate(pTime));
	}
	else if (lCamera->GetApertureMode() == KFbxCamera::eHORIZONTAL_AND_VERTICAL)
	{
		double lFieldOfViewX = lCamera->FieldOfViewX.Get();
		double lFieldOfViewY = lCamera->FieldOfViewY.Get();
		fc = lCamera->FieldOfViewX.GetCurve<KFbxAnimCurve>(gCurrentAnimationLayer);
		if (fc)
			lFieldOfViewX = fc->Evaluate(pTime);

		fc = lCamera->FieldOfViewY.GetCurve<KFbxAnimCurve>(gCurrentAnimationLayer);
		if (fc)
			lFieldOfViewY = fc->Evaluate(pTime);

		double lSqueezeRatio = (lFieldOfViewX * lCamera->GetApertureHeight()) / (lFieldOfViewY * lCamera->GetApertureWidth());

		lCamera->FieldOfViewX.Set(lFieldOfViewX);
		lCamera->FieldOfViewY.Set(lFieldOfViewY);
		lCamera->SetSqueezeRatio(lSqueezeRatio);
	}
	else if (lCamera->GetApertureMode() == KFbxCamera::eFOCAL_LENGTH)
	{
		double lFocalLength = lCamera->FocalLength.Get();
		fc = lCamera->FocalLength.GetCurve<KFbxAnimCurve>(gCurrentAnimationLayer);
		if (fc && fc ->Evaluate(pTime))
			lCamera->FocalLength.Set(lFocalLength);
	}
}