To get the current camera of the view pane, usually, we can use the API FBRenderer::CurrentCamera to get the camera. But when there are multiple view panes, the API does not work as you expected, it always return back the camera of the 1st view pane, this is a known issue of Motionbuilder. So how to get the correct camera for the specified view pane?
There are 2 different situations.
First, let’s take a look at this example, if you have a customized shader which is derived from FBShader, and you want to display some special effects only when current camera is a specified camera, in general, you will write some code in the virtual method FBShader::ShadeModel() similar as follow:
void MyShaderExample::ShadeModel( FBRenderOptions* pRenderOptions, FBShaderModelInfo* pShaderModelInfo, FBRenderingPass pPass ) { ... ... // Get current camera FBRenderer* lRenderer = mSystem.Renderer; lModelCam = (FBCamera*)(lRenderer->CurrentCamera()); std::string cameraName(lModelCam->LongName.AsString()); std::string prefix("MyCustomizedCamera"); if( ! lModelCam->SystemCamera && strncmp(cameraName.c_str(), prefix.c_str(), strlen(prefix.c_str())) == 0 ) { //add some special effects here. } }
It works when there is only one view pane, but as I mentioned below, this will not work as expected when there are multiple view panes, the solution is to use the method FBRenderOptions::GetRenderingCamera() instead, it will provide you the correct camera for each different view pane.
Let's look at another scenario, how about if you just want to get the camera for the specified view pane without FBRenderOptions parameter? Within Motionbuilder 2017, we provided some methods including FBRenderer::GetCameraInPane() to help you get the camera for the specified view pane. If you are interested, please refer to the online SDK help for more details.
Comments
You can follow this conversation by subscribing to the comment feed for this post.