From: Craig B. <cd...@gm...> - 2010-02-02 19:16:02
|
Hi, all, In the available doc I found information about how my program can set the camera look-position and direction, but not the zoom level (distance from look-position). Can that be controlled as well, and if so, how? -- Craig Berry - http://www.cine.net/~cberry/ "Lots of things in the universe don’t solve any problems, and nevertheless exist." -- Sean Carroll |
From: Bruce S. <Bru...@nc...> - 2010-02-02 19:46:23
|
Basically, by setting scene.range. For some examples of camera manipulation see the example program stonehenge.py (included in the examples installed with VPython) and, in the Contributed section of vpython.org, the programs movecamera.py, look_around.py, and rotate_scene.py. Bruce Sherwood Craig Berry wrote: > Hi, all, > > In the available doc I found information about how my program can set > the camera look-position and direction, but not the zoom level > (distance from look-position). Can that be controlled as well, and if > so, how? > > |
From: Craig B. <cd...@gm...> - 2010-02-03 18:05:47
|
Okay, I stayed up way too late last night (er, this morning) experimenting with vpython camera view-distance control, and have come to the following conclusions (all relative to a scene containing a fixed set of static objects): 1. There are two fundamental parameters involved: eyeDistance = mag(scene.mouse.camera - scene.center) range = scene.range 2. eyeDistance can only be changed via user zooming, using mouse-middle dragging. Nothing the program does directly ever changes it. 3. range can only be changed by the program. Nothing the user does ever changes it. This seems wildly counterintuitive, and I wasted a lot of time trying to violate point 2 or 3. But all this seems quite solid. So, as in your movecamera.py example, the only way to move the eye to a known apparent viewpoint following user-induced changes to eyeDistance is to change range proportionately, so that the two change cancel out. Is that a fair summary? Or am I missing something? And if any vpython developers are listening, why isn't there a programmatic way to change eyeDistance directly, as for other camera parameters like "forward"? -- Craig Berry - http://www.cine.net/~cberry/ "Lots of things in the universe don’t solve any problems, and nevertheless exist." -- Sean Carroll |
From: Bruce S. <Bru...@nc...> - 2010-02-03 21:53:43
|
Could you describe briefly what it is that you want to do? Bruce Sherwood Craig Berry wrote: > Okay, I stayed up way too late last night (er, this morning) > experimenting with vpython camera view-distance control, and have come > to the following conclusions (all relative to a scene containing a > fixed set of static objects): > > 1. There are two fundamental parameters involved: > eyeDistance = mag(scene.mouse.camera - scene.center) > range = scene.range > > 2. eyeDistance can only be changed via user zooming, using > mouse-middle dragging. Nothing the program does directly ever changes > it. > > 3. range can only be changed by the program. Nothing the user does > ever changes it. > > This seems wildly counterintuitive, and I wasted a lot of time trying > to violate point 2 or 3. But all this seems quite solid. > > So, as in your movecamera.py example, the only way to move the eye to > a known apparent viewpoint following user-induced changes to > eyeDistance is to change range proportionately, so that the two change > cancel out. > > Is that a fair summary? Or am I missing something? And if any > vpython developers are listening, why isn't there a programmatic way > to change eyeDistance directly, as for other camera parameters like > "forward"? > > |
From: Craig B. <cd...@gm...> - 2010-02-03 22:50:01
|
On Wed, Feb 3, 2010 at 13:53, Bruce Sherwood <Bru...@nc...> wrote: > Could you describe briefly what it is that you want to do? I want to allow the user to control the camera with middle- and right-drag mouse gestures, but also, if they click on an object, slew the camera to point at that object from a particular distance. I can slew the camera's aim point by changing scene.center, but I'm having the difficulties described previously with putting it at a particular (apparent) distance from the selected object. -- Craig Berry - http://www.cine.net/~cberry/ "Lots of things in the universe don’t solve any problems, and nevertheless exist." -- Sean Carroll |
From: Craig B. <cd...@gm...> - 2010-02-04 20:06:21
|
On Wed, Feb 3, 2010 at 14:49, Craig Berry <cd...@gm...> wrote: > On Wed, Feb 3, 2010 at 13:53, Bruce Sherwood <Bru...@nc...> wrote: >> Could you describe briefly what it is that you want to do? > > I want to allow the user to control the camera with middle- and > right-drag mouse gestures, but also, if they click on an object, slew > the camera to point at that object from a particular distance. I can > slew the camera's aim point by changing scene.center, but I'm having > the difficulties described previously with putting it at a particular > (apparent) distance from the selected object. So...anybody have a clue on how to do that elegantly? -- Craig Berry - http://www.cine.net/~cberry/ "Lots of things in the universe don’t solve any problems, and nevertheless exist." -- Sean Carroll |
From: Symion <kn...@ip...> - 2010-02-06 05:08:21
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html;charset=windows-1252" http-equiv="Content-Type"> <title></title> </head> <body bgcolor="#ffffff" text="#000000"> Craig Berry wrote: <blockquote cite="mid:8de...@ma..." type="cite"> <pre wrap="">On Wed, Feb 3, 2010 at 14:49, Craig Berry <a class="moz-txt-link-rfc2396E" href="mailto:cd...@gm..."><cd...@gm...></a> wrote: </pre> <blockquote type="cite"> <pre wrap="">On Wed, Feb 3, 2010 at 13:53, Bruce Sherwood <a class="moz-txt-link-rfc2396E" href="mailto:Bru...@nc..."><Bru...@nc...></a> wrote: </pre> <blockquote type="cite"> <pre wrap="">Could you describe briefly what it is that you want to do? </pre> </blockquote> <pre wrap="">I want to allow the user to control the camera with middle- and right-drag mouse gestures, but also, if they click on an object, slew the camera to point at that object from a particular distance. I can slew the camera's aim point by changing scene.center, but I'm having the difficulties described previously with putting it at a particular (apparent) distance from the selected object. </pre> </blockquote> <pre wrap=""><!----> So...anybody have a clue on how to do that elegantly? </pre> </blockquote> Hi there,<br> I don't know if this program is elegant or not but it does give you control over Range, Center and Forward.<br> It also enables you to defines the Range upper and lower boundaries.<br> This requires that Userzoom be turned off and scene.range driven directly.<br> <br> A Feedback loop is setup between scene.range and scene.mouse.pos that drives the zoom effect.<br> Careful positioning of the mouse pointer gives you more control.<br> <br> <br> ''Simple zoom routine GNU \xa9 Symion MMX<br> <br> "r" will Reset the scene range, scene.center and scene.forward<br> <br> Middle Mouse key and drag will Zoom<br> Hint:<br> Find the spot (any corner) and draw mouse with middle key pressed<br> toward the scene center and back to the corner!<br> <br> Right Mouse key will Spin<br> Left Mouse key will change scene.center<br> <br> "x" will exit<br> '''<br> <br> from visual import *<br> <br> userzoom = False<br> nexit = False<br> scene.userzoom = userzoom<br> scene.autoscale = False<br> srange = 10.0<br> scene.range = srange<br> rangemin = 1.0<br> rangemax = 100.0<br> scenter = vector(scene.center)<br> forward = vector(scene.forward)<br> <br> col = (0,1,0)<br> work = list()<br> work.append(sphere(color=col))<br> work.append(box(pos=(1,0,0),color=(1,0,0)))<br> scene.visible = True<br> print __doc__<br> while not nexit:<br> post = scene.mouse.pos<br> if scene.kb.keys>0:<br> km = scene.kb.getkey()<br> if km == 'x':<br> nexit = True<br> elif km == 'r':<br> srange = 10.0<br> scene.range = srange<br> scenter = vector(0,0,0)<br> scene.center = scenter<br> scene.forward = forward<br> elif scene.mouse.events>0:<br> mk = scene.mouse.getevent()<br> if mk.drop == 'middle':<br> userzoom = False<br> print 'Zoom Off: %s' %(srange)<br> elif mk.drag == 'middle':<br> userzoom = True<br> print 'Zoom On: %s' %(srange)<br> elif mk.press == 'left':<br> if mk.pick:<br> post = vector(mk.pick.pos)<br> scene.center = scenter = post<br> print 'Center %s' %(scenter)<br> if userzoom:<br> # print 'range (%0.3f,%0.3f,%0.3f) = %s' %(post.x,post.y,post.z,mag(post))<br> # Limit zoom! This line controls the Entire process<br> srange = min(rangemax,max(rangemin,mag(post)))<br> scene.range = srange<br> <br> for thing in work:<br> thing.visible = False<br> del work<br> scene.visible = False<br> <br> <br> Symion<br> </body> </html> |