Jump to content

[SOLVED] Viewport, GUI buttons and players


photo

Recommended Posts

Posted

Hello. I tried to use a viewport in our application and met two problems. I used ViewportWidgetQt class from examples, Qt 5.5.1, Unigine 2.3.

 

1) As I can see, viewport don't send to Unigine keyboards and mouse events. So, I can not use standard player controls (i.e. of PlayerSpectator) to move camera and I should implement it in C++ code or there is some way to do it?

 

2) Gui buttons are drawed only in main window, not in viewport. For my task, I wanted to see them in both windows or may be only in viewport.

And even if buttons would be drawed, I could not click on them, because of the problem from first question.

Posted

Hi,

 

Our controls are indeed designed to be used with only main viewport. You can try to pass controls to the Qt vieweport by yourself - something like that:

void ViewportWidgetQt::mousePressEvent(QMouseEvent *event)
{
 if (event->button() & Qt::LeftButton)
  mouse_button |= Unigine::App::BUTTON_LEFT;
 ...
 Unigine::App::get()->setMouseButton(mouse_button);
 QWidget::mousePressEvent(event);
}

With that method I think you should be able to get controls working with viewports.

 

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Posted

Thank you. But can I draw Unigine GUI button in viewport?

Posted

Hi,

Each viewport should have their own Gui (you can get it via getGui()):

WidgetButtonPtr b = WidgetButton::create("test");
vieport->getGui()->addChild(b->getWidget());

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

  • silent changed the title to [SOLVED] Viewport, GUI buttons and players
×
×
  • Create New...