SAMSON Forum
    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • SAMSON Connect
    • Get SAMSON

    In-code camera duplication

    Apps
    2
    2
    1971
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • K
      Karsten last edited by

      Hello there,

      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

      SAMSON::getActiveDocument()->setActiveCamera(camcopy);
      

      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,
      Karsten

      1 Reply Last reply Reply Quote 0
      • DmitriyMarin
        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
        

        Dmitriy,
        The SAMSON Team, https://s-c.io

        1 Reply Last reply Reply Quote 1
        • First post
          Last post