WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 02-27-2008, 12:25 PM
erchrastil erchrastil is offline
Member
 
Join Date: Feb 2008
Posts: 17
vizact.fall

i'm trying to make an environment using a tracker that gives a visual appearance of falling, but the actual tracker doesn't move. i have something that works fine when i'm just using keyboard commands to move, but it doesn't seem to work with the tracker.

here is the code i'm using:
*****************
fallAction = vizact.fall(-28.18)

if view.getPosition(mode=viz.ABS_GLOBAL)[0] > 1.0
view.add(fallAction)
*****************
this is enclosed within a timer loop that generally controls all of the actions:
def masterLoop(num):
.
.
.
viz.callback(viz.TIMER_EVENT,masterLoop)
viz.starttimer(0,1/60.0,viz.FOREVER)

but here is the error message i get, which seems to want some sort of timer:

AttributeError: 'VizFallAction' object has no attribute 'elapsed'
Traceback (most recent call last):
File "C:\Program Files\WorldViz\Vizard30\python\viz.py", line 8030, in __update
curAction.update(elaps,curAction._obj_)
File "C:\Program Files\WorldViz\Vizard30\python\vizact.py", line 479, in update
self.elapsed += elapsed


any suggestions?
Reply With Quote
  #2  
Old 02-27-2008, 04:04 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
You should be getting another error message before the one you posted. What does that one say? What kind of object is the view object? The easiest way for me to solve the problem would be if you posted an entire script that reproduces the error.
Reply With Quote
  #3  
Old 02-27-2008, 07:12 PM
erchrastil erchrastil is offline
Member
 
Join Date: Feb 2008
Posts: 17
for this code, view is just the vizard mainview:
view = viz.MainView

here is a stripped down version of the code. there are a few models at the top which can be replaced with a generic ground. basically, there is a ground with a pit in it, and we want people to have the view of falling into the pit. i'd also like to have them pop back up when they get out of the range of the pit. it works fine on keyboard control but not when using the tracker:
import viz
import vizact
import time
import math
import random
import winsound

ground = viz.add('Models/ground_2m.ive')
pit = viz.add('Models/ground_pit_new.ive')

#Select this for single-monitor desktop use...
#viz.go(viz.FULLSCREEN)
#OR select these for HMD/dual-monitor use:
viz.go(viz.STEREO | viz.FULLSCREEN)


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?')

#HMD field of view: (vert. FOV, aspect ratio H:V)
#viz.fov(53,1.1887) #Kaiser SR80 specs
viz.fov(43,1.395) #Cybermind specs

##Rename the main view ##
view = viz.MainView
#Link viewpoint with tracker, initialize boresite
if keyControl == 1: #If you're using the tracker
headTrack = viz.addSensor('intersense')#Ignore documentation stating you need "intersense.dls" - this is correct
linkedTracker = viz.link(headTrack, view) #Link the sensor to the view.
linkedTracker.preTrans([0,-.15,.14]) #Boresite function - translates the viewpoint from the tracker position to eyepoint position
# viz.link(headTrack, view) #Link the sensor to the view.
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)


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

#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

viz.phys.enable() # Enable physics
viz.MainView.gravity (0)

#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

fallAction = vizact.fall(-28.18)
riseAction = vizact.fall(1.82)

if view.getPosition(mode=viz.ABS_GLOBAL)[0] > -1 and view.getPosition(mode=viz.ABS_GLOBAL)[0] < 1:
if view.getPosition(mode=viz.ABS_GLOBAL)[2] > 5.375:
view.add(fallAction)
Risen = False

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

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

