WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Wiimote in 4 sided Cave (https://forum.worldviz.com/showthread.php?t=2041)

Sjaak 05-20-2009 05:58 AM

Wiimote in 4 sided Cave
 
Hello,

I want to use the buttons of the Wiimote to travel (no rotation) through a world projected in our Cave.

How can I do that? I don't see an example in the help neither on this forum. There are examples with the keyboard that work in the cave.

#Create another tracker using the keyboard and mouse (arrow keys adjust position, mouse changes orientation)
origintracker = viztracker.KeyboardMouse6DOF()

#Link the keyboard/mouse so that it moves the cave and user around the virtual environment
originlink = viz.link (origintracker, caveorigin)

But the wiimote?

Something like this?

def CaveTravel():
#take the caveorigin and move
# I don't know what to put here


vizact.onsensordown(wiimote,wii.BUTTON_A,CaveTrave l)

thanks
Sjaak

farshizzo 05-20-2009 09:13 AM

Here is some code that uses the arrow keys on the wiimote to change the position of an object:
Code:

MOVE_SPEED = 5 # meters/sec

def WiiMove():
       
        elapsed = viz.elapsed()

        state = wiimote.state

        if state & wii.BUTTON_LEFT:
                caveorigin.setPosition([-MOVE_SPEED*elapsed,0,0],viz.REL_LOCAL)
        if state & wii.BUTTON_RIGHT:
                caveorigin.setPosition([MOVE_SPEED*elapsed,0,0],viz.REL_LOCAL)
        if state & wii.BUTTON_UP:
                caveorigin.setPosition([0,0,MOVE_SPEED*elapsed],viz.REL_LOCAL)
        if state & wii.BUTTON_DOWN:
                caveorigin.setPosition([0,0,-MOVE_SPEED*elapsed],viz.REL_LOCAL)
vizact.ontimer(0, WiiMove)

Let me know if this doesn't do what you want.

Sjaak 05-20-2009 01:05 PM

Thank you.

In your code you use a timer. Is it not better to react on event? I think the timer checks every often unneccesary. Or is that not possible.

I test the code next week.


All times are GMT -7. The time now is 07:15 PM.

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