// -- Cameras ---------------------------------------------------------------------------- KFbxCamera* Scene::getCurrentCamera(KTime time) { KFbxGlobalSettings& lGlobalSettings = fbxScene->GetGlobalSettings(); KFbxGlobalCameraSettings& lGlobalCameraSettings = fbxScene->GlobalCameraSettings(); KString lCurrentCameraName = lGlobalSettings.GetDefaultCamera(); // check if we need to create the Producer cameras! if (lGlobalCameraSettings.GetCameraProducerPerspective() == NULL && lGlobalCameraSettings.GetCameraProducerBottom() == NULL && lGlobalCameraSettings.GetCameraProducerTop() == NULL && lGlobalCameraSettings.GetCameraProducerFront() == NULL && lGlobalCameraSettings.GetCameraProducerBack() == NULL && lGlobalCameraSettings.GetCameraProducerRight() == NULL && lGlobalCameraSettings.GetCameraProducerLeft() == NULL) { lGlobalCameraSettings.CreateProducerCameras(); } if (lCurrentCameraName.Compare(PRODUCER_PERSPECTIVE) == 0) { return lGlobalCameraSettings.GetCameraProducerPerspective(); } else if (lCurrentCameraName.Compare(PRODUCER_BOTTOM) == 0) { return lGlobalCameraSettings.GetCameraProducerBottom(); } else if (lCurrentCameraName.Compare(PRODUCER_TOP) == 0) { return lGlobalCameraSettings.GetCameraProducerTop(); } else if (lCurrentCameraName.Compare(PRODUCER_FRONT) == 0) { return lGlobalCameraSettings.GetCameraProducerFront(); } else if (lCurrentCameraName.Compare(PRODUCER_BACK) == 0) { return lGlobalCameraSettings.GetCameraProducerBack(); } else if (lCurrentCameraName.Compare(PRODUCER_RIGHT) == 0) { return lGlobalCameraSettings.GetCameraProducerRight(); } else if (lCurrentCameraName.Compare(PRODUCER_LEFT) == 0) { return lGlobalCameraSettings.GetCameraProducerLeft(); } else if (lCurrentCameraName.Compare(CAMERA_SWITCHER) == 0) { KFbxCameraSwitcher* lCameraSwitcher = fbxScene->GlobalCameraSettings().GetCameraSwitcher(); KFbxAnimCurve* lCurve = NULL; if (lCameraSwitcher) { lCurve = lCameraSwitcher->CameraIndex.GetCurve<KFbxAnimCurve>(currentAnimationLayer); KFCurve* lFCurve = (lCurve)?lCurve->GetKFCurve():NULL; int lCameraIndex = 0; if (lFCurve) // Get the index of the camera in the camera array. lCameraIndex = (int) lFCurve->Evaluate(time) - 1; if (lCameraIndex >= 0 && lCameraIndex < cameras.GetCount()) { KFbxNode* lNode = cameras[lCameraIndex]; // Get the animated parameters of the camera. getCameraAnimatedParameters(lNode, time); return (KFbxCamera*) lNode->GetNodeAttribute(); } } } else { int i; KFbxNode* lNode = NULL; // Find the camera in the camera array. for (i = 0; i < cameras.GetCount(); i++) { if (lCurrentCameraName.Compare(cameras[i]->GetName()) == 0) { lNode = cameras[i]; break; } } if (lNode) { // Get the animated parameters of the camera. getCameraAnimatedParameters(lNode, time); return (KFbxCamera*) lNode->GetNodeAttribute(); } } return lGlobalCameraSettings.GetCameraProducerPerspective(); }
KFbxCamera* GetCurrentCamera(KFbxScene* pScene, KTime& pTime, KArrayTemplate<KFbxNode*>& pCameraArray) { KFbxGlobalSettings& lGlobalSettings = pScene->GetGlobalSettings(); KFbxGlobalCameraSettings& lGlobalCameraSettings = pScene->GlobalCameraSettings(); KString lCurrentCameraName = lGlobalSettings.GetDefaultCamera(); if (lGlobalCameraSettings.GetCameraProducerPerspective() == NULL && lGlobalCameraSettings.GetCameraProducerBottom() == NULL && lGlobalCameraSettings.GetCameraProducerTop() == NULL && lGlobalCameraSettings.GetCameraProducerFront() == NULL && lGlobalCameraSettings.GetCameraProducerBack() == NULL && lGlobalCameraSettings.GetCameraProducerRight() == NULL && lGlobalCameraSettings.GetCameraProducerLeft() == NULL) { lGlobalCameraSettings.CreateProducerCameras(); } if (lCurrentCameraName.Compare(PRODUCER_PERSPECTIVE) == 0) { return lGlobalCameraSettings.GetCameraProducerPerspective(); } else if (lCurrentCameraName.Compare(PRODUCER_BOTTOM) == 0) { return lGlobalCameraSettings.GetCameraProducerBottom(); } else if (lCurrentCameraName.Compare(PRODUCER_TOP) == 0) { return lGlobalCameraSettings.GetCameraProducerTop(); } else if (lCurrentCameraName.Compare(PRODUCER_FRONT) == 0) { return lGlobalCameraSettings.GetCameraProducerFront(); } else if (lCurrentCameraName.Compare(PRODUCER_BACK) == 0) { return lGlobalCameraSettings.GetCameraProducerBack(); } else if (lCurrentCameraName.Compare(PRODUCER_RIGHT) == 0) { return lGlobalCameraSettings.GetCameraProducerRight(); } else if (lCurrentCameraName.Compare(PRODUCER_LEFT) == 0) { return lGlobalCameraSettings.GetCameraProducerLeft(); } else if (lCurrentCameraName.Compare(CAMERA_SWITCHER) == 0) { KFbxCameraSwitcher* lCameraSwitcher = pScene->GlobalCameraSettings().GetCameraSwitcher(); KFbxAnimCurve* lCurve = NULL; if (lCameraSwitcher) { lCurve = lCameraSwitcher->CameraIndex.GetCurve<KFbxAnimCurve>(gCurrentAnimationLayer); KFCurve* lFCurve = (lCurve)?lCurve->GetKFCurve():NULL; int lCameraIndex = 0; if (lFCurve) lCameraIndex = (int) lFCurve->Evaluate(pTime) - 1; if (lCameraIndex >= 0 && lCameraIndex < pCameraArray.GetCount()) { KFbxNode* lNode = pCameraArray[lCameraIndex]; GetCameraAnimatedParameters(lNode, pTime); return (KFbxCamera*) lNode->GetNodeAttribute(); } } } else { int i; KFbxNode* lNode = NULL; for (i = 0; i < pCameraArray.GetCount(); i++) { if (lCurrentCameraName.Compare(pCameraArray[i]->GetName()) == 0) { lNode = pCameraArray[i]; break; } } if (lNode) { GetCameraAnimatedParameters(lNode, pTime); return (KFbxCamera*) lNode->GetNodeAttribute(); } } return lGlobalCameraSettings.GetCameraProducerPerspective(); }