def SackAnim (self, sid): #sid is the sack id: {1R, 2R, 1L, or 2L} self._usedSackCounter += 1 sack = self.components['sack'+sid] self.sack_path = self.sackItem.getChild('path'+sid).copy() self.sack_path.setParent(self.factory) #prevent from appearing in MainWindow sack.setParent(self.sack_path, node='path'+sid) self.sack_path.setAnimationSpeed(1) sack.addAction(vizact.waittime(3)) #wait for sack animation endAnimSignal = vizact.signal() trig = endAnimSignal.trigger hide = vizact.method.visible(0) sack.addAction(vizact.parallel(hide, trig)) self.sackPour.addAction(endAnimSignal.wait) # wait for animation before pouring starts self.sackPour.addAction(vizact.method.alpha(1, node='sack_bent')) self.sackPour.addAction(vizact.spinTo(euler=[0,-45,0], time=.75, interpolate=vizact.easeInStrong)) self.sackPour.addAction(vizact.fadeTo(1, begin=0, time=.5, node='olive_flow')) loadSignal = vizact.signal() self.sackPour.addAction(loadSignal.trigger) self.sackPour.addAction(vizact.waittime(5)) self.sackPour.addAction(vizact.fadeTo(0, time=.5)) self.sackPour.addAction(vizact.method.setEuler([0,0,0])) # put it back standing self.mixedPulp.addAction(loadSignal.wait) # wait for olive pouring before pulp appears self.mixedPulp.addAction(vizact.method.visible(1)) #self.mixedPulp.addAction(vizact.fadeTo(1, begin=0, time=1, node='olives')) move = vizact.moveTo([0, 0, 0], time=5) resize = vizact.sizeTo([1, 1, 1], time=5, interpolate=vizact.easeIn) self.mixedPulp.addAction(vizact.parallel(move, resize)) self.sack_path.addAction(loadSignal.wait) self.sack_path.addAction(vizact.method.setAnimationSpeed(-100)) #put sack back
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])
def loadMeshes(self, meshes = [], animate = False, randomize = True): """Load all of the files from the dataset into puzzle.mesh instances""" for i, fileName in enumerate(meshes): # This is the actual mesh we will see b = model.Mesh(fileName) print b.name if (not randomize): #Hardcoded keystone b.setPosition([0.0,1.5,0.0]) b.setEuler([0.0,90.0,180.0]) # [0,0,180] flip upright [0,90,180] flip upright and vertical else: # b.setPosition([(random.random()-0.5)*3, 1.0, (random.random()-0.5)*3]) # random sheet, not a donut angle = random.random() * 2 * math.pi radius = random.random() + 1.5 targetPosition = [math.sin(angle) * radius, 1.0, math.cos(angle) * radius] targetEuler = [0.0,90.0,180.0] #targetEuler = [(random.random()-0.5)*40,(random.random()-0.5)*40 + 90.0, (random.random()-0.5)*40 + 180.0] if (animate): move = vizact.moveTo(targetPosition, time = 2) spin = vizact.spinTo(euler = targetEuler, time = 2) transition = vizact.parallel(spin, move) b.addAction(transition) else: b.setPosition(targetPosition) b.setEuler(targetEuler) self._meshes.append(b) self._meshesById[b.id] = b
def trialCountDownTask(): """Task that count downs to time limit for trial""" # Action for text fading out text_fade = vizact.parallel( vizact.fadeTo(0,time=0.8,interpolate=vizact.easeOut) ,vizact.sizeTo([.1,.1,.1],time=0.8,interpolate=vizact.easeOut) ) # Reset time text time_text.clearActions() time_text.alpha(1.0) time_text.color(viz.BLACK) time_text.setScale([.05,.05,.05]) time_text.message('REMAINING: ' + str(int(globals_oa.TIME_TO_FIND_IN_SCAVENGER_HUNT)/60)+ ':' + str(int(globals_oa.TIME_TO_FIND_IN_SCAVENGER_HUNT)%60).zfill(2)) # Countdown from time limit start_time = viz.getFrameTime() last_remain = int(globals_oa.TIME_TO_FIND_IN_SCAVENGER_HUNT) while (viz.getFrameTime() - start_time) < globals_oa.TIME_TO_FIND_IN_SCAVENGER_HUNT: # Compute remaining whole seconds remain = int(math.ceil(globals_oa.TIME_TO_FIND_IN_SCAVENGER_HUNT - (viz.getFrameTime() - start_time))) # Update text if time remaining changed if remain != last_remain: if remain <= 5: time_text.alpha(1.0) time_text.color(viz.RED) time_text.setScale([.05]*3) time_text.runAction(text_fade) time_text.message(str(remain/60)+ ':'+str(remain%60).zfill(2)) last_remain = remain # Wait tenth of second yield viztask.waitTime(0.1) print 'OUT OF TIME'
def PulpInTank (self, inOut): # >0 -> add, <0 -> subtract self.PulpLevel += inOut amount = self.PulpLevel * .05 pulp = self.components['pulp'] move = vizact.moveTo([0,amount,0], time=3) resize = vizact.sizeTo([1+amount/4,1,1+amount/2], time=3) pulp.addAction(vizact.parallel(move, resize))
def TrialCountDownTask(): """Task that count downs to time limit for trial""" # Action for text fading out text_fade = vizact.parallel( vizact.fadeTo(0, time=0.8, interpolate=vizact.easeOut), vizact.sizeTo([1.5, 1.5, 1.0], time=0.8, interpolate=vizact.easeOut)) # Reset time text time_text.clearActions() time_text.alpha(1.0) time_text.color(viz.WHITE) time_text.setScale([1, 1, 1]) time_text.message(str(int(TRIAL_DURATION))) # Countdown from time limit start_time = viz.getFrameTime() last_remain = int(TRIAL_DURATION) while (viz.getFrameTime() - start_time) < TRIAL_DURATION: # Compute remaining whole seconds remain = int( math.ceil(TRIAL_DURATION - (viz.getFrameTime() - start_time))) # Update text if time remaining changed if remain != last_remain: if remain <= 5: time_text.alpha(1.0) time_text.color(viz.RED) time_text.setScale([1] * 3) time_text.runAction(text_fade) viz.playSound('sounds/beep.wav') time_text.message(str(remain)) last_remain = remain # Wait tenth of second yield viztask.waitTime(0.1)
def moveToDash(node): if (node == cup1):#cup1 move = vizact.sequence(vizact.moveTo([-.70,1.4,-2.4],speed=.5),vizact.moveTo([.69,1.4,-2.4],speed=.5), vizact.moveTo([.69,1.23,-2.76],speed=.5)) node.addAction(move) yield viztask.waitActionEnd(node,move) viz.sendEvent(FINDING_TASK_OVER_EVENT, SCENE) elif (node == toothBrush or node == bristles): #toothbrush move = vizact.sequence(vizact.moveTo([7,10,-3],speed=5), vizact.moveTo([10,13.5,-15],speed=5)) toothBrush.addAction(move) bristles.addAction(move) yield viztask.waitActionEnd(bristles,move) elif (node == toothPaste or node == cap): #toothpaste move = vizact.sequence(vizact.moveTo([0,1,10],speed=7),vizact.moveTo([18,1,-3],speed=7)) toothPaste.addAction(move) cap.addAction(move) yield viztask.waitActionEnd(cap,move) elif (node == bottle1 or node == bottleCap1):#bottle 1 move = vizact.moveTo([0,-17.5, -8], time=1) spin = vizact.spinTo(euler=[0,25,0], time = 1) spinMove = vizact.parallel(spin, move) move = vizact.sequence(spinMove, vizact.moveTo([15,-13,-6],speed=8), vizact.moveTo([15,-3,-6],speed=8), vizact.moveTo([18,-5,-17],speed=8)) bottle1.addAction(move) bottleCap1.addAction(move) yield viztask.waitActionEnd(bottle1,move) elif (node == bottle2 or node == bottleCap2): #bottle 2 move = vizact.sequence(vizact.moveTo([7,12,-3],speed=5), vizact.moveTo([8,12,-14],speed=5)) bottle2.addAction(move) bottleCap2.addAction(move) yield viztask.waitActionEnd(bottle2,move) elif (node == cup2): #cup 2 move = vizact.sequence(vizact.moveTo([0,2.5,0],speed=5),vizact.moveTo([15,2.5,0],speed=5), vizact.moveTo([15,0,0],speed=5)) node.addAction(move) yield viztask.waitActionEnd(node,move) viz.sendEvent(FINDING_TASK_OVER_EVENT, SCENE)
def TrialCountDownTask(): """Task that count downs to time limit for trial""" global revealSelf global manChase # Action for text fading out text_fade = vizact.parallel( vizact.fadeTo(0,time=0.8,interpolate=vizact.easeOut) ,vizact.sizeTo([1.5,1.5,1.0],time=0.8,interpolate=vizact.easeOut) ) # Reset time text time_text.clearActions() time_text.alpha(1.0) time_text.color(viz.WHITE) time_text.setScale([1,1,1]) time_text.message(str(int(TRIAL_DURATION))) # Countdown from time limit start_time = viz.getFrameTime() last_remain = int(TRIAL_DURATION) male2.clearActions() male2.setPosition(2.5,0,7.5) while (viz.getFrameTime() - start_time) < TRIAL_DURATION: if revealSelf: pigeon.clearActions() pos = viz.MainView.getPosition() pigeon.addAction( vizact.walkTo([pos[0], 0, pos[2]]) ) if manChase: male.clearActions() male2.state(2) pos = pigeon.getPosition() male2.addAction( vizact.walkTo([pos[0] - .5, 0, pos[2] - .5])) if male2.getPosition()[2] == (pigeon.getPosition()[2] - .5): #allow for other actions to take place (chase takes precedence) manChase = False male2.state(9) # Compute remaining whole seconds remain = int(math.ceil(TRIAL_DURATION - (viz.getFrameTime() - start_time))) # Update text if time remaining changed if remain != last_remain: if remain <= 5: time_text.alpha(1.0) time_text.color(viz.RED) time_text.setScale([1]*3) time_text.runAction(text_fade) viz.playSound('sounds/beep.wav') time_text.message(str(remain)) last_remain = remain # Wait tenth of second yield viztask.waitTime(0.1)
def snap(self): """ Moves dog to the pos and euler of its target (dogTarget) """ movePos = vizact.moveTo(self.outlineCenter.getPosition(), time = self.snapTransitionTime) moveAng = vizact.spinTo(euler = self.outlineCenter.getEuler(), time = self.snapTransitionTime) transition = vizact.parallel(movePos, moveAng) self.dogCenter.addAction(transition) viz.playSound(".\\dataset\\snap.wav") viztask.schedule(self.mechanics())
def snap(dog, dogTarget): """ Moves dog to the pos and euler of its target (dogTarget) """ movePos = vizact.moveTo(dogTarget.getPosition(), time=snapTransitionTime) moveAng = vizact.spinTo(euler=dogTarget.getEuler(), time=snapTransitionTime) transition = vizact.parallel(movePos, moveAng) dog.addAction(transition) viz.playSound(".\\dataset\\snap.wav") viztask.schedule(Tutorial.mechanics())
def UpdateScore(self, points): curScore = int(self._score.getMessage()) if self._newScore == None: #this ensures correct update of the score self._newScore = curScore + points else: self._newScore += points self.SOUNDS['score'+str(int(points>0))].play() resize = vizact.sizeTo([1.5-(points<0),1.5-(points<0),0], time=.25) #resizes to .5 if deducting points color = [viz.RED, viz.GREEN][points>0] fade = vizact.fadeTo(color, time=.25) self._scoreIcon.addAction(vizact.parallel(resize, fade)) waitAnim = vizact.signal() self._scoreIcon.addAction(waitAnim.trigger) self._score.addAction(waitAnim.wait) self._score.addAction(vizact.method.message(str(self._newScore))) self._score.addAction(vizact.call(self.resetNewScore)) resize = vizact.sizeTo([1,1,0], time=.25) fade = vizact.fadeTo(viz.YELLOW, time=.25) self._scoreIcon.addAction(vizact.parallel(resize, fade))
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)
def MoveBarrow (self): barrow = self.components['barrow'] #update barrow to the new position self.faClass.componentPos[barrow] = [-22.5,0.5,9.5] barrow.addAction(vizact.spinTo(euler=[0,0,10], time=.5)) waitLift = vizact.signal() barrow.addAction(waitLift.trigger) self.wheel.addAction(waitLift.wait) self.wheel.addAction(vizact.spin(0,0,1,120, dur=4)) moveB = vizact.moveTo([-22.5,0.325,9.5], time=4, mode=viz.ABS_GLOBAL, interpolate=vizact.easeOut) rotateB = vizact.spinTo(euler=[-90,0,10], time=5) barrow.addAction(vizact.parallel(moveB, rotateB)) barrow.addAction(vizact.spinTo(euler=[-90,0,0], time=.5))
def moveTo(self, matrix, animate = True, time = 0.3): """ Invoked by the puzzle.snap method to handle local business """ # WARNING the full setMatrix cannot be assigned because scale is different! if (animate): move = vizact.moveTo(matrix.getPosition(), time = time, mode = viz.ABS_GLOBAL) spin = vizact.spinTo(euler = matrix.getEuler(), time = time, mode = viz.ABS_GLOBAL) transition = vizact.parallel(spin, move) self.addAction(transition) else: self.setPosition(targetPosition, viz.ABS_GLOBAL) self.setEuler(targetEuler,viz.ABS_GLOBAL)
def moveTo(self, BB, animate = True, time = 0.3): """ move bounding box to new targetPos and targetEuler """ targetPos = BB.checker.getPosition(viz.ABS_GLOBAL) targetEuler = BB.checker.getEuler(viz.ABS_GLOBAL) if (animate): move = vizact.moveTo(pos = targetPos, time = time, mode = viz.ABS_GLOBAL) spin = vizact.spinTo(euler = targetEuler, time = time, mode = viz.ABS_GLOBAL) transition = vizact.parallel(spin, move) self.addAction(transition) else: self.setPosition(targetPosition, viz.ABS_GLOBAL) self.setEuler(targetEuler,viz.ABS_GLOBAL)
def moveFlashlightToCar(scene=viz.MainScene, walkTime=10): global currSpotExponent, spotExponentEnd, flashlight, timeToReachWindow timeToReachWindow = walkTime currSpotExponent = 1 spotExponentEnd = 0.5 behindCarPOS = [-1.08, 1.38, 3.7] nextToCarPOS = [1.75, 1.38, -1.8] flashlight = addPoliceLights(scene) shortenLight = vizact.ontimer2((timeToReachWindow / spotExponentEnd), spotExponentEnd, changeSpotExponent) moveToCar = vizact.moveTo(nextToCarPOS, begin=behindCarPOS, time=timeToReachWindow) simulatePoliceVisit = vizact.parallel(shortenLight, moveToCar) global footstepsAudio footstepsAudio = flashlight.playsound("resources/audio/Footsteps.wav", viz.LOOP) flashlight.add(simulatePoliceVisit)
def SetMotion (self): #reset component position self.shaft.setEuler(0,0,0) self.rodL.setPosition(13.245,-196.394,738.167) self.rodR.setPosition(13.245,-196.394,738.167) self.rodL.setEuler(0,0,0) self.rodR.setEuler(0,0,0) self.pistonL.setPosition(13.245,-196.394,738.167) self.pistonR.setPosition(13.245,-196.394,738.167) self.pistonL.setEuler(0,0,0) self.pistonR.setEuler(0,0,0) #self.wheel.setEuler(0,0,0) self.gear.addAction(vizact.spin(0,0,1, 90,viz.FOREVER)) self.shaft.addAction(vizact.spin(0,0,1,-36,viz.FOREVER)) #set the left rod's action (rotation and transform) moveRodUp = vizact.moveTo([13.245,-130,738.167], time=5) moveRodDown = vizact.moveTo([13.245,-196.394,738.167], time=5) rodLTransform = vizact.sequence([moveRodUp, moveRodDown], viz.FOREVER) spinRodFw = vizact.spin(0,0,1, 2, 2.5) spinRodBw = vizact.spin(0,0,1, -2, 2.5) rodLRotation = vizact.sequence([spinRodFw, spinRodBw, spinRodBw, spinRodFw], viz.FOREVER) rodLMotion = vizact.parallel(rodLTransform, rodLRotation) #set the right rod's action (rotation and transform) moveRodRUp = vizact.moveTo([13.245,-196.394,738.167], time=5) moveRodRDown = vizact.moveTo([13.245,-262,738.167], time=5) rodRTransform = vizact.sequence([moveRodRDown, moveRodRUp], viz.FOREVER) rodRRotation = vizact.sequence([spinRodBw, spinRodFw, spinRodFw, spinRodBw], viz.FOREVER) rodRMotion = vizact.parallel(rodRTransform, rodRRotation) # start moving the rods self.rodL.addAction(rodLMotion) self.rodR.addAction(rodRMotion) # start moving the pistons pistonLTransform = vizact.sequence([moveRodUp, moveRodDown], viz.FOREVER) self.pistonL.addAction(pistonLTransform) pistonRTransform = vizact.sequence([moveRodRDown, moveRodRUp], viz.FOREVER) self.pistonR.addAction(pistonRTransform)
def updatePos(self): rad_to_deg = math.pi / 180.0 msg = viz.addText("", parent=viz.SCREEN, pos=(0.05, 0.9, 0), scale=(0.25, 0.25, 0)) msg.setBackdrop(viz.BACKDROP_OUTLINE) self.readTime = 0 t0 = viz.tick() while True: if self.going: #self.T1.ReadBothBeltsPosition() #self.T1.ReadBothBeltsSpeed() self.lbp = self.T1.plabTreadmill.leftBeltPosition.value self.rbp = self.T1.plabTreadmill.rightBeltPosition.value self.lbs = self.T1.plabTreadmill.leftBeltSpeed.value self.rbs = self.T1.plabTreadmill.rightBeltSpeed.value if self.verbose: self.message = "Left: %6.6f, %6.6f\nRight: %6.6f, %6.6f\nReadTime: %6.6f ms"%(\ self.lbp, self.lbs, self.rbp, self.rbs, 1000.0*self.readTime) else: self.message = "" msg.message(self.message) dt = viz.tick() - t0 dtheta_dt = (self.lbs - self.rbs) / self.separation dr_dt = 0.5 * (self.lbs + self.rbs) spinner = vizact.spin(0, 1, 0, dtheta_dt, dt) mover = vizact.move(0, 0, dr_dt, dt) spinmove = vizact.parallel(spinner, mover) #print "gh1",dr_dt, dt self.track.addAction(spinmove) yield viztask.waitActionEnd(self.track, spinmove) t0 = viz.tick() #for the recording if self.recording: #time, left pos, left speed, right pos, right speed, head pos (xyz, dir) pp = self.track.getPosition() self.history.append( (viz.tick(), self.lbp, self.lbs, self.rbp, self.rbs, pp[0], pp[1], pp[2], self.track.getEuler()[0])) #yield viztask.waitTime(1.0/19.0) yield viztask.waitEvent(TREADMILL_STATE_UPDATED)
def PasteInTank (self): hatch = self.components['hatch'+self.LR] hatch.addAction(vizact.moveTo([.3-.275, .976-.879, -0.956+.907], time=1, interpolate=vizact.easeInOut)) hatch.addAction(vizact.waittime(1)) openSignal = vizact.signal() hatch.addAction(openSignal.trigger) # code for pouring animation self.pourPulp.addAction(openSignal.wait) self.pourPulp.addAction(vizact.fadeTo(1, time=.5)) self.pourPulp.addAction(vizact.waittime(5)) self.pourPulp.addAction(vizact.fadeTo(0, time=.5)) self.tankPulp.addAction(openSignal.wait) self.tankPulp.addAction(vizact.waittime(.5)) self.tankPulp.addAction(vizact.moveTo([0,.4,0], time=5, interpolate=vizact.easeOut)) self.mixedPulp.addAction(openSignal.wait) # self.mixedPulp.addAction(vizact.fadeTo(0, time=5)) move = vizact.moveTo([0, -.28, 0], time=5, interpolate=vizact.easeOut) resize = vizact.sizeTo([.85,1,.85], time=5, interpolate=vizact.easeOut) self.mixedPulp.addAction(vizact.parallel(move, resize))
def disperseRandom(self, nodes, animate = False): for m in nodes: angle = random.random() * 2 * math.pi radius = random.random() + 1.5 targetPosition = [math.sin(angle) * radius, math.cos(angle) * radius, -1.0] targetEuler = m.getEuler() # targetEuler = [0.0,90.0,180.0] #targetEuler = [(random.random()-0.5)*40,(random.random()-0.5)*40 + 90.0, (random.random()-0.5)*40 + 180.0] if (animate): move = vizact.moveTo(targetPosition, time = 2) spin = vizact.spinTo(euler = targetEuler, time = 2) transition = vizact.parallel(spin, move) m.addAction(transition) else: m.setPosition(targetPosition) m.setEuler(targetEuler) if isinstance(m, BoundingBox): m.disperseMembers()
def TrialCountDownTask(): """Task that count downs to time limit for trial""" # Action for text fading out text_fade = vizact.parallel( vizact.fadeTo(0,time=0.8,interpolate=vizact.easeOut) ,vizact.sizeTo([1.5,1.5,1.0],time=0.8,interpolate=vizact.easeOut) ) # Reset time text time_text.clearActions() time_text.alpha(1.0) time_text.color(viz.WHITE) time_text.setScale([1,1,1]) time_text.message(str(int(TRIAL_DURATION))) # Countdown from time limit start_time = viz.getFrameTime() last_remain = int(TRIAL_DURATION) while (viz.getFrameTime() - start_time) < TRIAL_DURATION: # Compute remaining whole seconds remain = int(math.ceil(TRIAL_DURATION - (viz.getFrameTime() - start_time))) # Update text if time remaining changed if remain != last_remain: if remain <= 5: time_text.alpha(1.0) time_text.color(viz.RED) time_text.setScale([1]*3) time_text.runAction(text_fade) viz.playSound('sounds/beep.wav') time_text.message(str(remain)) last_remain = remain # Wait tenth of second yield viztask.waitTime(0.1)
def MoveTank (self): #change tank and cart animation depending on mill if self.LR == 'L': offset = .50 self.cart = self.factory.add('models/objects/cart.osgb', pos = [-23.835,0,3.97]) else: offset = 0 self.cart = self.factory.add('models/objects/cart.osgb', pos = [-5.2166,0,4.448]) self.cart.setEuler(360*offset,0,0) #millL: rotate 180 deg cTank = self.cart.insertGroupBelow('tank') cTank.visible(0) cTank.alpha(0, node='pourPulp') tank = self.components['tank'+self.LR] tank.addAction(vizact.moveTo([-0.25+offset,0,-.5], time=1, interpolate=vizact.easeInOutSine)) tank.addAction(vizact.moveTo([-0.25+offset,.5,-.5], time=.5, interpolate=vizact.easeInOutSine)) tank.addAction(vizact.spinTo(euler=[60-270*offset,0,0], time=.5)) #millL: rotate -75 deg tank.addAction(vizact.moveTo([offset,.5,-1.5], time=1, interpolate=vizact.easeInOutSine)) tank.addAction(vizact.moveTo([offset,.2,-1.5], time=.5, interpolate=vizact.easeInSine)) waitLoad = vizact.signal() tank.addAction(waitLoad.trigger) tank.addAction(vizact.method.visible(0)) cTank.addAction(waitLoad.wait) cTank.addAction(vizact.method.visible(1)) self.cart.addAction(waitLoad.wait) self.cart.addAction(vizact.call(self.PlayAudio, 'cart_roll', self.cart, viz.PLAY)) self.cart.addAction(vizact.spinTo(euler=[-20+440*offset,0,0], time=.5)) #millL: rotate to 200 deg moveCart = vizact.moveTo([-14.65-4.9*offset, 0, .75], time=3, interpolate=vizact.easeInOut) rotateCart = vizact.spinTo(euler=[0+360*offset,0,0], time=3) #millL: rotate to 180 deg self.cart.addAction(vizact.parallel(moveCart, rotateCart)) waitMove = vizact.signal() self.cart.addAction(waitMove.trigger) cTank.addAction(waitMove.wait) cTank.addAction(vizact.moveTo([0,1,-0.1], time=1)) cTank.addAction(vizact.spinTo(euler=[0,-90,0], time=1)) cTank.addAction(vizact.fadeTo(1, time=.5, node='pourPulp')) cTank.addAction(vizact.fadeTo(0, time=3, node='pulp', interpolate=vizact.easeInExp)) cTank.addAction(vizact.fadeTo(0, time=.5, node='pourPulp'))
def mechanics(self): """tutorial mechanics: moves the dog outline around the environment and waits for the dog to be snapped to it before preforming the next action.""" if self.iterations == 0: #setting conditions for position transformations along single axis # model.pointer.setParent(viz.WORLD) config.orientationVector = [0, 0, 0] proxList.append(self.dogCenter) # elif self.iterations ==3: # #setting conditions for position transformations along all axes # proxList.remove(self.dogCenter) # elif self.iterations==4: # #setting conditinos for angular transformations # proxList.append(self.dogCenter) # config.orientationVector = self.origOrienVec # config.positionVector = [0,0,0] ## model.pointer.setPosition(0,1,-1) ## model.pointer.color(0,0,5) elif self.iterations == 3: #setting conditions for positional and angular transformations # model.pointer.color(self.startColor) # model.pointer.setParent(model.display.camcenter) proxList.remove(self.dogCenter) config.orientationVector = self.origOrienVec config.positionVector = self.origPosVec if self.iterations <= 0: # X AXIS POS TRANSFORMATION config.positionVector = [.0001, 0, 0] recordData.event(event='ROUND ' + str(self.iterations), result='move along x-axis') randomPos = [4 * (random.random() - 0.5), 0, 0] self.movePos = vizact.move(randomPos[0], randomPos[1], randomPos[2], time=animateOutline) yield viztask.waitTime(1) yield viztask.addAction(self.outlineCenter, self.movePos) elif self.iterations > 0 and self.iterations <= 1: #Y AXIS POS TRANS config.positionVector = [0, .0001, 0] recordData.event(event='ROUND ' + str(self.iterations), result='move along y-axis') randomPos = [0, 2 * (random.random() - 0.5), 0] self.movePos = vizact.move(randomPos[0], randomPos[1], randomPos[2], time=animateOutline) yield viztask.waitTime(1) yield viztask.addAction(self.outlineCenter, self.movePos) elif self.iterations > 1 and self.iterations <= 2: #Z AXIS POS TRANS config.positionVector = [0, 0, .0001] recordData.event(event='ROUND ' + str(self.iterations), result='move along z-axis') randomPos = [0, 0, 4 * (random.random() - 0.5)] self.movePos = vizact.move(randomPos[0], randomPos[1], randomPos[2], time=animateOutline) yield viztask.waitTime(1) yield viztask.addAction(self.outlineCenter, self.movePos) elif self.iterations > 2 and self.iterations <= 3: #ALL AXES POS TRANS config.positionVector = self.origPosVec recordData.event(event='ROUND ' + str(self.iterations), result='move along all axis') randomPos = [0, 1, -1] self.movePos = vizact.moveTo(randomPos, time=animateOutline) yield viztask.waitTime(1) yield viztask.addAction(self.outlineCenter, self.movePos) # # elif self.iterations>3 and self.iterations<=4: # #X AXIS ANG TRANS # config.orientationVector = [.01,0,0] # model.pointer.setEuler(0,0,0) # recordData.event(event = 'ROUND ' + str(self.iterations), result = 'euler about x-axis') # thisEuler = [0,0,0] # thisEuler[1] = random.randint(-100,100) # self.moveAng = vizact.spinTo(euler = thisEuler, time = animateOutline, mode = viz.REL_GLOBAL) # yield viztask.waitTime(1) # yield viztask.addAction(self.outlineCenter, self.moveAng) # # elif self.iterations>4 and self.iterations<=5: # #Y AXIS ANG TRANS # config.orientationVector = [0,.01,0] # model.pointer.setEuler(0,0,0) # recordData.event(event = 'ROUND ' + str(self.iterations), result = 'euler about y-axis') # thisEuler = [0,0,0] # thisEuler[0] = random.randint(-100,100) # self.moveAng = vizact.spinTo(euler = thisEuler, time = animateOutline, mode = viz.REL_GLOBAL) # yield viztask.waitTime(1) # yield viztask.addAction(self.outlineCenter, self.moveAng) # # elif self.iterations>5 and self.iterations<=6: # #Z AXIS ANG TRANS # config.orientationVector = [0,0,.01] # model.pointer.setEuler(0,0,0) # recordData.event(event = 'ROUND ' + str(self.iterations), result = 'euler about z-axis') # thisEuler = [0,0,0] # thisEuler[2] = random.randint(-100,100) # self.moveAng = vizact.spinTo(euler = thisEuler, time = animateOutline, mode = viz.REL_GLOBAL) # yield viztask.waitTime(1) # yield viztask.addAction(self.outlineCenter, self.moveAng) # # elif self.iterations>6 and self.iterations<=7: # #ALL AXES ANG TRANS # config.orientationVector = self.origOrienVec # model.pointer.setEuler(0,0,0) # recordData.event(event = 'ROUND ' + str(self.iterations), result = 'euler about all axis') # randomEuler = [random.randint(-100,100),random.randint(-100,100),random.randint(-100,100)] # self.moveAng = vizact.spinTo(euler = randomEuler, time = animateOutline) # yield viztask.waitTime(1) # yield viztask.addAction(self.outlineCenter, self.moveAng) elif self.iterations > 3 and self.iterations <= 9: #ALL AXES POS AND ANG TRANS recordData.event(event='ROUND ' + str(self.iterations), result='move along all axis') randomPos = [ 4 * (random.random() - 0.5), 2 * (random.random() - 0.5), 4 * (random.random() - 0.5) ] # randomEuler = [random.randint(-90,90),random.randint(-90,90),random.randint(-90,90)] self.movePos = vizact.moveTo(randomPos, time=animateOutline) # self.moveAng = vizact.spinTo(euler = randomEuler, time = animateOutline) transition = vizact.parallel(self.movePos) yield viztask.waitTime(1) yield viztask.addAction(self.outlineCenter, transition) else: #END menu.ingame.toggle() config.orientationVector = self.origOrienVec config.positionVector = self.origPosVec recordData.event(event='FINISHED', result='FINISHED') self.iterations = self.iterations + 1
def mechanics(self): """tutorial mechanics: moves the dog outline around the environment and waits for the dog to be snapped to it before preforming the next action.""" if self.iterations == 0: # setting conditions for position transformations along single axis # model.pointer.setParent(viz.WORLD) config.orientationVector = [0, 0, 0] proxList.append(self.dogCenter) # elif self.iterations ==3: # #setting conditions for position transformations along all axes # proxList.remove(self.dogCenter) # elif self.iterations==4: # #setting conditinos for angular transformations # proxList.append(self.dogCenter) # config.orientationVector = self.origOrienVec # config.positionVector = [0,0,0] ## model.pointer.setPosition(0,1,-1) ## model.pointer.color(0,0,5) elif self.iterations == 3: # setting conditions for positional and angular transformations # model.pointer.color(self.startColor) # model.pointer.setParent(model.display.camcenter) proxList.remove(self.dogCenter) config.orientationVector = self.origOrienVec config.positionVector = self.origPosVec if self.iterations <= 0: # X AXIS POS TRANSFORMATION config.positionVector = [0.0001, 0, 0] recordData.event(event="ROUND " + str(self.iterations), result="move along x-axis") randomPos = [4 * (random.random() - 0.5), 0, 0] self.movePos = vizact.move(randomPos[0], randomPos[1], randomPos[2], time=animateOutline) yield viztask.waitTime(1) yield viztask.addAction(self.outlineCenter, self.movePos) elif self.iterations > 0 and self.iterations <= 1: # Y AXIS POS TRANS config.positionVector = [0, 0.0001, 0] recordData.event(event="ROUND " + str(self.iterations), result="move along y-axis") randomPos = [0, 2 * (random.random() - 0.5), 0] self.movePos = vizact.move(randomPos[0], randomPos[1], randomPos[2], time=animateOutline) yield viztask.waitTime(1) yield viztask.addAction(self.outlineCenter, self.movePos) elif self.iterations > 1 and self.iterations <= 2: # Z AXIS POS TRANS config.positionVector = [0, 0, 0.0001] recordData.event(event="ROUND " + str(self.iterations), result="move along z-axis") randomPos = [0, 0, 4 * (random.random() - 0.5)] self.movePos = vizact.move(randomPos[0], randomPos[1], randomPos[2], time=animateOutline) yield viztask.waitTime(1) yield viztask.addAction(self.outlineCenter, self.movePos) elif self.iterations > 2 and self.iterations <= 3: # ALL AXES POS TRANS config.positionVector = self.origPosVec recordData.event(event="ROUND " + str(self.iterations), result="move along all axis") randomPos = [0, 1, -1] self.movePos = vizact.moveTo(randomPos, time=animateOutline) yield viztask.waitTime(1) yield viztask.addAction(self.outlineCenter, self.movePos) # # elif self.iterations>3 and self.iterations<=4: # #X AXIS ANG TRANS # config.orientationVector = [.01,0,0] # model.pointer.setEuler(0,0,0) # recordData.event(event = 'ROUND ' + str(self.iterations), result = 'euler about x-axis') # thisEuler = [0,0,0] # thisEuler[1] = random.randint(-100,100) # self.moveAng = vizact.spinTo(euler = thisEuler, time = animateOutline, mode = viz.REL_GLOBAL) # yield viztask.waitTime(1) # yield viztask.addAction(self.outlineCenter, self.moveAng) # # elif self.iterations>4 and self.iterations<=5: # #Y AXIS ANG TRANS # config.orientationVector = [0,.01,0] # model.pointer.setEuler(0,0,0) # recordData.event(event = 'ROUND ' + str(self.iterations), result = 'euler about y-axis') # thisEuler = [0,0,0] # thisEuler[0] = random.randint(-100,100) # self.moveAng = vizact.spinTo(euler = thisEuler, time = animateOutline, mode = viz.REL_GLOBAL) # yield viztask.waitTime(1) # yield viztask.addAction(self.outlineCenter, self.moveAng) # # elif self.iterations>5 and self.iterations<=6: # #Z AXIS ANG TRANS # config.orientationVector = [0,0,.01] # model.pointer.setEuler(0,0,0) # recordData.event(event = 'ROUND ' + str(self.iterations), result = 'euler about z-axis') # thisEuler = [0,0,0] # thisEuler[2] = random.randint(-100,100) # self.moveAng = vizact.spinTo(euler = thisEuler, time = animateOutline, mode = viz.REL_GLOBAL) # yield viztask.waitTime(1) # yield viztask.addAction(self.outlineCenter, self.moveAng) # # elif self.iterations>6 and self.iterations<=7: # #ALL AXES ANG TRANS # config.orientationVector = self.origOrienVec # model.pointer.setEuler(0,0,0) # recordData.event(event = 'ROUND ' + str(self.iterations), result = 'euler about all axis') # randomEuler = [random.randint(-100,100),random.randint(-100,100),random.randint(-100,100)] # self.moveAng = vizact.spinTo(euler = randomEuler, time = animateOutline) # yield viztask.waitTime(1) # yield viztask.addAction(self.outlineCenter, self.moveAng) elif self.iterations > 3 and self.iterations <= 9: # ALL AXES POS AND ANG TRANS recordData.event(event="ROUND " + str(self.iterations), result="move along all axis") randomPos = [4 * (random.random() - 0.5), 2 * (random.random() - 0.5), 4 * (random.random() - 0.5)] # randomEuler = [random.randint(-90,90),random.randint(-90,90),random.randint(-90,90)] self.movePos = vizact.moveTo(randomPos, time=animateOutline) # self.moveAng = vizact.spinTo(euler = randomEuler, time = animateOutline) transition = vizact.parallel(self.movePos) yield viztask.waitTime(1) yield viztask.addAction(self.outlineCenter, transition) else: # END menu.ingame.toggle() config.orientationVector = self.origOrienVec config.positionVector = self.origPosVec recordData.event(event="FINISHED", result="FINISHED") self.iterations = self.iterations + 1
HiHatBottom.sounds = ['sounds/hat_open.wav','sounds/hat_closed.wav'] HiHatBottom.action = [OpenHiHat,CloseHiHat] def ondrum(drum): if drum == CymbalDrum: #Animate cymbal CymbalHitAnimation.hit(360,min(10*drum.hitSpeed,80)) vizact.onevent (DRUM_HIT_EVENT, lambda e: (True, e), ondrum) #Create action for when kick drum is hit SizeUp = vizact.size(1.1,1.1,1.1,8) SizeDown = vizact.size(1,1,1,8) SizeUp.object = KickBassModel SizeDown.object = KickBassModel KickBassAction = vizact.sequence(vizact.method.rotate(1,0,0,-45),KickBassModel.scale(1,1,1),vizact.spinto(1,0,0,45,1000),vizact.parallel(vizact.spinto(1,0,0,-45,1400),vizact.sequence(SizeUp,SizeDown))) def kickbass(): KickBassModel.playsound('sounds/kick.wav') KickBassHammer.clear(viz.ALL) KickBassHammer.add(KickBassAction) vizact.onkeydown('t',kickbass) def ToggleHat(): HiHatBottom.open = not HiHatBottom.open HiHatBottom.add(HiHatBottom.action[HiHatBottom.open]) HatDrum.hitSound = HiHatBottom.sounds[HiHatBottom.open] vizact.onkeydown('1',ToggleHat) def ToggleSnare(): SnareDrum.curSound = not SnareDrum.curSound