How to set camera settings properly

How to set camera settings properly

volkerenderlein
Contributor Contributor
333 Views
1 Reply
Message 1 of 2

How to set camera settings properly

volkerenderlein
Contributor
Contributor

In a FBX exporter from a Qt3d scene I try to copy the camera parameters to a FBX camera. First I create camera and camera node as follows:

	auto lCamera = FbxCamera::Create(d->mFbxScene, "camera");
	auto lCameraNode = FbxNode::Create(d->mFbxScene, "cameraNode");
	lCameraNode->SetNodeAttribute(lCamera);

	auto lRootNode = d->mFbxScene->GetRootNode();
	lRootNode->AddChild(lCameraNode);
	d->mFbxCamera = lCamera;

Then I try to copy the parameters from the QCamera object:

bool FbxExport::copyCameraSettings(Qt3DRender::QCamera* camera)
{
	if (!camera || !d->mFbxManager)
		return false;

	auto position = camera->position();
	auto viewCenter = camera->viewCenter();
	auto upVector = camera->upVector().normalized();

	FbxDouble3 lCameraLocation(position[0], position[1], position[2]);
	FbxDouble3 lNewPointOfInterest(viewCenter[0], viewCenter[1], viewCenter[2]);
	FbxDouble3 lUpVector(upVector[0], upVector[1], upVector[2]);

	auto lCamera = d->mFbxCamera;
	lCamera->ProjectionType.Set(camera->lens()->projectionType() == Qt3DRender::QCameraLens::PerspectiveProjection ? FbxCamera::ePerspective : FbxCamera::eOrthogonal);
	lCamera->Position.Set(lCameraLocation);
	lCamera->InterestPosition.Set(lNewPointOfInterest);
	lCamera->UpVector.Set(lUpVector);
	lCamera->SetNearPlane(camera->nearPlane());
	lCamera->SetFarPlane(camera->farPlane());
	lCamera->FieldOfView.Set(camera->fieldOfView());
	lCamera->FocalLength.Set(lCamera->ComputeFocalLength(camera->fieldOfView()));
	lCamera->FocusSource.Set(FbxCamera::eFocusSpecificDistance);
	lCamera->FocusDistance.Set((viewCenter - position).length());
...
	d->mFbxScene->GetGlobalSettings().SetDefaultCamera(lCamera->GetName());
}

 

But this does not seem to work as when opening the exported FBX in FBX Review I see the cameraNode selected but the camera settings not applied.

 

How should one copy the settings to be applicable in FBX Review?

 

Cheers, Volker

0 Likes
334 Views
1 Reply
Reply (1)
Message 2 of 2

volkerenderlein
Contributor
Contributor

I was under the impression that 

lCamera->Position.Set(lCameraLocation);

should work. Setting the camera position using a camera nodes LcLTranslation property worked like a charm.

 

So out of curiosity what can the lCamera->Position property be used for other than positioning the camera?

0 Likes