In-code camera duplication
I was wondering if there is any possibility to create a duplicate of the currently active camera, modify the duplicate, and then replace the active camera with the modified duplicate. I tried several approaches and none of them worked as intended. Please note that it is crucial for my application case that this process happens purely in code and requires no user interaction. The general copying of a camera via
auto camcopy = SAMSON::getActiveCamera()->clone();
is working as intended and the modification of the copy is perfectly possible without affecting the original camera. However, the replacement of the currently active camera leads to unexpected behaviour. The command
seems to do nothing at all, while the more hacky approach
(*SAMSON::getActiveCamera()) = *camcopy;
leads to a camera that is not movable by the user and to an access violation when quitting SAMSON.
Is there any possibility to do this correctly, or is the in-code swapping of active cameras not intended at all?
Thanks in advance,
DmitriyMarin last edited by DmitriyMarin
Hi @Karsten ,
For every node, you create you need to invoke create function, and then if you want it to appear in the DataGraph this node needs to be added to a parent node:
auto camcopy = SAMSON::getActiveCamera()->clone(); // clone the camera camcopy->create(); // create the node document->addChild(camcopy); // add the created camera into the active document /* ... some modifications of the camcopy */ SAMSON::getActiveDocument()->setActiveCamera(camcopy); // set the active camera