GetSceneCamera() always true?
-
On 11/07/2013 at 22:02, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R13+
Platform: Windows ; Mac OSX ;
Language(s) : C++ ;---------
There is no camera in sight in my document. The current scene camera is the Editor Camera. When I call:bd->GetSceneCamera(pDoc);
it always returns a camera! I've tried both GetActiveBaseDraw() and GetRenderBaseDraw(), same result. I need to put a clone of the Editor Camera into the document for export purposes. So, what use is GetSceneCamera() and GetEditorCamera() if they both always return the Editor Camera when no other is active?
Frustrating - and it completely invalidates all four uses in the cinema4dsdk examples - because it doesn't work that way.
// Get Camera // - Always clone camera and give unique name to avoid the possibility of showing the wrong camera // - which can otherwise happen if there are multiple cameras with the same name in the scene. BaseDraw* bd = pDoc->GetRenderBaseDraw(); if (!bd) { m_pLivePanel->AddToLog("PushScene: No Active BaseDraw"); return; } StopAllThreads(); BaseObject* camera = bd->GetSceneCamera(pDoc); if (!camera) { camera = bd->GetEditorCamera(); camera = CreateCameraClone(pDoc, camera); if (camera) { bd->SetSceneCamera(camera); EventAdd(); } } else m_pLivePanel->AddToLog("PushScene: There is a Scene Camera!");
The else condition always happens.
-
On 11/07/2013 at 22:11, xxxxxxxx wrote:
And here is how you 'actually' do it:
BaseObject* asceneCam = bd->GetSceneCamera(pDoc); BaseObject* editorCam = bd->GetEditorCamera(); // - No active scene camera, make scene camera based on editor camera // - and make it the scene camera if ((!asceneCam) || (asceneCam == editorCam)) { asceneCam = editorCam; // - Clone camera into cloned document, giving it a unique name asceneCam = CreateCameraClone(pDoc, asceneCam); // Make active camera if (asceneCam) { bd->SetSceneCamera(asceneCam); EventAdd(); } }
You need to update your example code to reflect this!
-
On 12/07/2013 at 00:38, xxxxxxxx wrote:
GetSceneCamera() returns the internal camera object if no other camera is available in the
scene. It's like a hidden camera object. Edit : And as you pointed out in your 2nd post, it's what
GetEditorCamera() returns. -
On 12/07/2013 at 01:20, xxxxxxxx wrote:
Well, you wouldn't get that from the examples and explanation. Their code explicitly does what my first posted code does - and it will FAIL! If you need to know if the camera is an actual camera in the scene or the Editor camera, you have to do what I did in the second posted code - or die a horrible death. Sorry, the entire enterprise is misleading and incorrect. They need to update their example code - it is dead wrong.
ETA: For any export format that retains cameras and, especially, the active scene camera, this information is imperative. If I could get this much, why can't they?
-
On 25/07/2013 at 12:11, xxxxxxxx wrote:
Won't HasCameraLink() do the distinction?
CameraObject* GetActiveCamera (BaseDocument* doc) { if (doc != NULL) { BaseDraw* basedraw = doc->GetActiveBaseDraw(); if (basedraw != NULL) { CameraObject* camera = NULL; if (basedraw->HasCameraLink()) { camera = (CameraObject* )basedraw->GetSceneCamera(doc); } else { camera = (CameraObject* )basedraw->GetEditorCamera(); } return camera; } } return NULL; } // GetActiveCamera