コード例 #1
0
ファイル: mocapInterfaceNew.py プロジェクト: vicmcg/CGMaze
	def createCalibrationCylinders(self):
		
		##############################################################
		##############################################################
		## left eye and calib grid
		
		self.leftEyeProbeCylinder = vizshape.addCylinder(height=self.eyeProbeCylLength,radius=self.eyeProbeRadius,top=False,bottom=False,axis = vizshape.AXIS_X,color=viz.BLUE)
		self.leftEyeProbeCylinder.disable(viz.CULL_FACE)
		self.leftEyeProbeCylinder.visible( viz.OFF )
		
		self.leftEyeCylinderBack = vizshape.addCircle(self.eyeProbeRadius,axis=vizshape.AXIS_X,color=viz.GREEN)
		self.leftEyeCylinderBack.disable(viz.CULL_FACE)
		self.leftEyeCylinderBack.setParent(self.leftEyeProbeCylinder)
		self.leftEyeCylinderBack.setPosition(self.eyeProbeCylLength/2,0,0) #self.leftEyeProbeCylinder)
		
		self.lGridVertBar = vizshape.addBox([self.probeBarWidthMM,self.eyeProbeRadius*2,self.probeBarWidthMM])
		self.lGridVertBar.setParent(self.leftEyeCylinderBack)

		##############################################################
		##############################################################
		## Draw right eye components 
		
		self.rightEyeProbeCylinder = vizshape.addCylinder(height=self.eyeProbeCylLength,radius=self.eyeProbeRadius,top=False,bottom=False,axis = vizshape.AXIS_X,color=viz.BLUE)
		self.rightEyeProbeCylinder.disable(viz.CULL_FACE)
		self.rightEyeProbeCylinder.visible( viz.OFF )
		
		self.rightEyeCylinderBack = vizshape.addCircle(self.eyeProbeRadius,axis=vizshape.AXIS_X,color=viz.GREEN)
		self.rightEyeCylinderBack.disable(viz.CULL_FACE)
		self.rightEyeCylinderBack.setParent(self.rightEyeProbeCylinder)
		self.rightEyeCylinderBack.setPosition(self.eyeProbeCylLength/2,0,0) #self.leftEyeProbeCylinder)
		
		self.rGridHorzBar = vizshape.addBox([self.probeBarWidthMM,self.probeBarWidthMM,self.eyeProbeRadius*2])
		self.rGridHorzBar.setParent(self.rightEyeCylinderBack)
コード例 #2
0
ファイル: mocapInterfaceNew.py プロジェクト: vicmcg/CGMaze
    def createCalibrationCylinders(self):

        ##############################################################
        ##############################################################
        ## left eye and calib grid

        self.leftEyeProbeCylinder = vizshape.addCylinder(
            height=self.eyeProbeCylLength,
            radius=self.eyeProbeRadius,
            top=False,
            bottom=False,
            axis=vizshape.AXIS_X,
            color=viz.BLUE)
        self.leftEyeProbeCylinder.disable(viz.CULL_FACE)
        self.leftEyeProbeCylinder.visible(viz.OFF)

        self.leftEyeCylinderBack = vizshape.addCircle(self.eyeProbeRadius,
                                                      axis=vizshape.AXIS_X,
                                                      color=viz.GREEN)
        self.leftEyeCylinderBack.disable(viz.CULL_FACE)
        self.leftEyeCylinderBack.setParent(self.leftEyeProbeCylinder)
        self.leftEyeCylinderBack.setPosition(self.eyeProbeCylLength / 2, 0,
                                             0)  #self.leftEyeProbeCylinder)

        self.lGridVertBar = vizshape.addBox([
            self.probeBarWidthMM, self.eyeProbeRadius * 2, self.probeBarWidthMM
        ])
        self.lGridVertBar.setParent(self.leftEyeCylinderBack)

        ##############################################################
        ##############################################################
        ## Draw right eye components

        self.rightEyeProbeCylinder = vizshape.addCylinder(
            height=self.eyeProbeCylLength,
            radius=self.eyeProbeRadius,
            top=False,
            bottom=False,
            axis=vizshape.AXIS_X,
            color=viz.BLUE)
        self.rightEyeProbeCylinder.disable(viz.CULL_FACE)
        self.rightEyeProbeCylinder.visible(viz.OFF)

        self.rightEyeCylinderBack = vizshape.addCircle(self.eyeProbeRadius,
                                                       axis=vizshape.AXIS_X,
                                                       color=viz.GREEN)
        self.rightEyeCylinderBack.disable(viz.CULL_FACE)
        self.rightEyeCylinderBack.setParent(self.rightEyeProbeCylinder)
        self.rightEyeCylinderBack.setPosition(self.eyeProbeCylLength / 2, 0,
                                              0)  #self.leftEyeProbeCylinder)

        self.rGridHorzBar = vizshape.addBox([
            self.probeBarWidthMM, self.probeBarWidthMM, self.eyeProbeRadius * 2
        ])
        self.rGridHorzBar.setParent(self.rightEyeCylinderBack)
コード例 #3
0
def Block3():
    datafile.write('\n')
    datafile.write('Block3')
    global dum3
    if dum == 2.5 and dum2 == 3.5:
        dum3 = 38
    if dum == 2.5 and dum2 == 38:
        dum3 = 3.5
    if dum == 3.5 and dum2 == 2.5:
        dum3 = 38
    if dum == 3.5 and dum2 == 38:
        dum3 = 2.5
    if dum == 38 and dum2 == 2.5:
        dum3 = 3.5
    if dum == 38 and dum2 == 3.5:
        dum3 = 2.5
    targets = [
        4.8, 6.2, 7.6, 9, 10.4, 11.8, 13.2, 14.6, 17.4, 20.2, 23, 25.8, 30,
        float(dum3),
        float(dum3)
    ]
    while len(targets) > 0:
        global k
        k = 0
        yield viztask.waitTime(.5)
        ready_text = viz.addText3D('Get ready!', pos=[-2, 1.7, 20])
        ready_text.color(0, 0, 0)
        yield viztask.waitTime(1)
        ready_text.remove()
        yield viztask.waitTime(2)
        yield room()
        doors = []
        D1 = random.choice([-4.25, -3.25, -2.25, -1.25])
        D2 = random.choice([4.75, 5.75, 6.75, 7.75])
        D3 = random.choice([13.75, 14.75, 15.75, 16.75])
        D4 = random.choice([22.75, 23.75, 24.75, 25.75])
        D5 = random.choice([31.75, 32.75, 33.75, 34.75])
        L_doors = []
        L_doors.append(D1)
        L_doors.append(D2)
        L_doors.append(D3)
        L_doors.append(D4)
        L_doors.append(D5)
        D7 = random.choice([-4.25, -3.25, -2.25, -1.25])
        D8 = random.choice([4.75, 5.75, 6.75, 7.75])
        D9 = random.choice([13.75, 14.75, 15.75, 16.75])
        D10 = random.choice([22.75, 23.75, 24.75, 25.75])
        D11 = random.choice([31.75, 32.75, 33.75, 34.75])
        R_doors = []
        R_doors.append(D7)
        R_doors.append(D8)
        R_doors.append(D9)
        R_doors.append(D10)
        R_doors.append(D11)
        people = []
        P1 = random.choice([-3.75, -2.75, -1.75, .75, 1.75, 2.75, 3.75, 5.25])
        P2 = random.choice(
            [9.25, 10.25, 11.25, 12.25, 18.25, 19.25, 20.25, 21.25])
        P3 = random.choice(
            [27.25, 28.25, 29.25, 30.25, 36.25, 37.25, 38.25, 39.25])
        L_people = []
        L_people.append(P1)
        L_people.append(P2)
        L_people.append(P3)
        P4 = random.choice([-3.75, -2.75, -1.75, .75, 1.75, 2.75, 3.75, 5.25])
        P5 = random.choice(
            [9.25, 10.25, 11.25, 12.25, 18.25, 19.25, 20.25, 21.25])
        P6 = random.choice(
            [27.25, 28.25, 29.25, 30.25, 36.25, 37.25, 38.25, 39.25])
        R_people = []
        R_people.append(P4)
        R_people.append(P5)
        R_people.append(P6)
        targ = random.choice(targets)
        if targ == 2.5:
            size = .051006
        if targ == 3.5:
            size = .071409
        if targ == 4.8:
            size = .097932
        if targ == 6.2:
            size = .126495
        if targ == 7.6:
            size = .155059
        if targ == 9:
            size = .183622
        if targ == 10.4:
            size = .212186
        if targ == 11.8:
            size = .240749
        if targ == 13.2:
            size = .269313
        if targ == 14.6:
            size = .297876
        if targ == 17.4:
            size = .355003
        if targ == 20.2:
            size = .41213
        if targ == 23:
            size = .469257
        if targ == 25.8:
            size = .526384
        if targ == 30:
            size = .612075
        if targ == 38:
            size = .775295
        print targ
        datafile.write('\n')
        datafile.write('%f' % (targ))
        sphere = vizshape.addSphere((size), 20, 20)
        sphere.color(1.02, .444, 0)
        sphere.setPosition([0, (size), (targ)])
        shadow = vizshape.addCircle((size), 20)
        shadow.color([.05, .05, .05])
        shadow.setEuler([0, 90, 0])
        shadow.setPosition([0, .001, (targ)])
        for z in np.asarray(L_doors):
            door = vizshape.addBox(size=[.04445, 2.13, .91])
            door.texture(wood)
            door.setPosition([-4.9733, 1.065, float(z)])
            doors.append(door)
            doorknob = vizshape.addSphere(radius=.045, axis=vizshape.AXIS_X)
            doorknob.color(viz.YELLOW)
            doorknob.setPosition(-4.9396, 1, (float(z) - .3364))
            doors.append(doorknob)
        for z in np.asarray(R_doors):
            door = vizshape.addBox(size=[.04445, 2.13, .91])
            door.texture(wood)
            door.setPosition([4.9683, 1.065, float(z)])
            doors.append(door)
            doorknob = vizshape.addSphere(radius=.045, axis=vizshape.AXIS_X)
            doorknob.color(viz.YELLOW)
            doorknob.setPosition(4.9396, 1, (float(z) - .3364))
            doors.append(doorknob)
        for z in np.asarray(L_people):
            object = random.choice([1, 2, 3])
            if object == 1:
                x = random.choice([0, 90, 180])
                person = viz.addAvatar('vcc_female.cfg',
                                       euler=(float(x), 0, 0))
                person.setPosition([-4.25, 0, float(z)])
                person.state(1)
                people.append(person)
            if object == 2:
                x = random.choice([0, 90, 180])
                person = viz.addAvatar('vcc_male.cfg', euler=(float(x), 0, 0))
                person.setPosition([-4.25, 0, float(z)])
                person.state(1)
                people.append(person)
            if object == 3:
                x = random.choice([0, 90, 180])
                person = viz.addAvatar('vcc_male2.cfg', euler=(float(x), 0, 0))
                person.setPosition([-4.25, 0, float(z)])
                person.state(1)
                people.append(person)
        for z in np.asarray(R_people):
            object = random.choice([1, 2, 3])
            if object == 1:
                x = random.choice([0, 180, 270])
                person = viz.addAvatar('vcc_female.cfg',
                                       euler=(float(x), 0, 0))
                person.setPosition([4.5, 0, float(z)])
                person.state(1)
                people.append(person)
            if object == 2:
                x = random.choice([0, 180, 270])
                person = viz.addAvatar('vcc_male.cfg', euler=(float(x), 0, 0))
                person.setPosition([4.5, 0, float(z)])
                person.state(1)
                people.append(person)
            if object == 3:
                x = random.choice([0, 180, 270])
                person = viz.addAvatar('vcc_male2.cfg', euler=(float(x), 0, 0))
                person.setPosition([4.5, 0, float(z)])
                person.state(1)
                people.append(person)
        targets.remove(targ)
        en_env()
        tic = time.time()
        yield viztask.waitTime(5.5)  #Actually is closer to 5 seconds
        toc = time.time()
        mask.enable(viz.RENDERING)
        dis_env()
        sphere.remove()
        shadow.remove()
        for door in np.asarray(doors):
            door.remove()
        for person in np.asarray(people):
            person.remove()
        yield viztask.waitTime(1)
        mask.disable(viz.RENDERING)
        print toc - tic
        datafile.write(' %f' % (toc - tic))
        viz.callback(viz.KEYDOWN_EVENT, KeyEvents)
        yield viztask.waitKeyDown(viz.KEY_KP_ENTER)
        if k == 1:
            targets.append(targ)
            datafile.write(' targ missed')
