WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 02-18-2010, 09: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
  #2  
Old 02-18-2010, 09:55 AM
jvacare1 jvacare1 is offline
Member
 
Join Date: Aug 2009
Posts: 6
never mind! found the answer i think

The post:

http://forum.worldviz.com/showthread.php?t=373

Seems to have the answer! Just didn't find it in my initial searches. I'll try it out now to see if it works! I think it's exactly what I needed. I was looking for a property on the MainView to do the same kind of thing.
Reply With Quote
  #3  
Old 02-18-2010, 11:25 AM
jvacare1 jvacare1 is offline
Member
 
Join Date: Aug 2009
Posts: 6
still a little bit of odd behavior

So now the script turns velocity off when the mouse is disabled. That fixes the problem of residual velocity, but there is still a strange issue when the mouse is re-enabled. It is as if the mouse's left button state of being pressed is being remembered through the mouse disabling / re-enabling.

Normal mouse navigation occurs when the left mouse button is held and the mouse is moved. If the left mouse button is released, mouse navigation seems to stop.

The odd behavior after the mouse state is enabled is that the MainView behaves as though the left mouse button is being pressed, even though it is not. Whatever direction the mouse pointer happens to be relative to the MainView, the MainView moves / rotates in that direction. (e.g. if the mouse pointer happens to be to the right and above the MainView center, the MainView will navigate forward and spin to the right). This is occuring even though the mouse isn't being touched at the time. If I subsequently press the left mouse button, the MainView navigates normally, and when the button is released, it returns to normal behavior.

Since the mouse is being disabled while the left mouse button is pressed, my guess is that that key state is being preserved through the disabling.

Is there a way to manually change the script's awareness of the left mouse button state? Or is there a better way to do that?

Thanks,

Jason

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

def NavigationLockDown():
  viz.velocity(0,0,0)
  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(PitCover.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
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Navigating an avatar using mouse position(2D) in 3D environment james007 Vizard 1 10-16-2009 12:29 PM
how to do it using mouse nasr Vizard 0 05-12-2009 03:38 AM
Mouse problem steve Vizard 7 07-14-2005 04:01 PM
Draw Line between Points selected by mouse Johannes Vizard 7 01-07-2005 03:50 PM
Halting mouse view-transforms FlyingWren Vizard 1 10-01-2003 06:29 PM


All times are GMT -7. The time now is 02:14 AM.


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