WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Cannot moving AR model...... (https://forum.worldviz.com/showthread.php?t=4194)

allanjjj 04-05-2012 07:27 PM

Cannot moving AR model......
 
I would like to animate AR model by keyboard input after the model is shown by detecting marker. The model is shown correctly in the center of marker but it cannot move. It just sticks on the marker no matter what key I pressed. Here is the code:

import viz
import vizact
viz.go()

ar = viz.add('artoolkit.dle')
camera = ar.addWebCamera()
marker = camera.addMarker('ar/patt.worldviz',width=1000)
wheel = viz.add('wheelbarrow.ive')
viz.link(marker,wheel)

moveForward = vizact.move(0,0,2,1)
moveBack = vizact.move(0,0,-2,1)
turnRight = vizact.spin(0,1,0,90,1)
turnLeft = vizact.spin(0,1,0,-90,1)

def mykeyboard(whichKey):
if whichKey == viz.KEY_UP:
wheel.addAction(moveForward)
elif whichKey == viz.KEY_DOWN:
wheel.addAction(moveBack)
elif whichKey == viz.KEY_LEFT:
wheel.addAction(turnLeft)
elif whichKey == viz.KEY_RIGHT:
wheel.addAction(turnRight)

viz.callback(viz.KEYDOWN_EVENT, mykeyboard)


Can anyone help me out? many thanks~

Darkmax 04-08-2012 07:48 PM

welcome to the forum.
Is because the viz.link, you need to make postTrans or preTrans or you can use these command .setGlobalMarker(marker) to make the marker the center of your virtual world and apply actions like you are doing instead of using the link, but with these you just can use one marker at the same time.

please use the code tags the next time when you want to show your code to maintain the spaces.

with setGlobalMarker
Code:

import viz
import vizact
viz.go()

ar = viz.add('artoolkit.dle')
camera = ar.addWebCamera()
marker = camera.addMarker('ar/patt.worldviz',width=1000)
wheel = viz.add('wheelbarrow.ive')
camera.setGlobalMarker(marker)

moveForward = vizact.move(0,0,2,1)
moveBack = vizact.move(0,0,-2,1)
turnRight = vizact.spin(0,1,0,90,1)
turnLeft = vizact.spin(0,1,0,-90,1)

def mykeyboard(whichKey):
        if whichKey == viz.KEY_UP:
                wheel.addAction(moveForward)
        elif whichKey == viz.KEY_DOWN:
                wheel.addAction(moveBack)
        elif whichKey == viz.KEY_LEFT:
                wheel.addAction(turnLeft)
        elif whichKey == viz.KEY_RIGHT:
                wheel.addAction(turnRight)
viz.callback(viz.KEYDOWN_EVENT, mykeyboard)



All times are GMT -7. The time now is 05:00 AM.

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