To use the modelview matrix to set the transformation of the object, the code in object. py needs to be updated thus:
.
def update (self, events $=$ None):
glPushMatrix ()
for $c$ in self.components:
if isinstance(c, Transform):
glLoadMatrixf(c.get_MVM())
mv $=$ glGetDoublev (GL_MODELVIEW_MATRIX)
print ("MV: ")
print (mv)
elif isinstance (c, Mesh3D) :
glColor(1, 1, 1)
Take note here of how the OpenGL transformations have been removed and replaced with a glLoadMatrixf () call instead. This method loads in the matrix calculated by the Transform class. The printing of the modelview matrix has been left to show you the contents of the matrix after we have calculated it manually. The idea is that if you perform the exact same transformations as we did in Chapter 13, Understanding the Importance of Matrices, the modelview matrix will be the same.