Mouselook & Keyboard Navigation
We are building a virtual training environment. And we would like to implement 'mouselook' and the standard FPS keyboard movement keys. We have it set up to move with the keyboard and it works fine:
keyTracker =viztracker.Keyboard6DOF(forward='w',backward='s', left='a',right='d',turnRight='e',turnLeft='q') keyLink = viz.link(keyTracker, viz.MainView) keyLink.enable() And we can do 'mouselook' how we want it: def mousemove(e): euler = view.get(viz.HEAD_EULER) euler[0] += e.dx*0.1 euler[1] += -e.dy*0.1 euler[1] = viz.clamp(euler[1],-90.0,90.0) view.rotate(euler,viz.HEAD_ORI) viz.callback(viz.MOUSE_MOVE_EVENT,mousemove) viz.setMouseOverride() However, when we try to implement both in the same program, one overrides the other and we only get one of the two navigation modes. I assume this is because we are implementing the two navigation modes in different ways. Does anyone have some quick and easy code that will allow for navigation using both methods? |
So you want 6DOF movement with the keyboard and orientation with the mouse. This should work.
Code:
import vizcam |
Thanks, that got it working great.
It does assign several other buttons on the keyboard 'g', 'h' and a couple others. We don't want these other keys mapped, and we also need some of them for other functions in our program. How can we unassign them? |
If you want to don't want to use some of the keyboard controls you can specify None for those.
Code:
vizcam.KeyboardCamera(forward='w',backward='s',left='a',right='d',up=None,down=None,turnRight='e',turnLeft='q',pitchDown=None,pitchUp=None,rollRight=None,rollLeft=None) |
Thanks Jeff, it's working great, I've developed a standalone class now that we can use in the future.
Code:
#Class allows typical FPS navigation controls |
In mousemove you could try setting
Code:
euler[2] = 0 |
hello
what to do if i want to increase the speed of keyboard navigation, i used viz.cam.setHandler(vizcam.KeyboardCamera(forward=' w',backward='s',left='a',right='d',turnLeft='q',tu rnRight='e',up=' ',down=viz.KEY_ALT_L,pitchDown=None,pitchUp=None,r ollRight=None,rollLeft=None)) and found nothing about it in the documentation, please help |
You can apply a scale to the move and turn speeds using the sensitivity method.
Code:
import vizcam |
Is there a way to bind the mouse to the center of the viewport? But continue to enable mouselook? At the moment the mouse goes all over the viewport, which makes it a bit difficult to navigate at times.
|
Are you saying you want the mouse to stay inside the graphics window? If so you can use:
Code:
viz.mouse.setTrap(viz.ON) |
All times are GMT -7. The time now is 12:34 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC