def snitchPath(self, pathNum): #Add the path. self.path = viz.addAnimationPath() #Add control points to the path, along with their time stamp. if (pathNum < 4): self.path.addControlPoint(0, pos=(22, 31, 20), euler=(90, 0, 0)) self.path.addControlPoint(3, pos=(-22, 21, 26), euler=(0, 90, 0)) self.path.addControlPoint(5, pos=(-22, 41, 46), euler=(0, 0, 90)) self.path.addControlPoint(6.5, pos=(-10, 10, 60), euler=(90, 0, 0)) self.path.addControlPoint(8, pos=(12, 21, 26), euler=(0, 90, 0)) self.path.addControlPoint(10, pos=(42, 45, 50), euler=(0, 0, 90)) self.path.addControlPoint(11.5, pos=(17, 35, 25), euler=(0, 90, 0)) self.path.addControlPoint(12, pos=(22, 31, 20), euler=(90, 0, 0)) else: pass #Loop the path to loop back to replay from beginning self.path.setLoopMode(viz.LOOP) self.path.computeTangents() self.path.setTranslateMode(viz.CUBIC_BEZIER) #Link the model to a path. self.link = viz.link(self.path, self.snitch) #Play the path. self.path.play()
def _extractPathFromRaw(self): """helper function to setup animation path from JSON object""" if 'path' not in self._raw: self._animation_path = None return self._animation_path = viz.addAnimationPath() for record in self._raw['path']: self._addControlPointFromObject(record)
def flyOut(): global specialMole, skipKey yield viztask.waitTime(1) path = viz.addAnimationPath() path.addControlPoint(0, pos=[-0.4,1.3,0.2], euler=(90,0,0), scale= ([4,4,4])) path.addControlPoint(1, pos=[-0.4,1.5,0.6], euler=(55,0,0), scale= ([4,4,4])) path.addControlPoint(2, pos=[-0.4,3.3,0.1], euler=(100,0,0), scale= ([4,4,4])) path.addControlPoint(3, pos=[-0.4,4.8,0.8], euler=(75,0,0), scale= ([4,4,4])) path.addControlPoint(50, pos=[-0.4,70,0.4], euler=(90,0,0), scale = ([4,4,4])) pathLink = viz.link(path, specialMole) path.play()
def flyingCO2(): global bigCO2, co2Path yield viztask.waitTime(1) co2Path = viz.addAnimationPath() co2Path.addControlPoint(0,pos=(0,21,20),euler=(0,0,0), scale=(8,8,8)) co2Path.addControlPoint(2, pos=(0.5,15,17), euler=(20,0,0), scale=(8,8,8)) co2Path.addControlPoint(4, pos=(0,10,14), euler=(-30,0,0), scale=(8,8,8)) co2Path.addControlPoint(6, pos=(0.7,7,10), euler=(15,0,0), scale=(8,8,8)) co2Path.addControlPoint(8, pos=(0.3,4,6), euler=(-20,0,0), scale=(8,8,8)) co2Path.addControlPoint(10, pos=(-0.1,1.7,2), euler=(0,0,0), scale=(8,8,8)) co2Link = viz.link(co2Path, bigCO2) co2Path.play()
def main(): global marker; global current; if marker.getVisible() and current == 1: current = 0; print "MARKER:" + str(marker.getPosition()); baseValueX1 = marker.getPosition(0)[0]; #this denotes the X position baseValueY1 = marker.getPosition(0)[1]; #this denotes the Y position baseValueZ1 = marker.getPosition(0)[2]; #this denotes the Z position path = viz.addAnimationPath() positions = [ [baseValueX1,baseValueY1,baseValueZ1]]; endValueX1 = endMarker.getPosition()[0]; endValueY1 = endMarker.getPosition()[1]; endValueZ1 = endMarker.getPosition()[2]; print "END:" + str(endValueX1) + "," + str(endValueY1) + "," + str(endValueZ1) i = 0; numPositions = 5; Coe = numPositions; constant = 0; X = baseValueX1; endX = endValueX1; Y = baseValueY1; endY = endValueY1; endZ = endValueZ1; Z = baseValueZ1; if float(abs(endX) - abs(X)) == 0: denominator = 1; else: denominator = float(abs(endX) - abs(X)); angle = math.atan(float(abs(endY) - abs(Y))/denominator); for p in range(numPositions+1): #need the +1 to complete the parabolic path #altering p affects the end point and speed of the parabolas X = (float(p)/float(numPositions))*endX; Y = (float(p)/float(numPositions))*endY; Z = (float(p)/float(numPositions))*endZ + 10; print str(p) + ": [" + str(X)+ ", " + str(Y)+ ", " + str(Z) + "]"; positions.append([X,Y,Z]); for i in range(numPositions): b = viz.addChild('beachball.osgb'); #print pos; b.setPosition(positions[i]); b.alpha(0.5);
def goSpecialMole(): global specialMole yield viztask.waitTime(1) specialMole = vizfx.addChild(globals_oa.FILE_PATH_TO_MOLECULE3) specialMole.setPosition([-1.33023,0.35456,-0.04151]) specialMole.setScale([4,4,4]) lowPolyMole = specialMole.getChild('singleCO2_noAnimation.OSGB') lowPolyMole.disable(viz.RENDERING) path = viz.addAnimationPath() path.addControlPoint(0, pos=[-1.33023,0.35456,-0.04151], euler=(90,0,0), scale= ([4,4,4])) path.addControlPoint(1, pos=[-1,0.4, 0], euler=(45,0,0), scale = ([4,4,4])) path.addControlPoint(2, pos=[-0.8,0.9,0.1], euler=(0,0,0), scale = ([4,4,4])) path.addControlPoint(3, pos=[-0.4,1.3,0.2], euler=(90,0,0), scale = ([4,4,4])) pathLink = viz.link(path, specialMole) path.play()
def setZepPath(ZEP, positions = getRandomPath()): #Generate random values for position print "blimp path: " + str(positions) #Create an animation path path = viz.addAnimationPath() for x,pos in enumerate(positions): #Add a ball at each control point and make it #semi-transparent, so the user can see where the #control points are #b = viz.addChild('beachball.osgb',cache=viz.CACHE_CLONE) #b.setScale(10,10,10) #b.setPosition(pos) #b.alpha(0.2) #Add the control point to the animation path #at the new time path.addControlPoint(x+1,pos=pos) #Set the initial loop mode to circular path.setLoopMode(viz.CIRCULAR) #make it go in a bezier between points circle path.setTranslateMode(viz.CUBIC_BEZIER) #Automatically compute tangent vectors for cubic bezier translations path.computeTangents() #Automatically rotate the path path.setAutoRotate(viz.ON) #Link the ZEPPELIN to the path viz.link(path, ZEP) #Play the animation path path.play() #Set the animation path speed path.speed(.006)
def DrawArrow(positions, parabolaHeight): global pathSpeed #from config file arrow = viz.addChild('thesis/greenArrow.dae') #import the arrow .dae object #arrow = viz.addChild('thesis/niceHand_1.dae'); scaleSize = parabolaHeight * 0.1 arrow.setScale(scaleSize, scaleSize, scaleSize) #change the size of arrow object path = viz.addAnimationPath() #create an animation path for x, pos in enumerate( positions): #for every position in the array (x = pos) a = viz.addChild('beachball.osgb', cache=viz.CACHE_CLONE) #add a control point object a.setPosition(pos) #set the object at the position specified a.alpha(0.5) #make it almost invisible path.addControlPoint(x + 1, pos=pos) #add it onto the path path.setSpeed(pathSpeed) #set the speed of the path path.setLoopMode(viz.LOOP) #set the path on a loop path.computeTangents() #compute the tangents path.setAutoRotate(viz.ON) #set it to auto rotate viz.link(path, arrow) #link the path to the arrow object so that the arrow will move path.play()
def playerAnimationPath (player, trial=getLatestTrial()): data = loadLogFile('position', trial) if data == None or not data.has_key(player): return data = data[player] #Add the ball as avatar to animate avatar = viz.addChild('beachball.osgb', scale=[1.5,1.5,1.5]) colors = [[197, 106, 183], [83, 171, 224], [255, 189, 0]] avatar.color([float(c)/255 for c in colors[player-1]]) #Create the animation path path = viz.addAnimationPath() #Initialize an array of control points and add them to the path positions = [[p[1],0,p[2]] for p in data] for x,pos in enumerate(positions): path.addControlPoint(x+1,pos=pos) #Set the initial loop mode to circular # path.setLoopMode(viz.LOOP) #Automatically rotate the path to face trajectory path.setAutoRotate(viz.ON) path.setRotateMode(viz.BEZIER) #Link the ball to the path viz.link(path, avatar) #Play the animation path path.play()
def main(): global marker global current if marker.getVisible() and current == 1: current = 0 print "MARKER:" + str(marker.getPosition()) baseValueX1 = marker.getPosition(0)[0] #this denotes the X position baseValueY1 = marker.getPosition(0)[1] #this denotes the Y position baseValueZ1 = marker.getPosition(0)[2] #this denotes the Z position logo = viz.add('thesis/greenArrow.dae') scaleSize = 0.5 logo.setScale(scaleSize, scaleSize, scaleSize) #change the size of arrow object logo.setEuler(270) logo.setPosition([baseValueX1, baseValueY1, baseValueZ1]) path = viz.addAnimationPath() positions = [[baseValueX1, baseValueY1, baseValueZ1]] endValueX1 = endMarker.getPosition()[0] endValueY1 = endMarker.getPosition()[1] endValueZ1 = endMarker.getPosition()[2] print "END:" + str(endValueX1) + "," + str(endValueY1) + "," + str( endValueZ1) i = 0 numPositions = 5 Coe = numPositions constant = 0 X = baseValueX1 endX = endValueX1 Y = baseValueY1 endY = endValueY1 endZ = endValueZ1 Z = baseValueZ1 if float(abs(endX) - abs(X)) == 0: denominator = 1 else: denominator = float(abs(endX) - abs(X)) angle = math.atan(float(abs(endY) - abs(Y)) / denominator) for p in range(numPositions + 1): #need the +1 to complete the parabolic path #altering p affects the end point and speed of the parabolas X = (float(p) / float(numPositions)) * endX Y = (float(p) / float(numPositions)) * endY Z = (float(p) / float(numPositions)) * endZ + 10 positions.append([X, Y, Z]) #for i in enumerate(positions): # b = viz.addChild('beachball.osgb'); # pathTrajectory = []; pathTrajectory = [] for x, pos in enumerate(positions): b = viz.addChild('beachball.osgb') b.setPosition(pos) b.alpha(0.5) #pathTrajectory.append(b); path.addControlPoint(x + 1, pos=pos) path.setSpeed(4) #path.setAxisAngle(90); #path.setLoopMode(viz.CUBIC_BEZIER) #not good, circular isn't good either path.computeTangents() path.setAutoRotate(viz.ON) #important - this is how the arrow is orientated along the path path.play() arrowPath = viz.link(path, logo) marker_arrowPath = viz.link(marker, arrowPath) def onEndReached(): print "path: " + str(enumerate(pathTrajectory)) marker_arrowPath.remove() arrowPath.remove() logo.remove() global current current = 1 path.addEventAtEnd('end') vizact.onPathEvent(path, 'end', onEndReached)
def main(): global marker global current if marker.getVisible() and current == 1: current = 0 print "MARKER:" + str(marker.getPosition()) baseValueX1 = marker.getPosition(0)[0] #this denotes the X position baseValueY1 = marker.getPosition(0)[1] #this denotes the Y position baseValueZ1 = marker.getPosition(0)[2] #this denotes the Z position #pinch = viz.addChild('thesis/niceHand_5.dae'); #scaleSize = 0.5; #pinch.setScale(scaleSize, scaleSize, scaleSize); #change the size of arrow object #pinch.setEuler([90,0,0]); #pinch.setPosition([baseValueX1, baseValueY1, baseValueZ1]); #markerLink = viz.link(marker,pinch); logo = viz.add('thesis/greenArrow.dae') scaleSize = 0.5 logo.setScale(scaleSize, scaleSize, scaleSize) #change the size of arrow object logo.setEuler([0, 90, 0]) logo.setPosition([baseValueX1, baseValueY1, baseValueZ1]) path = viz.addAnimationPath() positions = [[baseValueX1, baseValueY1, baseValueZ1]] endValueX1 = endMarker.getPosition()[0] endValueY1 = endMarker.getPosition()[1] endValueZ1 = endMarker.getPosition()[2] print "END:" + str(endValueX1) + "," + str(endValueY1) + "," + str( endValueZ1) i = 0 numPositions = 5 Coe = numPositions constant = 0 X = baseValueX1 endX = endValueX1 Y = baseValueY1 endY = endValueY1 endZ = endValueZ1 Z = baseValueZ1 if float(abs(endX) - abs(X)) == 0: denominator = 1 else: denominator = float(abs(endX) - abs(X)) angle = math.atan(float(abs(endY) - abs(Y)) / denominator) for p in range(numPositions + 1): #need the +1 to complete the parabolic path #altering p affects the end point and speed of the parabolas X = (float(p) / float(numPositions + 1)) * endX Y = (float(p) / float(numPositions + 1)) * endY Z = (float(p) / float(numPositions + 1)) * endZ + 5 #X = p*math.cos(angle) - (-p**2+Coe*p+constant)*math.sin(angle); #troubleshooting: I wasn't using f(t) here, which was giving me problems #Y = p*math.sin(angle) + (-p**2+Coe*p+constant)*math.cos(angle); #Z = (float(p)/float(numPositions))*endZ; #X = p*math.cos(angle) - (-p**2+Coe*p+constant)*math.sin(angle); #troubleshooting: I wasn't using f(t) here, which was giving me problems #Z = p*math.sin(angle) + (-p**2+Coe*p+constant)*math.cos(angle); #Y = (float(p)/float(numPositions))*endZ; positions.append([X, Y, Z]) for x, pos in enumerate(positions): b = viz.addChild('beachball.osgb', cache=viz.CACHE_CLONE) b.setPosition(pos) b.alpha(0) #bpath = viz.link(path, b); #bpath.remove(); #Add the control point to the animation path path.addControlPoint(x + 1, pos=pos) path.setSpeed(4) #path.setAxisAngle(90); #path.setLoopMode(viz.CUBIC_BEZIER) #not good, circular isn't good either path.computeTangents() path.setAutoRotate(viz.ON) #important - this is how the arrow is orientated along the path path.play() arrowPath = viz.link(path, logo) marker_arrowPath = viz.link(marker, arrowPath) def onEndReached(): marker_arrowPath.remove() arrowPath.remove() logo.remove() global current current = 1 path.addEventAtEnd('end') vizact.onPathEvent(path, 'end', onEndReached)
viz.fov(60) viz.go() vizinfo.InfoPanel(align=viz.ALIGN_RIGHT_TOP) #Add the ground plane ground = viz.addChild('ground.osgb') #Add the ball to animate ball = viz.addChild('beachball.osgb') #Move the viewpoint back viz.MainView.move([0,0,-7]) #Create the animation path path = viz.addAnimationPath() #Initialize an array of control points positions = [ [0,0,2], [2,0,0], [0,0,-2], [-2,0,0] ] for x,pos in enumerate(positions): #Add a ball at each control point and make it #semi-transparent, so the user can see where the #control points are b = viz.addChild('beachball.osgb',cache=viz.CACHE_CLONE) b.setPosition(pos) b.alpha(0.2) #Add the control point to the animation path #at the new time path.addControlPoint(x+1,pos=pos)
car8.setEuler(270,0,0) #yellow car 2 car9= viz.addChild('car6.dae') car9.setScale(1.5,1.5,1.5) car9.setPosition(-83,0.8,250) car9.setEuler(90,0,0) #green car 3 car10= viz.addChild('car8.dae') car10.setScale(1.5,1.5,1.5) car10.setPosition(-73,1,250) car10.setEuler(270,0,0) #Create the animation path path1 = viz.addAnimationPath() path2 = viz.addAnimationPath() path3 = viz.addAnimationPath() path4 = viz.addAnimationPath() path5 = viz.addAnimationPath() path6 = viz.addAnimationPath() path7 = viz.addAnimationPath() path8 = viz.addAnimationPath() path9 = viz.addAnimationPath() path10 = viz.addAnimationPath() #Initialize an array of control points positions1 = [ [136,0,150],[136,0,-50],[136,0,250]] positions2 = [ [-50,0,50], [80,0,50],[130,0,50] ] positions3 = [ [131.5,0,85], [131.5,0,-50],[131.5,0,285] ]