WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #7  
Old 04-28-2008, 12:57 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Yes, the problem is that you are linking the viewpoint to the tracker location, which will override any translations made by the fall action. You will need to apply the fall action to a dummy node and transfer the position of the dummy node to the viewpoint as an offset. I've made the changes to your script that implement this, and it should work correctly now.
Code:
import viz
import vizact
import time
import math
import random
import winsound

ground = viz.add('tut_ground.wrl')
pit = viz.add('ball.wrl')

viz.go()


light1 = viz.addLight() #Add an overhead light
light1.setEuler(0,90,0)
## Prompt for the participant's identification number - generally keep this uncommented! ##
keyControl = viz.input('Using Tracker? 1 = Yes, 2 = No')
#subject = viz.input('What is the participant number?')
if keyControl == 1:

	eyeohd = viz.input('What is the participants IOD?')


viz.fov(43,1.395) #Cybermind specs

#Dummy node for falling
fallNode = viz.addGroup()
fallAction = vizact.fall(-28.18)
riseAction = vizact.fall(0)

##Rename the main view ##
view = viz.MainView
#Link viewpoint with tracker, initialize boresite
if keyControl == 1: #If you're using the tracker

	tracker = viz.addSensor('intersense')#Ignore documentation stating you need "intersense.dls" - this is correct
	viz.eyeheight(0.0)
	view.translate(0,-.19,.14) #Boresite function - translates the viewpoint from the tracker position to eyepoint position
	viz.ipd(eyeohd/100.0)
	
else:
	import viztracker
	tracker = viztracker.Keyboard6DOF(forward=viz.KEY_UP,backward=viz.KEY_DOWN,turnRight=viz.KEY_RIGHT,turnLeft=viz.KEY_LEFT)
	

linkedTracker = viz.link(tracker, view) #Link the sensor to the view.
linkedTracker.preTrans([0,-.15,.14]) #Boresite function - translates the viewpoint from the tracker position to eyepoint position
linkedTracker.postMultLinkable(fallNode,mask=viz.LINK_POS)



#####################################

#Initialize parameters for keyboard control
MOVE_SPEED = 1.3 #m/s
TURN_SPEED = 60 #deg/s
#NOTE: Default eye height for keyboard control is 6', doesn't affect tracked viewpoint

#This turns mouse control of view and mouse pointer off - very disconcerting for subjects!
# Generally keep both viz.OFF, unless you have a specific need.
viz.mouse(viz.OFF)
viz.cursor(viz.OFF)


Risen = True




def masterLoop(num):

	global Risen

	

	if view.getPosition(mode=viz.ABS_GLOBAL)[0] > -1 and view.getPosition(mode=viz.ABS_GLOBAL)[0] < 1 and Risen == True:


		if view.getPosition(mode=viz.ABS_GLOBAL)[2] > 5.375:

			fallNode.addAction(fallAction)
			print 'in pit'
			Risen = False

		elif view.getPosition(mode=viz.ABS_GLOBAL)[2] < 4.625 and view.getPosition(mode=viz.ABS_GLOBAL)[2] > -1.625:

			fallNode.addAction(fallAction)
			print 'pit 2'
			Risen = False

		elif view.getPosition(mode=viz.ABS_GLOBAL)[2] < -2.375:

			fallNode.addAction(fallAction)
			print 'pit 3'
			Risen = False

		else:

			fallNode.addAction(riseAction)
			Risen = False
			print 'back up'

	elif (view.getPosition(mode=viz.ABS_GLOBAL)[0] < -1 or view.getPosition(mode=viz.ABS_GLOBAL)[0] > 1) and Risen == False:

		fallNode.addAction(riseAction)
		Risen = True
		print 'normal view'


viz.callback(viz.TIMER_EVENT,masterLoop)

#This starts the timer. First value (0) is a timer identifier, second (1/60) is the refresh rate, third (viz.FOREVER) is how long it lasts
viz.starttimer(0,1/60.0,viz.FOREVER)
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


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


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