Jump to content

I'd like to know how to split and print the camera.


photo

Recommended Posts

Posted

I would like to split the 1P and 2P cameras on one screen and output them. I would like to know how to output two cameras at the same time without using Widget SpriteViewportPtr.

Posted

Hi!

It’s definitely possible to display two cameras on the same screen without using WidgetSpriteViewport, but to be honest, that approach is usually the most straightforward and convenient.

If you really want to avoid that approach, you could look into rendering each camera’s view to a separate texture, and then combining those textures manually into a split-screen layout. This method is technically feasible, but it’s significantly more complex and may require extra handling for performance, synchronization, and layout logic.

Posted

Then, will there be no performance problem even if I use WidgetSpriteViewport and print it out??

Posted

There shouldn’t be any major performance issues. WidgetSpriteViewport is just a subclass of WidgetSprite, so it builds on existing functionality - you're not introducing anything fundamentally heavier than what’s already in use.

The key is to make sure there’s no active or "main" player rendering to the main viewport, so you’re not wasting resources drawing something you don’t use. With WidgetSpriteViewport, it literally renders a texture every frame, and that texture is what’s shown in the sprite - so performance is about what you’d expect from real-time rendering, but it’s fairly optimized for this kind of use.

Posted

Then, is there a way to divide and output the camera using ViewportPtr?? I am currently using the AppWall plug-in.

Posted

With the AppWall plugin you can set up a custom camera configuration as described in the following article in our documentation under the chapter "How to Set Up Custom Cameras Configuration": https://developer.unigine.com/en/docs/2.6.1/principles/render/output/multi_monitor/appwall/?rlang=cpp

Simply create two windows for the two cameras and set the parameters for each window via UnigineScript:

// Settings for the 1st monitor
engine.wall.setProjection(0,0,projection_0);
engine.wall.setModelview(0,0,modelview_0);

Thanks!

Posted

Can I print out the main camera itself using WidgetSpriteViewport??

Posted
3 hours ago, rlaguddgh said:

Can I print out the main camera itself using WidgetSpriteViewport??

Yes, you can render the main camera simply by using its parameters—specifically, the projection and modelview:

WidgetSpriteViewportPtr widget_sprite_viewport;

void init()
{
widget_sprite_viewport = WidgetSpriteViewport::create(1920, 1080);
Gui::get()->addChild(widget_sprite_viewport, Gui::ALIGN_OVERLAP);
}

void update()
{
auto main_player = Game::getPlayer();
widget_sprite_viewport->setProjection(main_player->getCamera()->getProjection());
widget_sprite_viewport->setModelview(main_player->getCamera()->getModelview());
}

Thanks!

×
×
  • Create New...