WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   euler problems in Vizard 3.0 (https://forum.worldviz.com/showthread.php?t=1182)

v-clizzin 08-15-2007 04:07 PM

euler problems in Vizard 3.0
 
Hi, I am running the following code in Vizard, and setting an avatar's head to follow the tracked euler does not work.

Code:

import viz
viz.go(viz.HMD + viz.STEREO + viz.TRACKER)

PORT_INTERSENSE = 3

# set up tracking
if viz.get(viz.TRACKER):
        headIsense = viz.add('intersense.dls')
        ppt = viz.add('vizppt.dls')
        ppt.command(5,'',5)        #Average over 5 samples
        #Automatically track head position and orientation
        viz.tracker()

avatar = viz.addAvatar('Male.cfg')
head = avatar.getBone('skel_Head')
head.lock()

def mytimer(num):
        #Rotate head
        euler = viz.get(viz.HEAD_EULER)
        head.setEuler(euler[2],euler[0],euler[1])        # works correctly, despite moving euler element indices!
        #head.setEuler(euler[0],euler[1],euler[2])        # does not work correctly!

viz.callback(viz.TIMER_EVENT, mytimer)
viz.starttimer(1,0.01,viz.FOREVER)

As you can see above, I have to move the indices of the euler elements one over to the right in order to get the avatar's head to rotate correctly. This is confusing, because the Vizard documentation says that both viz.get(viz.HEAD_EULER) and node3d.setEuler() order euler elements as [yaw, pitch, roll]. I'd appreciate advice on whether there's been some upgrade of Vizard I need to download. I'm currently running version 3.00.2051.

Thank you!
Christopher Lin

farshizzo 08-15-2007 05:52 PM

The default behavior when setting the euler of a bone, is to set it in its local coordinate system. Since the head bone is the child of other bones, its local coordinate system does not match up with the world coordinate system. If you want to rotate the head bone in world coordinates, try the following:
Code:

head.setEuler(euler,viz.AVATAR_WORLD)
This will rotate the bone in the avatars world coordinate frame.

v-clizzin 08-16-2007 04:23 PM

Great, thanks a lot! That worked just fine.

By the way, is there a list of the viz module's constants with descriptions of what they do, particularly for the constants that have to do with the types of coordinate systems? (I hadn't heard of viz.AVATAR_WORLD before now.) I've looked through the documentation, but can only find lists of methods/functions. Thanks!

farshizzo 08-16-2007 06:10 PM

The viz.AVATAR_WORLD value is mentioned in the command reference for all the bone transform commands (i.e. bone.setEuler, bone.setQuat, etc...)


All times are GMT -7. The time now is 03:26 AM.

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