Using show() with multiple renderers
See original GitHub issueI have a plotter initialized as:
vp1 = vedo.Plotter(shape=(3,5), axes=0)
I’ve added meshes and spheres to these and they display fine. Now, I have a loop where I’m updating the positions of these spheres. At the end of the update, I want to redraw all the renderers. If I try:
vp1.show(interactive=False, at=0, resetcam=False)
the camera control(by mouse) works, but the 0th renderer has ALL the spheres in(ie the ones I created in other renderers):
Instead, if I update the show command to:
vp1.show()
Now the number of spheres is correct, but I cannot move the camera.
I’m running the latest dev build(was trying to follow the examples but it seems some of them conform to the latest build, and some to an older version of the library). Here is the complete source code:
import vedo
from random import random
# this is one instance of the class Plotter with 3 rows and 5 columns
vp1 = vedo.Plotter(shape=(3,5), axes=0)
for i in range(15):
vp1.show(str(i),at=i)
class Particle:
def __init__(self, at):
global vp1
self.p = vedo.vector((0.0, 0.0, 0.0))
self.vsphere = vedo.Sphere(self.p, r=0.1, c='red')
vp1.add(self.vsphere, at=at)
def update(self):
self.vsphere.pos(self.p)
particles = []
for d in range(15):
for i in range(5):
particles.append(Particle(at=d))
while True:
for particle in particles:
particle.p[0] += (random()-0.5)*0.2
particle.update()
# I can control the camera fine, but the 0-th renderer has ALL the particles, not
# just the ones that were added to it.
# vp1.show(interactive=False, at=0, resetcam=False)
# This version will render correctly, but I cannot control the camera with the mouse
vp1.show()
Basically, I want to update the positions of spheres in all the renderers, while continuing to be able to interactively adjust the view with the mouse. How do I accomplish this?
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (3 by maintainers)
Top GitHub Comments
maybe you just missed:
vp1 = vedo.Plotter(size=(2000,500), interactive=False)
otherwise your script works fine on my pc…
PS: you can press
q
otherwise to exit interactivity and let the script continue.@maghamis try the particle simulator example: https://github.com/marcomusy/vedo/blob/master/examples/simulations/particle_simulator.py