From: Symion <kn...@ip...> - 2009-12-06 05:38:26
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type"> <title></title> </head> <body bgcolor="#ffffff" text="#000000"> Hi there,<br> I'm just answering my own question.<br> The following program demonstrates 'the problem' and shows how I got around it.<br> <br> Source Code: <a href="http://home.iprimus.com.au/knoware/webpage/Basic_0.py">Basic_0.py</a> A simple 2D line drawer.<br> <br> This is not a problem with Vpython, but is related to My reliance on the Default scene object and my attempts to<br> preserve it. <br> The solution is to instantiate new display object instead of trying to reuse the old one.<br> <br> Symion <br> <br> Symion wrote: <blockquote cite="mid:4B1...@ip..." type="cite">Hi there,<br> I have been trying to reset a scene to its original settings and I can not seem to be able to reset Userzoom input.<br> The following snippet demonstrates my problem.<br> If you run the code and spin the object around , then press any key! The program will close down the scene and restart with Exactly the same initial values.<br> So far so good!<br> Now zoom in or out and press any key!<br> The zoom factor is not removed from the new scene, and I can not seem to find any way to removing it!<br> Bearing in mind that turning Userzoom off is not an option, could you point me in the right direction?<br> Any help would be appreciated.<br> <br> '''Try to remove user zoom and spin components from scene<br> <br> Control:<br> Any key for next scene.<br> esc to quit.'''<br> <br> from visual import *<br> <br> print __doc__<br> i = 1<br> while 1:<br> scene.visible = False<br> scene.width, scene.height, scene.title = 600, 600, 'Demo%01i' %(i)<br> scene.forward = (0,0,-1) # Cancels previous Userspin component<br> scene.range = 1 # Does NOT cancel previous Userzoom component!<br> rate(2)<br> scene.visible = True<br> b = box()<br> while scene.kb.keys==0:<br> rate(50)<br> while scene.kb.keys>0:<br> kb = scene.kb.getkey()<br> b.visible = False<br> del b # Make sure object is Really gone<br> i+= 1<br> <br> <br> Symion <pre wrap=""> </pre> </blockquote> </body> </html> |