def run(self): if self.angle % 10 == 0: print "running: _nodeID = ", self._nodeID, "angle = " , self.angle self.angle += 0.05 x = self.radius * math.cos(self.angle); y = self.radius * math.sin(self.angle); #cascadeEvents = 1: setTranslation can trigger more event scripts! like hotspot.py libSPINPyWrap.callback(self._nodeID, "setTranslation", [x, y, 0.0], 1)
def run(self, eventMethod, eventArgs): print "hotspot.run( ", eventMethod, eventArgs, " )" self.applyEvent(eventMethod, eventArgs, 0) # cascadeEvents = 0... actually do the translation, don't redo hotspot.run #print "am I in the box?", self.box ret = libSPINPyWrap.callback(self._nodeID, "getTranslation", [], 0) x,y,z = ret.getVector() if isInside(x, y, z, self.box): if not self.inbox: print "IN the box!" libSPINPyWrap.callback(self._nodeID, "setScale", [self.scale, self.scale, self.scale], 0) self.inbox = True else: if self.inbox: print "OUT of the box!" libSPINPyWrap.callback(self._nodeID, "setScale", self.normalScale, 0) self.inbox = False
def run( self ): t = libSPINPyWrap.time_s() val = 0 if (t > self.start_time + self.duration ): self.start_time = t; # start < NOW < start + attack if ( self.start_time <= t and t < self.start_time + self.attack ): #print "ATTACK" val = interpolate( 0, self.scale, self.attack, t - self.start_time) # start + attack < NOW < start + attack + decay elif ( self.start_time + self.attack <= t and t < self.start_time + self.attack + self.decay ): #print "DECAY" val = interpolate( self.scale, self.sustain*self.scale, self.decay, t - self.start_time - self.attack ) # start + attack + decay < NOW < start + soundclip duration - decay elif ( self.start_time + self.attack + self.decay <= t and t < self.start_time + self.duration - self.release ): #print "SUSTAIN" val = self.sustain*self.scale # start + soundclip duration - release < NOW < start + soundclip duration elif ( self.start_time + self.duration - self.release <= t and t <self.start_time + self.duration ): #print "RELEASE" val = interpolate( self.sustain*self.scale, 0, self.release , t - (self.start_time + self.duration - self.release) ) else: print "DONE" libSPINPyWrap.callback( self._nodeID, "setTranslation", [0, 0, val], 1 )
def applyEvent(self, eventMethod, eventArgs, cascade): libSPINPyWrap.callback( self._nodeID, eventMethod, eventArgs, cascade)
def run(self, eventMethod, eventArgs): print "grow.run( ", eventMethod, eventArgs, " )" self.scale += 0.1 libSPINPyWrap.callback(self._nodeID, "setScale", [self.scale, self.scale, self.scale], 0)