else:
view.add(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:
view.add(riseAction)
Risen = True
print 'normal view'

###### KEYBOARD CONTROL MODULE - DON'T TOUCH ######
if keyControl == 2: #If you're using the keyboard; defined at top
if viz.iskeydown(viz.KEY_UP): #If the up key is depressed
view.move(0,0,MOVE_SPEED*viz.elapsed(),viz.BODY_OR I) # Move view to z coordinate specified by speed*elapsed time
elif viz.iskeydown(viz.KEY_DOWN): #And so on and so forth
view.move(0,0,-MOVE_SPEED*viz.elapsed(),viz.BODY_ORI)
if viz.iskeydown(viz.KEY_RIGHT):
view.rotate(0,1,0,TURN_SPEED*viz.elapsed(),viz.BOD Y_ORI,viz.RELATIVE_WORLD)
elif viz.iskeydown(viz.KEY_LEFT):
view.rotate(0,1,0,-TURN_SPEED*viz.elapsed(),viz.BODY_ORI,viz.RELATIVE _WORLD)
#############################################


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
  #4  
Old 02-28-2008, 02:01 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
You need to post the code using the [code][/code] tags. This will preserve the indentation, which is necessary for running Python code.
Reply With Quote
  #5  
Old 03-01-2008, 11:03 AM
erchrastil erchrastil is offline
Member
 
Join Date: Feb 2008
Posts: 17
sorry, i'm new to this format so i thought it would preserve the tabs that were in place. here's the code again:


import viz
import vizact
import time
import math
import random
import winsound

ground = viz.add('Models/ground_2m.ive')
pit = viz.add('Models/ground_pit_new.ive')


viz.go(viz.STEREO | viz.FULLSCREEN)


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

##Rename the main view ##
view = viz.MainView
#Link viewpoint with tracker, initialize boresite
if keyControl == 1: #If you're using the tracker
headTrack = viz.addSensor('intersense')#Ignore documentation stating you need "intersense.dls" - this is correct
linkedTracker = viz.link(headTrack, view) #Link the sensor to the view.
linkedTracker.preTrans([0,-.15,.14]) #Boresite function - translates the viewpoint from the tracker position to eyepoint position
# viz.link(headTrack, view) #Link the sensor to the view.
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)

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

#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

viz.phys.enable() # Enable physics
viz.MainView.gravity (0)

#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

fallAction = vizact.fall(-28.18)
riseAction = vizact.fall(1.82)

if view.getPosition(mode=viz.ABS_GLOBAL)[0] > -1 and view.getPosition(mode=viz.ABS_GLOBAL)[0] < 1:
view.add(fallAction)
Risen = False
if view.getPosition(mode=viz.ABS_GLOBAL)[2] > 5.375:
view.add(fallAction)
Risen = False
elif view.getPosition(mode=viz.ABS_GLOBAL)[2] < 4.625 and view.getPosition(mode=viz.ABS_GLOBAL)[2] > -1.625:
view.add(fallAction)
Risen = False
elif view.getPosition(mode=viz.ABS_GLOBAL)[2] < -2.375:
view.add(fallAction)
Risen = False
else:
view.add(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:
view.add(riseAction)
Risen = True
print 'normal view'
###### KEYBOARD CONTROL MODULE - DON'T TOUCH ######
if keyControl == 2: #If you're using the keyboard; defined at top
if viz.iskeydown(viz.KEY_UP): #If the up key is depressed
view.move(0,0,MOVE_SPEED*viz.elapsed(),viz.BODY_OR I) # Move view to z coordinate specified by speed*elapsed time
elif viz.iskeydown(viz.KEY_DOWN): #And so on and so forth
view.move(0,0,-MOVE_SPEED*viz.elapsed(),viz.BODY_ORI)
if viz.iskeydown(viz.KEY_RIGHT):
view.rotate(0,1,0,TURN_SPEED*viz.elapsed(),viz.BOD Y_ORI,viz.RELATIVE_WORLD)
elif viz.iskeydown(viz.KEY_LEFT):
view.rotate(0,1,0,-TURN_SPEED*viz.elapsed(),viz.BODY_ORI,viz.RELATIVE _WORLD)
#############################################

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
Reply With Quote
  #6  
Old 03-03-2008, 12:54 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
I get a syntax error when trying to run your code. It doesn't seem like you used the [code][/code] tags. Just copy the contents of your script and paste them in between the tags.
Reply With Quote
  #7  
Old 03-03-2008, 09:09 PM
erchrastil erchrastil is offline
Member
 
Join Date: Feb 2008
Posts: 17
are there additional tags to indicate that the code is starting and ending? they are not clearly marked in any of the message options.

Code:
import viz
import vizact
import time
import math
import random
import winsound


viz.go(viz.STEREO | viz.FULLSCREEN)


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

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

    headTrack = viz.addSensor('intersense')#Ignore documentation stating you need "intersense.dls" - this is correct
    linkedTracker = viz.link(headTrack, view) #Link the sensor to the view.
    linkedTracker.preTrans([0,-.15,.14]) #Boresite function - translates the viewpoint from the tracker position to eyepoint position
    # viz.link(headTrack, view) #Link the sensor to the view.
    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)


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

