From: Kadir H. <kha...@ya...> - 2009-06-12 16:19:22
|
Hello All, I am trying to Zoom-In / Zoom-Out under program control. By changing scene.center vector, it looks like we get the zoom effect working OK. However, if we have any large object in the "space" (i.e., not necessarily in scene/display), the behaviour gets somewhat corrupted. The zoom depth is decreased and objects start to get lost as we zoom in. The interesting thing is that the userzoom (manual zoom) works OK even if you have the same large object around. Another funny behaviour is that, after program controlled zoom with large object around, the manual zoom also seems to be somewhat affected. Any idea on how userzoom normally works and prevents such problems to occur? I tried to observe any differences in scene.mouse.camera, scene.range, scene.fov behaviour for two different cases, but noticed nothing meaningful. It must be something like scene.depth, which does not exist (at least explicitely as far as I know), which gets changed with the existance of a large object. Kadir Here is my small Zoom Test code to see two differnt behaviour: ## ZOOM TEST from visual import * scene.range = (5.0,5.0,5.0) LargeObject = sphere(pos=(-125.0,-95.0,-125.0), radius=125.0, color=(0.7,0.7,0.7), visible=0) cyl1 = cylinder(pos=(0,-0.5,0), radius=0.5, axis=(0,1,0)) box1 = box(pos=(1,0,1)) bal1 = sphere(pos=(-1,0,2)) def ZoomIn(): scene.center = scene.center+scene.forward*0.10 def ZoomOut(): scene.center = scene.center-scene.forward*0.10 i=0 while 1: i += 1 if 50 < i < 150: ZoomIn() # Zoom with LargeObject not visible if 150 < i < 250: ZoomOut() if i == 250: LargeObject.visible=1 if 250 < i < 350: ZoomIn() # Zoom with LargeObject visible if 350 < i < 450: ZoomOut() rate(25) |
From: Bruce S. <Bru...@nc...> - 2009-06-12 17:08:01
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type"> </head> <body bgcolor="#ffffff" text="#000000"> The two cases aren't really the same. With manual zoom, scene.center remains at (0,0,0), whereas in your ZoomIn and ZoomOut routines you're changing scene.center (see the example program stonehenge.py for a similar case, where you "fly through" the scene by dragging with the left mouse button down, either vertically for in or out or horizontally to turn). Your programmatic zoom goes past the small objects, whereas manual zoom doesn't. As you point out, once you've changed scene.center to something other than (0,0,0), manual zoom will behave differently.<br> <br> Notice too that if you comment out your loop and just use manual zoom, you do see a difference in the presence of the large object. Zoom in slowly and you'll see the front of the small sphere get cut off. Evidently what happens is a depth of field issue, as you suggest.<br> <br> I found the behavior of the programmatic zoom to be similar to manual zoom after changing your routines to vary scene.range instead of scene.center:<br> <br> def ZoomIn():<br> ## scene.center = scene.center+scene.forward*0.10<br> scene.range *= 0.95<br> <br> def ZoomOut():<br> ## scene.center = scene.center-scene.forward*0.10<br> scene.range *= 1.05<br> <br> Bruce Sherwood<br> <br> Kadir Haldenbilen wrote: <blockquote cite="mid:269...@we..." type="cite"> <style type="text/css"><!-- DIV {margin:0px;} --></style> <div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"> <div>Hello All,<br> <br> I am trying to Zoom-In / Zoom-Out under program control.<br> <br> By changing scene.center vector, it looks like we get the zoom effect working OK.<br> <br> However, if we have any large object in the "space" (i.e., not necessarily in scene/display),<br> the behaviour gets somewhat corrupted. The zoom depth is decreased and objects start to get lost as we zoom in.<br> <br> The interesting thing is that the userzoom (manual zoom) works OK even if you have the same large object around.<br> <br> Another funny behaviour is that, after program controlled zoom with large object around, the manual zoom also seems to be somewhat affected.<br> <br> Any idea on how userzoom normally works and prevents such problems to occur?<br> I tried to observe any differences in scene.mouse.camera, scene.range, scene.fov behaviour for two different cases, but noticed nothing meaningful.<br> It must be something like scene.depth, which does not exist (at least explicitely as far as I know), which gets changed with the existance of a large object.<br> <br> Kadir<br> <br> Here is my small Zoom Test code to see two differnt behaviour:<br> <br> <br> ## ZOOM TEST<br> <br> from visual import *<br> <br> scene.range = (5.0,5.0,5.0)<br> <br> LargeObject = sphere(pos=(-125.0,-95.0,-125.0),<br> radius=125.0, color=(0.7,0.7,0.7), visible=0)<br> <br> cyl1 = cylinder(pos=(0,-0.5,0), radius=0.5, axis=(0,1,0))<br> box1 = box(pos=(1,0,1))<br> bal1 = sphere(pos=(-1,0,2))<br> <br> def ZoomIn():<br> scene.center = scene.center+scene.forward*0.10<br> <br> def ZoomOut():<br> scene.center = scene.center-scene.forward*0.10<br> <br> i=0<br> while 1:<br> i += 1<br> <br> if 50 < i < 150: ZoomIn() # Zoom with LargeObject not visible<br> if 150 < i < 250: ZoomOut()<br> <br> if i == 250: LargeObject.visible=1<br> <br> if 250 < i < 350: ZoomIn() # Zoom with LargeObject visible<br> if 350 < i < 450: ZoomOut()<br> <br> rate(25)<br> <br> </div> </div> <br> <pre wrap=""> <hr size="4" width="90%"> ------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. <a class="moz-txt-link-freetext" href="http://p.sf.net/sfu/businessobjects">http://p.sf.net/sfu/businessobjects</a></pre> <pre wrap=""> <hr size="4" width="90%"> _______________________________________________ Visualpython-users mailing list <a class="moz-txt-link-abbreviated" href="mailto:Vis...@li...">Vis...@li...</a> <a class="moz-txt-link-freetext" href="https://lists.sourceforge.net/lists/listinfo/visualpython-users">https://lists.sourceforge.net/lists/listinfo/visualpython-users</a> </pre> </blockquote> </body> </html> |