def interaction(e):
    if e.sensor == maleSensor:
        female.addAction(vizact.animation(2))
        male.addAction(vizact.animation(3))
    else:
        male.addAction(vizact.animation(4))
        pigeon.state(3)
Exemple #2
0
def walkToFemale():
	yield viztask.addAction(male, walkToFaceFemale)
	female.state(29)
	male.lookAt(FEMALE_POSITION)
	male.runAction(vizact.animation(35))
	yield viztask.waitTime(4)
	yield viztask.runAction(male, walkNextToFemale)
	female.state(3)
	male.runAction(vizact.animation(3))
Exemple #3
0
def go():
  man.state(162)
  woman.state(35) # doesn't work
  yield viztask.addAction(woman, vizact.walkTo([1.35,0,-1.35]))
  yield viztask.addAction(man, vizact.animation(11))
  yield viztask.addAction(woman, vizact.turn(-145))
  # woman.state(86)
  # woman.state(142)
  man.state(7)
  while True:
    # goes to a weird animatin in-between
    yield viztask.addAction(woman, vizact.animation(143))
    yield viztask.addAction(woman, vizact.animation(144))
Exemple #4
0
def luigiActions():
    yield viztask.waitTime(53)
    yield viztask.addAction(luigi, vizact.walkTo([-0, 0, 4]))
    yield viztask.addAction(luigi, vizact.walkTo([-1, 0, 3], turnInPlace=True))
    yield viztask.addAction(luigi, vizact.walkTo([0, 0, 2]))
    yield viztask.addAction(luigi, vizact.turn(0, 220))
    yield viztask.addAction(luigi, vizact.animation(4))
def moveBackwards( node, seat ):
	global seatQueue
	spin = vizact.turn(145)
	moveHead = vizact.headto(25,0,0, bone='Bip01 Head')
	move = vizact.moveTo(pos=seat,speed=0.75,interpolate=vizact.easeInOut)
	slide = vizact.animation(66)
	shuffle = vizact.parallel(spin,moveHead,move,slide)
	shuffleBack = vizact.sequence(shuffle)
	node.add(shuffleBack)
	yield viztask.waitActionEnd(node,shuffleBack)
	node.setPosition(seat)
Exemple #6
0
def myTask():
	while True:
		question_text.message('Hit the spacebar to begin.')
		yield viztask.waitKeyDown(' ')
		female.state(5)
		yield viztask.waitTime(1)
		yield viztask.addAction(male, vizact.walkTo([-1,-0,0]))
		male.state(5)
		yield mySubTask()
		male.state(9)
		yield viztask.addAction(female,vizact.animation(6))
		male.addAction( vizact.walkTo( [2,0,-1],2.5,90,11 ) )
def moveBackToFirstSeat( node, seatQueue ):
	yield viztask.waitTime(1)
	spin = vizact.turn(145)
	moveHead = vizact.headto(25,0,0, bone='Bip01 Head')
	moveFirst = vizact.moveTo(pos=seatQueue[2],speed=0.75,interpolate=vizact.easeInOut)
	moveSecond = vizact.moveTo(pos=seatQueue[1],speed=0.75,interpolate=vizact.easeInOut)
	moveThird = vizact.moveTo(pos=seatQueue[0],speed=0.75,interpolate=vizact.easeInOut)
	slide = vizact.animation(66)
	slideBackOnce = vizact.parallel(spin,moveHead,moveFirst,slide)
	slideBackTwice = vizact.parallel(spin,moveHead,moveSecond,slide)
	slideBackThrice = vizact.parallel(spin,moveHead,moveThird,slide)
	shuffleToFirst = vizact.sequence(slideBackOnce,slideBackTwice,slideBackThrice)
	node.add(shuffleToFirst)
	yield viztask.waitActionEnd(node,shuffleToFirst)
	node.setPosition(seatQueue[0])
Exemple #8
0
def walkAndAnimate():
    while True:

        # yield waits until a task is finished before progressing to the next one
        # walks to the left side of the user, by the bench
        yield viztask.addAction(manuel,
                                vizact.walkTo([2.4, 0, 2.57996], walkSpeed=2))
        yield viztask.addAction(manuel, vizact.turn(-45, 220))

        # change the position and rotation of the linked guitar
        link.setOffset([-0.5, 0.05, -0])
        link.setEuler([-45, 0, 70])

        # pauses animations for 13 seconds so the guitar playing animation is in sync with audio
        yield viztask.waitTime(13)

        # locking of bones and setting their positions/rotations so left arm of 'manuel' will 'play' the guitar
        upperarm = manuel.getbone('Bip01 L UpperArm')
        upperarm.lock()
        upperarm.setEuler(0, 0, 0)

        forearm = manuel.getBone('Bip01 L Forearm')
        forearm.lock()
        forearm.setEuler(0, 0, -120)

        hand = manuel.getBone('Bip01 L Hand')
        hand.lock()
        hand.setEuler(0, 180, 45)

        #luigi.addAction(vizact.animation(4,speed =1))
        for num in range(0, 11):
            yield viztask.addAction(manuel, vizact.animation(4))

        #unlocks bones
        upperarm.unlock()
        forearm.unlock()
        hand.unlock()

        # kill task when done
        animationTask.kill()
