View Single Post
  #1  
Old 10-27-2009, 11:36 AM
GiudiceLab GiudiceLab is offline
Member
 
Join Date: May 2009
Location: Orono, ME
Posts: 49
Trouble with listener updating position?

We have a script that toggles an object to play a sound whenever the viewpoint orientation is within a certain threshold (so when the person is looking at the object). It works very well until the viewpoint translates--If the person moves, then turns in place and looks at an object, the sound will trigger, but it will be spatialized as though the person was still in their original position. The stranger part is that if they move at all from their current position, the sound jumps to the correct location.

We are using keyboard commands to emulate orientation and position tracking. I have code snippets that cover the basics of this issue, but I am not sure if I included everything pertinent.
Code:
(in a separate module, called onupdate)

if viz.iskeydown(viz.KEY_LEFT):
   VIEW.rotate(0,1,0,-TURN_SPEED*viz.elapsed(),viz.HEAD_ORI,viz.REL_PARENT)
elif viz.iskeydown(viz.KEY_RIGHT):
   VIEW.rotate(0,1,0,TURN_SPEED*viz.elapsed(),viz.HEAD_ORI,viz.REL_PARENT)

if viz.iskeydown('w'):
   VIEW.translate(0,0,MOVE_SPEED*viz.elapsed(),viz.REL_LOCAL)
elif viz.iskeydown('s'):
   VIEW.translate(0,0,-MOVE_SPEED*viz.elapsed(),viz.REL_LOCAL)
elif viz.iskeydown('a'):
   VIEW.translate(-MOVE_SPEED*viz.elapsed(),0,0,viz.REL_LOCAL)
elif viz.iskeydown('d'):
   VIEW.translate(MOVE_SPEED*viz.elapsed(),0,0,viz.REL_LOCAL)

(in the experimental module, called onupdate)
def monitorOri(e):
	global objplay
	# the purpose of this function is to determine whether the viewpoint
	# is facing an object (within a certain threshold)
	# then have that object play its tone until the viewpoint moves outside
	# the threshold
	view_yaw = view.getEuler()
	view_pos = view.getPosition()

	for item in range(len(objects)):

		object_pos = objects[item].getPosition()
		target_angle = utilities.genTargetAngle(object_pos,view_pos)
		relative_angle = abs(vizmat.AngleDiff(target_angle,view_yaw[0]))
		
		if  (relative_angle <= threshold_angle) and objplay[item] == False:
			toggleTone(item,viz.ON)
			objplay[item] = True
		elif (relative_angle > threshold_angle) and objplay[item] == True:
			toggleTone(item,viz.OFF)
			objplay[item] = False
		else:
			pass
I use vizact onupdate to call the keystroke monitoring in the module, but use viz.callback(viz.UPDATE_EVENT, monitorOri) for monitoring the orientation with respect to each object. Maybe that is causing some sort of interference?

Any suggestions are appreciated, thanks.
__________________
Virtual Environments and Multimodal Interaction (VEMI) Lab

This time, it should work...
Reply With Quote