Rotating views

38 views
Skip to first unread message

Persei8

unread,
Sep 25, 2020, 12:43:39 AM9/25/20
to pi3d
I hope it's OK to ask implementation type questions, I am not an experienced programmer and may have some dumb questions. Anyway, I am attempting to port some opengl code to pi3d. I managed to get the display object into a qt5 label widget and create 3 orthogonal lines, each a different color, which represents an axis origin point. For panning and rotating around the view, is it better to use a fixed camera and rotate the origin object or should I fix the origin object and move the camera around? I would prefer to move the camera but am having trouble making it work. I can relocate the camera but the view doesn't change until I  move one of the lines. The display is set to constantly redraw the lines on a 100 mSec timer interval. Thank you for any help.

Paddy

unread,
Sep 25, 2020, 4:43:13 AM9/25/20
to pi3d
Hi, no problem asking questions here, and well done to get pi3d rendering to a qt5 widget! You can move the camera nearly as easily as moving the objects in the scene but there is a subtle difference. When objects are moved/rotated/scaled the matrix representing that change 'starts from scratch' each frame. But for the camera, because the same matrix is used to draw all the objects in the scene (or maybe just because of the way pi3d evolved) the camera matrix has to be reset before translation or rotation is applied.

However that doesn't really explain why view in your example doesn't change until you move one of the lines. Is the code available to view?

The ProceduralTerrain demo uses camera rotation about a static object, maybe compare your code with that.

Persei8

unread,
Sep 26, 2020, 2:03:33 PM9/26/20
to pi3d
Thanks for that explanation. Things are slowly beginning to sink in. Even though I can render the image in a qt label, the pi3d display window is still showing on the desktop. The code I use to create it is :
        self.display = pi3d.Display.create(w=WIDTH, h=HEIGHT, background=(0,0,0,1), frames_per_second=10, layer=-128)
I would like to completely hide this window or not even show it at all and just use the screenshot function.
I should say I am currently accessing the pi via VNC, so maybe that makes a difference?

Paddy

unread,
Sep 27, 2020, 4:00:56 AM9/27/20
to pi3d
Hi the layer argument will only do anything on dispmanx render surfaces. ie not fake KMS driver. You can hide the pi3d window with new driver by Display.resize and set the X position to screen width. On phone at moment but you should be able to find some discussion on same issue either on GitHub issues or raspberry pi forum. I will dig it out when I get home.
Reply all
Reply to author
Forward
0 new messages