Exemple #9
0
def myTask():
    #As long as the task is running . . .
    while True:
        question_text.message( 'Hit the spacebar to begin.' )
        #Wait for a keypress.
        yield viztask.waitKeyDown( ' ' )
        #Animate the female.
        female.state( 5 )
        #Wait for a second.
        yield viztask.waitTime( 1 )
        #Make the male walk and wait for him to finish the action.
        yield viztask.addAction( male,  vizact.walkTo( [-1,0,0] ) )
        #Make the male dance.
        male.state( 5 )
        #Wait for a sub task to finish.
        yield mySubTask()
        #Give the male a new animation.
        male.state(9)
        #Give the female a new animation and wait for it to finish.
        yield viztask.addAction( female, vizact.animation(6) )
        #Make the male run.
        male.addAction( vizact.walkTo( [2,0,-1],2.5,90,11 ) )
Exemple #10
0
    def updateWalkTarget(self, evtData):
        # this function will be called after any action is finished
        # however: only update avatars
        if isinstance(evtData.object, VizAvatar):

            # if avatar is walker
            if evtData.object.getAvType() == 'walker':

                # if there is less than X clones around
                if len(self.actors) < ct.N_CLONES:

                    # if we need a clone of this context
                    if len([
                            cl.getCtx() for cl in self.actors
                            if cl.getCtx() == evtData.object.getCtx()
                    ]) < ct.N_CLONES / 2:

                        # if this walker has not a clone already
                        if not evtData.object.getAvID() in [
                                cl.getAvID() for cl in self.actors
                        ]:

                            # copy avatar to clone and assign orig ID
                            cClone = evtData.object.copy()
                            cClone.setAvType('clone')

                            # DEBUGGING -> set clone to transparent
                            #cClone.alpha(0.5)

                            # set walker avatar to invisible
                            # -> allows to continue walking
                            evtData.object.visible(viz.OFF)
                            evtData.object.isVisible = 0

                            # queue process to look for path to closest entrance
                            self.homeTargetFinder.findPath(
                                evtData.object.getPosition(), cClone.getCtx(),
                                cClone.getAvID())

                            # assign animation
                            if not self.oneCtx:
                                do = vizact.animation(random.randint(6, 10))
                            else:
                                # draw from all animations
                                anInds = [6, 7, 8, 9, 10, 14, 15, 16, 17, 18]
                                random.shuffle(anInds)
                                do = vizact.animation(anInds[0])
                            cClone.addAction(do,
                                             viz.tick())  # override addAction

                            # save this clone in list
                            self.actors.append(cClone)

                            #print "Orig: ", evtData.object.getAvID()
                            #print "Clone: ", cClone.getAvID()

                # assign next routing point to orig avatar
                self.routeAvatar(evtData.object.getAvID())

            # if avatar is clone
            elif evtData.object.getAvType() == 'clone':

                cClone = evtData.object

                # did clone complete current action?
                if cClone.isActionReady():

                    # if clone arrived at pZone
                    if cClone.hasArrived:

                        # we are reaching our destination
                        if cClone.isInHouse:

                            # remove clone, update clone list
                            cClone.pZone.pNode.setAnimationState(viz.STOP,
                                                                 node='door')

                            # set walker to visible
                            for cA in self.avatars:
                                if cA.getAvID() == cClone.getAvID():
                                    cA.visible(viz.ON)
                                    cA.isVisible = 1
                                    # DEBUGGING: set to transparent
                                    #cA.alpha(0.5)
                                    break

                            # remove clone node from scene and actors list
                            cClone.remove()
                            self.actors = [
                                cl for cl in self.actors
                                if cl.getAvID() is not cA.getAvID()
                            ]

                            #print "actors: ", self.actors

                            return

                        else:
                            # walk in house
                            dX, dY, dZ = cClone.pZone.getDoorXYZ()
                            walk = viz.ActionData()
                            walk.data = [
                                dX, dY, dZ, viz.AUTO_COMPUTE, None,
                                vizact.ROTATION_SPEED
                            ]  # prevents animation from resetting
                            walk.verb = 'walk'
                            walk.turnInPlace = False
                            walk.actionclass = vizact.VizWalkRotAction
                            # add walk action
                            cClone.addAction(walk)
                            cClone.isInHouse = 1
                            return

                    # check whether this clone has been assigned to a path already
                    # returns [] if not ready yet
                    if not cClone.path:
                        # poll queue
                        pData = self.homeTargetFinder.getTarget(
                            cClone.getAvID())

                        # if path is ready
                        if pData:
                            #print pData
                            cClone.path = pData["path"]
                            cClone.pZone = self.deliveryHdl.pZones[
                                pData["targetInd"]]

                            cClone.nPathSteps = len(cClone.path)
                            cClone.cPathStep = 0

                            # start walk animation
                            cClone.state(2)

                    # walk!
                    if cClone.path:

                        # increase pathstep
                        cClone.cPathStep = cClone.cPathStep + 1

                        # if we reached middle of path -> stay a while and do an animation
                        if cClone.cPathStep == round(cClone.nPathSteps / 2.0):
                            # assign animation
                            if not self.oneCtx:
                                do = vizact.animation(random.randint(6, 10))
                            else:
                                # draw from all animations
                                anInds = [6, 7, 8, 9, 10, 14, 15, 16, 17, 18]
                                random.shuffle(anInds)
                                do = vizact.animation(anInds[0])

                            cClone.addAction(do, viz.tick())

                        # walk
                        else:
                            # if this is the last waypoint
                            if len(cClone.path) == 1:

                                # open door
                                cClone.pZone.pNode.setAnimationState(
                                    viz.STOP, node='door')
                                cClone.pZone.pNode.setAnimationSpeed(
                                    2, node='door')
                                cClone.pZone.pNode.setAnimationState(
                                    viz.PLAY, node='door')

                                cClone.hasArrived = 1

                            # walk
                            wp = cClone.path.pop(0)
                            walk = viz.ActionData()
                            # flip y coord to get to world space
                            walk.data = [
                                wp[0], 0, wp[1], viz.AUTO_COMPUTE, None,
                                vizact.ROTATION_SPEED
                            ]  # prevents animation from resetting
                            walk.verb = 'walk'
                            walk.turnInPlace = False
                            walk.actionclass = vizact.VizWalkRotAction

                            # add walk action
                            cClone.addAction(walk)

                    else:
                        # assign animation
                        if not self.oneCtx:
                            do = vizact.animation(random.randint(6, 10))
                        else:
                            # draw from all animations
                            anInds = [6, 7, 8, 9, 10, 14, 15, 16, 17, 18]
                            random.shuffle(anInds)
                            do = vizact.animation(anInds[0])

                        cClone.addAction(do, viz.tick())