コード例 #4
0
def practice():
    practice_text = viz.addText3D('Practice trials', pos=[-2.5, 1.7, 20])
    practice_text.color(0, 0, 0)
    yield viztask.waitKeyDown(viz.KEY_KP_ENTER)
    practice_text.remove()
    targets = [5, 12, 24]
    while len(targets) > 0:
        global k
        k = 0
        yield viztask.waitTime(.5)
        ready_text = viz.addText3D('Get ready!', pos=[-2, 1.7, 20])
        ready_text.color(0, 0, 0)
        yield viztask.waitTime(1)
        ready_text.remove()
        yield viztask.waitTime(2)
        yield room()
        doors = []
        D1 = random.choice([-4.25, -3.25, -2.25, -1.25])
        D2 = random.choice([4.75, 5.75, 6.75, 7.75])
        D3 = random.choice([13.75, 14.75, 15.75, 16.75])
        D4 = random.choice([22.75, 23.75, 24.75, 25.75])
        D5 = random.choice([31.75, 32.75, 33.75, 34.75])
        L_doors = []
        L_doors.append(D1)
        L_doors.append(D2)
        L_doors.append(D3)
        L_doors.append(D4)
        L_doors.append(D5)
        D7 = random.choice([-4.25, -3.25, -2.25, -1.25])
        D8 = random.choice([4.75, 5.75, 6.75, 7.75])
        D9 = random.choice([13.75, 14.75, 15.75, 16.75])
        D10 = random.choice([22.75, 23.75, 24.75, 25.75])
        D11 = random.choice([31.75, 32.75, 33.75, 34.75])
        R_doors = []
        R_doors.append(D7)
        R_doors.append(D8)
        R_doors.append(D9)
        R_doors.append(D10)
        R_doors.append(D11)
        people = []
        P1 = random.choice(
            [9.25, 10.25, 11.25, 12.25, 18.25, 19.25, 20.25, 21.25])
        P2 = random.choice(
            [27.25, 28.25, 29.25, 30.25, 36.25, 37.25, 38.25, 39.25])
        L_people = []
        L_people.append(P1)
        L_people.append(P2)
        P3 = random.choice(
            [9.25, 10.25, 11.25, 12.25, 18.25, 19.25, 20.25, 21.25])
        P4 = random.choice(
            [27.25, 28.25, 29.25, 30.25, 36.25, 37.25, 38.25, 39.25])
        R_people = []
        R_people.append(P3)
        R_people.append(P4)
        targ = random.choice(targets)
        if targ == 5:
            size = .102012
        if targ == 12:
            size = .24483
        if targ == 24:
            size = .48966
        sphere = vizshape.addSphere((size), 20, 20)
        sphere.color(1.02, .444, 0)
        sphere.setPosition([0, (size), (targ)])
        shadow = vizshape.addCircle((size), 20)
        shadow.color(
            [.05, .05, .05]
        )  #proportion of 1 for amount of each color (red, green, blue). 0,0,0 = black, 1,1,1 = white.
        shadow.setEuler([0, 90, 0])
        shadow.setPosition([0, .001, (targ)])
        for z in np.asarray(L_doors):
            door = vizshape.addBox(size=[.04445, 2.13, .91])
            door.texture(wood)
            door.setPosition([-4.9733, 1.065, float(z)])
            doors.append(door)
            doorknob = vizshape.addSphere(radius=.045, axis=vizshape.AXIS_X)
            doorknob.color(viz.YELLOW)
            doorknob.setPosition(-4.9396, 1, (float(z) - .3364))
            doors.append(doorknob)
        for z in np.asarray(R_doors):
            door = vizshape.addBox(size=[.04445, 2.13, .91])
            door.texture(wood)
            door.setPosition([4.9683, 1.065, float(z)])
            doors.append(door)
            doorknob = vizshape.addSphere(radius=.045, axis=vizshape.AXIS_X)
            doorknob.color(viz.YELLOW)
            doorknob.setPosition(4.9396, 1, (float(z) - .3364))
            doors.append(doorknob)
        for z in np.asarray(L_people):
            x = random.choice([0, 90, 180])
            person = viz.addAvatar('vcc_female.cfg', euler=(float(x), 0, 0))
            person.setPosition([-4.25, 0, float(z)])
            person.state(1)
            people.append(person)
        for z in np.asarray(R_people):
            x = random.choice([0, 180, 270])
            person = viz.addAvatar('vcc_female.cfg', euler=(float(x), 0, 0))
            person.setPosition([4.5, 0, float(z)])
            person.state(1)
            people.append(person)
        targets.remove(targ)
        en_env()
        tic = time.time()
        yield viztask.waitTime(
            .01
        )  #this is necessary to keep the headset display on for the duration of time.sleep. Can't use time.sleep for any longer than 100 ms or so bc it pauses tracking
        time.sleep(
            .09
        )  #this is necessary to be as precise as possible in the display time. Still not perfect bc of unknown processing time of background functions
        toc = time.time()
        mask.enable(viz.RENDERING)
        dis_env()
        sphere.remove()
        shadow.remove()
        for door in np.asarray(doors):
            door.remove()
        for person in np.asarray(people):
            person.remove()
        yield viztask.waitTime(1)
        mask.disable(viz.RENDERING)
        print toc - tic
        viz.callback(
            viz.KEYDOWN_EVENT, KeyEvents
        )  #press Enter (main keyboard) if the participant misses the target and the target will be appended back into the list.
        yield viztask.waitKeyDown(viz.KEY_KP_ENTER)
        if k == 1:
            targets.append(targ)
コード例 #5
0
    def createVisualObjects(self):

        self.IOD = 0.06
        
        # create a node3D leftEyeNode
        self.cyclopEyeNode = vizshape.addSphere(0.015, color = viz.GREEN)
        self.cyclopEyeNode.alpha(0.3)
        #cyclopEyeNode.visible(viz.OFF)
        self.cyclopEyeNode.setPosition(*self.rawDataStruct['view_Pos_XYZ'][:,0])
        self.cyclopEyeNode.setQuat(*self.rawDataStruct['view_Quat_WXYZ'][:,0])

        # create a node3D rightEyeNode
        self.rightEyeNode = vizshape.addSphere(0.015, color = viz.RED)
        #rightEyeNode.visible(viz.OFF)
        self.rightEyeNode.setParent(self.cyclopEyeNode)
        self.rightEyeNode.setPosition(self.IOD/2, 0, 0.0,viz.ABS_PARENT)
        self.rightEyeNode.alpha(0.3)
    #    right_sphere = gazeSphere(eyeTracker,viz.RIGHT_EYE,rightEyeNode,[clientWindowID],sphereColor=viz.ORANGE)
    #    rightGazeVector = gazeVector(eyeTracker,viz.RIGHT_EYE,rightEyeNode,[clientWindowID],gazeVectorColor=viz.ORANGE)
    #    right_sphere.toggleUpdate()
    #    rightGazeVector.toggleUpdate()
    #    right_sphere.node3D.alpha(0.7)    


        # create a node3D leftEyeNode
        self.leftEyeNode = vizshape.addSphere(0.015, color = viz.BLUE)
        #leftEyeNode.visible(viz.OFF)
        self.leftEyeNode.setParent(self.cyclopEyeNode)
        self.leftEyeNode.setPosition(-self.IOD/2, 0, 0.0,viz.ABS_PARENT)
        self.leftEyeNode.alpha(0.3)
    #    left_sphere = gazeSphere(eyeTracker,viz.LEFT_EYE,leftEyeNode,[clientWindowID],sphereColor=viz.YELLOW)
    #    leftGazeVector = gazeVector(eyeTracker,viz.LEFT_EYE,leftEyeNode,[clientWindowID],gazeVectorColor=viz.YELLOW)
    #    left_sphere.toggleUpdate()
    #    leftGazeVector.toggleUpdate()
    #    left_sphere.node3D.alpha(0.7)
        self.hmdDisplay = vizshape.addPlane([0.126, 0.071], axis = -vizshape.AXIS_Z, color = viz.GRAY)
        self.hmdDisplay.alpha(0.3)
        self.hmdDisplay.setParent(self.cyclopEyeNode)
        self.hmdDisplay.setPosition([0,0,0.0725], viz.ABS_PARENT) # 0.0725

        self.pixelatedBall = vizshape.addCircle(0.001, axis = -vizshape.AXIS_Z, color = viz.WHITE)
        self.pixelatedBall.setParent(self.hmdDisplay)
        self.pixelatedBall.setPosition([0,0,0])
        self.pixelatedBall.alpha(1)
        
        self.eyePOR = vizshape.addCircle(0.001, axis = -vizshape.AXIS_Z, color = viz.GREEN)
        self.eyePOR.setParent(self.hmdDisplay)
        self.eyePOR.setPosition([0,0,0])
        self.eyePOR.alpha(1)

        self.rightPOR = vizshape.addCircle(0.001, axis = -vizshape.AXIS_Z, color = viz.RED)
        self.rightPOR.setParent(self.hmdDisplay)
        self.rightPOR.setPosition([0,0,0])
        self.rightPOR.alpha(1)

        self.leftPOR = vizshape.addCircle(0.001, axis = -vizshape.AXIS_Z, color = viz.BLUE)
        self.leftPOR.setParent(self.hmdDisplay)
        self.leftPOR.setPosition([0,0,0])
        self.leftPOR.alpha(1)



        #creats a sphere(the ball) with radius of 5cm
        self.ball = vizshape.addSphere(radius = .08)
        #colors the ball red
        self.ball.color(viz.YELLOW)
        self.ball.visible(True)
        self.ball.setParent(self.cyclopEyeNode)

        self.Origin = vizshape.addAxes()
        self.Origin.setPosition(-5.5,0.1,8)
    #    #creats a sphere(the ball) with radius of 5cm
    #    #Head = vizshape.addCone( radius = 0.5, height = 0.8)
    #    Head = vizshape.addArrow(1, color = viz.YELLOW_ORANGE)
    #    #colors the ball red
    #    Head.color(viz.PURPLE)
    #    Head.visible(True)
    #    Head.setScale(.2,.2,.3)

        #creats a sphere(the hand) with radius of 10cm
        self.Hand = vizshape.addCylinder( height = 0.02, radius = 0.2, axis = vizshape.AXIS_Z)
        #colors the hand red
        self.Hand.color(viz.RED)
        self.Hand.visible(True)

        # Creating a Line to represent Cyclopean Eye Gaze Vector
        viz.startLayer(viz.LINES)
        viz.vertex(0,0,0)
        viz.vertex(0,0,3)
        viz.vertexColor(viz.GREEN)
        self.eyeGazeVector = viz.endLayer() # Object will contain both points and lines
        self.eyeGazeVector.visible(True)
        self.eyeGazeVector.setParent(self.cyclopEyeNode)
        self.eyeGazeVector.pointSize(10)
        #rightGazeVector.setScale(5,5,5)
        self.eyeGazeSphere = vizshape.addSphere(0.02, color = viz.GREEN)
        self.eyeGazeSphere.setParent(self.cyclopEyeNode)


        # Creating a Line to represent Right Eye Gaze Vector
        viz.startLayer(viz.LINES)
        viz.vertex(0,0,0)
        viz.vertex(0,0,3)
        viz.vertexColor(viz.RED)
        self.rightGazeVector = viz.endLayer() # Object will contain both points and lines
        self.rightGazeVector.visible(True)
        #rightGazeVector.setParent(rightEyeNode)
        self.rightGazeVector.pointSize(10)
        #rightGazeVector.setScale(5,5,5)
        self.rightGazeSphere = vizshape.addSphere(0.02, color = viz.RED)
        self.rightGazeSphere.setParent(self.rightEyeNode)
        self.rightGazeSphere.visible(False)

        # Creating a Line to represent Left Eye Gaze Vector
        viz.startLayer(viz.LINES)
        viz.vertex(0,0,0)
        viz.vertex(0,0,3)
        viz.vertexColor(viz.BLUE)
        self.leftGazeVector = viz.endLayer() # Object will contain both points and lines
        self.leftGazeVector.visible(True)
        #leftGazeVector.setParent(leftEyeNode)
        #leftGazeVector.setScale(5,5,5)
        self.leftGazeSphere = vizshape.addSphere(0.02, color = viz.BLUE)
        self.leftGazeSphere.setParent(self.leftEyeNode)
        self.leftGazeSphere.visible(False)


        # Creating a Line to represent Eye-Ball Vector
        viz.startLayer(viz.LINES)
        viz.vertex(0,0,0)
        viz.vertex(0,0,3)
        viz.vertexColor(viz.YELLOW)
        self.EyeBallLine = viz.endLayer() # Object will contain both points and lines
        self.EyeBallLine.visible(False)
        #EyeBallLine.setScale(5,5,5)

        self.male = viz.add('ktex.obj') 
        #male.state(1) #looping idle animation
        #self.headBone = self.male.getBone('Bip01 Head')
        #self.headBone.lock()
        self.male.setParent(self.cyclopEyeNode)
コード例 #6
0
def createEnvironment():	
	global point 
	global arrow 
	global goal	 
	global thrust
	global shadow

	#create 3D environment
	if parameters.dreiDEnvironment:

		piazza = viz.addChild('piazza.osgb')
	
		#look from above
		viz.MainView.setPosition([0,1.8,-5])
		viz.MainView.setEuler([0,20,0])
		viz.collision(viz.ON)
		# gorund for collision
		ground = viz.add('tut_ground.wrl')  # Add ground
		ground.collidePlane()   # Make collideable plane 
		ground.disable(viz.RENDERING)
		ground.disable(viz.DEPTH_WRITE)
		
		# point
		#point = viz.add('ball.wrl')
		point = vizshape.addSphere(radius = parameters.pointRadius, slices = 20, stacks = 20, axis = vizshape.AXIS_Y)
		pointPhys = point.collideSphere()   # Define ball's physical properties 
	
		point.setEuler(0,90,0)
		point.setPosition(0,parameters.point_height,0)
		point.color(viz.RED)
		point.setScale(0.5,0.5,0.5)
		point.enable( viz.COLLIDE_NOTIFY )
		
		#goal
		goal = vizshape.addCircle(slices=100, radius=0.3)		
		goal.setEuler(0,90,0)
		goal.color(viz.GREEN)		
		goal.setPosition(0,parameters.goal_height,0)
		goal.setScale(parameters.goal_scale3D,parameters.goal_scale3D,parameters.goal_scale3D)
		
		#shadow
		shadow = vizshape.addCircle(slices=100, radius=0.3)		
		shadow.setEuler(0,90,0)
		shadow.color(viz.GRAY)		
		shadow.setPosition(0,parameters.shadow_height,0)
		shadow.setScale(parameters.shadow_scale3D,parameters.shadow_scale3D,parameters.shadow_scale3D)

		#arrow
		arrow = vizshape.addArrow()	
		arrow.setPosition(0,parameters.arrow_height3D,0)
		arrow.color(viz.BLUE)
		
		#thrust
		thrust = point.addThruster(force=[0,0,0]) 

	#or create 2d environment
	else:
		viz.clearcolor(viz.WHITE)

		#look from above
		viz.MainView.setPosition([0,8,0])
		viz.MainView.setEuler([0,90,0])
		
		#point = viz.add('ball.wrl')
		point = vizshape.addSphere(radius = parameters.pointRadius, slices = 20, stacks = 20, axis = vizshape.AXIS_Y)
		pointPhys = point.collideSphere()   # Define ball's physical properties 		
		point.setEuler(0,90,0)
		point.setPosition(0,parameters.point_height,0)
		point.color(viz.RED)	
		point.visible(False)
		point.enable( viz.COLLIDE_NOTIFY )

		#wind force
		thrust = point.addThruster(force=[0,0,0]) 
		
		#goal
		goal = vizshape.addCircle(slices=100, radius=0.2)
		goal.setEuler(0,90,0)
		goal.color(viz.GREEN)
		goal.visible(False)
		goal.setScale(parameters.goal_scale2D,parameters.goal_scale2D,parameters.goal_scale2D)
		
		#arrow
		arrow = vizshape.addArrow()
		viz.mouse(viz.OFF)
		arrow.setPosition(0,parameters.arrow_height2D,0)
		arrow.color(viz.BLUE)
		arrow.visible(False)
コード例 #7
0
import viz
import viztask
import vizact
import vizinfo
import vizproximity
import vizshape

import parameters

#physics stuff
viz.phys.enable()
viz.phys.setGravity([0,0,0]) 

# point
point = vizshape.addCircle(radius = 0.5, slices=100)
pointPhys = point.collideSphere()   # Define ball's physical properties 
thrust = point.addThruster(force=[0,0,0]) 

#goal
goal = vizshape.addCircle(slices=100, radius=2)

#arrow
arrow = vizshape.addArrow()


viz.mouse(viz.OFF)

# Load DirectInput plug-in
dinput = viz.add('DirectInput.dle')

# Add first available joystick
コード例 #8
0
earth.addAction(vizact.spin(0, 1, 0, 5))

neptuneTexture = viz.addTexture('Neptune.jpg')
neptune = vizshape.addSphere(radius=3.8, slices=20, stacks=20, pos=(0, 0, -4))
neptune.texture(neptuneTexture)
neptune.alpha(.8)
neptune.addAction(vizact.spin(0, 1, 0, 5))

uranusTexture = viz.addTexture('Uranus.jpg')
uranus = vizshape.addSphere(radius=4.00, slices=20, stacks=20, pos=(0, 0, -8))
uranus.texture(uranusTexture)
uranus.alpha(.8)
uranus.addAction(vizact.spin(0, 1, 0, 5))

