WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 08-19-2010, 07:11 AM
johannes2 johannes2 is offline
Member
 
Join Date: Apr 2007
Posts: 7
Warning mouse() -> Set mouse() of window

Hi,


I'm getting the following error-message - which is difficult to locate as it is inside quite a long file.

** WARNING: mouse() method of view class has been removed. Set mouse() of window instead

My guess: I'm using the vizcam.py file you provided me some years ago to implement different navigational behavior. I think it is in there.


See for the code-snippet below.
Thank you.

HTML Code:
[HTML]import viz
import vizmat
import math

###########################################
############# Pivot Camera ################
###########################################

#BEGIN_PANORAMA_EVENT = viz.eventid('BeginPanoramaEvent')
#END_PANORAMA_EVENT = viz.eventid('EndPanoramaEvent')

class PivotNavigate1(viz.EventClass):
	
	PAN_SPEED = 2.0
	ROTATE_SPEED = 90.0
	
	def __init__(self,view=0):
		viz.EventClass.__init__(self)

		self.__PanScale = 1.0
		self.__RotateScale = 1.0

		if not view:
			view = viz.get(viz.MAIN_VIEWPOINT)
		
		self.__view = view
		self.__view.mouse(0)
		
		self.__center = [0,0,0]
		self.__distance = 2
		self.__lastmousepos = [0,0]
		
		self.__enabled = 1
		
		self.callback(viz.TIMER_EVENT,self.__ontimer)
		self.callback(viz.MOUSEWHEEL_EVENT,self.__onmousewheel)
		self.callback(viz.MOUSEDOWN_EVENT,self.__onmousedown)
		self.starttimer(0,0,viz.FOREVER)
		
	def __ontimer(self,num):
		mouse = viz.mousepos()
		if self.__enabled:
			button = viz.buttonstate()
			if viz.iskeydown(viz.KEY_RIGHT):
				#self.__view.rotate(self.__view.get(viz.HEAD_EULER)[0]+1,self.__view.get(viz.HEAD_EULER)[1],self.__view.get(viz.HEAD_EULER)[2])
				self.rotateRight((0.03)*self.__RotateScale*self.ROTATE_SPEED)
			if viz.iskeydown(viz.KEY_LEFT):
				#self.__view.rotate(self.__view.get(viz.HEAD_EULER)[0]-1,self.__view.get(viz.HEAD_EULER)[1],self.__view.get(viz.HEAD_EULER)[2])
				self.rotateRight((-0.03)*self.__RotateScale*self.ROTATE_SPEED)
			if viz.iskeydown(viz.KEY_SHIFT_L):
				 if button & viz.MOUSEBUTTON_LEFT:					
					panFactor = self.__PanScale*self.PAN_SPEED*self.__distance
					panX = -(mouse[0] - self.__lastmousepos[0])*panFactor
					panY = -(mouse[1] - self.__lastmousepos[1])*panFactor
					self.pan(panX,panY,0)
				
			elif viz.iskeydown(viz.KEY_TAB):
				 if button & viz.MOUSEBUTTON_LEFT:
					self.rotateRight((mouse[0] - self.__lastmousepos[0])*self.__RotateScale*self.ROTATE_SPEED)
					self.rotateUp(-(mouse[1] - self.__lastmousepos[1])*self.__RotateScale*self.ROTATE_SPEED)
		self.__lastmousepos = mouse
		
	def __onmousewheel(self,dir):
		if not self.__enabled:
			return
		self.pan(0,0,0.2*  dir)
