WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   passing data to viz.director (https://forum.worldviz.com/showthread.php?t=358)

vadrian 05-18-2005 03:07 PM

passing data to viz.director
 
is there a way to pass information to vis.director(func)? I have an array of people i want to blink, and this is my setup, but i don't see it working:

Code:

class Person(viz.VizAvatar, viz.EventClass):
...
    def _blink(self):
        self._head.morph(0,1.0,0.1)
        viz.waittime(BLINK_DURATION)
        self._head.morph(0,0.0,0.1)
        viz.starttimer(TIMER_BLINK, random.uniform(BLINK_DELAY_MIN, BLINK_DELAY_MAX))

    def _ontimer(self, num):
        if num == TIMER_BLINK:
            viz.director(self._blink)

i don't think "self" is getting passed into blink(). is there a better way to make an avatar blink on its own (I dont want to have N timers or N blink funtions)

EDIT: my reason for the director function is because i need the waittime. otherwise the blink happens too fast and looks unnatural.

farshizzo 05-18-2005 03:30 PM

Hi,

How is it not working? From what I can tell it should work fine. Anyway, to answer your question, you can pass arguments to director functions. Example:
Code:

def func(x,y,z):
    print x,y,z

viz.director(func,1,2,3)
viz.director(func,4,5,6)

There are a bunch of ways to make an avatar blink. You could use timers, director functions, or node actions. If I had to choose I would use node actions. Take a look in the documentation under the "Actions" section. Here is how you could create a blink action:
Code:

#Create action that will make a face blink
blinkAction = vizact.sequence(vizact.waittime(vizact.randfloat(BLINK_DELAY_MIN, BLINK_DELAY_MAX)),vizact.morph(0,1.0,0.1),vizact.waittime(BLINK_DURATION),vizact.morph(0,0.0,0.1),viz.FOREVER)

#Add the action to the face object
avatar._head.add(blinkAction)

As you can tell, I really like creating long unreadable lines of code ;)

If you use the above example then you might need to change the BLINK_DURATION value since the actions are performed sequentially.


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

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