WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 02-03-2009, 03:21 AM
DrunkenBrit DrunkenBrit is offline
Member
 
Join Date: Dec 2008
Location: England
Posts: 25
Inheritance ambiguities

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
Reply With Quote
  #2  
Old 02-06-2009, 03:03 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
Sorry we have not had a chance to answer this yet. We'll get back to you early next week.
Reply With Quote
  #3  
Old 02-09-2009, 01:17 AM
DrunkenBrit DrunkenBrit is offline
Member
 
Join Date: Dec 2008
Location: England
Posts: 25
That's ok, I gathered you guys are rather busy. Thanks for informing me.
Reply With Quote
  #4  
Old 02-10-2009, 11:25 AM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
self.__moveScale and self.__turnScale are private to the FlyNavigate class and when you try to set those in your MyFlyNavigation class your are creating new instances of them and so the viewpoint is not affected.

When you call the sensitivity method it works
Code:
vizcam.FlyNavigate.sensitivity(self, 1.0, turnScale)
but by passing in a 1 you are re-setting the moveScale valueback to its original value

keep track of both moveScale and turnScale in your class and then pass them both to FlyNavigate.sensitivity
Code:
def __init__(self):
	# Default movement keys
	vizcam.FlyNavigate.__init__(self,'w','s','a','d')
	self.__moveScale = 1
	self.__turnScale = 1
and then you can set each value individually and pass in the value set before
Code:
def setMoveSensitivity(self, moveScale):
	self.__moveScale = moveScale
	vizcam.FlyNavigate.sensitivity(self, self.__moveScale, self.__turnScale)
	
def setLookSensitivity(self, turnScale):
	self.__turnScale = turnScale
	vizcam.FlyNavigate.sensitivity(self, self.__moveScale, self.__turnScale)
Reply With Quote
  #5  
Old 02-11-2009, 12:24 AM
DrunkenBrit DrunkenBrit is offline
Member
 
Join Date: Dec 2008
Location: England
Posts: 25
Thanks!
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 02:12 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC