def main(): global wingl global wingr viz.cam.setHandler(vizcam.KeyboardCamera()) myo.init() gyrolist = [[0,0,0]] viz.setMultiSample(4) viz.fov(150) wingl = viz.addChild('basketball.osgb') wingl.setScale([10,0.3,1]) wingl.setCenter([100,100,100]) wingl.setEuler([0,90,0]) wingl.collideSphere(0.5) lStartPOS = [ 0, 2.5, 2 ] wingl.setPosition( lStartPOS ) wingr = viz.addChild('basketball.osgb') wingr.setScale([10,0.3,1]) wingr.setCenter([100,100,100]) wingr.setEuler([0,90,0]) wingr.collideSphere(0.5) rStartPOS = [ 0, 2.5, 2 ] wingr.setPosition( rStartPOS ) #viz.MainView.setPosition([0,2,-15]) hub = myo.Hub() hub.set_locking_policy(myo.locking_policy.none) hub.run(1000, Listener()) vizact.ontimer(0.01 ,updateMyo, [gy, gy2, gy3, wingl, orx, ory, orz, orw, or1x, or1y, or1z, or1w, wingr])
def addAppendage(avatar, skinChoices, skin = 0, appendage = 0): global thirdAppendage, usingInvisibleRod thirdAppendageHorn = viz.addGroup() if(appendage == 0): #Third Arm usingInvisibleRod = False thirdAppendage = viz.addChild(resources.ARM) if skin == 9: texture = viz.addTexture("skin_tones/010.png") texture.wrap(viz.WRAP_S,viz.REPEAT) texture.wrap(viz.WRAP_T,viz.REPEAT) else: texture = viz.addTexture("skin_tones/00" + skinChoices[skin] + ".png") texture.wrap(viz.WRAP_S,viz.REPEAT) texture.wrap(viz.WRAP_T,viz.REPEAT) thirdAppendage.texture(texture) thirdAppendage.emissive([.75, .75, .75]) thirdAppendage.setScale(resources.ARM_SCALE) elif(appendage == 1): #Cylinder usingInvisibleRod = False thirdAppendage = viz.addChild(resources.CYLINDER) thirdAppendage.setScale(resources.ARM_SCALE) thirdAppendage.setParent(thirdAppendageHorn) global tahLink tahLink = viz.link(avatar.getBone('Bip01 Spine'), thirdAppendageHorn) global offsetOp offsetOp = tahLink.preTrans([0, 0.3, 0.1]) tahLink.preEuler([-90.0, 0.0, 0.0]) thirdAppendage.collideBox() thirdAppendage.disable(viz.DYNAMICS) TouchCube.thirdAppendage = thirdAppendage
def SpawnStandingNPC(train, stage): # Remove if (len(trainStandingNPC) > 0): for x in range(0, len(trainStandingNPC)): trainStandingNPC[x].remove() trainStandingNPC[:] = [] spotsTaken = [] for x in range(0, 82): spotsTaken.append(1) spotsTaken[x] = False numToSpawn = 0 if (stage == 0): numToSpawn = 0 elif (stage == 1): numToSpawn = 2 elif (stage == 2): numToSpawn = 20 elif (stage == 3): numToSpawn = 55 elif (stage == 4): numToSpawn = 75 elif (stage == 5): numToSpawn = 80 else: numToSpawn = 0 if (numToSpawn > 0): for x in range(0, numToSpawn): # Random Pos numFound = False rand = 0 while (numFound == False): rand = random.randint(0, 81) if (spotsTaken[rand] == False): numFound = True spotsTaken[rand] = True pos = trainStandingPos[rand] trainStandingNPC.append(1) randGener = random.randint(0, 10) if (randGener < 5): trainStandingNPC[x] = viz.addChild('vcc_male.cfg') else: trainStandingNPC[x] = viz.addChild('vcc_female.cfg') trainStandingNPC[x].state(1) # Looping idle animation trainStandingNPC[x].setEuler(random.randint(-180, 180), 0, 0) # Turns him to face you trainStandingNPC[x].setPosition( pos ) # Moves him back so that he is in full view xPos,yPos,zPos trainStandingNPC[x].setParent(train)
def SpawnPlatformNPC(): seatTaken = [] for x in range(0, 29): seatTaken.append(1) seatTaken[x] = False for x in range(0, 10): # Random Pos numFound = False rand = 0 while (numFound == False): rand = random.randint(0, 28) if (seatTaken[rand] == False): numFound = True seatTaken[rand] = True pos = platStandingPos[rand] platformNPC.append(1) randGener = random.randint(0, 10) if (randGener < 5): platformNPC[x] = viz.addChild('vcc_male.cfg') else: platformNPC[x] = viz.addChild('vcc_female.cfg') platformNPC[x].state(1) # Looping idle animation platformNPC[x].setEuler(0, 0, 0) platformNPC[x].setPosition(pos) #seatedNPC.append(1) #seatedNPC[0] = viz.addChild('vcc_male2.cfg') #seatedNPC[0].state(6) # Looping idle animation #seatedNPC[0].setEuler(180,0,) # Turns him to face you #seatedNPC[0].setPosition(-0.8,0.2,7) # Moves him back so that he is in full view ##man.collideMesh() # #seatedNPC.append(1) #seatedNPC[1] = viz.addChild('vcc_male2.cfg') #seatedNPC[1].state(6) # Looping idle animation #seatedNPC[1].setEuler(180,0,) # Turns him to face you #seatedNPC[1].setPosition(0.0,0.2,7) # Moves him back so that he is in full view ##man.collideMesh() # #seatedNPC.append(1) #seatedNPC[2] = viz.addChild('vcc_male2.cfg') #seatedNPC[2].state(6) # Looping idle animation #seatedNPC[2].setEuler(180,0,) # Turns him to face you #seatedNPC[2].setPosition(0.7,0.2,7) # Moves him back so that he is in full view ##man.collideMesh() # #seatedNPC.append(1) #seatedNPC[3] = viz.addChild('vcc_male2.cfg') #seatedNPC[3].state(6) # Looping idle animation #seatedNPC[3].setEuler(180,0,) # Turns him to face you #seatedNPC[3].setPosition(1.4,0.2,7) # Moves him back so that he is in full view ##man.collideMesh()
def loadColiseum(): """loads colosseum enviornment""" sf = .5 colosseum = viz.addChild('.\\dataset\\environment\\coliseum.OSGB') colosseum.setEuler([0,-90,0]) colosseum.setScale([sf,sf,sf]) colosseum.setPosition([-37.5*sf , 0, 0]) #center colisseum pedistal = viz.addChild('.\\dataset\\environment\\capital.OSGB') pedistal.setScale([100,100,100]) pedistal.setPosition([0,-7.26,0]) #Found by testing
def main(): ### Configuration parameters # moved to config.py ### Game startup #overwrite escape key viz.setOption('viz.default_key.quit','0') # Physics viz.phys.enable() #viz.phys.setGravity(0,0,0) # Initialize pointer tool # Unused? glove = viz.addChild('.\\dataset\\Hand\\handPoint_Reduced.ply') glove.disable([viz.PHYSICS, viz.DYNAMICS]) glovePhys = glove.collideSphere() glove.setPosition([0,1,0]) glove.setScale([1,1,1]) # Initialize environment this will load the coliseum and sky sky = viz.addChild('sky_day.osgb') sky.collideMesh() sky.disable(viz.DYNAMICS) init.loadTemple() # Initialize pointer controls device = init.pointerInput(config.pointerMode, glove, sky) # Initialize display puzzle.model.display = init.DisplayInstance(config.dispMode,config.camMode,device,glove) #init.display(config.dispMode) # Initialize camera controls #init.cameraInput(config.camMode,config.dispMode, device, glove) # Launch menu system menu.init() puzzle.model.pointer = glove puzzle.model.pointer.setScale(0.015, 0.015, 0.015) puzzle.model.pointer.setEuler(0, -115, 0) # Override default escape key map to call main menu vizact.onkeydown(viz.KEY_ESCAPE, menu.toggle) # # Record moviefilms # viz.setOption('viz.AVIRecorder.maxWidth', '1280') # viz.setOption('viz.AVIRecorder.maxHeight', '720') # vizact.onkeydown(viz.KEY_F11, viz.window.startRecording, 'D:\\recording.avi') # vizact.onkeydown(viz.KEY_F12, viz.window.stopRecording) # Stuff to run on program termination vizact.onexit(puzzle.controller.end)
def main(): ### Configuration parameters # moved to config.py ### Game startup # overwrite escape key viz.setOption("viz.default_key.quit", "0") # Physics viz.phys.enable() # viz.phys.setGravity(0,0,0) # Initialize pointer tool # Unused? glove = viz.addChild(".\\dataset\\Hand\\handPoint_Reduced.ply") glove.disable([viz.PHYSICS, viz.DYNAMICS]) glovePhys = glove.collideSphere() glove.setPosition([0, 1, 0]) glove.setScale([1, 1, 1]) # Initialize environment this will load the coliseum and sky sky = viz.addChild("sky_day.osgb") sky.collideMesh() sky.disable(viz.DYNAMICS) init.loadTemple() # Initialize pointer controls device = init.pointerInput(config.pointerMode, glove, sky) # Initialize display puzzle.model.display = init.DisplayInstance(config.dispMode, config.camMode, device, glove) # init.display(config.dispMode) # Initialize camera controls # init.cameraInput(config.camMode,config.dispMode, device, glove) # Launch menu system menu.init() puzzle.model.pointer = glove puzzle.model.pointer.setScale(0.015, 0.015, 0.015) puzzle.model.pointer.setEuler(0, -115, 0) # Override default escape key map to call main menu vizact.onkeydown(viz.KEY_ESCAPE, menu.toggle) # # Record moviefilms # viz.setOption('viz.AVIRecorder.maxWidth', '1280') # viz.setOption('viz.AVIRecorder.maxHeight', '720') # vizact.onkeydown(viz.KEY_F11, viz.window.startRecording, 'D:\\recording.avi') # vizact.onkeydown(viz.KEY_F12, viz.window.stopRecording) # Stuff to run on program termination vizact.onexit(puzzle.controller.end)
def loadColiseum(): """loads colosseum enviornment""" sf = .5 colosseum = viz.addChild('.\\dataset\\environment\\coliseum.OSGB') colosseum.setEuler([0, -90, 0]) colosseum.setScale([sf, sf, sf]) colosseum.setPosition([-37.5*sf, 0.0, 0.0]) #center colisseum pedistal = viz.addChild('.\\dataset\\environment\\capital.OSGB') pedistal.setScale([100, 100, 100]) pedistal.setPosition([0.0, -7.26, 0.0]) #Found by testing
def main(): global train train = viz.addChild('Assets/Railcar_Main_OS.osgb', scene=viz.Scene1) platform = viz.addChild('Assets/environment.osgb', scene=viz.Scene1) viz.addChild('sky_day.osgb', scene=viz.Scene1) EnvironmentSetup.Start(train) NPCSpawner.InitPlat(platform) NPCSpawner.InitSeatedPos(train) NPCSpawner.InitStandingPos(train) NPCSpawner.SpawnPlatformNPC() viztask.schedule(RecordHR()) viztask.schedule(InitalSetup(train))
def recordViewAnimation(): ### replace with your own application setup import viz import vizcam import vizact viz.setMultiSample(4) viz.go() vizcam.WalkNavigate() piazza = viz.addChild("piazza.osgb") ### ### Add this at the bottom ''' Create an AnimationPathRecorder and link it to any node, which needs to have it's transformation documented. If 'start' is set to True the recording will start automatically, otherwise you need to start manually. you can specify the file name under which the animation will be saved. '.txt' is automatically added. ''' rec = AnimationPathRecorder(start=False) viz.link(viz.MainView, rec) # toggle path recording and saving finished recording to a file named 'test_animation.txt' def toggleRecord(rec): if rec.isRunning(): rec.stop() rec.writeToFile("test_animation") print "Animation path saved to test_animation.txt" else: rec.start() print "Animation path recording started." vizact.onkeydown('r', toggleRecord, rec)
def __init__(self, fileName, SF=1.0 / 500): """Pull the BodyParts3D mesh into an instance and set everything up""" self.tooltip = None self.snapAttempts = 0 self.metaData = model.ds.getMetaData(file=fileName) self.centerPoint = self.metaData['centerPoint'] self.centerPointScaled = [a * SF for a in self.centerPoint] self.centerPointScaledFlipped = [a * SF * -1 for a in self.centerPoint] self._lineUpdateEvent = None self.name = self.metaData['name'] for region, names in config.OntologicalGroups.regions.iteritems(): files = model.ds.getOntologySet([(set.union, names)]) if self.metaData['filename'] in files: self.region = region break else: self.region = None self.nameFormatted = '' for i, w in enumerate(self.name.split()): if (i + 1) % 2 == 0 and i != 0: self.nameFormatted += w + '\n' else: self.nameFormatted += w + ' ' # We are using a 'center' viznode to make manipulation easy self.center = vizshape.addCube(0.001) # An arbitrary placeholder cube super(Mesh, self).__init__(self.center.id) # This is the actual mesh we will see self.mesh = viz.addChild(config.DATASET_PATH + fileName + '.obj') self.mesh.setScale([SF, SF, SF]) # This is the viznode that will be moved around to check distances for snapping self.checker = vizshape.addCube(0.001) # Setup heirarchy for proper movement behavior self.mesh.setParent(self) self.checker.setParent(self.mesh) # Offset mesh to lie in center of center viznode self.mesh.setPosition(self.centerPointScaledFlipped, viz.ABS_PARENT) self.checker.setPosition(self.centerPoint) # Turn off visibility of center and checker viznodes self.mesh.color(self.metaData['color']) self.checker.disable([viz.RENDERING, viz.INTERSECTION, viz.PHYSICS]) self.center.disable([viz.RENDERING, viz.INTERSECTION, viz.PHYSICS]) self.scale = SF self._enabled = True self.grounded = False self.grabbedFlag = 0 self.proxCounter = 0 # Group handling self.group = MeshGroup([self])
def __init__(self): # base class constructor viz.EventClass.__init__(self) self.model = viz.addChild('piazza.osgb') # set up keyboard and timer callback methods self.callback(viz.KEYDOWN_EVENT,self.onKeyDown) self.callback(viz.MOUSEDOWN_EVENT,self.onMouseDown) #booleans for video self.check1 = False #avatar's postion and rotation angle self.x = 0.5 self.z = 0.5 #counts for animaions self.count = 0.0 self.count2 = 0.0 self.theta = 0 #inserting avater self.avatar = vizfx.addAvatar('mazinger/mazinger.cfg') self.avatar.state(0) #translating avatar to correct position mat = viz.Matrix() #mat.postAxisAngle(0,1,0,self.theta) mat.postTrans(0,7,0); self.avatar.setMatrix(mat) self.callback(viz.TIMER_EVENT,self.onTimer) #mazin.addAction(spin) #Music #add ground grass = viz.addTexture('images/tile_grass.jpg', wrap=viz.REPEAT)
def createEnvironment(): #create 2D environment if parameters.DreiDEnvironment: viz.clearcolor(viz.WHITE) #look from above viz.MainView.setPosition([0,50,0]) viz.MainView.setEuler([0,90,0]) goal.setEuler(0,90,0) goal.color(viz.GREEN) point.setEuler(0,90,0) point.setPosition(0,20,0) point.color(viz.RED) arrow.setPosition(0,20,0) arrow.color(viz.BLUE) #or create 3d environment else: piazza = viz.addChild('piazza.osgb') #look from above viz.MainView.setPosition([0,1.8,0]) #viz.MainView.setEuler([0,90,0]) goal.setEuler(0,90,0) goal.color(viz.GREEN) point.setEuler(0,90,0) point.setPosition(0,20,0) point.color(viz.RED) arrow.setPosition(0,20,0) arrow.color(viz.BLUE)
def Collect(objName, objLoc, ScaleFac, tel): viz.MainWindow.setScene(1) #teleport to new location each trial? if tel: x, y = pol2cart(numpy.random.randint(12, radius), numpy.random.randint(0, 360)) viz.MainView.setPosition(x, 0, y) viz.MainView.setEuler(numpy.random.randint(0, 360), 0, 0) #add object obj = viz.addChild(objName + '.osgb') obj.setPosition(objLoc) obj.setScale([ScaleFac, ScaleFac, ScaleFac]) sensor = vizproximity.addBoundingBoxSensor(obj, scale=(1.5, 10, 1.5)) manager.addSensor(sensor) obj.visible(viz.ON) yield vizproximity.waitEnter(sensor) obj.remove() manager.removeSensor(sensor)
def __init__(self, room, size, marker_num, hand='left'): VisualObject.__init__(self, room=room, shape='sphere', size=size) # remove the sphere and add the baseball glove self.vis_node.remove() model_path = 'res/glove_{}.OSGB'.format(hand) try: self.vis_node = viz.addChild(model_path) except: print 'Hand must be left or right.' # setup position and orientation tracking glove_tracker = ppt.add_tracker(1) isense = viz.add('intersense.dle') self.ori_tracker = isense.addTracker(port=0) self.ori_tracker.setCompass(0) self.ori_tracker.setEnhancement(0) self.ori_tracker.resetHeading() vizact.onkeydown('i', self.ori_tracker.resetHeading) if hand == 'left': pre_trans = [0.04, -0.02, 0] else: pre_trans = [-0.04, -0.02, 0] link = ppt.link(tracker=glove_tracker, target=self.vis_node, ori=self.ori_tracker, pre_trans=pre_trans) # setup physics object # TODO: do we really want this? self.toggleUpdatePhysWithVis()
def main(): global marker global current if marker.getVisible() and current == 1: current = 0 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 endValueX1 = endMarker.getPosition()[0] endValueY1 = endMarker.getPosition()[1] endValueZ1 = endMarker.getPosition()[2] arrow = viz.add('thesis/greenArrow.dae') scaleSize = 0.5 arrow.setScale(scaleSize, scaleSize, scaleSize) #change the size of arrow object arrow.setEuler(90) arrow.setPosition([baseValueX1, baseValueY1, baseValueZ1]) positions = [[baseValueX1, baseValueY1, baseValueZ1], [1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4]] for p in range(5): 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(positions[p])
def froo(): yield viztask.waitKeyDown('k') boxL.visible(0) stuff = viz.addChild('targetexplode12.osgb',pos=[-0.2,targetL,0],scale=[0.1,(targettol+0.02),0.0125]) # stuff = viz.addChild('targetexplode10.osgb',pos=[0,2,20]) stuff.setAnimationState(0)
def loadTemple(bounding = True): """loads temple enviornment""" sf = 100 temple = viz.addChild('.\\dataset\\environment\\temple.OSGB') temple.setEuler([0,90,0]) temple.setScale([sf,sf,sf]) temple.setPosition([0.0, -1.569, 0.0]) #Found by measuring pedistal = viz.addChild('.\\dataset\\environment\\Column.OSGB') pedistal.setScale([3.0, 3.0, 3.0]) pedistal.setPosition([0.0, -1.5, 0.0]) #Found by testing if bounding == True: dimensions = [2,4,1] boundingBox = games.puzzleView.WireFrameCube(dimensions) # boundingBox.setPosition(0,dimensions[1],0) boundingBox.alpha(0.25)
def loadTemple(bounding = True): """loads temple enviornment""" sf = 100 temple = viz.addChild('.\\dataset\\environment\\temple.OSGB') temple.setEuler([0,90,0]) temple.setScale([sf,sf,sf]) temple.setPosition([0.0, -1.569, 0.0]) #Found by measuring pedistal = viz.addChild('.\\dataset\\environment\\Column.OSGB') pedistal.setScale([3.0, 3.0, 3.0]) pedistal.setPosition([0.0, -1.5, 0.0]) #Found by testing if bounding == True: dimensions = [2,4,1] boundingBox = games.puzzleView.WireFrameCube(dimensions) # boundingBox.setPosition(0,dimensions[1],0) boundingBox.alpha(0.25)
def __init__(self, plane, planepos, escena, next, sound): self.plane = viz.addChild(plane, scene=escena) self.plane.setScale(2.5, 2.5, 2.5) self.plane.setPosition(planepos[0], planepos[1]) self.sensorPlane = vizproximity.Sensor( vizproximity.RectangleArea( [2, 10], center=[self.plane.getPosition(0)[0], 0]), None) self.chimesound = sound self.next = next
def setModel (self, path): global model global modelIsLoaded if not (modelIsLoaded): model = viz.addChild(path) model.disable(viz.CULL_FACE) model.setPosition(0,0,60, viz.ABS_GLOBAL) model.setEuler([0,0,0]) alphaSlider.set(1.0) modelIsLoaded = True
def __init__(self): if Falcon._captainFalcon == None: Falcon._captainFalcon = viz.addChild(Falcon._MODEL_FILE) Falcon._captainFalcon.visible(viz.OFF) self.node = Falcon._captainFalcon.copy() viz.VizNode.__init__(self,self.node.id) self.collideBox() self.initEuler() self.initForces()
def setup(self): yield viztask.waitTime(3) self.head.reset() stamp = datetime.datetime.now().strftime('%Y%m%d%H%M%S') self.output = os.path.join( DESKTOP, 'tracing-data', '{}-{:08x}'.format( stamp, random.randint(0, 0xffffff))) logging.info('storing output in %s', self.output) self.environment = viz.addChild('dojo.osgb')
def setUpWorld(): global city city = viz.addChild('metro.osgb') # NOTE: Look at CityModel.py for more details on the avatars, cars, and pigeons. viz.addChild('models/People/CC2_f001_hipoly_A1_v2.cfg') # Add avatars for avatarInfo in cityModel.PEOPLE_INFO: addAvatarToWorld(avatarInfo) # Add cars for carInfo in cityModel.CARS_INFO: addCarToWorld(carInfo) # Add pigeons for pigeonInfo in cityModel.PIGEONS_INFO: addPigeonToWorld(pigeonInfo) # Fog color viz.fogcolor([.5] * 3)
def CreateRoom(): #Load in the entire room, s tore all geometry in the roomgroup #BL:start global roomGroup # roomGroup = viz.addChild("Resources/NewRoom/vroom.obj") roomGroup = viz.addChild('Resources/NewRoom/labroom.osgb') roomGroup.setScale([0.8,0.75,0.8]) # roomGroup.setPosition([-0.4,0,-1.4]) # roomGroup.setPosition(-3, -1.75, 0, viz.ABS_GLOBAL) roomGroup.emissive([1, 1, 1]) #BL:end # Lag... placeMirror()
def addArm(texturePath, pathToArm): # armPointer = viz.addChild(resources.ARM) armPointer = viz.addChild(pathToArm) texture = viz.addTexture(texturePath) texture.wrap(viz.WRAP_S,viz.REPEAT) texture.wrap(viz.WRAP_T,viz.REPEAT) armPointer.texture(texture) armPointer.emissive([.75, .75, .75]) armPointer.setScale(resources.ARM_SCALE) armPointer.collideBox() armPointer.disable(viz.DYNAMICS) armPointer.visible(False) return armPointer
def __init__(self,use_keyboard = True, desktop_mode = False): """Initialization function.""" # viz.phys.enable() self.view = viz.MainView; caveapp.CaveApplication.__init__(self,desktop_mode) #call constructor of super class, you have to do this explicitly in Python self.wand = vizshape.addAxes()#load axis model to represent the wand\ self.cylinder = vizshape.addCylinder(15,0.002,axis=vizshape.AXIS_X) self.cylinder.setEuler([0,0,0]) #self.cylinder.setCenter([0,0,-1]) self.cylinder.setPosition(7.5,0.08,0) self.stuff = vizshape.addSphere(0.0001) self.cylinder.setParent(self.stuff) # temp = vizshape.addSphere(0.05) # temp.setParent(self.cylinder) # temp.setPosition(self.cylinder.getCenter()) self.wand = self.stuff # self.wand.setPosition(.5,-1,0) # self.cm = self.wand.getMatrix() # self.Room = viz.addChild('D:\Cave software\NFI Cave\Scene\ScannedRoom.3DS') # self.Room.collidePlane() # self.Room.setScale([1.25,1.25,1.25]) # self.Room.setEuler([90,0,0]) # self.Room.setPosition([-1.5,0,1.55]) self.Room = viz.addChild('scene/ScannedRoom.3DS') self.Room.collidePlane() self.Room.setScale([0.002,0.002,0.002]) self.Room.setEuler([90,0,0]) self.Room.setPosition([-1.5,0.015,1.58]) """ mylight = viz.addLight() mylight.enable() mylight.position(0, 1, 0) mylight.spread(180) mylight.intensity(2) # vizact.onkeydown('f', dance) """ viz.disable(viz.LIGHTING) self.headLight = viz.MainView.getHeadLight() #disable the headlight self.headLight.disable() #the headlight is disabled because the piazza.osgb is already shaded self.use_keyboard = use_keyboard #store if we want to use the keyboard self.time = 0.0 #note that to 0.0 is important because it is a double precision floating point number
def __init__(self, use_keyboard = True, desktop_mode = True): caveapp.CaveApplication.__init__(self, desktop_mode) #call constructor of super class, you have to do this explicitly in Python self.wand = vizshape.addAxes()#load axis model to represent the wand self.thing = viz.addChild('plant.osgb') #load plant model to represent the thing self.horse = viz.addChild('horse.wrl') #load a horse model (this model will be animated in cave space) self.horse.color(0.5,0.5,0.5)#make the horse gray self.horse.disable(viz.LIGHTING) #disable the shading of the horse self.worldModel = viz.add('piazza.osgb') #load a world model self.headLight = viz.MainView.getHeadLight() #disable the headlight self.headLight.disable() #the headlight is disabled because the piazza.osgb is already shaded self.use_keyboard = use_keyboard #store if we want to use the keyboard self.time = 0.0 #note that to 0.0 is important because it is a double precision floating point number self.forwardVelocity = 0.0
def main(): viz.vsync(viz.ON) viz.window.setFullscreenMonitor([2]) viz.setMultiSample(4) viz.MainWindow.clip(0.01, 200) viz.go(viz.FULLSCREEN) environment = viz.addChild("piazza.osgb") environment.setPosition(2.75, 0, -0.75) mocap = phasespace.Phasespace() head = mocap.get_rigidTracker("hmd") # DOES NOT ACCOUNT FOR RIGID BODY OFFSET DURING RESET # mocap.track_rigid('Resources/hmd-nvisMount.rb', center_markers=(1,2)) head.link_pose(viz.MainView) # glove = mocap.track_points([8, 9, 10]) paddle = mocap.track_rigid({17: (0, 0, 1), 19: (0, 0, 0), 20: (1, 0, 0), 22: (0, 1, 0)}) mocap.start_thread() # mocap.start_timer() def log_mocap(timer_id): # print 'glove#9 pos {0[1]:.2f} {0[1]:.2f} {0[2]:.2f}'.format(*glove.get_marker(9)) print "head pos {0[0]:.2f} {0[1]:.2f} {0[2]:.2f}, quat {1[0]:.3f} {1[1]:.3f} {1[2]:.3f} {1[3]:.3f}".format( *head.get_pose() ) print "main " + str(viz.MainView.getPosition()) # print 'paddle pos {0[0]:.2f} {0[1]:.2f} {0[2]:.2f}, quat {1[0]:.3f} {1[1]:.3f} {1[2]:.3f} {1[3]:.3f}'.format(*paddle.get_pose()) viz.callback(viz.TIMER_EVENT, log_mocap) viz.starttimer(0, 1, viz.FOREVER) def keydown(key): if key == "h": head.reset() if key == "H": head.save() elif key == "1": print "Marker Pos: " + str(mocap.get_MarkerPos(1)) viz.callback(viz.KEYDOWN_EVENT, keydown)
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 __load_STL(self, stl_directory, objects_STL, initial_orientations, initial_position): parent_object = None for file_name, dh_parameters in objects_STL: full_file_name = os.path.join(stl_directory, file_name) if parent_object: current_object = viz.addChild(full_file_name, parent=parent_object) else: current_object = viz.addChild(full_file_name) current_object.color(1.0, .5, 0) current_object.specular(.1, .1, .1) current_object.shininess(50) current_object.collideMesh() self.__axes.append(current_object) self.__angles.append(0.0) parent_object = current_object self.__axes[1].color(.8, .8, .8) self.__axes[3].color(.8, .8, .8) self.__axes[5].color(.8, .8, .8) self.__axes[7].color(.8, .8, .8) for index, current_object in enumerate(self.__axes): dh_parameters = objects_STL[index][1] current_object.setAxisAngle(0, 0, 1, dh_parameters[0], viz.REL_PARENT) current_object.setPosition(0, 0, dh_parameters[1], viz.REL_PARENT) current_object.setPosition(dh_parameters[2], 0, 0, viz.REL_LOCAL) current_object.setAxisAngle(1, 0, 0, dh_parameters[3], viz.REL_LOCAL) for o in initial_orientations: self.set_axis_angle(o[0], o[1]) if initial_position != None: self.set_position(initial_position)
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 bambooForest(self): # Add the ground plane ground = viz.addChild('ground.osgb') # Bamboo sticks bambooForest1 = [] bambooForest2 = [] # add 200 bamboo trees to each forest for i in range(0, 400, 1): bambooForest1.append(vizshape.addCylinder(random.randint(10,16),0.1)) bambooForest2.append(vizshape.addCylinder(random.randint(10,16),0.1)) bambooForest1[i].setPosition(random.randint(-16,-3),0.5,random.randint(-20,20)) bambooForest2[i].setPosition(random.randint(3,16),0.5,random.randint(-20,20)) bambooForest1[i].color(0.3,0.8,0.3) bambooForest2[i].color(0.3,0.8,0.3)
def __setupWorld__(self): #Initialize cave and load the powerwall# self.cave = vizcave.Cave() #This line of code opens the file if a filename is provided and loads the corner co-ordinates from it, else uses the default co-ordinates# self.cave.load(self.caveWallFileName) if None is not self.caveWallFileName else self.cave.addWall(self.powerwall) # TODO: Pair every obstacle with an invisible "hat" object to detect when the obstacle was avoided. # Create a seperate module that does this automatically for each object added. # Like from a config file. self.crate = viz.addChild( 'crate.osgb' ) self.crate.setScale([.2,.2,.2]) self.crate.setPosition([-.45, 0, -.10]) self.cratePole = vizshape.addCylinder(height = .5, radius = 0.025) self.cratePole.setPosition( [-.45, .3, -.10] ) self.cratePole.alpha(0.5) self.avatar = viz.addAvatar('duck.cfg') self.avatar.setScale(.2, .2, .2) self.avatar.setPosition([-1, .1, -.10]) #self.floor = viz.addChild('lab.osgb') self.floor = viz.addChild('piazza.osgb')
def __init__(self, handTracker = None): # These two lines are weird necessities to subclass the VizNode class (which most Vizard objects are?) self.node = viz.addChild(Dart._MODEL_FILE) viz.VizNode.__init__(self,self.node.id) self.setScale(Dart._SCALE, Dart._SCALE, Dart._SCALE) self.color(1, 0, 0) self.collideBox() self.enable(viz.COLLIDE_NOTIFY) viz.callback(viz.COLLIDE_BEGIN_EVENT, onCollide) self.initVelocity() self.initEuler() self.setVelocity([0, 0, 0]) if handTracker != None: self.attachToHand(handTracker)
def main(): viz.setOption('viz.fullscreen.monitor', 1) viz.setOption('viz.window.width', 2 * 640) viz.setOption('viz.window.height', 480) viz.setMultiSample(4) viz.MainWindow.clip(0.01, 500) vizconfig.register(nvis.nvisorSX111()) viz.go(viz.FULLSCREEN) piazza = viz.addChild('piazza.osgb') mocap = phasespace.Mocap('192.168.1.230') head = mocap.track_rigid('Resources/hmd-nvis.rb', center_markers=(0, 5)) head.link_pose(viz.MainView) glove = mocap.track_points([8, 9, 10]) paddle = mocap.track_rigid({ 17: (0, 0, 1), 19: (0, 0, 0), 20: (1, 0, 0), 22: (0, 1, 0), }) mocap.start_thread() #mocap.start_timer() def log_mocap(timer_id): print 'glove#9 pos {0[1]:.2f} {0[1]:.2f} {0[2]:.2f}'.format( *glove.get_marker(9)) print 'head pos {0[0]:.2f} {0[1]:.2f} {0[2]:.2f}, quat {1[0]:.3f} {1[1]:.3f} {1[2]:.3f} {1[3]:.3f}'.format( *head.get_pose()) print 'paddle pos {0[0]:.2f} {0[1]:.2f} {0[2]:.2f}, quat {1[0]:.3f} {1[1]:.3f} {1[2]:.3f} {1[3]:.3f}'.format( *paddle.get_pose()) viz.callback(viz.TIMER_EVENT, log_mocap) viz.starttimer(0, 1, viz.FOREVER) def keydown(*args): head.reset() paddle.reset() viz.callback(viz.KEYDOWN_EVENT, keydown)
def main(): if marker.getVisible(): 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)
def __init__(self, scale=1, color=None): if Balloon._masterBalloon == None: Balloon._masterBalloon = viz.addChild(Balloon._MODEL_FILE) Balloon._masterBalloon.visible(viz.OFF) self.node = Balloon._masterBalloon.copy() viz.VizNode.__init__(self,self.node.id) self.setScale(scale * Balloon._SCALE_NORMALIZER, scale * Balloon._SCALE_NORMALIZER, scale * Balloon._SCALE_NORMALIZER) if color != None: self.color(color) else: self.color(self._DEFAULT_COLOR) self.collideBox() self.float()
def bmw_card_driver(): car = viz.addChild('bmw.dae') car.setEuler([0,0,0]) car.setScale(0.5,0.5,0.5) MOVE_SPEED = 5 TURN_SPEED = 60 def updatecar(): #move view forward and backward if viz.key.isDown(viz.KEY_UP): view.move([0,0,MOVE_SPEED*viz.elapsed()],viz.BODY_ORI) elif viz.key.isDown(viz.KEY_DOWN): view.move([0,0,-MOVE_SPEED*viz.elapsed()],viz.BODY_ORI) #rotate body of view left and right if viz.key.isDown(viz.KEY_RIGHT): view.setEuler([TURN_SPEED*viz.elapsed(),0,0],viz.BODY_ORI,viz.REL_PARENT) elif viz.key.isDown(viz.KEY_LEFT): view.setEuler([-TURN_SPEED*viz.elapsed(),0,0],viz.BODY_ORI,viz.REL_PARENT) #set the car to view position and body orientation car.setPosition(view.getPosition()) car.setEuler(view.getEuler(viz.BODY_ORI)) car.setPosition([3.02,-5.50,5.04],viz.REL_LOCAL) vizact.ontimer(0,updatecar) #update head of view based on mouse movements def mousemove(e): euler = view.getEuler(viz.HEAD_ORI) euler[0] += e.dx*0.1 euler[1] += -e.dy*0.1 euler[1] = viz.clamp(euler[1],-85.0,85.0) view.setEuler(euler,viz.HEAD_ORI) viz.callback(viz.MOUSE_MOVE_EVENT,mousemove) viz.mouse(viz.OFF) viz.mouse.setVisible(False) vizact.onmousedown(viz.MOUSEBUTTON_LEFT,view.reset,viz.HEAD_ORI) vizact.onmousedown(viz.MOUSEBUTTON_RIGHT,view.reset, viz.BODY_ORI |viz.HEAD_POS) vizact.onmousedown(viz.MOUSEBUTTON_RIGHT,updatecar)
def main(): viz.setOption('viz.fullscreen.monitor', 1) viz.setOption('viz.window.width', 2 * 640) viz.setOption('viz.window.height', 480) viz.setMultiSample(4) viz.MainWindow.clip(0.01, 500) vizconfig.register(nvis.nvisorSX111()) viz.go(viz.FULLSCREEN) piazza = viz.addChild('piazza.osgb') mocap = phasespace.Mocap('192.168.1.230') head = mocap.track_rigid('Resources/hmd-nvis.rb', center_markers=(0, 5)) head.link_pose(viz.MainView) glove = mocap.track_points([8, 9, 10]) paddle = mocap.track_rigid({ 17:(0, 0, 1), 19:(0, 0, 0), 20:(1, 0, 0), 22:(0, 1, 0), }) mocap.start_thread() #mocap.start_timer() def log_mocap(timer_id): print 'glove#9 pos {0[1]:.2f} {0[1]:.2f} {0[2]:.2f}'.format(*glove.get_marker(9)) print 'head pos {0[0]:.2f} {0[1]:.2f} {0[2]:.2f}, quat {1[0]:.3f} {1[1]:.3f} {1[2]:.3f} {1[3]:.3f}'.format(*head.get_pose()) print 'paddle pos {0[0]:.2f} {0[1]:.2f} {0[2]:.2f}, quat {1[0]:.3f} {1[1]:.3f} {1[2]:.3f} {1[3]:.3f}'.format(*paddle.get_pose()) viz.callback(viz.TIMER_EVENT, log_mocap) viz.starttimer(0, 1, viz.FOREVER) def keydown(*args): head.reset() paddle.reset() viz.callback(viz.KEYDOWN_EVENT, keydown)
def loadTemple(bounding=True): """loads temple enviornment""" global boundingBox global temple sf = 100 temple = viz.addChild('.\\dataset\\environment\\temple.OSGB') temple.setEuler([0, 90, 0]) temple.setScale([sf, sf, sf]) temple.setPosition([0, -2.8, 0]) #Found by testing # pedistal = viz.addChild('.\\dataset\\environment\\Column.OSGB') # pedistal.setScale([3.0,3.0,3.0]) # pedistal.setPosition([0,-1.5,0]) #Found by testing if bounding == True: dimensions = [1, 2, 0.5] boundingBox = puzzle.view.wireframeCube(dimensions) boundingBox.setPosition(0, dimensions[1] / 2, 0) boundingBox.alpha(0.25)
def create3DEnvironment(): #ground = viz.add('tut_ground.wrl') # Add ground #ground.collidePlane() # Make collideable plane #viz.clearcolor(viz.WHITE) piazza = viz.addChild('piazza.osgb') #look from above viz.MainView.setPosition([0,1.8,0]) #viz.MainView.setEuler([0,90,0]) goal.setEuler(0,90,0) goal.color(viz.GREEN) point.setEuler(0,90,0) point.setPosition(0,20,0) point.color(viz.RED) arrow.setPosition(0,20,0) arrow.color(viz.BLUE)
def loadTemple(bounding = True): """loads temple enviornment""" global boundingBox global temple sf = 100 temple = viz.addChild('.\\dataset\\environment\\temple.OSGB') temple.setEuler([0,90,0]) temple.setScale([sf,sf,sf]) temple.setPosition([0,-2.8, 0]) #Found by testing # pedistal = viz.addChild('.\\dataset\\environment\\Column.OSGB') # pedistal.setScale([3.0,3.0,3.0]) # pedistal.setPosition([0,-1.5,0]) #Found by testing if bounding == True: dimensions = [1,2,0.5] boundingBox = puzzle.view.wireframeCube(dimensions) boundingBox.setPosition(0,dimensions[1]/2,0) boundingBox.alpha(0.25)
def addFishes(self): self.fishes = [] fish_root = viz.addChild('art/environment/floater.osgb') fish_root.angle = 30 fish_root.setPosition(0, -100, 0) self.fishes.append(fish_root) fishToAdd = self.numFish + 1; for angle in self.angularOffsets: fishToAdd -= 1 if (self.numFish != DEFAULT_NUM_FISH and fishToAdd >= (self.numFish * .9)): continue #FISH EULER NEEDS TO BE SET IN INSPECTOR fish = vizfx.addChild(self.FISH_FILE, parent=fish_root) if (self.modScale): mult = vizmat.GetRandom(-.1, .2) * (self.numFish - fishToAdd) fish.setScale(1 + mult,1 + mult,1 + mult,viz.ABSOLUTE) fish.angle = angle / (vizmat.GetRandom(self.numFish - 2, self.numFish + .5)) self.updateFishCircle(fish) self.fishes.append(fish) if (fishToAdd == 0): break
def main(): global wingl # global wingr viz.cam.setHandler(vizcam.KeyboardCamera()) myo.init() gyrolist = [[0,0,0]] viz.setMultiSample(4) # wingl = viz.addChild('basketball.osgb') wingl.setScale([10,0.3,1]) wingl.setCenter([100,100,100]) wingl.setEuler([0,90,0]) wingl.collideSphere(0.5) lStartPOS = [ 0, 2.5, 2 ] wingl.setPosition( lStartPOS ) # wingr = viz.addChild('basketball.osgb') # wingr.setScale([10,0.3,1]) # wingr.setCenter([100,100,100]) # wingr.setEuler([0,90,0]) # wingr.collideSphere(0.5) # rStartPOS = [ 0, 2.5, 2 ] # wingr.setPosition( rStartPOS ) #viz.MainView.setPosition([0,2,-15]) hub = myo.Hub() hub.set_locking_policy(myo.locking_policy.none) hub.run(1000, Listener()) vizact.ontimer(0.01 ,updateMyo, [gy, gy2, gy3, wingl, orx, ory, orz, orw, or1x, or1y, or1z, or1w]) vizact.onkeydown('p', hub.shutdown) FileReader() initializeObjectFiles() initializeLocations() vizact.ontimer(0.1, update) vizact.onkeydown(' ', statusUpdate) vizact.onkeydown('s', hub.shutdown) # viz.AVIRecorder.maxWidth = 1920; # viz.AVIRecorder.maxHight = 1080; vizact.onkeydown('b', viz.window.startRecording, 'myo_capture.avi' ) vizact.onkeydown('e', viz.window.stopRecording )
def __init__(self, camera, player_prefs, move_speed=5.0, turn_speed=25.0): self.view = viz.MainView self.camera = camera self.player_prefs = player_prefs # TODO: Init paddle and board based on player_prefs self.paddle = None self.board = viz.addChild('seaeagle.dae') self.board.collidePlane() self.board.disable(viz.DYNAMICS) self.move_speed = move_speed self.turn_speed = turn_speed self.max_speed = 10 self.ball_dir = viz.add('white_ball.wrl') #viz.link(self.board, self.ball_board) self.PS1 = None self.PS2 = None self.ball1 = None self.ball = None self.last_pos_ball = None self.water_level = 0.4
def __init__(self,**kw): # Initialize base class with model model = viz.addChild('models/steve.ive') model.setCenter(0,.3,0) viz.VizNode.__init__(self,model.id,**kw) # Get handle to head/body self.head = self.getChild(_HEAD_NAME) self.body = self.getChild(_BODY_YAW_NAME) self.body_root = self.getChild(_BODY_NAME) # Internal state variables self._updateFunc = None self._incrementFunc = None self._tracker = None self._trackerFlag = 0 self._bodyTrackMode = BODY_TRACK_NONE self._bodyYawIncrement = 0.0 self._bodyIncrementTime = 0.0 self._lastBodyYaw = 0.0 self._bodyDragPos = [0.0,0.0,0.0]
def setup(self): # set up a folder to store data for a subject. dirname = self.find_output(threshold_min=GAP_MINUTES) self.output = os.path.join(BASE_PATH, dirname) logging.info('storing output in %s', self.output) # configure the phasespace. mocap = vrlab.Phasespace('192.168.1.230', freq=120) self.suit = mocap.track_points(range(len(suit.MARKER_LABELS))) self.leds = [] for i in range(50): sphere = vizshape.addSphere(0.02, color=viz.RED) self.suit.link_marker(i, sphere) self.leds.append(sphere) mocap.start_thread() # set up a proximity manager to detect touch events. self.prox = vizproximity.Manager() #self.prox.setDebug(viz.ON) # add an environment and navigation to help with visualization. self.environment = viz.addChild('dojo.osgb') viz.cam.setHandler(None)
def setup(self): # set up a folder to store data for a subject. dirname = self.find_output(threshold_min=GAP_MINUTES) self.output = os.path.join(BASE_PATH, dirname) logging.info('storing output in %s', self.output) # configure the phasespace. mocap = vrlab.Phasespace('192.168.1.230', freq=120) self.suit = mocap.track_points(range(len(suit.MARKER_LABELS))) self.leds = [] for i in range(50): sphere = vizshape.addSphere(0.02, color=viz.RED) self.suit.link_marker(i, sphere) self.leds.append(sphere) mocap.start_thread() # set up a proximity manager to detect touch events. self.prox = vizproximity.Manager() #self.prox.setDebug(viz.ON) # add an environment and navigation to help with visualization. self.environment = viz.addChild('dojo.osgb') viz.cam.setHandler(None)
def __init__(self, gem, gempos, escena, sound): print "ESCENA-2", escena self.gem = viz.addChild(gem, scene=escena) self.gem.setScale(2.5, 2.5, 2.5) self.gem.setPosition(gempos[0], gempos[1]) self.sensorGem = vizproximity.addBoundingBoxSensor(self.gem, scale=[6, 4, 6]) self.chimesound = sound self.canvas = viz.addGUICanvas() self.canvas.alignment(viz.ALIGN_CENTER) viz.MainWindow.setDefaultGUICanvas(self.canvas) self.info = vizinfo.InfoPanel('AVERNO', align=viz.ALIGN_RIGHT_TOP, icon=False) self.info.setTitle('Ejemplo') self.info.setPanelVisible(False) self.canvas.setRenderWorld([600, 500], [3, viz.AUTO_COMPUTE]) self.canvas.setPosition([ self.gem.getPosition()[0], self.gem.getPosition()[1] + 0.5, self.gem.getPosition()[2] ]) self.canvas.setEuler(0, 0, 0)
def load_robot_parts(): """ Die Einzelteile des Roboters werden geladen und auf dem Tisch positioniert. Die Positionen sthen in der globalen Liste positions. """ global robot, positions robot_parts = [] i = 0 for file_name, dh_parameters in robot.objects_STL: full_file_name = os.path.join(r'STL', file_name) current_object = viz.addChild(full_file_name) current_object.color(1.0, 0.5, 0) # current_object.color(.5, .5, .7) current_object.specular(.1, .1, .1) current_object.shininess(50) # Die Basis des Roboters wird nicht auf dem # Tisch positioniert if robot_parts: current_object.setPosition([positions[i], 1.1, 4.5]) current_object.collideBox() i += 1 robot_parts.append(current_object) # Positionierung der Basis robot_parts[0].setPosition(robot.get_position(0)) #robot_parts[0].setPosition([0,-0.3,0],viz.REL_LOCAL) robot_parts[0].setAxisAngle(robot.get_orientation(0)) robot_parts[0].collideMesh() robot_parts[1].setAxisAngle([0, 0, 1, 90]) robot_parts[4].setAxisAngle([0, 0, 1, 90]) robot_parts[5].setAxisAngle([1, 0, 0, 90]) robot_parts[1].color(.8, .8, .8) robot_parts[3].color(.8, .8, .8) robot_parts[5].color(.8, .8, .8) robot_parts[7].color(.8, .8, .8) return robot_parts
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 _setup_environment(self): """ Setup all objects to create the environments. Environments can be switched with the R key on the keyboard. """ # Add the comfortable "kitchen" room self._room = viz.addChild("Room.osgb") self._room.setScale(.01, .01, .01) # Create the clean "ground" environment (just a white round ground). # This environment isn't saved in a osgb file, because the lights couldn't be configured to use the light group 1 instead of 0. # Only 8 lights are allowed per light group. Room has already 8 lights. img = viz.addTexture('assets/ground.png') self._ground = vizshape.addQuad() self._ground.setScale(6, 6, 6) self._ground.setEuler(0, 90, 0) self._ground.texture(img) # Create the lights for the "ground" envirtonment. light_positions = [ [0, 5, 0], # From top [0, -5, 0], # From bottom [3, 1.5, 0], [-3, 1.5, 0], [0, 1.5, 3], [0, 1.5, -3] ] for light_position in light_positions: light = viz.addLight(group=1) light.setParent(self._ground) light.spread(45) light.intensity(1) light.spotexponent(3) light.setPosition(light_position, mode=viz.ABS_GLOBAL) light.lookAt(self._ground.getPosition()) # Hide the second environment until the environment gets changed self._ground.visible(False)
def __init__(self, model, escena, gems, gemspos, gemcount, planes, planespos, nextScene, gemsound, planesound): self.mine = viz.addChild(model, scene=escena) self.planeList = list() contpos = 0 for x in planes: planeitem = Plane(x, planespos[contpos], escena, nextScene[contpos], planesound) self.planeList.append(planeitem) contpos = contpos + 1 self.btn_regresa = viz.addButtonLabel("regresar", scene=escena) self.btn_regresa.setPosition(0.9, 0.1) self.gemList = list() contpos = 0 print escena for x in gems: gemitem = Gem(x, gemspos[contpos], escena, gemsound) self.gemList.append(gemitem) contpos = contpos + 1
#setup a variable to scale the height of objects so that the screen setup is optimized for viewing base on target values global scalorxx scalorxx = 0.6667 #set target tolerance for step time global targetL targetL = 1 global targetR targetR = 1 global targettol targettol = 0.05 global boxL boxL = viz.addChild('target.obj',color=(0.063,0.102,0.898),scale=[0.1,(targettol+0.04)*0.75,0.0125]) boxL.setPosition([-0.2,targetL*scalorxx,0]) #place quad behind to show movie global rvideo global lvideo global Rquad global Lquad rvideo = viz.addVideo('RightSuccess0001-0040.avi') lvideo = viz.addVideo('LeftSuccess0001-0040.avi') #rvideo.loop() #lvideo.loop() #rvideo.play() #lvideo.play()
import vizact import viztask import vizproximity import vizinfo from vhil_devkit import * RIFT = True PPT1 = True vhilGo(RIFT, PPT1) view = viz.MainView view.setPosition(0, .5, -10) viz.setMultiSample(4) viz.fov(60) #viz.go(viz.FULLSCREEN) room = viz.addChild('MeghaRoom2.osgb') room.setEuler(-88, 0, 0) room.setScale(.08, .08, .08) instructions = vizinfo.InfoPanel(icon=False,text=None) cat = viz.addAvatar('cat_tabby_med2.cfg') girl = viz.addAvatar('CC2_f006_hipoly_A2_v2.cfg') girl.state(34) girl.setEuler(180, 0, 0) cat.setPosition(-2.8, 0, -3) girl.setPosition(-2.8, 0, 2) cat.setScale(1.5, 1.5, 1.5) girl.setScale(1.5, 1.5, 1.5) cat.lookAt([2.8, 0, -3]) ball = viz.add('ball.wrl')
def __init__(self, fileName, SF = 1.0/200): """Pull the BodyParts3D mesh into an instance and set everything up""" self.metaData = ds.getMetaData(file = fileName) self.centerPoint = self.metaData['centerPoint'] self.centerPointScaled = [a*SF for a in self.centerPoint] self.centerPointScaledFlipped = [a*SF*-1 for a in self.centerPoint] print self.centerPointScaledFlipped self.name = self.metaData['name'] self.nameFormatted = '' for i, w in enumerate(self.name.split()): if (i + 1) % 2 == 0 and i != 0: self.nameFormatted += w + '\n' else: self.nameFormatted += w + ' ' #give a bone an information property # self.info = '' # for j,bd in enumerate(boneDesc['info'].split()): # if(j+1) % 10 ==0 and j != 0: # self.info += bd + ' \n' # else: # self.info += bd + ' ' # We are using a 'center' viznode to make manipulation easy self.center = vizshape.addCube(0.1) # An arbitrary placeholder cube super(Mesh, self).__init__(self.center.id) # This is the actual mesh we will see self.mesh = viz.addChild(config.DATASET_PATH + fileName + '.obj') self.mesh.setScale([SF,SF,SF]) # This is the viznode that will be moved around to check distances for snapping self.checker = vizshape.addCube(10.0) # Tooltip self.tooltip = viz.addText(self.nameFormatted) self.tooltip.color(0,5,1) self.tooltip.billboard(viz.BILLBOARD_VIEW) self.tooltip.setScale(0.001,0.001,0.001) #small scale for bounding box calc #Description # if display.displayMode == 2: # self.dialogue = viz.addText(self.info,pos = [0,3,0],parent=viz.WORLD) # self.dialogue.billboard(viz.BILLBOARD_VIEW) # self.dialogue.setBackdrop(viz.BACKDROP_CENTER_TOP) # self.dialogue.setScale(0.15,0.15,0.15) # self.dialogue.alignment(viz.ALIGN_CENTER_CENTER) # #self.dialogue.setPosition([0.03,0.85,0]) # #self.dialogue.color(viz.BLACK) # else: # self.dialogue = viz.addText(self.info,parent=viz.SCREEN) # #self.dialogue.setBackdrop(viz.BACKDROP_CENTER_TOP) # self.dialogue.setScale(0.3,0.3,0.0) # self.dialogue.alignment(viz.ALIGN_LEFT_BOTTOM) # self.dialogue.setPosition([0.03,0.85,0]) # #self.dialogue.color(viz.BLACK) # Setup heirarchy for proper movement behavior self.mesh.setParent(self) self.tooltip.setParent(self.center) self.checker.setParent(self.mesh) # Offset mesh to lie in center of center viznode self.mesh.setPosition(self.centerPointScaledFlipped, viz.ABS_PARENT) self.checker.setPosition(self.centerPoint) self.addSensor() # Tooltip formatting self.tooltip.setScale(0.1,0.1,0.1)#set to prefered scale self.tooltip.setPosition(0,0,-1) self.tooltip.alignment(viz.TEXT_CENTER_CENTER) self.tooltip.visible(viz.OFF) #Line between tooltip and mesh centerPoint # viz.startLayer(viz.LINES) # viz.vertexColor(viz.BLUE) # viz.lineWidth(5) # viz.vertex(self.getPosition(viz.ABS_GLOBAL)) # viz.vertex(self.tooltip.getPosition(viz.ABS_GLOBAL)) # self.nameLine = viz.endLayer() # self.nameLine.dynamic() # self.nameLine.visible(viz.OFF) # Turn off visibility of center and checker viznodes self.center.disable([viz.RENDERING]) self.color([0.3,0,0]) self.checker.disable([viz.RENDERING,viz.INTERSECTION,viz.PHYSICS]) self.scale = SF self._enabled = True self.nameAudioFlag = 1 #defualt: 1, 1 allows name to be played, 0 does not allow name playback self.descAudioFlag = 1 #default: 1, 1 allows description to be played, 0 does not allow dec playback self.grabbedFlag = 0 self.proxCounter = 0 # Group handling self.group = BoneGroup([self]) groups.append(self.group)