May 2019
Intermediate to advanced
542 pages
13h 37m
English
Animating our wedge is purely a matter of manipulating the view matrix and redrawing our image. We'll start in GlWidget.initializeGL() by creating an instance variable to hold rotation values:
self.rotation = [0, 0, 0, 0]
The first value in this list represents an angle of rotation; the remaining values are the X, Y, and Z coordinates of the point around which the view matrix will rotate.
At the end of paintGL(), we can pass these values into the matrix object's rotate() method:
self.view_matrix.rotate(*self.rotation)
Right now, this will do nothing, because our rotation values are all 0. To cause rotation, we will have to change self.rotation and trigger a repaint of the image.
So, our rotation callbacks will look like ...
Read now
Unlock full access