From: Ting L. <dri...@gm...> - 2007-02-14 10:12:45
|
Hello, I have a display problem with my Vpython program. In the scene, I need to draw thousands of spheres and cylinders, and I also need to switch the visibility of some groups of them on and off, fast sometimes. I used a list to store all the objects and then loop over each object to change its visible property. The problem is When I set visible to 1 for a group of objects by loop, then in the following code I immediately change visible to 0 for a sub-group of them, I found the whole group first displayed then the objects in the sub-group disappeared (because I set them to be invisible). When I repeat this procedure quickly, this problem cause ugly 'flashing'. (some object appear then disappear.) ... for o in objects: o.visible = 1 ... for o in objects[start:end]: o.visible = 0 ... Is there a better way to set the visibility of a group of objects more efficiently? According to the VPython doc, I can group some objects into one frame, then I can move or rotate them as a whole. But to change the visible property, I still need loop, right? One guess of mine is this problem is related to the display mechanism of Vpython. VPython doesn't have a 'redraw' or 'UpdateView' or something like that exposed to the user. Once you draw an object, it call the internal 'redraw' method implicitly. If this is true, then I think we need an explicit 'redraw' method to control the display of the scene we don't want them to display immediately. This is in fact the intention of the 'double buffer' in OpenGL. I know I can combine the two loops into one if I can know the visibility of all the objects in a prior. Thing maybe becomes better. But the problem I explained above remains, because during the looping, if an object will show up immediately after setting the 'visible=1', the objects in the scene will look like cabbages emerging or growing from underground! I do prefer to hide them first and display all of them at the same time. I have to say I'm not very familiar with Vpython. So if somebody can help me to clarify these problems, it would be very appreciated! Ting |