Esempio n. 1
0
	def __init__(self,use_keyboard = True, desktop_mode = False):
		
		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 (WALL FFS!)
		
		# Add skybox
		sky = viz.add(viz.ENVIRONMENT_MAP,'alien/jajalien1.jpg')
		skybox = viz.add('skydome.dlc')
		skybox.texture(sky)
		
		# First light added seems to be ignored....
		# Add lighting
		dummy = viz.addLight()
		light = viz.addLight()
		light.position(0, 0, 0)
		light.color([0.8, 1, 0.8])
		
		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.speed = 400.0 #--four-- meters per second
		originTracker = self.cavelib.getOriginTracker()
		#originTracker.setPosition([-100,100,0],viz.REL_LOCAL)
		self.returnToStart()
		self.yaw = 90
		self.startSet=0
		self.joystickpressed=0
		
		vizact.onkeydown(' ', viz.setDebugSound3D, viz.TOGGLE)
Esempio n. 2
0
    def setLighting(self):
        # TODO: think about lighting!!!
        viz.MainView.getHeadLight().disable()
        viz.setOption('viz.lightModel.twoSided', 1)
        viz.setOption('viz.lightModel.ambient', [.6, .6, .6])

        self.light_source = viz.addLight()
        # print self.light_source.getEuler()
        self.light_source2 = viz.addLight()
        self.light_source2.setEuler(180, 0, 0)
    def setLighting(self):
        
        viz.MainView.getHeadLight().disable()
        #viz.MainView.get

        self.topLight = viz.addLight() 
        self.topLight.setPosition(-4,6,10)
        self.topLight.setEuler( 135, 45 ,0 )
        self.topLight.spread(350) 
        self.topLight.intensity(2) 

        self.bottomLight = viz.addLight() 
        self.bottomLight.setPosition(4,0,-10)
        self.bottomLight.setEuler( -45, -45 ,0 )
        self.bottomLight.spread(350) 
        self.bottomLight.intensity(2) 
Esempio n. 4
0
    def setLighting(self):

        viz.MainView.getHeadLight().disable()

        #        #viz.MainView.get
        #        self.lightSource = viz.addLight()
        #        self.lightSource.enable()
        #        #self.lightSource.position(0, self.ceilingHeight, 0)
        #        self.lightSource.spread(180)
        #        self.lightSource.intensity(1)
        #
        #        viz.MainView.getHeadLight().disable()

        self.lightSource = viz.addLight()
        self.lightSource.enable()
        #self.lightSource.position(0, self.ceilingHeight, 0)
        self.lightSource.spread(180)
        self.lightSource.intensity(1)

        ### ADD A SHADOW
        #SHADOW_RES = 256*10
        SHADOW_RES = 100 * 10
        SHADOW_PROJ_POS = (0, self.ceilingHeight, 0)
        SHADOW_AREA = (self.roomWidth, self.roomLength)

        #Create shadow projector
        self.shadowSource = Shadow.ShadowProjector(size=SHADOW_RES,
                                                   pos=SHADOW_PROJ_POS,
                                                   area=SHADOW_AREA)
def makeLight(scene=viz.MainScene):
  lantern_light = viz.addLight(scene=scene, group=1)
  lantern_light.position( 0,0,0,1 )
  lantern_light.color( viz.YELLOW )
  lantern_light.quadraticattenuation( 1 )
  lantern_light.intensity( 8 )
  return lantern_light
Esempio n. 6
0
	def AddLight(self, pos, lightColor, glareColor, group, intensity=0.15):
		Light = viz.addLight(group=group)
		Light.position(0,0,0)
		Light.setPosition(pos)
		Light.color(lightColor)
		Light.linearattenuation(intensity)
#		GlareQuad = viz.addTexQuad(parent=Light)
#		GlareQuad.billboard()
#		GlareQuad.color(glareColor)
#		GlareQuad.disable(viz.LIGHTING)
#		GlareQuad.setScale([0.2,0.2,0.2])
		return Light
Esempio n. 7
0
def addBusLight(scene=viz.MainScene):
    busLightModel = viz.add("Bus Light.vzf", scene=scene)
    light = viz.addLight(scene=scene, group=1)
    viz.link(busLightModel, light)
    light.position(0, 0, 0, 1)
    busLightModel.emissive(viz.WHITE)
    busLightModel.setEuler([0, 90.0, 0])
    light.color(viz.WHITE)
    intensity = 3
    light.intensity(intensity)
    light.quadraticattenuation(1)
    return busLightModel
    def add_light(euler):
        """
        Creates and returns a light object.

        Args:
            euler: degree relating to the x, y plane from which the light shines.

        Returns: A Vizard light object instance.

        """

        light = viz.addLight()
        light.setEuler(0, euler, 0)

        return light
Esempio n. 9
0
    def setup(self):
        #Disable the headlight on the room
        viz.MainView.getHeadLight().disable()

        #Add a light to the empty node
        self.mylight = viz.addLight()

        #Set the light parameters
        self.mylight.position(0, 0, 0)
        self.mylight.direction(0, 0, 1)
        self.mylight.spread(15)
        self.mylight.intensity(self.start)
        self.mylight.spotexponent(100)
        self.mylight.setPosition([0, 1, 0])

        #Link the torch to the MainView
        viz.link(viz.MainView, self.mylight)
        return None
Esempio n. 10
0
	def setup(self):
		#Disable the headlight on the room
		viz.MainView.getHeadLight().disable()
		
		#Add a light to the empty node
		self.mylight = viz.addLight()

		#Set the light parameters
		self.mylight.position(0,0,0)
		self.mylight.direction(0,0,1)
		self.mylight.spread(15)
		self.mylight.intensity(self.start)
		self.mylight.spotexponent(100)
		self.mylight.setPosition([0,1,0])
		
		#Link the torch to the MainView
		viz.link(viz.MainView, self.mylight)
		return None
Esempio n. 11
0
 def setLighting(self):
     
     viz.MainView.getHeadLight().disable()
     #viz.MainView.get
     self.lightSource = viz.addLight() 
     self.lightSource.enable() 
     self.lightSource.position(0, self.ceilingHeight, 0) 
     self.lightSource.spread(180) 
     self.lightSource.intensity(2)
 
     
     ### ADD A SHADOW
     #SHADOW_RES = 256*10
     SHADOW_RES = 100*10
     SHADOW_PROJ_POS = (0, self.ceilingHeight, 0)
     SHADOW_AREA = (self.roomWidth,self.roomLength)
     
     #Create shadow projector
     self.shadowSource = Shadow.ShadowProjector(size=SHADOW_RES,pos=SHADOW_PROJ_POS,area=SHADOW_AREA)
Esempio n. 12
0
    def __init__(self):
        viz.EventClass.__init__(self)

        self.callback(viz.KEYDOWN_EVENT, self.onKeyDown)

        # generate random terrain using diamond-square algorithm
        self.terrainData = diamondSquare(7)

        # add some craters to the terrain
        self.makeCrater(self.terrainData,
                        len(self.terrainData) / 4,
                        len(self.terrainData) / 4, 10)
        self.makeCrater(self.terrainData, 6 * len(self.terrainData) / 8,
                        len(self.terrainData) / 2, 22)

        # create a triangular mesh (a Vizard layer of triangles) out of the data
        terrainLayer = self.generateLayer(self.terrainData)
        terrainLayer.enable(viz.LIGHTING)
        # viewer is located at (self.x,self.y,self.z)
        self.x = 0
        self.y = self.terrainData[0][0] + 1
        self.z = 0
        # viewer is rotated by self.rotate, an angle measured off the +x axis,
        # so initially the viewer is looking down the +z axis
        self.rotate = 90
        # initialize this starting view
        self.setView()

        viz.MainView.getHeadLight().disable()

        self.myLight = viz.addLight()
        self.myLight.enable()
        self.myLight.color(1, 1, 1)
        m = viz.Matrix()
        m.postAxisAngle(1, 0, 0, 45)
        self.myLight.setMatrix(m)
        #print self.normal([1,1830,1],[2,1820,2], [2,1835,1])

        for row in self.terrainData:
            for col in row:
                print(col),
            print()
Esempio n. 13
0
    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)
Esempio n. 14
0
tower.setScale(1.5, 4, 1.5)
station.setPosition(-100, -3.3, 250)
station.collideMesh()
#buildings.collideMesh()
tower.collideMesh()
speeddisplay = viz.addTextbox()
speeddisplay.setPosition(0.11, 0.985)
steerdisplay = viz.addTextbox()
steerdisplay.setPosition(0.11, 0.95)
cardisplay = viz.addTextbox()
cardisplay.setPosition(0.9, 0.02)
geardisplay = viz.addTextbox()
geardisplay.setPosition(0.11, 0.915)
headLight = viz.MainView.getHeadLight()
headLight.disable()
myLight = viz.addLight()
view = viz.MainView
if environmentchoice == 0:
    myLight.intensity(1)
else:
    myLight.intensity(0.25)
myLight.setEuler(45, 12, 0)
camera = vizconnect.getTransport('orientation')
rotcam = viz.link(offsetNode, camera.getNode3d())

viz.mergeLinkable(rotcam, view)


