Message 1 of 2
How to set camera settings properly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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