saturnRingTexture = viz.addTexture('Rings_2.png')
saturnRing = vizshape.addCircle(15, slices=20)
saturnRing.setEuler(90, 90, 0)
saturnRing.setPosition(0, 0, -32)
saturnRing.alpha(.8)
saturnRing.texture(saturnRingTexture)
saturnTexture = viz.addTexture('Saturn.jpg')
saturn = vizshape.addSphere(radius=9.45, slices=20, stacks=20, pos=(0, 0, -32))
saturn.texture(saturnTexture)
saturn.alpha(.8)
saturn.addAction(vizact.spin(0, 1, 0, 5))
saturnRing.addAction(vizact.spin(0, 0, 1, 1))

jupiterTexture = viz.addTexture('Jupiter_2.jpg')
jupiter = vizshape.addSphere(radius=11.2,
                             slices=20,
                             stacks=20,
コード例 #9
0
ファイル: Threshold.py プロジェクト: lindsayah/VR-Projects
def trial_down ():
	global k
	k = 0
	global x
	x = 0
	for i in range (100):
		yield viztask.waitTime(.5)
		ready_text = viz.addText3D('Get ready!',pos = [-2,1.7,20])	
		ready_text.color(0,0,0)
		yield viztask.waitTime(1)
		ready_text.remove ()
		yield viztask.waitTime(2)	
		yield room ()
		doors = []
		D1 = random.choice([-4.25,-3.25,-2.25,-1.25])
		D2 = random.choice([4.75,5.75,6.75,7.75])
		D3 = random.choice([13.75,14.75,15.75,16.75])
		D4 = random.choice([22.75,23.75,24.75,25.75])
		D5 = random.choice([31.75,32.75,33.75,34.75])
		L_doors = []
		L_doors.append(D1)
		L_doors.append(D2)
		L_doors.append(D3)
		L_doors.append(D4)
		L_doors.append(D5)
		D7 = random.choice([-4.25,-3.25,-2.25,-1.25])
		D8 = random.choice([4.75,5.75,6.75,7.75])
		D9 = random.choice([13.75,14.75,15.75,16.75])
		D10 = random.choice([22.75,23.75,24.75,25.75])
		D11 = random.choice([31.75,32.75,33.75,34.75])
		R_doors = []
		R_doors.append(D7)
		R_doors.append(D8)
		R_doors.append(D9)
		R_doors.append(D10)
		R_doors.append(D11)
		people = []
		P1 = random.choice([9.25,10.25,11.25,12.25,18.25,19.25,20.25,21.25])
		P2 = random.choice([27.25,28.25,29.25,30.25,36.25,37.25,38.25,39.25])
		L_people = []
		L_people.append(P1)
		L_people.append(P2)
		P3 = random.choice([9.25,10.25,11.25,12.25,18.25,19.25,20.25,21.25])
		P4 = random.choice([27.25,28.25,29.25,30.25,36.25,37.25,38.25,39.25])
		R_people = []
		R_people.append(P3)
		R_people.append(P4)
		targ = random.choice(targets)
		if targ == 2.5:
			size = .051006
		if targ == 3.5:
			size = .071409	
		if targ == 4.8:
			size = .097932
		if targ == 6.2:
			size = .126495
		if targ == 7.6:
			size = .155059
		if targ == 9:
			size = .183622
		if targ == 10.4:
			size = .212186
		if targ == 11.8:
			size = .240749
		if targ == 13.2:
			size = .269313
		if targ == 14.6:
			size = .297876
		if targ == 17.4:
			size = .355003
		if targ == 20.2:
			size = .41213
		if targ == 23:
			size = .469257
		if targ == 25.8:
			size = .526384
		if targ == 30:
			size = .612075
		if targ == 38:
			size = .775295
		print targ
		sphere = vizshape.addSphere((size),20,20)
		sphere.color(1.02,.444,0)
		sphere.setPosition([0,(size),(targ)])
		shadow = vizshape.addCircle((size),20)
		shadow.color([.05,.05,.05]) #proportion of 1 for amount of each color (red, green, blue). 0,0,0 = black, 1,1,1 = white.
		shadow.setEuler([0,90,0])
		shadow.setPosition([0,.001,(targ)])
		for z in np.asarray(L_doors):
			door = vizshape.addBox(size=[.04445,2.13,.91])  
			door.texture(wood)
			door.setPosition([-4.9733,1.065,float(z)])
			doors.append(door)
			doorknob = vizshape.addSphere(radius=.045,axis=vizshape.AXIS_X)
			doorknob.color(viz.YELLOW)
			doorknob.setPosition(-4.9396,1,(float(z)-.3364))
			doors.append(doorknob)
		for z in np.asarray(R_doors):
			door = vizshape.addBox(size=[.04445,2.13,.91])  
			door.texture(wood)
			door.setPosition([4.9683,1.065,float(z)])
			doors.append(door)
			doorknob = vizshape.addSphere(radius=.045,axis=vizshape.AXIS_X)
			doorknob.color(viz.YELLOW)
			doorknob.setPosition(4.9396,1,(float(z)-.3364))
			doors.append(doorknob)	
		for z in np.asarray(L_people):
			o = random.choice([0,90,180])
			person = viz.addAvatar('vcc_female.cfg',euler=(float(o),0,0))
			person.setPosition([-4.25,0,float(z)])
			person.state(1)
			people.append(person)
		for z in np.asarray(R_people):
			o = random.choice([0,180,270])
			person = viz.addAvatar('vcc_female.cfg',euler=(float(o),0,0))
			person.setPosition([4.5,0,float(z)])
			person.state(1)
			people.append(person)	
		en_env()
		tic = time.time()
		yield viztask.waitTime(.01) 
		time.sleep(.09+x)
		toc = time.time ()
		mask.enable(viz.RENDERING)
		dis_env()
		sphere.remove ()
		shadow.remove ()
		for door in np.asarray(doors):
			door.remove()
		for person in np.asarray(people):
			person.remove()
		yield viztask.waitTime(1)
		mask.disable(viz.RENDERING)
		print toc - tic
		viz.callback(viz.KEYDOWN_EVENT,KeyEvents)
		yield viztask.waitKeyDown(viz.KEY_KP_ENTER) 
		if k == 1:
			break
	times.append((toc - tic)+.01)		
	print times
コード例 #10
0
import vizinfo
import vizproximity
import vizshape

#physics stuff
viz.phys.enable()
viz.phys.setGravity([0,0,0]) 
viz.gravity(0)

# point
point = viz.add('ball.wrl')
pointPhys = point.collideSphere()   # Define ball's physical properties 
thrust = point.addThruster(force=[0,0,0]) 

#goal
goal = vizshape.addCircle(slices=100, radius=2)

#arrow
arrow = vizshape.addArrow()


viz.mouse(viz.OFF)

# Load DirectInput plug-in
dinput = viz.add('DirectInput.dle')

# Add first available joystick
joy = dinput.addJoystick()

# Set dead zone threshold so small movements of joystick are ignored
joy.setDeadZone(0.2)
コード例 #11
0
def createEnvironment():
    global point
    global arrow
    global goal
    global thrust
    global shadow

    #create 3D environment
    if parameters.dreiDEnvironment:

        piazza = viz.addChild('piazza.osgb')

        #look from above
        viz.MainView.setPosition([0, 1.8, -5])
        viz.MainView.setEuler([0, 20, 0])
        viz.collision(viz.ON)
        # gorund for collision
        ground = viz.add('tut_ground.wrl')  # Add ground
        ground.collidePlane()  # Make collideable plane
        ground.disable(viz.RENDERING)
        ground.disable(viz.DEPTH_WRITE)

        # point
        #point = viz.add('ball.wrl')
        point = vizshape.addSphere(radius=parameters.pointRadius,
                                   slices=20,
                                   stacks=20,
                                   axis=vizshape.AXIS_Y)
        pointPhys = point.collideSphere()  # Define ball's physical properties

        point.setEuler(0, 90, 0)
        point.setPosition(0, parameters.point_height, 0)
        point.color(viz.RED)
        point.setScale(0.5, 0.5, 0.5)
        point.enable(viz.COLLIDE_NOTIFY)

        #goal
        goal = vizshape.addCircle(slices=100, radius=0.3)
        goal.setEuler(0, 90, 0)
        goal.color(viz.GREEN)
        goal.setPosition(0, parameters.goal_height, 0)
        goal.setScale(parameters.goal_scale3D, parameters.goal_scale3D,
                      parameters.goal_scale3D)

        #shadow
        shadow = vizshape.addCircle(slices=100, radius=0.3)
        shadow.setEuler(0, 90, 0)
        shadow.color(viz.GRAY)
        shadow.setPosition(0, parameters.shadow_height, 0)
        shadow.setScale(parameters.shadow_scale3D, parameters.shadow_scale3D,
                        parameters.shadow_scale3D)

        #arrow
        arrow = vizshape.addArrow()
        arrow.setPosition(0, parameters.arrow_height3D, 0)
        arrow.color(viz.BLUE)

        #thrust
        thrust = point.addThruster(force=[0, 0, 0])

    #or create 2d environment
    else:
        viz.clearcolor(viz.WHITE)

        #look from above
        viz.MainView.setPosition([0, 8, 0])
        viz.MainView.setEuler([0, 90, 0])

        #point = viz.add('ball.wrl')
        point = vizshape.addSphere(radius=parameters.pointRadius,
                                   slices=20,
                                   stacks=20,
                                   axis=vizshape.AXIS_Y)
        pointPhys = point.collideSphere()  # Define ball's physical properties
        point.setEuler(0, 90, 0)
        point.setPosition(0, parameters.point_height, 0)
        point.color(viz.RED)
        point.visible(False)
        point.enable(viz.COLLIDE_NOTIFY)

        #wind force
        thrust = point.addThruster(force=[0, 0, 0])

        #goal
        goal = vizshape.addCircle(slices=100, radius=0.2)
        goal.setEuler(0, 90, 0)
        goal.color(viz.GREEN)
        goal.visible(False)
        goal.setScale(parameters.goal_scale2D, parameters.goal_scale2D,
                      parameters.goal_scale2D)

        #arrow
        arrow = vizshape.addArrow()
        viz.mouse(viz.OFF)
        arrow.setPosition(0, parameters.arrow_height2D, 0)
        arrow.color(viz.BLUE)
        arrow.visible(False)