def ChangeCar(direction):
    global carchoice
    global speed
    def __init__(self):
        viz.EventClass.__init__(self)

        self.callback(viz.KEYDOWN_EVENT, self.onKeyDown)
        self.callback(viz.TIMER_EVENT, self.onTimer)

        #turn on lighting

        # generate random terrain using diamond-square algorithm
        self.terrainData = diamondSquare(8)

        # add some craters to the terrain
        self.makeCrater(self.terrainData, 0, 0, 80)
        self.makeCrater(self.terrainData, 0, len(self.terrainData) / 4.5, 40)
        self.makeCrater(self.terrainData, 0, len(self.terrainData), 100)
        self.makeCrater(self.terrainData,
                        len(self.terrainData) / 4,
                        len(self.terrainData) + 20, 60)
        self.makeCrater(self.terrainData, (len(self.terrainData) * 3) / 4,
                        len(self.terrainData) + 20, 60)
        self.makeCrater(self.terrainData, -20, len(self.terrainData) / 2, 40)
        self.makeCrater(self.terrainData, len(self.terrainData) / 2, 0, 40)
        self.makeCrater(self.terrainData,
                        len(self.terrainData) / 2,
                        len(self.terrainData) / 8, 40)

        #		self.makeHill(self.terrainData, 5, len(self.terrainData)/2, len(self.terrainData)/2, 25,40)

        # create a triangular mesh (a Vizard layer of triangles) out of the data
        terrainLayer = self.generateLayer(self.terrainData)
        terrainLayer.enable(viz.LIGHTING)
        viz.MainView.getHeadLight().disable()
        self.newLight = viz.addLight()
        self.newLight.enable()
        self.newLight.color(1, 1, 1)

        m = viz.Matrix()
        m.postAxisAngle(1, 0, 0, 45)
        self.newLight.setMatrix(m)

        # viewer is located at (self.x,self.y,self.z)

        self.rotate = 0
        self.height = 0
        self.xVal = 0
        self.zVal = 0
        # initializing this starting view
        view = viz.MainView
        m = viz.Matrix()
        m.postAxisAngle(0, 1, 0, self.rotate)
        m.postTrans(self.xVal, self.height, self.zVal)
        view.setMatrix(m)

        #Put monsters
        self.zombie = viz.add('licker.dae')
        self.zombX = len(self.terrainData) - 15
        self.zombZ = len(self.terrainData) - 20
        m = viz.Matrix()
        m.postTrans(0, 0, 0)
        m.postAxisAngle(1, 0, 0, 90)
        m.postScale(10, 10, 10)
        m.postTrans(self.zombX, self.terrainData[self.zombX][self.zombZ],
                    self.zombZ)
        self.zombie.setMatrix(m)

        self.zombie2 = viz.add('licker.dae')
        self.zombX2 = len(self.terrainData) / 2
        self.zombZ2 = len(self.terrainData) - 20
        m = viz.Matrix()
        m.postTrans(0, 0, 0)
        m.postAxisAngle(1, 0, 0, 90)
        m.postScale(10, 10, 10)
        m.postTrans(self.zombX2, self.terrainData[self.zombX2][self.zombZ2],
                    self.zombZ2)
        self.zombie2.setMatrix(m)
	def __init__(self,use_keyboard = True, desktop_mode = False):
		"""Initialization function."""
		
		caveapp.CaveApplication.__init__(self,desktop_mode) #call constructor of super class, you have to do this explicitly in Python		
		viz.phys.enable()
		
		self.view = viz.MainView;
		
		self.backGroundMusic = viz.addAudio('Windmill hut.wav')
		self.backGroundMusic.volume(0.5)
		self.backGroundMusic.loop(viz.ON)
		self.backGroundMusic.play()
		self.gameMusic = viz.addAudio('Battle.wav')
		self.gameMusic.volume(0.7)
		
		headLight = viz.MainView.getHeadLight()
		headLight.intensity(100)
		headLight.disable()
		
		for i in range(3):
			light = viz.addLight()
			light.setPosition(0, 2, (i*10))
			light.position(0,0,0,1)
				
		self.use_keyboard = use_keyboard #store if we want to use the keyboard
		self.scaleValue = 0.03
		
		self.shootingRange = viz.addChild('ShootingRange.FBX')
		self.shootingRange.setScale(self.scaleValue, self.scaleValue,self.scaleValue )
		self.shootingRange.name = 'shootingRange'
		self.shootingRange.collideMesh()
		self.shootingRange.disable(viz.DYNAMICS)		
		
		self.target = viz.addChild('target.FBX')
		self.target.name = 'target'
		self.target.setScale(0.9, 0.9, 0.9)
		self.target.collideBox(density = 100)
		self.target.enable(viz.COLLIDE_NOTIFY)
		self.target.setPosition(0,0, 15)
				
		self.enemyGun = viz.addChild('Gun.FBX')
		self.enemyGun.name = 'enemyGun'
		self.enemyGun.setScale(self.scaleValue, self.scaleValue, self.scaleValue)
		self.enemyGun.setPosition(0, 1.8, 14)
		self.enemyGun.setEuler(180,0,0)						
				
		self.bullet = viz.add('Bullet.FBX')
		self.bullet.setPosition(0,1,2)
		self.bullet.setScale(self.scaleValue, self.scaleValue,self.scaleValue)
		self.bullet.name = 'bullet'
		self.bullet.collideCapsule(0.2, 0.1, density = 1, hardness = 1)
		self.bullet.enable(viz.COLLIDE_NOTIFY)
		self.nextShot = True
		
		self.enemyBullet = viz.add('Bullet.FBX')
		self.enemyBullet.setPosition(0,1,10)
		self.enemyBullet.setScale(0.05, 0.05, 0.05)
		self.enemyBullet.name = 'enemyBullet'
		
		self.enemyShot = False
		
		self.enemyShootTimer = vizact.ontimer(3, self.repositionEnemyGun)
		self.moveEnemyBulletTimer = vizact.ontimer(0, self.moveEnemyBullet)
		
		self.moveEnemyBulletTimer.setEnabled(False)
		self.enemyShootTimer.setEnabled(False)
		
		self.shootTimer = vizact.ontimer(1, self.schootClick)
		self.shootTimer.setEnabled(False)	
		
		self.rings = ['Ring10', 'Ring20', 'Ring30', 'Ring40', 'Ring50'] 
									
		self.currentScore = 0		
		self.scoreBaseText = 'Score: '
		self.firstLabelText = self.scoreBaseText + str(self.currentScore)
		self.scoreLabel = viz.addText3D(self.firstLabelText)
		self.scoreLabel.setBackdrop(viz.BACKDROP_RIGHT_BOTTOM)
		self.scoreLabel.setPosition(-1.7, 1, 0)
		self.scoreLabel.setEuler(-90,0,0)
		self.scoreLabel.color(viz.SKYBLUE)
		self.scoreLabel.setScale(0.3, 0.3, 0.3)
		self.scoreLabel.alignment(viz.ALIGN_CENTER_BOTTOM)
		
		self.currentHighScore = 0		
		self.highScoreBaseText = 'Highscore: '
		self.firstHighScoreLabelText = self.highScoreBaseText + str(self.currentHighScore)
		self.highScoreLabel = viz.addText3D(self.firstHighScoreLabelText)
		self.highScoreLabel.setPosition(-1.7, 1.5, 0)
		self.highScoreLabel.setEuler(-90,0,0)
		self.highScoreLabel.color(viz.BLUE)
		self.highScoreLabel.setScale(0.3, 0.3, 0.3)
		self.highScoreLabel.alignment(viz.ALIGN_CENTER_BOTTOM)
		
		self.newPointLabel = viz.addText3D('')
		self.newPointLabel.color(viz.GREEN)
		self.newPointLabel.setPosition(self.target.getPosition()[0], self.target.getPosition()[1] + 2, self.target.getPosition()[2])
		self.newPointLabel.alignment(viz.ALIGN_CENTER_BOTTOM)
		self.maxTimeNewPointVisible = 1
		
		self.newHitLabel = viz.addText3D('')
		self.newHitLabel.color(viz.RED)
		self.newHitLabel.setPosition(self.target.getPosition()[0], self.target.getPosition()[1] + 2.5, self.target.getPosition()[2])
		self.newHitLabel.alignment(viz.ALIGN_CENTER_BOTTOM)
		self.maxTimeHitVisible = 1
		
		self.newPointTimer = vizact.ontimer(self.maxTimeNewPointVisible, self.makeNewPointLabelInvisible)
		self.newPointTimer.setEnabled(False)	
		
		self.newHitPointTimer = vizact.ontimer(self.maxTimeHitVisible, self.makeNewHitLabelInvisible)
		self.newHitPointTimer.setEnabled(False)	
									
		self.goodSound = viz.addAudio('good.mp3')
		self.coinSound = viz.addAudio('coin.wav')	
		self.hitSound = viz.addAudio('hit.mp3')
			
		self.playTimer = vizact.ontimer(1, self.timerClick)
		self.playTimer.setEnabled(False)
		self.playTime = 35		
		self.currentTime = 0
		self.isPlaying = False
		
		self.timeBaseText = 'Time: '
		self.timeLabel = viz.addText3D(self.timeBaseText)
		self.timeLabel.setPosition(1.1, 1.3, 3)
		self.timeLabel.setEuler(50,0,0)
		self.timeLabel.setScale(0.3, 0.3, 0.3)
		self.timeLabel.alignment(viz.ALIGN_CENTER_BOTTOM)
		self.timeLabel.visible(False)
				
		self.scope = viz.addChild('Scope.FBX')
		
		viz.startLayer(viz.LINES)
		viz.vertexColor(viz.RED)
		viz.vertex(-0.2, 0,0)
		viz.vertex(0.2, 0, 0)
		self.topLine = viz.endLayer()
		
		viz.startLayer(viz.LINES)
		viz.vertexColor(viz.RED)
		viz.vertex(0, 0,0)
		viz.vertex(0, -0.3, 0)
		self.leftLine = viz.endLayer()
		
		viz.startLayer(viz.LINES)
		viz.vertexColor(viz.RED)
		viz.vertex(0, 0,0)
		viz.vertex(0, -0.3, 0)
		self.rightLine = viz.endLayer()
		
		self.time = 0.0 
Esempio n. 17
0
screenMode=viz.FULLSCREEN

if data["hmd"]["resolutions"][0]["display_mode"] != "full_screen":
    if data["hmd"]["resolutions"][0]["display_mode"]== "vert_side_by_side":
        screenMode=viz.FULLSCREEN | viz.STEREO_VERT
    else:
        screenMode=viz.FULLSCREEN | viz.STEREO_HORZ

hmd=CustomHMD(data["hmd"]["field_of_view"]["monocular_horizontal"],
    data["hmd"]["field_of_view"]["monocular_vertical"],
    overlap=1.0*data["hmd"]["field_of_view"]["overlap_percent"]*data["hmd"]["field_of_view"]["monocular_horizontal"]/100,
    leftRollShift=data["hmd"]["rendering"]["left_roll"],
    rightRollShift=data["hmd"]["rendering"]["right_roll"],
    verticalShift=data["hmd"]["field_of_view"]["pitch_tilt"],
    stereo=screenMode);


viz.window.setFullscreenMonitor(1)
viz.enable(viz.AUTO_COMPUTE)

viz.go(screenMode)

#Create skylight
sky_light = viz.addLight(euler=(0,0,0))
sky_light.position(0,0,0,0)
sky_light.color(viz.WHITE)
sky_light.ambient([5,5,5]) # necessary to light up images in Vizard 5

#Add the gallery mode
gallery = viz.addChild('gallery.osgb')
Esempio n. 18
0
    else:  #context 2 is square world:
        boundary5.visible(1)
        boundary6.visible(1)
        boundary7.visible(1)
        boundary8.visible(1)
        boundary1.visible(0)
        boundary2.visible(0)
        boundary3.visible(0)
        boundary4.visible(0)

    return context


##lighting
mylight = viz.addLight()
mylight.enable()
mylight.position(0, 10, 0)
mylight.spread(180)  ##uniform ambient lighting
mylight.intensity(2.5)

#setup keyboard controls
vizcam.KeyboardCamera(forward='w',
                      turnRight='d',
                      turnLeft='a',
                      backward='s',
                      left='æ',
                      right='¨',
                      moveMode=viz.REL_LOCAL,
                      moveScale=1.1,
                      turnScale=0.45)
Esempio n. 19
0
boundary9 = viz.add('CIRCLE.osgb',scene=viz.Scene3)
boundary9.setPosition(0.05,0,-0.05) 
boundary10 = viz.add('SQUARE.osgb',scene=viz.Scene3)
boundary10.setEuler( [ 90, 0, 0 ] ) 
boundary10.setPosition(-0.05,0,-0.05) 
boundary11 = viz.add('SQUARE.osgb',scene=viz.Scene3)
boundary11.setEuler( [ -90, 0, 0 ] ) 
boundary11.setPosition(0.05,0,0.05) 
boundary12 = viz.add('CIRCLE.osgb',scene=viz.Scene3)
boundary12.setEuler( [ 180, 0, 0 ] ) 
boundary12.setPosition(-0.05,0,0.05) 


##lighting
intense = 2.5
mylight = viz.addLight() 
mylight.enable() 
mylight.position(0, 10, 0)
mylight.spread(180) ##uniform ambient lighting 
mylight.intensity(intense)

mylight2 = viz.addLight(scene=viz.Scene2) 
mylight2.enable() 
mylight2.position(0, 10, 0)
mylight2.spread(180) ##uniform ambient lighting 
mylight2.intensity(intense)