#		distance = dir * (vizmat.Distance(self.__view.get(viz.HEAD_POS),self.__center) / 8.0)
#		self.__view.move(0,0,distance)
#		self.__distance -= distance
#	def __onmousewheel(self,dir):
#		distance = vizmat.Distance(self.__view.get(viz.HEAD_POS),self.__center) / 8.0
#		self.__view.move(0,0,dir*distance)
		
	def __onmousedown(self,button):
		if not self.__enabled:
			return
		#if button == viz.MOUSEBUTTON_LEFT and viz.iskeydown(viz.KEY_SHIFT_L):
		if button == viz.MOUSEBUTTON_LEFT and viz.iskeydown(viz.KEY_SHIFT_R):
			info = viz.pick(1)
			if info.intersected:
				self.setCenter(info.intersectPoint)

	def enable(self):
		self.__enabled = 1
		
	def disable(self):
		self.__enabled = 0

	def sensitivity(self,rotateScale,panScale):
		self.__RotateScale = rotateScale
		self.__PanScale = panScale

	def rotateRight(self,amount):
		oldPos = self.__view.get(viz.HEAD_POS)
		self.__view.translate(self.__center)
		self.__view.rotate(0,1,0,amount,viz.HEAD_ORI,viz.RELATIVE_WORLD)
#		self.__view.move(0,0,-self.__distance)
		self.__view.translate(oldPos)
		
	def rotateUp(self,amount):
		oldPos = self.__view.get(viz.HEAD_POS)
		self.__view.translate(self.__center)
		self.__view.rotate(1,0,0,amount,viz.HEAD_ORI,viz.RELATIVE_LOCAL)
		pitch = self.__view.get(viz.HEAD_PITCH)
		if abs(pitch) > 85.0:
			if pitch > 0:
				self.__view.rotate(1,0,0,85.0-pitch,viz.HEAD_ORI,viz.RELATIVE_LOCAL)
			else:
				self.__view.rotate(1,0,0,-85-pitch,viz.HEAD_ORI,viz.RELATIVE_LOCAL)
#		self.__view.move(0,0,-self.__distance)
		self.__view.translate(oldPos)
	def pan(self,x,y=0,z=0):		
		self.__view.translate(self.__center)
		self.__view.move(x,y,z)
		self.__center = self.__view.get(viz.HEAD_POS)
#		self.__view.move(0,0,-self.__distance)
		
	def setCenter(self,x,y=0,z=0):
		if viz._islist(x):
			center = x
		else:
			center = [x,y,z]
		diff = viz.Vector(center)
		diff = diff - self.__center
		pos = self.__view.get(viz.HEAD_POS)
		self.__view.translate(pos[0]+diff[0],pos[1]+diff[1],pos[2]+diff[2])
		self.__center = center

	def updateCenter(self):
		oldPos = self.__view.get(viz.HEAD_POS)
		self.__view.move(0,0,self.__distance)
		self.__center = self.__view.get(viz.HEAD_POS)
		self.__view.translate(oldPos)
		
	def updateDistance(self):
		self.__distance = vizmat.Distance(self.__view.get(viz.HEAD_POS),self.__center)
		self.__view.lookat(self.__center)
		
	def panCameraTo(self,x,y=0,z=0):
		self.__view.translate(x,y,z)
		self.updateCenter()

	def rotateCameraTo(self,x,y=0,z=0):
		self.__view.translate(x,y,z)
		self.updateDistance()
[/HTML]

Last edited by johannes2; 08-19-2010 at 07:11 AM. Reason: spelling mistake
Reply With Quote
  #2  
Old 08-19-2010, 02:11 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,454
The command used there for turning off standard mouse navigation has been removed. You can replace:
Code:
self.__view.mouse(0)
with:
Code:
viz.mouse(viz.OFF)
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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
how to remove velocity when mouse is disabled? jvacare1 Vizard 2 02-18-2010 10:25 AM
Navigating an avatar using mouse position(2D) in 3D environment james007 Vizard 1 10-16-2009 11:29 AM
Using Window Buttons Uttama_vizard Vizard 2 01-16-2008 10:25 AM
Warning: CullVisitor enkeli Vizard 1 06-05-2006 02:04 PM
Warning in the output window Adam Vizard 4 11-17-2005 07:08 AM


All times are GMT -7. The time now is 02:01 PM.


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