WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 08-30-2009, 09:40 AM
jvacare1 jvacare1 is offline
Member
 
Join Date: Aug 2009
Posts: 6
Question More specific flow control questions

Thanks for the reply. I had looked at tasks initially, but got a little lost in their implementation. After your suggestion that they are the appropriate way to proceed, I took a closer look.

I integrated my task into a hot spot event. When a particular hot spot is entered it executes a hot spot event handler, which schedules the desired task:

Code:
# define the hotspot events
SETUP1, SETUP2, TRIAL = 1, 2, 3
def HotSpotHandler(id, x, y, z):
  if id == TRIAL:
    viztask.schedule(PerformTrialTask)
  else:
    viz.starthotspot(TRIAL, viz.RECTANGLE_HOTSPOT_IN, 0, 4, 2, .5)
viz.callback(viz.HOTSPOT_EVENT, HotSpotHandler)
viz.starthotspot(SETUP1, viz.RECTANGLE_HOTSPOT_IN, -20, 10, 2, .5)
viz.starthotspot(SETUP2, viz.RECTANGLE_HOTSPOT_IN, 20, 10, 2, .5)

# perform the trial task
def PerformTrialTask():
  while True:
    # prepare the next setup hot spots
    viz.starthotspot(SETUP1, viz.RECTANGLE_HOTSPOT_IN, -20, 10, 2, .5)
    viz.starthotspot(SETUP2, viz.RECTANGLE_HOTSPOT_IN, 20, 10, 2, .5)

    # move into position
    viz.MainView.goto([0, 1.82, 4])
    viz.MainView.lookat(PitCover.getPosition())
		
    # process question
    yield TrialSubTask()

# sub task to handle question / answer
def TrialSubTask():
  while True:
    global PromptText
    PromptText = viz.addText('What will you do?\n\n\'J\' - Try to jump over.\n\'A\' - Use assistance.', viz.SCREEN, scene=1)
    PromptText.setScale([.5, .5, 1])
    PromptText.translate(0.05, 0.9)
    DataObject = viz.Data
    yield viztask.waitEvent(viz.KEYDOWN_EVENT, DataObject)

    # process answer
    PromptText.remove()
    if DataObject.data[0] == 'j':
      viz.MainView.goto([0, 1.82, 9], 5, viz.SPEED)
      viz.MainView.lookat(0, 1.82, 100)
      return;
    elif DataObject.data[0] == 'a':
      viz.MainView.goto([0, 1.82, 7], 5, viz.SPEED)
      viz.MainView.lookat(0, 1.82, 100)
      return;
This seems to function as expected except that when I run the script I am still able to navigate the view point around while the task is waiting for the KEYDOWN_EVENT. We want the simulation to essentially ignore all input except for the two keypresses. I thought the "while True" loops might accomplish this, as presented in the tutorial, but I am still able to navigate around the maze while the task is running and waiting.

Can you describe how I might prevent that navigation? Let me know if this question isn't specific enough and I'll try again.

Thanks,

Jason
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
adding more than 1 action for avatar animation slider control yak Vizard 0 07-21-2009 12:22 PM
orientation question whj Vizard 3 01-21-2009 12:22 PM
Control of timers vizmaster Vizard 6 08-22-2008 10:36 AM
General question and question regarding arrays dan12345 Vizard 1 01-15-2008 11:15 AM
to rephrase my question... shai Vizard 2 10-27-2004 11:55 AM


All times are GMT -7. The time now is 12:26 AM.


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