mylight3 = viz.addLight(scene=viz.Scene3) 
mylight3.enable() 
mylight3.position(0, 10, 0)
mylight3.spread(180) ##uniform ambient lighting 
Esempio n. 20
0
def start():
    """
	Run everything necessary for game startup
	"""
    # Physics
    viz.phys.enable()

    ### Initialize pointer tool
    model.pointer = viz.addChild('.\\dataset\\Hand\\handPoint_reduced.ply')
    pointer = model.pointer

    pointer.setScale(0.012, 0.012, 0.012)
    pointer.setEuler(0, -115, 0)
    pointer.disable([viz.PHYSICS, viz.DYNAMICS])

    #	### Alpha slice plane setup
    #	viz.startLayer(viz.POINTS)
    #	viz.vertex(0,0,0)
    #	planeVert = viz.endLayer(parent = pointer)
    #	planeVert.dynamic()
    #
    #	# Setup normal vector for alpha slicing plane calculation
    #	planeVert.setNormal(0,[0,1,0])
    #	model.planeVert = planeVert
    #	slicePlane = vizshape.addPlane(size = [20, 20, 20], parent = pointer, cullFace = False)
    #	slicePlane.alpha(0.20)
    #	slicePlane.color(viz.ORANGE)

    ### Initialize environment this will load the coliseum and sky
    sky = viz.addChild('gallery.osgb')
    sky.setPosition([0, 0, -5])
    sky.collideMesh()
    sky.disable(viz.DYNAMICS)

    # Lighting
    lights = []
    [lights.append(viz.addLight()) for _ in range(2)]
    lights[0].setEuler(90, 40, 0)
    lights[0].intensity(0.5)
    lights[1].setEuler(270, 40, 0)
    lights[1].intensity(0.3)

    # Initialize pointer controls
    device = init.pointerInput(config.pointerMode, pointer, sky)
    ### Initialize display
    model.display = init.DisplayInstance(config.dispMode, config.camMode,
                                         device, pointer)

    ### Launch menu system
    model.menu = menu.MenuController()

    ### Override escape key to toggle menu
    viz.setOption('viz.default_key.quit', '0')

    #	# 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(endGame)
Esempio n. 21
0
import viz

viz.go()

room = viz.addChild('HMRL8.osgb')
room.setPosition(0,0,0)
room.setEuler(90,270,0)
room.setScale(0.01,0.01,0.01)
#room.disable(viz.LIGHTING)

mylight = viz.addLight() 
mylight.enable() 
mylight.position(0, 3, 0) 
mylight.spread(180) 
mylight.intensity(50) 

mylight2 = viz.addLight() 
mylight2.enable() 
mylight2.position(0, 3, 2) 
mylight2.spread(180) 
mylight2.intensity(50) 

mylight3 = viz.addLight() 
mylight3.enable() 
mylight3.position(0, 3, 1) 
mylight3.spread(180) 
mylight3.intensity(50) 

#man = viz.addChild('robot.osgb')
#man.color(1,0,0)
#man.setPosition(0,0,0)
def CreateTheRoom(room):

    viz.disable(viz.LIGHT0)

    room.topLight = viz.addLight()
    room.topLight.setPosition(0, 4, 0)
    room.topLight.setEuler(-45, 90, 0)

    room.topLight.spread(270)
    room.topLight.intensity(2)

    room.sideLight = viz.addLight()
    room.sideLight.setPosition(0, 1, 0)
    room.sideLight.setEuler(45, 0, -90)
    #see if needs to be put to 360 -room.sideLight.spread(270)
    room.sideLight.intensity(1.2)

    #room.backLight = viz.addLight()
    #room.backLight.setPosition(0,1,0)
    #room.backLight.setEuler(180,0,0)
    #room.backLight.spread(270)
    #room.backLight.intensity(2)

    #creates the floor plane to be 35x80
    #rotated around the Z axis(perpendicular to Y axis)
    room.floor = vizshape.addPlane(size=(35.0, 80.0),
                                   axis=vizshape.AXIS_Y,
                                   cullFace=False)
    #makes the floor look like wood
    room.floor.texture(viz.addTexture('images/tile_wood.jpg'))
    #moves the floor +20 meters in the z direction
    room.floor.setPosition(0, 0, 20)

    #adds the wall(plane) farthest from the hand/person
    #35x10 meters**2
    #rotated around the X axis (perpendicular to Z axis)
    room.frontWall = vizshape.addPlane(size=(35, 10),
                                       axis=-vizshape.AXIS_Z,
                                       cullFace=False)
    #makes the front wall look like wall
    #room.frontWall.texture(viz.addTexture('images/tile_gray.jpg'))
    #moves the wall to match the edge of the
    room.frontWall.setPosition(0, 5, 25)
    #makes the wall appear white
    room.frontWall.color(viz.GRAY)

    #adds the wall(plane) that when facing the frontWall, is to the camera's left
    #wall is 80x10 meters**2
    #wall is rotated about the Y axis(perpendicular to X axis)
    room.leftWall = vizshape.addPlane(size=(80, 10),
                                      axis=-vizshape.AXIS_X,
                                      cullFace=False)
    #makes the left wall look like wall
    room.leftWall.texture(viz.addTexture('images/tile_gray.jpg'))
    #shifts the wall to match the edge of the floor
    room.leftWall.setPosition(-17.5, 5, 20)
    #makes the wall appear white
    room.leftWall.color(viz.GRAY)

    #adds a wall(plane) that when facing the frontWall is to the camera's right
    #wall is 80x10 meters**2
    #wall is rotated about the Y axis(perpendicular to X axis)
    room.rightWall = vizshape.addPlane(size=(80, 10),
                                       axis=-vizshape.AXIS_X,
                                       cullFace=False)
    #makes the right wall look like wall
    room.rightWall.texture(viz.addTexture('images/tile_gray.jpg'))
    #shifts the wall to match the edge of the floor
    room.rightWall.setPosition(17.5, 5, 20)
    #makes the wall appear white
    room.rightWall.color(viz.GRAY)

    #adds a wall(plane) that when facing the frontWall is to the camera's back
    #wall is 35x10 meters**2
    #wall is rotated about the X axis(perpendicular to Z axis)
    room.backWall = vizshape.addPlane(size=(35, 10),
                                      axis=vizshape.AXIS_Z,
                                      cullFace=False)
    #shifts the wall to match the edge of the floor
    room.backWall.setPosition(0, 5, -20)
    room.backWall.color(viz.GRAY)
    #adds texture to backWall
    #room.backWall.texture(viz.addTexture('images/tile_slate.jpg'))
    #makes the wall appear white
    room.backWall.color(viz.GRAY)

    #adds a ceiling(plane) that when facing the frontWall is to the camera's topside
    #wall is 35x80 meters**2
    #wall is rotated about the Z axis(perpendicular to Y axis)
    room.ceiling = vizshape.addPlane(size=(35.0, 80.0),
                                     axis=vizshape.AXIS_Y,
                                     cullFace=False)
    #makes the ceiling appear Skyblue in color
    room.ceiling.color(viz.SKYBLUE)
    #shifts the ceiling to rest on top of the four walls
    room.ceiling.setPosition(0, 10, 20)

    #add a meter marker at 0 meters along the z axis of the room
    #meter0 = vizshape.addPlane(size = (5,.3), axis = vizshape.AXIS_Y, cullFace = False)
    #meter0.setPosition(0,.3, 0)
    #makes the meter marker appear yellow
    #meter0.color(viz.WHITE)

    #adds a wall(plane) that when facing the frontWall is to the camera's back
    #wall is 35x10 meters**2
    #wall is rotated about the X axis(perpendicular to Z axis)
    room.ballPlane = vizshape.addPlane(size=(2, 2),
                                       axis=vizshape.AXIS_Z,
                                       cullFace=False)
    #shifts the wall to match the edge of the floor
    room.ballPlane.setPosition(0, 5, -20)
    #makes the wall appear white
    room.ballPlane.color(viz.WHITE)
    room.ballPlane.alpha(0.0)

    room.ball = vizshape.addSphere(radius=0.04, color=viz.RED)
    room.paddle = vizshape.addCylinder(height=0.03,
                                       radius=0.15,
                                       color=viz.RED,
                                       axis=vizshape.AXIS_Z)
    room.paddle.alpha(1)
    room.cycEyeNode = vizshape.addCone(radius=0.05,
                                       height=0.17,
                                       color=viz.PURPLE,
                                       axis=vizshape.AXIS_Z)
    room.cycEyeNode.alpha(1)
    if (room.visualizeModelOutput == True):
        room.paddleCloneA = vizshape.addCylinder(height=0.05,
                                                 radius=0.15,
                                                 color=viz.ORANGE,
                                                 axis=vizshape.AXIS_Z)
        room.paddleCloneA.alpha(.80)
        room.paddleCloneB = vizshape.addCylinder(height=0.05,
                                                 radius=0.15,
                                                 color=viz.ORANGE,
                                                 axis=vizshape.AXIS_Z)
        room.paddleCloneB.alpha(.70)
        room.paddleCloneC = vizshape.addCylinder(height=0.05,
                                                 radius=0.15,
                                                 color=viz.ORANGE,
                                                 axis=vizshape.AXIS_Z)
        room.paddleCloneC.alpha(.60)
        room.paddleCloneD = vizshape.addCylinder(height=0.05,
                                                 radius=0.15,
                                                 color=viz.ORANGE,
                                                 axis=vizshape.AXIS_Z)
        room.paddleCloneD.alpha(.50)
        room.paddleCloneE = vizshape.addCylinder(height=0.05,
                                                 radius=0.15,
                                                 color=viz.ORANGE,
                                                 axis=vizshape.AXIS_Z)
        room.paddleCloneE.alpha(.40)
        room.paddleCloneF = vizshape.addCylinder(height=0.05,
                                                 radius=0.15,
                                                 color=viz.ORANGE,
                                                 axis=vizshape.AXIS_Z)
        room.paddleCloneF.alpha(.30)
        room.paddleCloneG = vizshape.addCylinder(height=0.05,
                                                 radius=0.15,
                                                 color=viz.ORANGE,
                                                 axis=vizshape.AXIS_Z)
        room.paddleCloneG.alpha(.20)
    if (room.renderGaze == True):
        room.gazePoint = vizshape.addSphere(radius=0.0005, color=viz.GREEN)
        room.gazePoint.setParent(room.cycEyeNode)

    room.male = viz.add('vcc_male.cfg')
    room.male.alpha(0.0)
    armBone = room.male.getBone('Bip01 R UpperArm')
    armBone.lock()
    #armBone.setEuler(0, 0, 0)

    armBone = room.male.getBone('Bip01 L UpperArm')
    armBone.lock()
    armBone.setEuler(-70, 0, 0)
    ForearmBone = room.male.getBone('Bip01 R Forearm')
    ForearmBone.lock()
    ForearmBone.setEuler(100, -90, 155)

    hand = room.male.getBone('Bip01 R Hand')
    hand.lock()
    hand.setEuler(0, -90, 0.0)

    room.squash = viz.addChild('Squash_Racquet.3ds')
    room.squash.scale(0.01, 0.01, 0.01)
    room.squash.setPosition(*hand.getPosition(mode=viz.ABS_GLOBAL) -
                            np.array([.55, -0.2, -0.2]),
                            mode=viz.ABS_GLOBAL)
    room.squash.setEuler([0, 0, 15])

    #room.squash.setQuat(hand.getQuat())
    return room
