View Single Post
  #3  
Old 03-09-2010, 04:58 AM
4711 4711 is offline
Member
 
Join Date: Jan 2010
Posts: 15
Thanks, masaki, for your idea!

Unfortunatelly, it leads exactly to the same result as the mouse-on-mouse-off approach.

My code is something like this:
Code:
import viz
import viztask


def SetTrial( configuration ):
	
	# ...
	
	# Middle mouse button or spacebar picks object
	vizact.onmousedown( viz.MOUSEBUTTON_MIDDLE, pickObject )
	vizact.onkeydown( ' ', pickObject )
	
	# Loop through all trials
	for i in range( TRIALS ):

		# ...
									
		# Prepare VE
		viz.go()
		viz.mouse( viz.OFF )
		viz.MainView.eyeheight( EYEHEIGHT )
		viz.clearcolor( SKYCOLOR ) 
		viz.collision( viz.ON )
		
		# -------------------------------------- #

		if ( WAIT_FOR ):
			yield viztask.waitTime( WAIT_FOR )
		else:
			yield viztask.waitKeyDown(' ')

		# -------------------------------------- #
			
		# Position the user
		viz.MainView.setPosition( Xc, Yc, Zc )
		viz.MainView.setEuler( Yr, Pr, Rr )

		# Enable mouse navigation
		viz.mouse( viz.ON )
			
		# Register callback for timers
		viz.callback( viz.TIMER_EVENT,onTimer )
		viz.starttimer( 0, 0,   viz.PERPETUAL )
		viz.starttimer( 1, .05, viz.PERPETUAL )
		
		# Wait till the trial is over
		yield viztask.waitTime( DURATION )

		# Disable user's activities
		viz.mouse( viz.OFF )
		viz.killtimer(0)
		viz.killtimer(1)

		# ...


# Start Vizard
viz.go()
viz.clearcolor( viz.SKYBLUE )

# Schedule Task
viztask.schedule( SetTrial( configuration ) )
I've yet tried to define a separate function which is then called (similar to masaki's suggestion), and also placed the "yield viztask.waitTime( WAIT_FOR )" command outside the "IF" condition. But the behaviour always is the same, the player keeps drifting during the viztask.

Maybe the problem is due to the structure of my code, however, I could not find an explanation so far...

So any help would be appreciated!
Reply With Quote