WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rating: Thread Rating: 6 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 07-09-2009, 01:58 PM
EnvisMJ EnvisMJ is offline
Member
 
Join Date: May 2009
Location: Purdue University, West Lafayette, Indiana
Posts: 44
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
#W,A,S,D and mouselook

import viz
import vizcam

#Define user movement class
class avatarMove:
	#initialization function
	def __init__(self):
		self.move = False
		self.view = viz.MainView
		self.camera = viz.cam.setHandler(vizcam.KeyboardCamera(forward=None,backward=None,left=None,right=None,turnRight=None,turnLeft=None,up=None,down=None,pitchDown=None,pitchUp=None,rollRight=None,rollLeft=None))
		viz.callback(viz.MOUSE_MOVE_EVENT,self.mousemove)
	#enable navigation
	def enable(self):
		viz.restrictmouse(viz.ON)
		self.move = True
		self.camera = viz.cam.setHandler(vizcam.KeyboardCamera(forward='w',backward='s',left='a',right='d',turnLeft='q',turnRight='e',up=' ',down=viz.KEY_ALT_L,pitchDown=None,pitchUp=None,rollRight=None,rollLeft=None))
	#disable navigation
	def disable(self):
		viz.restrictmouse(viz.OFF)
		self.move = False
		self.camera = viz.cam.setHandler(vizcam.KeyboardCamera(forward=None,backward=None,left=None,right=None,turnRight=None,turnLeft=None,up=None,down=None,pitchDown=None,pitchUp=None,rollRight=None,rollLeft=None))
	#tracks mouse movements
	def mousemove(self,e):
		if self.move == True:
			euler = self.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)
			self.view.rotate(euler,viz.HEAD_ORI) 
	#allows you to set the position of the user
	def setPosition(self,x,y,z):
		self.view.setPosition(x,y,z)
	#allows you to get the position of the user
	def getPosition(self):
		return self.view.getPosition()
	#allows you to set the rotation of the user
	def setRotation(self,y,p,r):
		self.view.setEuler(y,p,r)
	#allows you to get the rotation of the user
	def getRotation(self):
		return self.view.getEuler()
After navigating for a while, the camera always develops a little bit of a roll, is there a way to lock the roll at 0? So the camera will always stay level, regardless of mouse movement?
Reply With Quote
 


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Question about input from virtual keyboard. yyang Vizard 4 12-23-2008 12:25 PM
navigation in cave environment Andy Vizard 4 03-28-2008 01:32 AM
On Screen Keyboard betancourtb82 Vizard 14 10-03-2006 12:38 PM
Multiple Viewports in Vizard, Utilizing keyboard callback shivanangel Vizard 2 02-21-2006 04:56 PM
Navigation Speed/Too Slow Plasma Vizard 2 01-28-2004 11:07 AM


All times are GMT -7. The time now is 05:01 AM.


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