Hi,
I've derived from the "FlyNavigate" class to implement my own camera class.
I'm basically trying to split the "FlyNavigate::sensitivity" function up so that I can set move and turn speeds seperately.
So far i've got:
Code:
############# MyFlyNavigation Camera ###########
import viz
import vizcam
class MyFlyNavigation(vizcam.FlyNavigate):
MOUSE_LEFT_DOWN = False
def __init__(self):
# Default movement keys
vizcam.FlyNavigate.__init__(self,'w','s','a','d')
# Only update the mouse movement if the left mouse has been clicked
def _camMouseMove(self,e):
if self.MOUSE_LEFT_DOWN == True:
vizcam.FlyNavigate._camMouseMove(self,e)
def _camMouseDown(self,e):
if e.button == viz.MOUSEBUTTON_LEFT:
self.MOUSE_LEFT_DOWN = True
def _camMouseUp(self,e):
self.MOUSE_LEFT_DOWN = False
# Overidden to add a bit of logic
def _camUpdate(self,e):
vizcam.FlyNavigate._camUpdate(self,e)
mousePos = viz.mouse.getPosition(viz.WINDOW_PIXELS, True)
windowSize = viz.window.getSize()
# If the mouse cursor leaves the client window then
# don't bother updating the _camMouseMove parent function
if mousePos[0] <= 0:
self.MOUSE_LEFT_DOWN = False
elif mousePos[0] >= windowSize[0]:
self.MOUSE_LEFT_DOWN = False
elif mousePos[1] <= 0:
self.MOUSE_LEFT_DOWN = False
elif mousePos[1] >= windowSize[1]:
self.MOUSE_LEFT_DOWN = False
def setMoveSensitivity(self, moveScale):
#vizcam.FlyNavigate.__moveScale = vizcam.FlyNavigate.MOVE_SPEED * moveScale
#vizcam.FlyNavigate.sensitivity(self, moveScale, 1.0)
self.__moveScale = self.MOVE_SPEED * moveScale
def setLookSensitivity(self, turnScale):
#vizcam.FlyNavigate.__turnScale = vizcam.FlyNavigate.MOVE_SPEED * turnScale
#vizcam.FlyNavigate.sensitivity(self, 1.0, turnScale)
self.__turnScale = self.MOVE_SPEED * turnScale
def getMoveSensitivity(self):
#return vizcam.FlyNavigate.__moveScale
return self.__moveScale
def getLookSensitivity(self):
#return vizcam.FlyNavigate.__turnScale
return self.__turnScale
Neither functions appear to work regardless of what "scope" I try and give to "__moveScale" or "__turnScale"...
Using "vizcam.FlyNavigate.sensitivity(self, 1.0, turnScale)" works until "vizcam.FlyNavigate.sensitivity(self, moveScale, 1.0)" is invoked, and vice versa.
I know this will be a simple mistake i'm doing for something so simple but can't seem to spot it...
Thanks,
DB