Hi all,
I'm new to pybullet. I was wondering if it is possible to control the 3D view of the opengl window using the mouse? I can only zoom in and out, but not other operations as rotating the view.
I mean just moving the 3D view as you can do with most viewers.
Does this require code or there is some trick with the mouse that I haven't discovered? (Using python3 in ubuntu 16.04).
Thanks.
Use mouse to control camera view in opengl window
-
- Posts: 2
- Joined: Fri Jul 20, 2018 11:15 pm
-
- Posts: 1
- Joined: Wed Sep 19, 2018 2:16 pm
Re: Use mouse to control camera view in opengl window
I'm not sure how to do it through mouse control, but you can use the pybullet.resetDebugVisualizerCamera() function explained in the API to change the camera view.
-
- Posts: 14
- Joined: Tue Sep 18, 2018 7:50 pm
Re: Use mouse to control camera view in opengl window
I think most of us have found the same issue and then turned to programmatically work around it. I think it will be improved in a future version.
Hope the example below helps you a bit further.
Example of moving the camera around programmatically with the keys (not the mouse sorry) while staying directed towards object called 'dog'
Hope the example below helps you a bit further.
Example of moving the camera around programmatically with the keys (not the mouse sorry) while staying directed towards object called 'dog'
Code: Select all
while (1):
cubePos, cubeOrn = p.getBasePositionAndOrientation(dog)
p.resetDebugVisualizerCamera( cameraDistance=cdist, cameraYaw=cyaw, cameraPitch=cpitch, cameraTargetPosition=cubePos)
keys = p.getKeyboardEvents()
#Keys to change camera
if keys.get(100): #D
cyaw+=1
if keys.get(97): #A
cyaw-=1
if keys.get(99): #C
cpitch+=1
if keys.get(102): #F
cpitch-=1
if keys.get(122): #Z
cdist+=.01
if keys.get(120): #X
cdist-=.01
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: Use mouse to control camera view in opengl window
Try holding the CONTROL or ALT key + left or middle or left mouse button to rotate, pan or zoom the camera, while dragging the mouse.
-
- Posts: 14
- Joined: Tue Sep 18, 2018 7:50 pm
Re: Use mouse to control camera view in opengl window
Yes that works great! I definitely thought I had tried that before without result but apparently not.