def start():
	"""
	Run everything necessary for game startup
	"""
	# Physics
	viz.phys.enable()

	### Initialize pointer tool
	model.pointer = viz.addChild('.\\dataset\\Hand\\handPoint_reduced.ply')
	pointer = model.pointer
	
	pointer.setScale(0.012, 0.012, 0.012)
	pointer.setEuler(0, -115, 0)
	pointer.disable([viz.PHYSICS, viz.DYNAMICS])
	
#	### Alpha slice plane setup
#	viz.startLayer(viz.POINTS)
#	viz.vertex(0,0,0)
#	planeVert = viz.endLayer(parent = pointer)
#	planeVert.dynamic()
#	
#	# Setup normal vector for alpha slicing plane calculation
#	planeVert.setNormal(0,[0,1,0])
#	model.planeVert = planeVert
#	slicePlane = vizshape.addPlane(size = [20, 20, 20], parent = pointer, cullFace = False)
#	slicePlane.alpha(0.20)
#	slicePlane.color(viz.ORANGE)
	
	### Initialize environment this will load the coliseum and sky
	sky = viz.addChild('gallery.osgb')
	sky.setPosition([0, 0, -5])
	sky.collideMesh()
	sky.disable(viz.DYNAMICS)

	# Lighting
	lights = []
	[lights.append(viz.addLight()) for _ in range(2)]
	lights[0].setEuler(90, 40, 0)
	lights[0].intensity(0.5)
	lights[1].setEuler(270, 40, 0)
	lights[1].intensity(0.3)
	
	# Initialize pointer controls
	device = init.pointerInput(config.pointerMode, pointer, sky)
	### Initialize display
	model.display = init.DisplayInstance(config.dispMode,config.camMode,device,pointer)
	
	### Launch menu system
	model.menu = menu.MenuController()
	
	### Override escape key to toggle menu
	viz.setOption('viz.default_key.quit','0')
	
#	# 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(endGame)
Esempio n. 24
0

#OPTIMIERUNGEN

# ADD world axis with X, Y, Z labels
world_axes = vizshape.addAxes()
X = viz.addText3D('X',pos=[1.1,0,0],color=viz.RED,scale=[0.3,0.3,0.3],parent=world_axes)
Y = viz.addText3D('Y',pos=[0,1.1,0],color=viz.GREEN,scale=[0.3,0.3,0.3],align=viz.ALIGN_CENTER_BASE,parent=world_axes)
Z = viz.addText3D('Z',pos=[0,0,1.1],color=viz.BLUE,scale=[0.3,0.3,0.3],align=viz.ALIGN_CENTER_BASE,parent=world_axes)

# start position
viz.MainView.setPosition(6,1,6)
viz.MainView.setEuler(0,0,0)

# ADD lighting
licht = viz.addLight()
licht.enable()
licht.setEuler(45,45,0)
licht.intensity(2.5)


# Proximity Stuff

# Target
target = vizproximity.Target(viz.MainView)

