WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Making avatar point with hand towards (https://forum.worldviz.com/showthread.php?t=1547)

dan12345 07-03-2008 04:58 AM

Making avatar point with hand towards
 
Hi,
I'm trying to manipulate an avatar, so it points with its hand towards different points ( for example having the avatar point at the viewpoint consistently throughout the script ).
I tried to duplicate the code in the follow-that-gaze tutorial, but with different bones (shoulders, arms...), but didn't get any sensible graphic result.
Could you please help?

Just to clarify - i simple want the whole arm to point at a given direction....

thanks!
dan.

farshizzo 07-07-2008 11:34 AM

I created a simple BonePointer class that allows you to specify a bone and where to point it at. This example will create an avatar and have it point its right arm towards the viewpoint. Let me know if anything is unclear.
Code:

import viz
viz.go()

class BonePointer(object):
        """Class for pointing a bone at a specified point"""
        def __init__(self,bone,offset=None):
               
                self._node = viz.addGroup()
                self._node.visible(0)
               
                self._bone = bone
               
                #Get offset matrix to child bone
                if offset is None:
                        srcPos = bone.getPosition(viz.AVATAR_LOCAL)
                        dstPos = bone.getChildren()[0].getPosition(viz.AVATAR_LOCAL)
                        self._node.setPosition(srcPos)
                        self._node.lookat(dstPos)
                        self._offset = viz.Matrix.quat(self._node.getQuat())
                else:
                        self._offset = viz.Matrix(offset)
                self._offset.invert()
       
        def pointAt(self,pos):
                """Point the bone at the specified position"""
                srcPos = self._bone.getPosition(viz.AVATAR_WORLD)
                self._node.setPosition(srcPos)
                self._node.lookat(pos)
                m = viz.Matrix.quat(self._node.getQuat())
                m.preMult(self._offset)
                self._bone.setQuat(m.getQuat(),viz.AVATAR_WORLD)
               
               
#Add avatar
model = viz.add('vcc_female.cfg',euler=(180,0,0))

#Create pointer object for shoulder bone
pointer = BonePointer(model.getBone('Bip01 R UpperArm'))

#Setup timer to update pointer every frame
def UpdatePointer():
        pointer.pointAt(viz.MainView.getPosition())
vizact.ontimer(0,UpdatePointer)


krimble 08-03-2017 07:07 AM

Thank you for this class!

I'm wondering how can I use .boneSpinTo() to have the avatar point at a certain position?

I would like to make an animation sequence of pointing to an object and going back to it's neutral pose again.

Can someone help me with this?

Thank you.

krimble 08-04-2017 12:13 AM

I found that the boneSpinTo function has an option that allows to put in a position vector.
However this doesn't result in correct behaviour. It seems to point at a random direction.

I tried playing around with the different modes, with no succes.

Code:

import viz
viz.go()

point = vizact.boneSpinTo('Bip01 R UpperArm',mode=viz.AVATAR_WORLD,point=viz.MainView.getPosition(),speed=90)

#Add avatar
model = viz.add('vcc_female.cfg',euler=(180,0,0))

def mykeyboard(key):
        if key == " " :
                model.runAction(point)
               
viz.callback(viz.KEYBOARD_EVENT,mykeyboard)


How can I make my avatar point at a certain location and when done go back to it's original position?

Thank you!

krimble 08-07-2017 04:48 AM

I tried putting a position point in the bonespinto function. This gives strange results. For example when I move the mainview to a position from where the avatar is visible and press spacebar the arm moves but not the the correct position.
Also after pressing spacebar a second time without moving the mainview the arm moves. Why is this, this shouldn't happen right?

Code:

import viz
viz.go()

point = vizact.boneSpinTo('Bip01 R UpperArm',mode=viz.AVATAR_WORLD,point=viz.MainView.getPosition(),speed=90)

#Add avatar
model = viz.add('vcc_female.cfg',euler=(180,0,0))

def mykeyboard(key):
        if key == " " :
                model.runAction(point)
               
viz.callback(viz.KEYBOARD_EVENT,mykeyboard)

I would like to make an animation sequence of an avatar pointing to an object and going back to it's neutral pose again.

Can someone help me with this?

Thank you!

Jeff 08-09-2017 11:05 PM

I think the issue maybe that the center of the bone spins to the correct location but the bone center is not necessarily facing the same direction as the end of the bone, which is what you want in this case. It maybe necessary to calculate an offset for the spinto point or orientation. I'll check with a developer for suggestions.

krimble 08-10-2017 05:01 AM

Thank you. Looking forward to your reply.

krimble 08-17-2017 06:12 AM

Hi Jeff,
is there any news on the boneSpinTo a position problem?

Thank you.

Best,
Jeroen Derks


All times are GMT -7. The time now is 01:17 AM.

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