#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

viz.phys.enable() # Enable physics
viz.MainView.gravity (0)

#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

    fallAction = vizact.fall(-28.18)
    riseAction = vizact.fall(1.82)

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

        view.add(fallAction)
        Risen = False

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

        view.add(fallAction)
        Risen = False

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

        view.add(fallAction)
        Risen = False

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

        view.add(fallAction)
        Risen = False

    else:

        view.add(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:

        view.add(riseAction)
        Risen = True
        print 'normal view'

    ###### KEYBOARD CONTROL MODULE - DON'T TOUCH ######
    if keyControl == 2: #If you're using the keyboard; defined at top

        if viz.iskeydown(viz.KEY_UP): #If the up key is depressed

            view.move(0,0,MOVE_SPEED*viz.elapsed(),viz.BODY_OR I) # Move view to z coordinate specified by speed*elapsed time

        elif viz.iskeydown(viz.KEY_DOWN): #And so on and so forth

            view.move(0,0,-MOVE_SPEED*viz.elapsed(),viz.BODY_ORI)

        if viz.iskeydown(viz.KEY_RIGHT):

            view.rotate(0,1,0,TURN_SPEED*viz.elapsed(),viz.BOD Y_ORI,viz.RELATIVE_WORLD)

        elif viz.iskeydown(viz.KEY_LEFT):

            view.rotate(0,1,0,-TURN_SPEED*viz.elapsed(),viz.BODY_ORI,viz.RELATIVE _WORLD)

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

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
Reply With Quote
Reply With Quote
  #8  
Old 03-04-2008, 06:56 AM
erchrastil erchrastil is offline
Member
 
Join Date: Feb 2008
Posts: 17
here is the code that should have all the tabs in the right place

Code:
import viz
import vizact
import time
import math
import random
import winsound

ground = viz.add('Models/ground_2m.ive')
pit = viz.add('Models/ground_pit_new.ive')

viz.go(viz.STEREO | viz.FULLSCREEN)


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

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

    headTrack = viz.addSensor('intersense')#Ignore documentation stating you need "intersense.dls" - this is correct
    linkedTracker = viz.link(headTrack, view) #Link the sensor to the view.
    linkedTracker.preTrans([0,-.15,.14]) #Boresite function - translates the viewpoint from the tracker position to eyepoint position
    # viz.link(headTrack, view) #Link the sensor to the view.
    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)


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

#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

viz.phys.enable() # Enable physics
viz.MainView.gravity (0)

