[SOLVED] Capture image of a node


Recommended Posts

Hello World !

I am asking for help to capture an image of a node.

Here is what I need to do :

  1. Have the screenshot saved
  2. See the camera view in the screenshot
  3. See the node in the screenshot

And here is what happens:

  1. Screenshot is saved - OK
  2. We can see the camera view - OK
  3. The node is not in the screenshot - NOT OK

What I do (after checking the sample "Screenshot") :

  • In WorldLogic.init():
    • Load a node in my world with World::loadnode();
    • Place the camera in order to see the node (player->setWorldTransform)
    •     PlayerSpectatorPtr player = PlayerSpectator::create();
          NodePtr node = World::loadNode("test.node");
          BoundBox bb = node->getBoundBox();
          player->setWorldPosition(Vec3(bb.getMax()) * 10);
  • In WorldLogic.update():
    • Create my TexturePtr if it does not exist and set its size to the size of the app
    •     if(!_screenTexture){
              _screenTexture = Texture::create();
              _screenTexture->create2D(App::getWidth(), App::getHeight(), Texture::FORMAT_RGBA8, Texture::FILTER_POINT | Texture::USAGE_RENDER);
  • In WorldLogic.beforeSwap():
    • if (_screenTexture)
  • In WorldLogic.swap():
    • Check if the screenshot was already taken
    • if no Take the screenshot and save it.
    •     if(_takeScreenshot)
              // Screenshot de l'objet
              ImagePtr image = Image::create();
              if (!Render::isFlipped())
              _takeScreenshot = false;


At the moment I have tried to use World::updateSpatial(); after loading the node but it does not change anything.

The next step is to load a list of nodes and take a screenshot of each one bye one, but if I can't even have the first one...

My main loop looks like that


AppSystemLogic system_logic;
    AppWorldLogic world_logic;
    AppEditorLogic editor_logic;
    // init engine
    Unigine::EnginePtr engine(UNIGINE_VERSION, argc, argv);
    while (!engine->isDone())

How can I manage to see my node in the screenshot ? Are there steps that I missed ?

And if I want to do that for a list of 10 nodes. Is there something else to do like waiting for the nodes to render ?

Tell me if you need any more information. 

Thanks for your time,

Best regards.


Link to post
  • silent changed the title to [SOLVED] Capture image of a node