mmatl / pyrender

Easy-to-use glTF 2.0-compliant OpenGL renderer for visualization of 3D scenes.
http://pyrender.readthedocs.io/
MIT License
1.29k stars 226 forks source link

Deforming Rendered Meshes #43

Open aykroyd-id opened 5 years ago

aykroyd-id commented 5 years ago

Hi,

Suppose I have a mesh (e.g. a sphere), which I want to render while performing a series of (non-rigid) deformations (as an animation). I would like to do this as a series of snapshots of an OffscreenRenderer. However, as soon as I render the first image, I cannot modify the mesh's positions without destroying the renderer and creating a new one. Is there a way to do this with the same renderer?

Here's what I have been doing:

# Create my scene, Create my mesh, and add to scene

renderer = OffscreenRenderer(viewport_width=640*2, viewport_height=480*2)
image_1, _ = renderer.render(self.scene)

# deform in some way the positions to animate
node.mesh.primitives[-1].positions = np.sin(node.primitives[-1].positions)
#node.primitives[-1].normals = # re-calculate normals

del renderer;
renderer = OffscreenRenderer(viewport_width=640*2, viewport_height=480*2)
image_2, _ = self.renderer.render(self.scene)

Without re-instancing the renderer, image 2 is no different from image 1. What should I do to properly update the positions?

vnghia commented 1 year ago

Hello, did you find a way to do it ?