0

I want to build a game and therefore I would like to create a game menu. This menu should be in front of the scene, but not totally hide it, somehow sticking at the lens of the camera. My first idea was to create planes as buttons and position them at the same position as the nearplane and move it with the camera. Is there also a easier way to do this?
(I also saw this, but I don't know how to do it without qml)

1 Answers1

0

The way games make HUDs or menus is by (I think) using orthographic projection which makes it unnecessary to have them at the near-plane (and gets rid of some side effects). I didn't find anything nicer than this to describe orthographic projections.

So to implement this you would have two framegraph branches:

  1. Draw your objects as normal
  2. Draw your menu using orthographic projection

The elements of the menu could be planes like you said. You can add QObjectPickers to the planes and then react to the clicks.

I have implemented an example for the opposite thing: I created a framegraph that draws a background image behind the 3D scene. It needs adjusting for rescaling the window but should give you the general idea. You can find the project here.


(This is a related question regarding how to put normal Qt widgets like QPushButton in a Qt3D window.)

Florian Blume
  • 3,237
  • 17
  • 37
  • Is there also a way to do it with standard qt? (the documentation says there is a way, but I don't see it yet) – der Gelassene May 10 '20 at 07:12
  • If you use QML you can use standard Qt components but since you were asking to do it without I did not include that in my answer. Other than that I'm not aware of any way of achieving what you want with Qt directly. If you find one let me know, I'd be interested in that as well ;) – Florian Blume May 10 '20 at 07:31