#Sensor
shape = (1,1,1)
source = [0.3,0.3,0.3]
#Sensor Objekt..
Esempio n. 25
0
    models['goalPole'] = viz.add(
        os.path.abspath(os.path.join(MODEL_DIR, 'pole_green.osgb')))
    models['pacePole'] = viz.add(
        os.path.abspath(os.path.join(MODEL_DIR, 'pole_yellow.osgb')))
    models['ground'] = viz.add(
        os.path.abspath(os.path.join(MODEL_DIR, 'ground.osgb')))

    # Adjust models size turn visible off
    models['homePole'].setScale([0.6, 0.45, 0.6])
    models['pacePole'].setScale([0.5, 0.6, 0.5])
    models['homePole'].visible(viz.OFF)
    models['orientPole'].visible(viz.OFF)
    models['goalPole'].visible(viz.OFF)
    models['pacePole'].visible(viz.OFF)
    # Turn on the lights
    light1 = viz.addLight()  #Add an overhead light
    light1.setEuler(0, 90, 0)
    light2 = viz.addLight(
    )  #Next four are lights from each direction to ensure even lighting
    light2.setEuler(90, 0, 0)
    light3 = viz.addLight()
    light3.setEuler(0, 0, 0)
    light4 = viz.addLight()
    light4.setEuler(180, 0, 0)
    light5 = viz.addLight()
    light5.setEuler(270, 0, 0)
    # Sounds
    sounds = {}
    sounds['end'] = viz.addAudio(
        os.path.abspath(os.path.join(SOUND_DIR, 'End.mp3')))
    sounds['begin'] = viz.addAudio(
Esempio n. 26
0
screenMode=viz.FULLSCREEN

if data["hmd"]["resolutions"][0]["display_mode"] != "full_screen":
    if data["hmd"]["resolutions"][0]["display_mode"]== "vert_side_by_side":
        screenMode=viz.FULLSCREEN | viz.STEREO_VERT
    else:
        screenMode=viz.FULLSCREEN | viz.STEREO_HORZ

hmd=CustomHMD(data["hmd"]["field_of_view"]["monocular_horizontal"],
    data["hmd"]["field_of_view"]["monocular_vertical"],
    overlap=1.0*data["hmd"]["field_of_view"]["overlap_percent"]*data["hmd"]["field_of_view"]["monocular_horizontal"]/100,
    leftRollShift=data["hmd"]["rendering"]["left_roll"],
    rightRollShift=data["hmd"]["rendering"]["right_roll"],
    verticalShift=data["hmd"]["field_of_view"]["pitch_tilt"],
    stereo=screenMode);


viz.window.setFullscreenMonitor(1)
viz.enable(viz.AUTO_COMPUTE)

viz.go(screenMode)

#Create skylight
sky_light = viz.addLight(euler=(0,0,0))
sky_light.position(0,0,0,0)
sky_light.color(viz.WHITE)
sky_light.ambient([5,5,5]) # necessary to light up images in Vizard 5

#Add the gallery mode
gallery = viz.addChild('gallery.osgb')
Esempio n. 27
0
import viz

viz.go()

room = viz.addChild('HMRL8.osgb')
room.setPosition(0, 0, 0)
room.setEuler(90, 270, 0)
room.setScale(0.01, 0.01, 0.01)
#room.disable(viz.LIGHTING)

mylight = viz.addLight()
mylight.enable()
mylight.position(0, 3, 0)
mylight.spread(180)
mylight.intensity(50)

mylight2 = viz.addLight()
mylight2.enable()
mylight2.position(0, 3, 2)
mylight2.spread(180)
mylight2.intensity(50)

mylight3 = viz.addLight()
mylight3.enable()
mylight3.position(0, 3, 1)
mylight3.spread(180)
mylight3.intensity(50)

#man = viz.addChild('robot.osgb')
#man.color(1,0,0)
#man.setPosition(0,0,0)
sensor_Kitchen = vizproximity.addBoundingSphereSensor(doorSuich_kitchen, scale = 4)
manager.addSensor(sensor_Kitchen)

#action = vizact.onpick(doorSuich_kitchen, doorKitchen)

doorSuich_salon = lab.getChild('Light_Switch salon')

sensor_salon = vizproximity.addBoundingSphereSensor(doorSuich_salon, scale = 4)
manager.addSensor(sensor_salon)

#action = vizact.onpick(doorSuich_salon, doorSalon)

#--------------------------------------ABRIR Y CERRAR PERSIANAS-------------------------------------------------------
#LUZ AMBIENTE
luzAmbiente = viz.addLight()
luzAmbiente.disable()

#PERSIANAS DORMITORIO
Rollup_bed_GEODE = lab.getChild('Blind bedroom-GEODE')

#def RollupBed (e): #SALA RV
def RollupBed ():
	def open_bedblind(): #ABRE LA PERSIANA DE FORMA CORRIDA
		dpos = Rollup_bed_GEODE.getPosition(viz.ABS_GLOBAL)
		new_dpos = [dpos[0], dpos[1]+ 0.5, dpos[2]]
		Rollup_bed_GEODE.setPosition(new_dpos, viz.ABS_GLOBAL)
		#luzAmbiente.enable()
		
	def close_bedblind(): #CIERRA LA PERSIANA DE FORMA CORRIDA
		dpos = Rollup_bed_GEODE.getPosition(viz.ABS_GLOBAL)
Esempio n. 29
0
    def __init__(self):
        self.mylight = viz.addLight()
        self.mylight.position(9, 500, -25)
        self.mylight.color(.3, .3, .3)
        # base class constructor
        self.boolean = False
        viz.EventClass.__init__(self)
        self.callback(viz.TIMER_EVENT, self.onTimer)
        self.starttimer(1, 1 / 5.0, viz.FOREVER)
        self.cyl1hei = 0
        self.bZ = 0
        self.startbZ = 0
        self.ang = 10
        self.tower = 1
        self.score = 0
        self.life = 5
        self.t = viz.addText("Score:" + "" + ` self.score `,
                             viz.SCREEN,
                             pos=[0, 0, 0])
        self.t.fontSize(100)
        self.t.font('Chiller')
        self.t1 = viz.addText("Lives:" + "" + ` self.life `,
                              viz.SCREEN,
                              pos=[0.8, 0, 0])
        self.t1.fontSize(100)
        self.t1.font('Chiller')
        self.bullet = None

        # Load texture
        pic = viz.addTexture('start.jpg')
        # Create surface to wrap the texture on
        self.start = viz.addTexQuad()
        mat = viz.Matrix()
        mat.postScale(1.995, 1.5, 1.5)
        self.start.setMatrix(mat)
        self.start.setPosition([0, 0, 0])  #put quad in view
        # Wrap texture on quad
        self.start.texture(pic)
        self.t1.remove()
        self.t.remove()

        #snow
        self.bigSnowman = Model('snowman\\model.dae')
        self.snowman = Model('snowman\\model.dae')
        self.glacier = Model('glacier\\model.dae')
        self.bigGlacier = Model('glacier\\model.dae')
        self.bigSnowman.setOrientation(8, .1, 5, .5, -50)
        self.snowman.setOrientation(3.1, .1, .7, .2, 75)
        self.glacier.setOrientation(7, .1, 2, .2, -90)
        self.bigGlacier.setOrientation(2.7, .1, 4.5, .32, 0)

        #desert
        self.bigPyr = Model('pyramidsmooth\\model.dae')
        self.pyr = Model('pyramidsmooth\\model.dae')
        self.sphinx = Model('sphinx\\model.dae')
        self.bigSphinx = Model('sphinx\\model.dae')
        self.bigPyr.setOrientation(7.3, -0.2, 12, .7, -50)
        self.pyr.setOrientation(8, -0.2, 17, .4, 75)
        self.sphinx.setOrientation(5.5, 0.2, 15.1, .6, 0)
        self.bigSphinx.setOrientation(2.9, 0.1, 10, 2, -90)

        #city
        self.city = Model('city\\model.dae')
        self.sCity = Model('city\\model.dae')
        self.empstbu = Model('empire\\model.dae')
        self.skyskr = Model('skyskraper\\model.dae')
        self.towe = Model('tower\\model.dae')
        self.city.setOrientation(14, 0.2, 9.8, .0087, 0)
        self.sCity.setOrientation(13, 0.2, 13.4, .006, 180)
        self.empstbu.setOrientation(14.8, -0.1, 15.17, .0082, 0)
        self.skyskr.setOrientation(11.8, 0.2, 9.7, .006, 0)
        self.towe.setOrientation(11.5, 0.2, 15.5, .03, 0)

        #forest
        self.fores = Model('forest\\model.dae')
        self.fores1 = Model('forest\\model.dae')
        self.garde = Model('garden\\model.dae')
        self.fores.setOrientation(18.4, 0.1, .3, 0.07, 0)
        self.fores1.setOrientation(18.4, 0.1, 9, 0.04, -90)
        self.garde.setzScale(0.8)

        #spaceship
        self.ship = Model('ship\\model.dae')
        self.ship.setOrientation(4.5, .7, 4, 0.06, 180)
        self.bZ = self.ship.getZ() + 0.05
        self.startbZ = self.ship.getZ()
        # set up keyboard and timer callback methods
        self.callback(viz.KEYDOWN_EVENT, self.onKeyDown)
        self.callback(viz.COLLIDE_BEGIN_EVENT, self.onCollideBegin)

        #avatar's postion and rotation angle
        self.x = 4.5
        self.y = 0.85
        self.z = 2
        self.theta = 0

        # The 2D array below stores the representation of a maze.
        # Array entries containing a 2 represent 1 x 2 x 1 wall blocks.
        # Array entries containing a 0 represent 1 x 0.1 x 1 floor blocks.
        self.maze = []
        self.maze = [[
            11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12,
            12, 12, 12
        ]] + self.maze  # row 17
        self.maze = [[
            11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 12
        ]] + self.maze  # row 17
        self.maze = [[
            11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 12
        ]] + self.maze  # row 16
        self.maze = [[
            11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 12
        ]] + self.maze  # row 15
        self.maze = [[
            11, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 4, 4, 4, 4, 12
        ]] + self.maze  # row 14
        self.maze = [[
            11, 0, 0, 0, 1, 0, 0, 0, 0, 0, 4, 4, 4, 1, 4, 4, 4, 4, 4, 12
        ]] + self.maze  # row 13
        self.maze = [[
            11, 0, 0, 0, 8, 0, 0, 0, 0, 0, 4, 4, 4, 7, 4, 4, 4, 4, 4, 12
        ]] + self.maze  # row 12
        self.maze = [[
            11, 0, 0, 0, 1, 0, 0, 0, 0, 0, 4, 4, 4, 1, 4, 4, 4, 4, 4, 12
        ]] + self.maze  # row 11
        self.maze = [[
            11, 0, 0, 0, 10, 0, 0, 0, 0, 0, 4, 4, 4, 10, 4, 4, 4, 4, 4, 12
        ]] + self.maze  # row 10
        self.maze = [[
            11, 0, 0, 0, 1, 0, 0, 0, 0, 0, 4, 4, 4, 1, 4, 4, 4, 4, 4, 12
        ]] + self.maze  # row 9

        self.maze = [[
            13, 3, 3, 3, 1, 3, 3, 3, 3, 3, 6, 6, 6, 1, 5, 5, 5, 5, 5, 14
        ]] + self.maze  # row 8
        self.maze = [[
            13, 3, 3, 3, 1, 3, 3, 3, 3, 3, 6, 6, 6, 1, 5, 5, 5, 5, 5, 14
        ]] + self.maze  # row 7
        self.maze = [[
            13, 3, 3, 3, 1, 3, 3, 3, 3, 3, 6, 6, 6, 1, 5, 5, 5, 5, 5, 14
        ]] + self.maze  # row 6
        self.maze = [[
            13, 3, 3, 3, 2, 3, 3, 3, 3, 3, 6, 6, 6, 9, 5, 5, 5, 5, 5, 14
        ]] + self.maze  # row 5
        self.maze = [[
            13, 3, 3, 3, 1, 3, 3, 3, 3, 3, 6, 6, 6, 1, 5, 5, 5, 5, 5, 14
        ]] + self.maze  # row 4
        self.maze = [[
            13, 3, 3, 3, 10, 1, 1, 1, 1, 1, 1, 1, 1, 10, 5, 5, 5, 5, 5, 14
        ]] + self.maze  # row 3
        self.maze = [[
            13, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 14
        ]] + self.maze  # row 2
        self.maze = [[
            13, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 14
        ]] + self.maze  # row 1
        self.maze = [[
            13, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 14
        ]] + self.maze  # row 0

        # Code to create blocks forming the maze goes here
        for r in range(0, len(self.maze)):
            for c in range(0, len(self.maze[0])):
                self.cVal = c
                self.rVal = r

                #Desert floor
                if (self.maze[r][c] == 0):
                    box = vizshape.addCube(size=1, color=[.92, .90, .68])
                    mat = viz.Matrix()
                    mat.postScale(1, .1, 1)
                    mat.postTrans(c + .5, 0.05, r + .5)
                    box.setMatrix(mat)
                elif (self.maze[r][c] == 11):
                    box = vizshape.addCube(size=1, color=[.92, .90, .68])
                    mat = viz.Matrix()
                    mat.postScale(1, 10, 1)
                    mat.postTrans(c + .5, 0.05, r + .5)
                    box.setMatrix(mat)

                #Snow tower
                elif (self.maze[r][c] == 2):
                    self.tower1 = vizshape.addCube(size=1, color=[1, .98, .98])
                    mat = viz.Matrix()
                    mat.postScale(1, 0.5, 1)
                    mat.postTrans(c + .5, 0.25, r + .5)
                    self.tower1.setMatrix(mat)
                    y = 0.4
                    self.cyl1 = vizshape.addCylinder(height=15.2,
                                                     radius=0.375,
                                                     color=[1, 1, 1],
                                                     alpha=0)

                    for i in range(19):
                        water = vizshape.addCylinder(height=0.2,
                                                     radius=0.375,
                                                     slices=20,
                                                     stacks=20,
                                                     color=[0.13, .53, .85])
                        mat = viz.Matrix()
                        mat.postTrans(0, y, 0)
                        water.setMatrix(mat)
                        y += 0.2
                        snow = vizshape.addCube(size=0.6, color=[0.76, .87, 1])
                        mat = viz.Matrix()
                        mat.postTrans(0, y, 0)
                        snow.setMatrix(mat)
                        y += 0.2
                        snow.setParent(self.cyl1)
                        water.setParent(self.cyl1)
                        self.cyl1.setParent(self.tower1)
                    self.cyl1.collideMesh()
                    self.cyl1.enable(viz.COLLIDE_NOTIFY)

                    self.barricade11 = vizshape.addCube(
                        size=0.2, color=[0.93, 0.82, 0.008])
                    self.barricade11.setParent(self.tower1)
                    mat = viz.Matrix()
                    mat.postScale(1, 1, 0.4)
                    mat.postTrans(0, 0.7, -0.48)
                    self.barricade11.setMatrix(mat)
                    self.barricade11.collideMesh()
                    self.barricade11.enable(viz.COLLIDE_NOTIFY)

                    self.barricade12 = vizshape.addCube(
                        size=0.2, color=[0.93, 0.82, 0.008])
                    self.barricade12.setParent(self.tower1)
                    mat = viz.Matrix()
                    mat.postScale(1, 1, 0.4)
                    mat.postTrans(0, 0.7, 0.48)
                    self.barricade12.setMatrix(mat)
                    self.barricade12.collideMesh()
                    self.barricade12.enable(viz.COLLIDE_NOTIFY)

                    self.barricade13 = vizshape.addCube(
                        size=0.2, color=[0.93, 0.82, 0.008])
                    self.barricade13.setParent(self.tower1)
                    mat = viz.Matrix()
                    mat.postScale(1, 1, 0.4)
                    mat.setAxisAngle(0, 1, 0, 90)
                    mat.postTrans(0.48, 0.7, 0)
                    self.barricade13.setMatrix(mat)
                    self.barricade13.collideMesh()
                    self.barricade13.enable(viz.COLLIDE_NOTIFY)

                    self.barricade14 = vizshape.addCube(
                        size=0.2, color=[0.93, 0.82, 0.008])
                    self.barricade14.setParent(self.tower1)
                    mat = viz.Matrix()
                    mat.postScale(1, 1, 0.4)
                    mat.setAxisAngle(0, 1, 0, 90)
                    mat.postTrans(-0.48, 0.7, 0)
                    self.barricade14.setMatrix(mat)
                    self.barricade14.collideMesh()
                    self.barricade14.enable(viz.COLLIDE_NOTIFY)

                #City tower
                elif (self.maze[r][c] == 7):
                    self.tower3 = vizshape.addCube(size=1,
                                                   color=[.43, .49, .50])
                    mat = viz.Matrix()
                    mat.postScale(1, 0.5, 1)
                    mat.postTrans(c + .5, 0.25, r + .5)
                    self.tower3.setMatrix(mat)
                    y = 0.4
                    self.cyl3 = vizshape.addCylinder(height=15.2,
                                                     radius=0.375,
                                                     color=[1, 1, 1],
                                                     alpha=0)

                    for i in range(19):
                        sand = vizshape.addCylinder(height=0.2,
                                                    radius=0.375,
                                                    slices=20,
                                                    stacks=20,
                                                    color=[0.31, 0.31, 0.31])
                        mat = viz.Matrix()
                        mat.postTrans(0, y, 0)
                        sand.setMatrix(mat)
                        y += 0.2
                        pyra = vizshape.addCube(size=0.6,
                                                color=[0.88, 0.88, 0.88])
                        mat = viz.Matrix()
                        mat.postTrans(0, y, 0)
                        pyra.setMatrix(mat)
                        y += 0.2
                        sand.setParent(self.cyl3)
                        pyra.setParent(self.cyl3)
                        self.cyl3.setParent(self.tower3)
                    self.cyl3.collideMesh()
                    self.cyl3.enable(viz.COLLIDE_NOTIFY)

                    self.barricade21 = vizshape.addCube(
                        size=0.2, color=[0.93, 0.82, 0.008])
                    self.barricade21.setParent(self.tower3)
                    mat = viz.Matrix()
                    mat.postScale(1, 1, 0.4)
                    mat.postTrans(0, 0.7, -0.48)
                    self.barricade21.setMatrix(mat)
                    self.barricade21.collideMesh()
                    self.barricade21.enable(viz.COLLIDE_NOTIFY)

                    self.barricade22 = vizshape.addCube(
                        size=0.2, color=[0.93, 0.82, 0.008])
                    self.barricade22.setParent(self.tower3)
                    mat = viz.Matrix()
                    mat.postScale(1, 1, 0.4)
                    mat.postTrans(0, 0.7, 0.48)
                    self.barricade22.setMatrix(mat)
                    self.barricade22.collideMesh()
                    self.barricade22.enable(viz.COLLIDE_NOTIFY)

                    self.barricade23 = vizshape.addCube(
                        size=0.2, color=[0.93, 0.82, 0.008])
                    self.barricade23.setParent(self.tower3)
                    mat = viz.Matrix()
                    mat.postScale(1, 1, 0.4)
                    mat.setAxisAngle(0, 1, 0, 90)
                    mat.postTrans(0.48, 0.7, 0)
                    self.barricade23.setMatrix(mat)
                    self.barricade23.collideMesh()
                    self.barricade23.enable(viz.COLLIDE_NOTIFY)

                    self.barricade24 = vizshape.addCube(
                        size=0.2, color=[0.93, 0.82, 0.008])
                    self.barricade24.setParent(self.tower3)
                    mat = viz.Matrix()
                    mat.postScale(1, 1, 0.4)
                    mat.setAxisAngle(0, 1, 0, 90)
                    mat.postTrans(-0.48, 0.7, 0)
                    self.barricade24.setMatrix(mat)
                    self.barricade24.collideMesh()
                    self.barricade24.enable(viz.COLLIDE_NOTIFY)

                #Desert tower
                elif (self.maze[r][c] == 8):
                    self.tower2 = vizshape.addCube(size=1,
                                                   color=[.92, .90, .68])
                    mat = viz.Matrix()
                    mat.postScale(1, 0.5, 1)
                    mat.postTrans(c + .5, 0.25, r + .5)
                    self.tower2.setMatrix(mat)
                    y = 0.4
                    self.cyl2 = vizshape.addCylinder(height=15.2,
                                                     radius=0.375,
                                                     color=[1, 1, 1],
                                                     alpha=0)

                    for i in range(19):
                        street = vizshape.addCylinder(height=0.2,
                                                      radius=0.375,
                                                      slices=20,
                                                      stacks=20,
                                                      color=[0.74, 0.49, 0.24])
                        mat = viz.Matrix()
                        mat.postTrans(0, y, 0)
                        street.setMatrix(mat)
                        y += 0.2
                        pole = vizshape.addCube(size=0.6,
                                                color=[0.86, 0.72, 0.58])
                        mat = viz.Matrix()
                        mat.postTrans(0, y, 0)
                        pole.setMatrix(mat)
                        y += 0.2
                        street.setParent(self.cyl2)
                        pole.setParent(self.cyl2)
                        self.cyl2.setParent(self.tower2)
                    self.cyl2.collideMesh()
                    self.cyl2.enable(viz.COLLIDE_NOTIFY)

                    self.barricade31 = vizshape.addCube(
                        size=0.2, color=[0.93, 0.82, 0.008])
                    self.barricade31.setParent(self.tower2)
                    mat = viz.Matrix()
                    mat.postScale(1, 1, 0.4)
                    mat.postTrans(0, 0.7, -0.48)
                    self.barricade31.setMatrix(mat)
                    self.barricade31.collideMesh()
                    self.barricade31.enable(viz.COLLIDE_NOTIFY)

                    self.barricade32 = vizshape.addCube(
                        size=0.2, color=[0.93, 0.82, 0.008])
                    self.barricade32.setParent(self.tower2)
                    mat = viz.Matrix()
                    mat.postScale(1, 1, 0.4)
                    mat.postTrans(0, 0.7, 0.48)
                    self.barricade32.setMatrix(mat)
                    self.barricade32.collideMesh()
                    self.barricade32.enable(viz.COLLIDE_NOTIFY)

                    self.barricade33 = vizshape.addCube(
                        size=0.2, color=[0.93, 0.82, 0.008])
                    self.barricade33.setParent(self.tower2)
                    mat = viz.Matrix()
                    mat.postScale(1, 1, 0.4)
                    mat.setAxisAngle(0, 1, 0, 90)
                    mat.postTrans(0.48, 0.7, 0)
                    self.barricade33.setMatrix(mat)
                    self.barricade33.collideMesh()
                    self.barricade33.enable(viz.COLLIDE_NOTIFY)

                    self.barricade34 = vizshape.addCube(
                        size=0.2, color=[0.93, 0.82, 0.008])
                    self.barricade34.setParent(self.tower2)
                    mat = viz.Matrix()
                    mat.postScale(1, 1, 0.4)
                    mat.setAxisAngle(0, 1, 0, 90)
                    mat.postTrans(-0.48, 0.7, 0)
                    self.barricade34.setMatrix(mat)
                    self.barricade34.collideMesh()
                    self.barricade34.enable(viz.COLLIDE_NOTIFY)

                #Forrest tower
                elif (self.maze[r][c] == 9):
                    self.tower4 = vizshape.addCube(size=1,
                                                   color=[.27, .40, .20])
                    mat = viz.Matrix()
                    mat.postScale(1, 0.5, 1)
                    mat.postTrans(c + .5, 0.25, r + .5)
                    self.tower4.setMatrix(mat)
                    y = 0.4
                    self.cyl4 = vizshape.addCylinder(height=15.2,
                                                     radius=0.375,
                                                     color=[1, 1, 1],
                                                     alpha=0)

                    for i in range(19):
                        grass = vizshape.addCylinder(height=0.2,
                                                     radius=0.375,
                                                     slices=20,
                                                     stacks=20,
                                                     color=[0.88, 1, 0.18])
                        mat = viz.Matrix()
                        mat.postTrans(0, y, 0)
                        grass.setMatrix(mat)
                        y += 0.2
                        leaf = vizshape.addCube(size=0.6,
                                                color=[0.00, 0.46, 0.00])
                        mat = viz.Matrix()
                        mat.postTrans(0, y, 0)
                        leaf.setMatrix(mat)
                        y += 0.2
                        grass.setParent(self.cyl4)
                        leaf.setParent(self.cyl4)
                        self.cyl4.setParent(self.tower4)
                    self.cyl4.collideMesh()
                    self.cyl4.enable(viz.COLLIDE_NOTIFY)

                    self.barricade41 = vizshape.addCube(
                        size=0.2, color=[0.93, 0.82, 0.008])
                    self.barricade41.setParent(self.tower4)
                    mat = viz.Matrix()
                    mat.postScale(1, 1, 0.4)
                    mat.postTrans(0, 0.7, -0.48)
                    self.barricade41.setMatrix(mat)
                    self.barricade41.collideMesh()
                    self.barricade41.enable(viz.COLLIDE_NOTIFY)

                    self.barricade42 = vizshape.addCube(
                        size=0.2, color=[0.93, 0.82, 0.008])
                    self.barricade42.setParent(self.tower4)
                    mat = viz.Matrix()
                    mat.postScale(1, 1, 0.4)
                    mat.postTrans(0, 0.7, 0.48)
                    self.barricade42.setMatrix(mat)
                    self.barricade42.collideMesh()
                    self.barricade42.enable(viz.COLLIDE_NOTIFY)

                    self.barricade43 = vizshape.addCube(
                        size=0.2, color=[0.93, 0.82, 0.008])
                    self.barricade43.setParent(self.tower4)
                    mat = viz.Matrix()
                    mat.postScale(1, 1, 0.4)
                    mat.setAxisAngle(0, 1, 0, 90)
                    mat.postTrans(0.48, 0.7, 0)
                    self.barricade43.setMatrix(mat)
                    self.barricade43.collideMesh()
                    self.barricade43.enable(viz.COLLIDE_NOTIFY)

                    self.barricade44 = vizshape.addCube(
                        size=0.2, color=[0.93, 0.82, 0.008])
                    self.barricade44.setParent(self.tower4)
                    mat = viz.Matrix()
                    mat.postScale(1, 1, 0.4)
                    mat.setAxisAngle(0, 1, 0, 90)
                    mat.postTrans(-0.48, 0.7, 0)
                    self.barricade44.setMatrix(mat)
                    self.barricade44.collideMesh()
                    self.barricade44.enable(viz.COLLIDE_NOTIFY)

                #Pink track
                elif (self.maze[r][c] == 1):
                    box = vizshape.addCube(size=1, color=[0.85, 0.44, .57])
                    mat = viz.Matrix()
                    mat.postScale(1, 0.5, 1)
                    mat.postTrans(c + .5, 0.25, r + .5)
                    box.setMatrix(mat)

                #pink track with mesh
                elif (self.maze[r][c] == 10):
                    box = vizshape.addCube(size=1, color=[0.85, 0.44, .57])
                    mat = viz.Matrix()
                    mat.postScale(1, 0.5, 1)
                    mat.postTrans(c + .5, 0.25, r + .5)
                    box.setMatrix(mat)
                    box.collideMesh()
                    box.enable(viz.COLLIDE_NOTIFY)

                #Snow floor
                elif (self.maze[r][c] == 3):
                    box = vizshape.addCube(size=1, color=[1, .98, .98])
                    mat = viz.Matrix()
                    mat.postScale(1, .1, 1)
                    mat.postTrans(c + .5, 0.05, r + .5)
                    box.setMatrix(mat)

                elif (self.maze[r][c] == 13):
                    box = vizshape.addCube(size=1, color=[1, .98, .98])
                    mat = viz.Matrix()
                    mat.postScale(1, 10, 1)
                    mat.postTrans(c + .5, 0.05, r + .5)
                    box.setMatrix(mat)

                #City floor
                elif (self.maze[r][c] == 4):
                    box = vizshape.addCube(size=1, color=[.43, .49, .50])
                    mat = viz.Matrix()
                    mat.postScale(1, .1, 1)
                    mat.postTrans(c + .5, 0.05, r + .5)
                    box.setMatrix(mat)

                elif (self.maze[r][c] == 12):
                    box = vizshape.addCube(size=1, color=[.43, .49, .50])
                    mat = viz.Matrix()
                    mat.postScale(1, 10, 1)
                    mat.postTrans(c + .5, 0.05, r + .5)
                    box.setMatrix(mat)

                #Outside Forrest floor
                elif (self.maze[r][c] == 5):
                    box = vizshape.addCube(size=1, color=[.27, .40, .20])
                    mat = viz.Matrix()
                    mat.postScale(1, .1, 1)
                    mat.postTrans(c + .5, 0.05, r + .5)
                    box.setMatrix(mat)
                elif (self.maze[r][c] == 14):
                    box = vizshape.addCube(size=1, color=[.27, .40, .20])
                    mat = viz.Matrix()
                    mat.postScale(1, 10, 1)
                    mat.postTrans(c + .5, 0.05, r + .5)
                    box.setMatrix(mat)

                #Inside Forrest floor
                elif (self.maze[r][c] == 6):
                    box = vizshape.addCube(size=1, color=[.325, .478, .239])
                    mat = viz.Matrix()
                    mat.postScale(1, .1, 1)
                    mat.postTrans(c + .5, 0.05, r + .5)
                    box.setMatrix(mat)

        self.mode = "thirdperson"
Esempio n. 30
0
    def __init__(self):

        # base class constructor
        viz.EventClass.__init__(self)

        #self.addCoordinateAxes()

        # set up keyboard and timer callback methods
        self.callback(viz.TIMER_EVENT, self.onTimer)
        self.callback(viz.KEYDOWN_EVENT, self.onKeyDown)

        self.starttimer(1, (1 / 25.0), viz.FOREVER)
        #self.starttimer(2, (30), viz.FOREVER)
        #self.starttimer(1, (30), viz.FOREVER)

        self.timePassed = 0

        # car's x,z location in maze and its rotation angle
        self.theta = 0
        self.x = 0
        self.z = 0

        #cars velocity
        self.vx = 0
        self.vy = 0
        self.vz = 0

        self.v = 0

        #lighting codeeeee
        self.myLight = viz.addLight()
        self.myLight.enable()
        self.myLight.color(1, 1, 1)

        m = viz.Matrix()
        m.postAxisAngle(1, 0, 0, 90)
        self.myLight.setMatrix(m)

        self.mat = viz.Matrix()

        #load taxi
        c = viz.add('taxiNew.dae')
        m = viz.Matrix()
        m.postAxisAngle(0, 1, 0, 90)
        c.setMatrix(m)

        self.car = viz.addGroup()
        c.setParent(self.car)

        # create ball and link it to car so the user can see where they are on the minimap
        self.circ2 = vizshape.addSphere(radius=15.0,
                                        slices=20,
                                        stacks=20,
                                        axis=vizshape.AXIS_Y)
        self.circ2.color(1, 1, 0)
        self.circ2.setParent(self.car)

        #create a rectangle over visible ground and add grass texture
        viz.startLayer(viz.QUADS)
        viz.texCoord(0, 16)
        viz.vertex(700, 0, -100)
        viz.texCoord(16, 16)
        viz.vertex(700, 0, 600)
        viz.texCoord(16, 0)
        viz.vertex(-100, 0, 600)
        viz.texCoord(0, 0)
        viz.vertex(-100, 0, -100)
        self.vertices = viz.endLayer()

        tex = viz.addTexture('grass.jpg')

        tex.wrap(viz.WRAP_S, viz.REPEAT)
        tex.wrap(viz.WRAP_T, viz.REPEAT)

        self.vertices.texture(tex)

        #load in models
        self.house1 = viz.add('house1\model.dae')

        m = viz.Matrix()
        m.postAxisAngle(0, 1, 0, 90)
        m.postTrans(115, 0, 230)
        self.house1.setMatrix(m)

        self.house2 = viz.add('house2\model.dae')

        m = viz.Matrix()
        m.postAxisAngle(0, 1, 0, 90)
        m.postTrans(15, 0, 30)
        self.house2.setMatrix(m)

        self.house3 = viz.add('house3\model.dae')

        m = viz.Matrix()
        m.postAxisAngle(0, 1, 0, 180)
        m.postTrans(20, 0, 35)
        self.house3.setMatrix(m)

        self.house4 = viz.add('house4\model.dae')

        m = viz.Matrix()
        m.postAxisAngle(0, 1, 0, 90)
        m.postTrans(220, 0, 235)
        self.house4.setMatrix(m)

        self.house5 = viz.add('house5\model.dae')

        m = viz.Matrix()
        m.postTrans(375, 0, 355)
        self.house5.setMatrix(m)

        self.house6 = viz.add('house6\model.dae')

        m = viz.Matrix()
        m.postAxisAngle(0, 1, 0, 90)
        m.postTrans(107, 0, 450)
        self.house6.setMatrix(m)

        self.house7 = viz.add('house2\model.dae')

        m = viz.Matrix()
        m.postAxisAngle(0, 1, 0, 90)
        m.postTrans(255, 0, 205)
        self.house7.setMatrix(m)

        self.house8 = viz.add('house5\model.dae')

        m = viz.Matrix()
        m.postAxisAngle(0, 1, 0, 180)
        m.postTrans(200, 0, 50)
        self.house8.setMatrix(m)

        self.house9 = viz.add('house7\model.dae')

        m = viz.Matrix()
        m.postAxisAngle(0, 1, 0, 90)
        m.postTrans(217, 0, 365)
        self.house9.setMatrix(m)

        self.house10 = viz.add('house8\model.dae')

        m = viz.Matrix()
        m.postAxisAngle(0, 1, 0, 90)
        m.postTrans(400, 0, 550)
        self.house10.setMatrix(m)

        self.house11 = viz.add('house9\model.dae')

        m = viz.Matrix()
        m.postTrans(375, 0, 180)
        self.house11.setMatrix(m)

        self.pizza = viz.add('pizza\model.dae')

        m = viz.Matrix()
        #m.postAxisAngle(0, 1, 0, 90)
        m.postTrans(300, 0, 550)
        self.pizza.setMatrix(m)

        self.diner = viz.add('diner\model.dae')

        m = viz.Matrix()
        m.postAxisAngle(0, 1, 0, 90)
        m.postTrans(260, 0, 570)
        self.diner.setMatrix(m)

        self.stop = viz.add('stop\model.dae')

        m = viz.Matrix()
        m.postAxisAngle(0, 1, 0, 90)
        m.postTrans(100, 1, 50)
        self.stop.setMatrix(m)

        self.stop2 = viz.add('stop\model.dae')

        m = viz.Matrix()
        m.postAxisAngle(0, 1, 0, -90)
        m.postTrans(108, 1, 57)
        self.stop2.setMatrix(m)

        self.tree = viz.add('tree\model.dae')

        m = viz.Matrix()
        m.postTrans(50, 0, 40)
        m.postScale(3, 3, 3)
        self.tree.setMatrix(m)

        self.tree2 = viz.add('tree\model.dae')
        m = viz.Matrix()
        m.postTrans(190, 0, 190)
        m.postScale(2, 2, 2)
        self.tree2.setMatrix(m)

        self.tree3 = viz.add('tree\model.dae')

        m = viz.Matrix()
        m.postTrans(120, 0, 90)
        m.postScale(2, 2, 2)
        self.tree3.setMatrix(m)

        self.tree4 = viz.add('tree\model.dae')

        m = viz.Matrix()
        m.postTrans(70, 0, 40)
        m.postScale(3, 3, 3)
        self.tree4.setMatrix(m)

        self.tree5 = viz.add('tree\model.dae')

        m = viz.Matrix()
        m.postTrans(65, 0, 50)
        m.postScale(2, 2, 2)
        self.tree5.setMatrix(m)

        self.tree6 = viz.add('tree\model.dae')

        m = viz.Matrix()
        m.postTrans(30, 0, 60)
        m.postScale(3, 3, 3)
        self.tree6.setMatrix(m)

        self.tree7 = viz.add('tree\model.dae')

        m = viz.Matrix()
        m.postTrans(25, 0, 40)
        m.postScale(4, 4, 4)
        self.tree7.setMatrix(m)

        self.tree8 = viz.add('tree\model.dae')

        m = viz.Matrix()
        m.postTrans(10, 0, 15)
        m.postScale(4, 4, 4)
        self.tree8.setMatrix(m)

        self.tree9 = viz.add('tree\model.dae')

        m = viz.Matrix()
        m.postTrans(65, 0, 200)
        m.postScale(2, 2, 2)
        self.tree9.setMatrix(m)

        self.tree10 = viz.add('tree\model.dae')

        m = viz.Matrix()
        m.postTrans(40, 0, 140)
        m.postScale(4, 4, 4)
        self.tree10.setMatrix(m)

        self.tree11 = viz.add('tree\model.dae')

        m = viz.Matrix()
        m.postTrans(35, 0, 150)
        m.postScale(3, 3, 3)
        self.tree11.setMatrix(m)

        self.tree13 = viz.add('tree\model.dae')
        m = viz.Matrix()
        m.postTrans(180, 0, 190)
        m.postScale(2, 2, 2)
        self.tree13.setMatrix(m)

        self.tree14 = viz.add('tree\model.dae')

        m = viz.Matrix()
        m.postTrans(120, 0, 90)
        m.postScale(2, 2, 2)
        self.tree14.setMatrix(m)

        self.tree15 = viz.add('tree\model.dae')

        m = viz.Matrix()
        m.postTrans(100, 0, 40)
        m.postScale(3, 3, 3)
        self.tree15.setMatrix(m)

        self.tree16 = viz.add('tree\model.dae')

        m = viz.Matrix()
        m.postTrans(165, 0, 50)
        m.postScale(2, 2, 2)
        self.tree16.setMatrix(m)

        self.tree17 = viz.add('tree2\model.dae')

        m = viz.Matrix()
        m.postTrans(100, 0, 50)
        m.postScale(2, 2, 2)
        self.tree17.setMatrix(m)

        self.tree18 = viz.add('tree3\model.dae')

        m = viz.Matrix()
        m.postTrans(90, 0, 70)
        m.postScale(2, 2, 2)
        self.tree18.setMatrix(m)

        self.road = viz.add('Roads.dae')

        self.road.ambient(.5, .5, .5)
        self.myLight.ambient(.5, .5, .5)

        #add text telling player who needs a ride

        textScreen = viz.addText('Mike needs a ride to the diner!',
                                 viz.SCREEN,
                                 pos=[0, 0, 0])
        textScreen.color(viz.BLUE)
        textScreen.fontSize(60)

        self.circ = vizshape.addSphere(radius=15.0,
                                       slices=20,
                                       stacks=20,
                                       axis=vizshape.AXIS_Y)
        self.circ.color(1, 0, 0)
        m = viz.Matrix()
        m.postTrans(350, 100, 345)
        self.circ.setMatrix(m)
boxR = viz.addChild('target.obj',color=(0.063,0.102,0.898),scale=[rscale1,targettolR,0.0125])
boxR.setPosition([rxdistance,0,Rdistance])
global cursorR
cursorR = viz.add('box3.obj', color=viz.RED, scale=[1.2*rscale1,rcursescale,0.0125], cache=viz.CACHE_NONE)
cursorR.setPosition([rxdistance,-rcursescale,Rdistance])
global neutralR
neutralR = viz.add('box3.obj', color=viz.RED, scale=[1.2*cscale[0],0.5*cscale[1],0.0125], cache=viz.CACHE_NONE)
neutralR.setPosition([0.165,-0.25,0.95])
global HistBallR
HistBallR = viz.add('footprint2.obj', color=viz.YELLOW, scale=[0.8*targettolR,0.8*targettolR,0.1], cache=viz.CACHE_NONE)
HistBallR.setPosition([rxdistance,0,Rdistance])
HistBallR.setEuler(180,0,0)
HistBallR.alpha(0.8)

#Add an extra light so the left target looks almost as bright as the right one
newlight = viz.addLight();
newlight.setPosition([-1,0,0.25])
newlight.intensity(1.5)

#setup counter panels
global RCOUNT
global LCOUNT
RCOUNT = 0
LCOUNT = 0
#rightcounter = vizinfo.InfoPanel(str(RCOUNT),align=viz.ALIGN_RIGHT_TOP,fontSize=50,icon=False,key=None)
rightcounter = viz.addText(str(RCOUNT),pos=[.4,-0.25,1],scale=[0.1,0.1,0.1])
#leftcounter = vizinfo.InfoPanel(str(LCOUNT),align=viz.ALIGN_LEFT_TOP,fontSize=50,icon=False,key=None)
leftcounter = viz.addText(str(LCOUNT),pos=[-.46,-0.25,1],scale=[0.1,0.1,0.1])

global RGOB
RGOB = 0 #this will be 0 or 1, depending on success or failure
Esempio n. 32
0
    def __init__(self):
        viz.EventClass.__init__(self)

        self.callback(viz.KEYDOWN_EVENT, self.onKeyDown)
        self.callback(viz.KEYUP_EVENT, self.onKeyUp)
        self.callback(viz.TIMER_EVENT, self.onTimer)
        self.starttimer(1, 1.0 / 25.0, viz.FOREVER)

        # avatar's x,z location in space and its rotation angle
        self.theta = 0
        self.alpha = 0
        self.x = 10
        self.z = 45
        self.y = 20
        self.dtheta = 0
        self.dalpha = 0
        self.moving = False

        #number of catches made
        self.catches = 0

        #create models
        self.quadribol = Model('quadribol' + os.sep + 'model.osgb')
        self.snitch = vizshape.addSphere(radius=0.5,
                                         slices=20,
                                         stacks=20,
                                         axis=vizshape.AXIS_Y,
                                         color=[0.7, 0.5, 0])
        self.broom = vizshape.addCylinder(height=10, radius=.25)

        #texture mapping on sky cube for background
        sky = viz.add(viz.ENVIRONMENT_MAP, 'mountsky\mount.jpg')
        skybox = viz.add('skydome.dlc')
        skybox.texture(sky)

        #texture mapping for broom
        self.woodTex = viz.addTexture('woodtex.jpg')
        self.broom.texture(self.woodTex)

        #score message displayed on the screen
        self.text = viz.addText('Score: ' + str(self.catches),
                                viz.SCREEN,
                                pos=[0.01, 0.92, 0])
        self.text.setBackdrop(viz.BACKDROP_RIGHT_BOTTOM)
        self.text.color(0.95, 0.95, 0.95)
        self.text.disable(viz.LIGHTING)

        #lighting
        self.mylight = viz.addLight()
        self.mylight.enable()
        self.mylight.color(1, 1, 1)
        mat = viz.Matrix()
        mat.postAxisAngle(1, 0, 0, 110)
        self.mylight.setMatrix(mat)
        #viz.MainView.getHeadLight().disable()
        self.snitch.specular([1, 1, .9])

        #choose a snitch path
        pathNum = random.randint(0, 3)
        self.snitchPath(pathNum)

        #collision detection
        self.broom.collideSphere(radius=10)
        self.broom.disable(viz.DYNAMICS)
        self.snitch.collideMesh()
        self.snitch.disable(viz.DYNAMICS)
        self.snitch.enable(viz.COLLIDE_NOTIFY)
        self.callback(viz.COLLIDE_BEGIN_EVENT, self.onCollideBegin)

        viz.playSound('Harry_Potter_Theme.wav')
Esempio n. 33
0
    datafile.write("%d " % (EHNum))
    datafile.write("%s " % (data.gender))
    datafile.write("%s" % (data.units))


#Load textures
plaster = viz.addTexture('CeilingLarge.jpg')
wallpaper = viz.addTexture('WallpaperLarge.jpg')
wallpaperlong = viz.addTexture('WallpaperLong.jpg')
carpet = viz.addTexture('CarpetLarge3.jpg')
wood = viz.addTexture('Door.jpg')
mask_img = viz.addTexture('Masktiny.jpg')

#Create skylight
viz.MainView.getHeadLight().disable()
sky_light = viz.addLight(euler=(0, 90, 0))  #euler = yaw, pitch, roll
sky_light.position(2, 0, -1, 0)
sky_light.color(viz.WHITE)
sky_light.intensity(2)

#Create backlight
back_light = viz.addLight(euler=(0, 215, 0))  #euler = yaw, pitch, roll
back_light.position(-2, 0, 4, 0)
back_light.color(viz.WHITE)
back_light.intensity(.75)

#Create frontlight?
front_light = viz.addLight(euler=(0, 45, 0))  #euler = yaw, pitch, roll
front_light.position(-2, 0, 4, 0)
front_light.color(viz.WHITE)
front_light.intensity(1.5)
def CreateTheRoom():

    """<START OF DEFINING THE WORLD>"""

    #disables the original light
    viz.disable(viz.LIGHT0)

    topLight = viz.addLight() 
    topLight.setPosition(0,4,0)
    topLight.setEuler( 0, 90 ,0 )
    #topLight.direction(0,-1,0) 
    topLight.spread(270) 
    topLight.intensity(2000) 
    #topLight.spotexponent(2)     
    sideLight = viz.addLight()
    sideLight.setPosition(0,5,0)
    sideLight.setEuler(0,0,90)

    #creates the floor plane to be 35x80
    #rotated around the Z axis(perpendicular to Y axis)
    floor = vizshape.addPlane(size=(35.0,80.0), axis=vizshape.AXIS_Y, cullFace=False)
    #makes the floor look like wood
    floor.texture(viz.addTexture('images/tile_wood.jpg'))
    #moves the floor +20 meters in the z direction
    floor.setPosition(0,0,20)

    """
    Could use Gabe's mocap interaface here to create a room easily
    and play with textures. 

    If performance is an issue, set cullFace to True.
    """
    #adds the wall(plane) farthest from the hand/person
    #35x10 meters**2
    #rotated around the X axis (perpendicular to Z axis)
    frontWall = vizshape.addPlane(size=(35,10), axis=vizshape.AXIS_Z, cullFace = False)
    #moves the wall to match the edge of the 
    frontWall.setPosition(0,5,60)
    #makes the wall appear white
    frontWall.color(viz.WHITE)

    #adds the wall(plane) that when facing the frontWall, is to the camera's left
    #wall is 80x10 meters**2
    #wall is rotated about the Y axis(perpendicular to X axis)
    leftWall = vizshape.addPlane(size=(80,10), axis=vizshape.AXIS_X, cullFace = False)
    #shifts the wall to match the edge of the floor
    leftWall.setPosition(-17.5,5,20)
    #makes the wall appear white
    leftWall.color(viz.WHITE)

    #adds a wall(plane) that when facing the frontWall is to the camera's right
    #wall is 80x10 meters**2
    #wall is rotated about the Y axis(perpendicular to X axis)
    rightWall = vizshape.addPlane(size=(80,10), axis=vizshape.AXIS_X, cullFace = False)
    #shifts the wall to match the edge of the floor
    rightWall.setPosition(17.5,5,20)
    #makes the wall appear white
    rightWall.color(viz.WHITE)

    #adds a wall(plane) that when facing the frontWall is to the camera's back
    #wall is 35x10 meters**2
    #wall is rotated about the X axis(perpendicular to Z axis)
    backWall = vizshape.addPlane(size=(35,10), axis=vizshape.AXIS_Z, cullFace = False)
    #shifts the wall to match the edge of the floor
    backWall.setPosition(0,5,-20)
    #makes the wall appear white
    backWall.color(viz.WHITE)

    #adds a ceiling(plane) that when facing the frontWall is to the camera's topside
    #wall is 35x80 meters**2
    #wall is rotated about the Z axis(perpendicular to Y axis)
    ceiling = vizshape.addPlane(size=(35.0,80.0), axis=vizshape.AXIS_Y, cullFace=False)
    #makes the ceiling appear Skyblue in color
    ceiling.color(viz.SKYBLUE)
    #shifts the ceiling to rest on top of the four walls
    ceiling.setPosition(0,10,20)

    #add a meter marker at 0 meters along the z axis of the room
    #meter0 = vizshape.addPlane(size = (5,.3), axis = vizshape.AXIS_Y, cullFace = False)
    #meter0.setPosition(0,.3, 0)
    #makes the meter marker appear yellow
    #meter0.color(viz.WHITE)


    """</END OF DEFINING THE WORLD>"""
Esempio n. 35
0
viz.MainView.setEuler(105, -0.0, 0.0)

def reset():
  ORI_TRACKER.reset()
vizact.onkeydown('r', reset)

# add homeless avatars
homeless1 = viz.addAvatar('Homeless Avatars/CC2_m006_hipoly_A2_v2.cfg', pos=(-1.8,.45,0), euler=(100, 0, 0))
homeless1.addAction(vizact.animation(68))

#add Bus Lights
busLight = viz.add('Bus Light.vzf')
busLight.setPosition([-6.1, -2.7, 2.9])
busLight.setEuler([180.0, 90.0, 180.0])

bus_light = viz.addLight()
bus_light.position( 0,0,0,1 )
viz.link( busLight, bus_light )
busLight.emissive(viz.WHITE)
bus_light.color(viz.WHITE)
intensity = .15
bus_light.intensity(intensity)
bus_light.linearattenuation( 3 )

busLight2 = viz.add('Bus Light.vzf')
busLight2.setPosition([-6.1, -2.7, 4.6])
busLight2.setEuler([180.0, 90.0, 180.0])

bus_light2 = viz.addLight()
bus_light2.position( 0,0,0,1 )
viz.link( busLight2, bus_light2 )
neutralR = viz.add('box3.obj',
                   color=viz.RED,
                   scale=[1.2 * cscale[0], 0.5 * cscale[1], 0.0125],
                   cache=viz.CACHE_NONE)
neutralR.setPosition([0.165, -0.25, 0.95])
global HistBallR
HistBallR = viz.add('footprint2.obj',
                    color=viz.YELLOW,
                    scale=[0.8 * targettolR, 0.8 * targettolR, 0.1],
                    cache=viz.CACHE_NONE)
HistBallR.setPosition([rxdistance, 0, Rdistance])
HistBallR.setEuler(180, 0, 0)
HistBallR.alpha(0.8)

#Add an extra light so the left target looks almost as bright as the right one
newlight = viz.addLight()
newlight.setPosition([-1, 0, 0.25])
newlight.intensity(1.5)

#setup counter panels
global RCOUNT
global LCOUNT
RCOUNT = 0
LCOUNT = 0
#rightcounter = vizinfo.InfoPanel(str(RCOUNT),align=viz.ALIGN_RIGHT_TOP,fontSize=50,icon=False,key=None)
rightcounter = viz.addText(str(RCOUNT),
                           pos=[.4, -0.25, 1],
                           scale=[0.1, 0.1, 0.1])
#leftcounter = vizinfo.InfoPanel(str(LCOUNT),align=viz.ALIGN_LEFT_TOP,fontSize=50,icon=False,key=None)
leftcounter = viz.addText(str(LCOUNT),
                          pos=[-.46, -0.25, 1],
Esempio n. 37
0
############################################################################################################################

viz.window.setFullscreenMonitor([2, 1])
clock = 0
GRAVITY = 9.81
num = 0
NUM_AVATARS = 2
headLocation = viz.addGroup()

##########################
#### Scene Creation   ####
##########################

light = viz.MainView.getHeadLight().ambient(1, 1, 1)
light2 = viz.addLight()

roomGroup = None
viz.clearcolor(0.1, 0.1, 0.3)
link = None

# list of limbs to check for collision body
COLLISION_LIMBS = [
    "Bip01 Head",
    "Bip01 L UpperArm",
    "Bip01 L Forearm",
    "Bip01 L Thigh",
    "Bip01 L Calf",
    "Bip01 R UpperArm",
    "Bip01 R Forearm",
    "Bip01 R Thigh",
Esempio n. 38
0
def addDirectionalLight():
  mylight = viz.addLight()
  mylight.setEuler( 80,0,0 )
Esempio n. 39
0
import path
import viz
import random
import viztask
import math

#viz.go()
viz.go()
viz.phys.enable()

#viz.disable( viz.LIGHTING )
light1 = viz.addLight()
light1.position(0,5,0)
light1.color(viz.WHITE)

#env = viz.add(viz.ENVIRONMENT_MAP, 'eucalyptus\eucalyptus.jpg',scene=viz.MainScene)
env = viz.add(viz.ENVIRONMENT_MAP, 'sky.jpg',scene=viz.MainScene)
sky = viz.add('skydome.dlc')
sky.texture(env)

TRANSLATE_INC = .2
ROTATION_INC = 2
SCALE = [0.03, 0.03, 0.03]
room = viz.add("../models/room2/room2.wrl")
room.setScale(SCALE)

ground = viz.add('tut_ground.wrl')
ground.setScale([5,1,5])
#viz.translate(viz.HEAD_POS,0,20,-20)
#viz.lookat(0,0,0)
viz.clearcolor(viz.SKYBLUE)
Esempio n. 40
0
########add sun and sky##############################
sky = viz.addChild('sky_day.osgb')
sun = vizfx.addDirectionalLight()
sun.setScale(500, 500, 500)
sun.color(5.0, 5.0, 5)
sun.setEuler(90, 0, 0)
sky.setPosition(500, 0, 500)
sky.setScale(10, 10, 10)

###########main view position############################
viz.MainView.move([-100, 20, 140])
viz.MainView.setEuler([90, 0, 0])
viz.MainView.gravity(0.0)

####################sun_light#####################################################
mylight = viz.addLight()
mylight.position(0, 15, 0)
mylight.direction(10, -10, -10)
mylight.spread(9000)
mylight.intensity(1.8)
mylight.spotexponent(2)
mylight.setPosition(100, 120, 100)

mylight1 = viz.addLight()
mylight1.position(40, 15, -10)
mylight1.direction(10, -10, 100)
mylight1.spread(9000)
mylight1.intensity(1.8)
mylight1.spotexponent(2)
mylight1.setPosition(100, 120, 100)