#1
|
|||
|
|||
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() |
#2
|
|||
|
|||
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. |
#3
|
|||
|
|||
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() |
Thread Tools | |
Display Modes | Rate This Thread |
|
|
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 11:29 AM |
how to do it using mouse | nasr | Vizard | 0 | 05-12-2009 02:38 AM |
Mouse problem | steve | Vizard | 7 | 07-14-2005 03:01 PM |
Draw Line between Points selected by mouse | Johannes | Vizard | 7 | 01-07-2005 02:50 PM |
Halting mouse view-transforms | FlyingWren | Vizard | 1 | 10-01-2003 05:29 PM |