View Single Post
  #1  
Old 02-18-2010, 08:37 AM
jvacare1 jvacare1 is offline
Member
 
Join Date: Aug 2009
Posts: 6
how to remove velocity when mouse is disabled?

I have an environment in which there is a hotspot which detects the arrival of the mainview. When the mainview arrives in the hotspot, the script disables the mouse while a scheduled task waits for user input.

The problem is that if the mouse is being used to navigate the mainview, any velocity or rotational velocity is preserved when the mouse is disabled. This means that if the mouse navigates the mainview into the hotspot, and the mouse is disabled, the mainview seems to continue to spin, move forward, or whatever the last command of the mouse input was.

Is there a way to set the velocity and rotational velocity of the mainvew to zero after disabling the mouse, to remove this effect?

A simplified version of my environment script (which still exihibits the problem) is below.

Thanks,

Jason

Code:
import viz, viztask, random, time, re, os
viz.go()
viz.gravity(viz.ON)

def NavigationLockDown():
  viz.mouse(viz.OFF)

def NavigationUnlock():
  viz.mouse(viz.ON)

def HotSpotHandler(id, x, y, z):
  NavigationLockDown()
  viztask.schedule(PerformTrialTask())

def InitiateHotSpot():
  viz.callback(viz.HOTSPOT_EVENT, HotSpotHandler)
  viz.starthotspot(3, viz.RECTANGLE_HOTSPOT_IN, 0, 4, 2, .5)

def PerformTrialTask():
  viz.MainView.goto([0, 1.82, 4])
  viz.MainView.lookat(ThingOfInterest.getPosition())
  d = viz.Data
  PROMPT_TEXT = viz.addText('What will you do?', viz.SCREEN, scene=1)
  PROMPT_TEXT.setScale([.5, .5, 1])
  PROMPT_TEXT.translate(0.05, 0.9)
  Keys = ('a', 'j')
  while True:
    yield viztask.waitKeyDown(Keys, d)
    if (d.key == 'j'):
      NavigationUnlock()
      return

    elif (d.key == 'a'):
      NavigationUnlock()
      return

InitiateHotSpot()
Reply With Quote