#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

    fallAction = vizact.fall(-28.18)
    riseAction = vizact.fall(1.82)

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


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

			view.add(fallAction)
			Risen = False

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

			view.add(fallAction)
			Risen = False

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

			view.add(fallAction)
			Risen = False

		else:

			view.add(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:

        view.add(riseAction)
        Risen = True
        print 'normal view'

    ###### KEYBOARD CONTROL MODULE - DON'T TOUCH ######
    if keyControl == 2: #If you're using the keyboard; defined at top

        if viz.iskeydown(viz.KEY_UP): #If the up key is depressed

            view.move(0,0,MOVE_SPEED*viz.elapsed(),viz.BODY_ORI) # Move view to z coordinate specified by speed*elapsed time

        elif viz.iskeydown(viz.KEY_DOWN): #And so on and so forth

            view.move(0,0,-MOVE_SPEED*viz.elapsed(),viz.BODY_ORI)

        if viz.iskeydown(viz.KEY_RIGHT):

            view.rotate(0,1,0,TURN_SPEED*viz.elapsed(),viz.BODY_ORI,viz.RELATIVE_WORLD)

        elif viz.iskeydown(viz.KEY_LEFT):

            view.rotate(0,1,0,-TURN_SPEED*viz.elapsed(),viz.BODY_ORI,viz.RELATIVE_WORLD)

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

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
  #9  
Old 03-04-2008, 06:57 AM
erchrastil erchrastil is offline
Member
 
Join Date: Feb 2008
Posts: 17
again note that i've put in a model just so that i can tell where i am in the world, can be replaced with any generic ground plane.
Reply With Quote
  #10  
Old 03-04-2008, 09:57 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
I just ran your script using an Intersense InertiaCube2 and it ran fine. What kind of Intersense device are you connecting to?
Reply With Quote
  #11  
Old 03-05-2008, 08:11 AM
erchrastil erchrastil is offline
Member
 
Join Date: Feb 2008
Posts: 17
we have an intersense IS900. i tried it again making sure that all the vizard software is up-to-date and it's still not working. it is just fine with the keyboard, however.
Reply With Quote
  #12  
Old 03-06-2008, 09:47 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Can you post the entire output of your script, not just the last error. The error message you posted earlier implies that another error occurred before that one. It would make it easier to determine what is causing the problem.
Reply With Quote
  #13  
Old 04-25-2008, 07:30 AM
erchrastil erchrastil is offline
Member
 
Join Date: Feb 2008
Posts: 17
i am run it again after updating to the latest edition to vizard, and now it does not give me any error messages at all. however, it is still not creating the visual fall when i hook it up to the HMD and tracker (is900), even though it works on keyboard mode. it is definitely detecting that it is in the right location because it prints "in pit" in the appropriate location. could it be that the viewpoint is bound to the physical location of the tracker and so it won't fall?

Code:
import viz
import vizact
import time
import math
import random
import winsound

ground = viz.add('Models/ground_2m.ive')
pit = viz.add('Models/ground_pit_new.ive')

viz.go(viz.STEREO | viz.FULLSCREEN)


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

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

    headTrack = viz.addSensor('intersense')#Ignore documentation stating you need "intersense.dls" - this is correct
    linkedTracker = viz.link(headTrack, view) #Link the sensor to the view.
    linkedTracker.preTrans([0,-.15,.14]) #Boresite function - translates the viewpoint from the tracker position to eyepoint position
    # viz.link(headTrack, view) #Link the sensor to the view.
    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)


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

#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

viz.phys.enable() # Enable physics
viz.MainView.gravity (0)

#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

    fallAction = vizact.fall(-28.18)
    riseAction = vizact.fall(1.82)

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


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

			view.add(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:

			view.add(fallAction)
			print 'pit 2'
			Risen = False

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

			view.add(fallAction)
			print 'pit 3'
			Risen = False

		else:

			view.add(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:

        view.add(riseAction)
        Risen = True
        print 'normal view'

    ###### KEYBOARD CONTROL MODULE - DON'T TOUCH ######
    if keyControl == 2: #If you're using the keyboard; defined at top

        if viz.iskeydown(viz.KEY_UP): #If the up key is depressed

            view.move(0,0,MOVE_SPEED*viz.elapsed(),viz.BODY_ORI) # Move view to z coordinate specified by speed*elapsed time

        elif viz.iskeydown(viz.KEY_DOWN): #And so on and so forth

            view.move(0,0,-MOVE_SPEED*viz.elapsed(),viz.BODY_ORI)

        if viz.iskeydown(viz.KEY_RIGHT):

            view.rotate(0,1,0,TURN_SPEED*viz.elapsed(),viz.BODY_ORI,viz.RELATIVE_WORLD)

        elif viz.iskeydown(viz.KEY_LEFT):

            view.rotate(0,1,0,-TURN_SPEED*viz.elapsed(),viz.BODY_ORI,viz.RELATIVE_WORLD)

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

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
  #14  
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
  #15  
Old 06-11-2008, 02:24 PM
erchrastil erchrastil is offline
Member
 
Join Date: Feb 2008
Posts: 17
thanks, it worked!
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


All times are GMT -7. The time now is 04:14 PM.


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