BUS_OSGB_SCALE = 35
curscale = BUS_OSGB_SCALE
bus = viz.add('bus_obj/Bus_Sept3.OSGB')
bus.setScale([curscale]*3)

#adjust to correct main viewpoint
viz.MainView.setPosition(-3, 1.82, 1.5)
viz.MainView.setEuler(105, -0.0, 0.0)

def reset():
  ORI_TRACKER.reset()
vizact.onkeydown('r', reset)

# add homeless avatars
homeless1 = viz.addAvatar('Homeless Avatars/CC2_m006_hipoly_A2_v2.cfg', pos=(-1.8,.45,0), euler=(100, 0, 0))
homeless1.addAction(vizact.animation(68))

#add Bus Lights
busLight = viz.add('Bus Light.vzf')
busLight.setPosition([-6.1, -2.7, 2.9])
busLight.setEuler([180.0, 90.0, 180.0])

bus_light = viz.addLight()
bus_light.position( 0,0,0,1 )
viz.link( busLight, bus_light )
busLight.emissive(viz.WHITE)
bus_light.color(viz.WHITE)
intensity = .15
bus_light.intensity(intensity)
bus_light.linearattenuation( 3 )
Exemple #12
0
def talk() :
	while True:
		yield viztask.waitKeyDown('1')
		yield viztask.addAction(avatar, vizact.animation(65))
		yield viztask.addAction(cat, vizact.animation(3))
def react():
	male.state(2)
	wait = vizact.waittime(3)
	scratchAndShrug = vizact.sequence(wait, vizact.animation(4),vizact.animation(6))
	male.add(scratchAndShrug)
Exemple #14
0
# load the avatars and set starting position
manuel = viz.addAvatar('vcc_male.cfg')
manuel.setPosition(-0.3, 0, -2.82)

luigi = viz.addChild('vcc_male2.cfg')
luigi.setPosition([-2, 0, 6])

# link the guitar to the back model
back = manuel.getBone('Bip01 Neck')
link = viz.link(back, guitar)

# manuel walking in, closing the door, and 'talking' to the user
manuel.addAction(vizact.walkTo([-0.48, 0, -1.15234], walkSpeed=2.0))
manuel.addAction(vizact.turn(160, 220))
manuel.addAction(vizact.animation(15, speed=2.2))
manuel.addAction(vizact.turn(0, 220))
manuel.addAction(vizact.walkTo([-0.5, 0.0, 2], walkSpeed=1.2))
manuel.addAction(vizact.turn(30, 220))
manuel.addAction(vizact.animation(14, speed=2))
manuel.addAction(vizact.animation(14, speed=2))
manuel.addAction(vizact.turn(0, 220))
manuel.addAction(vizact.walkTo([-2, -0.00000, 6.02116], walkSpeed=2))
manuel.addAction(vizact.animation(3, speed=0.7))
manuel.addAction(vizact.turn(160, 220))
manuel.addAction(vizact.walkTo([-0.5, 0.0, 2], walkSpeed=2))


# handling actions of luigi
def luigiActions():
    yield viztask.waitTime(53)