moderngl-window
moderngl-window copied to clipboard
Modifying node matrix doesn't change rendered model
Using the gltf_scenes,py example with "RiggeredFigure.gltf", I want to move a joint when I press a key. This is what I've tried:
n = self.scene.find_node("neck_joint_1")
m = n.matrix
print("Node matrix:")
print(m)
m = m * Matrix44.from_eulers((1,1,1), dtype='f4')
print(m)
n.matrix = m
print("Matrix global:")
print(n.matrix_global)
self.scene.matrix = self.scene.matrix*Matrix44.from_eulers((0.1,0,0), dtype='f4')
print("Matrix global:")
print(n.matrix_global)
#self.scene.calc_scene_bbox()
#for node in self.root_nodes:
# node.calc_model_mat(self.scene.matrix)
The print statements show that both the neck joint matrix and the neck joint matrix_global are being changed, and changing the scene matrix is rotating the model, but the head of the model doesn't turn. Looking in the code, changing the scene matrix should cause the calc_model_mat function to be called, but I've also tried calling it explicitly (see commented section). ( also tried calling the calc_scene_bbox function). The only thing odd I can find in the library source is that under programs.py, the MeshProgram draw method accepts a camera_matrix but doesn't use it (unlike all the other program classes). Also, unlike the other programs, the model_matrix is written to a "m_mv" uniform instead of "m_model" used by the other draw classes. I haven't been able to find where this example loads the default glsl programs, but I'll keep hunting.
Sorry about late reply here. I would not be surprised if there is something fishy somewhere ein the Scene system. It was thrown together in a rush when I added gltf support. Did you figure this out? You should at least be able to override shaders and the buffers animation data should be present in the VAO instances.
No worries. At least I know now that I'm not missing something incredibly obvious. I'm still new to vertex shaders and VAO buffers. I'll try pulling apart the VAO and see if that gives me any clues. Otherwise I am enjoying modernGL's low level approach. :)
Be free to join moderngl discord linked from the project readme if you need any help
Closing this for now. Not much to go on in this issue. Be free to open if you have a MRE.