# Vizard Game

a guest
Jul 12th, 2016
80
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import viz
2. import vizact
4. import vizshape
5. import vizcam
6. import vizinput
7. import vizinfo
8. import math
9.
10.
11. viz.setMultiSample(4)
12. viz.fov(60)
13. viz.phys.enable()
14.
15. ######HARDWARE SETUP######
16. choice = vizinput.choose('Select a 3D display type:', ['None', 'Stereo Horizontal', 'Stereo Vertical', 'Anagyphic', 'Interlaced Horizontal', 'Interlaced Vertical'])
17. fullscreen = vizinput.ask('Fullscreen?')
18. name = vizinput.input('What is your name?')
19. viz.message('Please put the sensors in the following order from left to right (with the port openings facing you) for the game to function correctly. Force, rotation, slider, magnetic.')
20.
21. if name == '': #If no name is supplied
22.     name = 'Player' #Make name = 'Player'
23.
24. ###LEVEL INSTRUCTIONS###
25. INSTRUCTIONS = """
26. Hi {} !
27. You should stay in this area for as long as you want to.
28. Play around with materials to get an understanding of their physical properties!
29. Click on an object to select it and use the rotation sensor to move the camera around it.
30. You can scroll the mouse wheel to change its material. This effects how the forces work on it!
31. To get into the game, click the GREEN button!
32. You can reset the objects by clicking the BLUE button!
33. You can click to get rid of this message!""".format(name)
34.
35. INSTRUCTIONS1 = """
36. Hi {} !
37. The if the colour of a switch matches the colour of a door, that's the door it will open when it activates!
38. A RED switch means activating that switch will take you to the next level!""".format(name)
39.
40. INSTRUCTIONS2 = """
41. Hi {} !
42. If you're having trouble getting through a gap, you can use the slider to make you cube bigger or smaller!
43. If you're stuck somewhere. Click the BLUE button to reset your cubes.""".format(name)
44.
45. INSTRUCTIONS3 = """
46. Hi {} !
47. Some switches are HOLD switches.
48. You'll have to keep a heavy cube on them, otherwise the door will close again!""".format(name)
49.
50. ##SENSOR INDEX###
51. sensorTouch = 0
52. sensorMagnetic = 3
53. sensorSlider = 2
54. sensorRotate = 1
55.
56. ###GLOBALS###
57. global currentLevel
58. global totalLevels
59. global ground
60. global levelEnvironment
61. global count
62. count = 0
63. ground = viz.addChild('ground.osgb')
64. levelEnvironment = viz.addChild('ground.osgb')
65. currentLevel = 0
66. totalLevels = 4
67. debug = False
68.
69. mouseState = viz.mouse.getState()
70.
71. forceBox = viz.addChild('box.wrl') #The force box is an invisible box at the end of the arrow, used to get a directional vector from it, to an object
72. forceBox.visible(viz.OFF)
73. forceBox.disable(viz.PHYSICS)
74.
75. arrow = viz.addChild('arrow.fbx')
76. arrow.setEuler([0, -90, 0])
77. arrow.disable(viz.PHYSICS)
78. arrow.visible(viz.OFF)
79.
80. viz.cam.setHandler(vizcam.KeyboardCamera(forward='w',backward='s', left='a',right='d',turnRight='e',turnLeft='q'))
81.
82. ####################Classes####################
83. class MaterialObject:
84.     def __init__(self, position, material):
85.         self.material = material #Bind its material
86.         self.selected = False
87.
88.         self.initPosition = position
89.
90.         self.object = viz.add('box.wrl')
91.         self.object.color(255,255,255)
92.         self.object.setPosition(position)
93.         self.object.texture(self.material.texture)
94.         self.object_shape = self.object.collideBox()
95.
96.         objectsCreated.append(self) #Add to our list of objects.
97.
98.     def GetName(self):
99.         return self.material.name
100.
101.     def GetPosition(self):
102.         return [self.object.getPosition()[0], self.object.getPosition()[1], self.object.getPosition()[2]]
103.
104.     def SetPosition(self, position):
105.         self.object.setPosition(position)
106.
107.     def DoPhysics(self):
108.         if (phidgetSensor.getIndex() == sensorTouch) and phidgetSensor.getValue() > 100.0: #If this is the correct sensor and it has a decent force on it
109.
110.             if debug == True: #Print the velocity magnitude for debug reasons
111.                 objectMagnitude = self.object.getVelocity()[0] + self.object.getVelocity()[1] + self.object.getVelocity()[2]
112.                 if objectMagnitude > 0:
113.                     objectMagnitude = math.fabs(math.sqrt(objectMagnitude))
114.                     print objectMagnitude
115.
116.             Finalforce = phidgetSensor.getValue() / self.material.density   #Take the sensor value and divide by the material density
117.             direction = viz.Vector(self.object.getPosition(mode = viz.ABS_GLOBAL)) - viz.Vector(forceBox.getPosition(mode = viz.ABS_GLOBAL)) #Set the directional vector from the force box to the object
118.             direction *= Finalforce #Times this directional vector by the force to get our velocity vector
119.
120.             self.object.applyForce(direction, 0) #Apply this velocity
121.
122.         elif (phidgetSensor.getIndex() == sensorMagnetic) and phidgetSensor.getValue() != 500:
123.             if self.material.magnetic == True:
124.                 view = viz.MainView
125.
126.                 #Phidget magnet sensor gives a lower or higher value dependant on the magnetic pole of the magnet.
127.                 #We want the game to respond in the same way no matter which side of the magnet is near the sensor. The sensor rests at 500, so we get the absolute value of the difference, which will give us a range of 0-500.
128.                 magnetValue = math.fabs(500 - phidgetSensor.getValue())
129.                 Finalforce = magnetValue / self.material.density
130.                 direction = viz.Vector(self.object.getPosition(mode = viz.ABS_GLOBAL)) - viz.Vector(forceBox.getPosition(mode = viz.ABS_GLOBAL))
131.                 direction *= Finalforce
132.
133.                 self.object.applyForce(-direction, 0) #Make the object come towards the arrow. i.e. Negative direction- the opposite of the force sensor
134.
135.     def SetScale(self):
136.         if phidgetSensor.getIndex() == sensorSlider:
137.             newValue = (phidgetSensor.getValue() * 0.001) + 0.5 #Clamp the value between 0.5 (50% size) and 1.5 (150% size)Make the centre of the slider be the original size of the box.
138.             self.object.setScale(newValue, newValue, newValue)
139.
140.     def RotateCamera(self):
141.         if phidgetSensor.getIndex() == sensorRotate:
142.             view = viz.MainView
143.             newValue = (phidgetSensor.getValue() /2.777777) #Clamp the rotation to 0-360 degrees
144.             view.setEuler([newValue, 0, 0]) #Set the camera rotation to match the new value
145.             view.setPosition([self.object.getPosition()[0], self.object.getPosition()[1], self.object.getPosition()[2]]) #Move the camera to the objects position
146.             view.move(0, 15, -7) #Raise it above and away from the object
147.             arrow.visible(viz.ON) #Turn the arrow on
148.             arrow.setPosition([self.object.getPosition()[0], self.object.getPosition()[1], self.object.getPosition()[2]])
149.             arrow.setEuler([newValue, 0, 0]) #Set this to the same rotation as the camera.
150.
151.             forceBox.setPosition([view.getPosition()[0], view.getPosition()[1] - 12, view.getPosition()[2]])
152.             forceBox.setEuler([newValue, 0, 0])
153.
154.         viz.lookAt(self.GetPosition())
155.
156.     def ChangeMaterial(self, newMaterial):
157.         self.material = newMaterial
158.         self.object.texture(newMaterial.texture)
159.
160. class MaterialType:
161.     def __init__(self, name, texture, density, magnetic):
162.         self.name = name
163.         self.texture = texture
164.         self.density = density
165.         self.magnetic = magnetic
166.
167. class Door:
168.     def __init__(self, position, rotation):
169.         self.object = vizshape.addBox(size = [4.5, 4.5, 0.5], pos=position)
170.         self.object.setEuler(rotation)
171.         self.object.collideMesh()
172.         doorsCreated.append(self)
173.
174. class FloorSwitch:
175.     def __init__(self, position, rotation, color, holdSwitch, linkedObject):
176.         self.object = viz.add('platform.osg')
177.         self.object.setPosition(position)
178.         self.object.setEuler(rotation)
179.         self.object.setScale(0.5, 0.5, 0.5)
180.
181.         self.active = False
182.         self.isExitSwitch = False
183.         self.holdSwitch = holdSwitch
184.
185.         self.object.collideMesh() #Give our switch a collision mesh so we can collide our objects with it
186.         self.object.color(color)
187.         self.collisionShape = vizshape.addCylinder(1.0, 1.5)
188.         self.collisionShape.setPosition(position)
189.         self.collisionShape.setEuler(rotation)
190.         self.collisionShape.collideMesh()
191.         self.collisionShape.disable(viz.CONTACTS) #We dont want our objects to make contact with this mesh, only go through it
192.         if debug:
193.             self.collisionShape.polyMode(viz.POLY_WIRE) #Make it wireframe for debug purposes
194.         else:
195.             self.collisionShape.disable(viz.RENDERING) #Otherwise just disable its renderer
196.         self.collisionShape.disable(viz.PICKING) #We dont want to click on this object so disable that too.
197.
198.         if linkedObject == 0: #Effectively if this is an exit switch
200.             self.isExitSwitch = True
201.
202.         if linkedObject != 0: #Otherwise link it to its object
203.             if isinstance(linkedObject, Door):
204.                 self.LinkToObject(linkedObject) #In this case a door
205.                 linkedObject.object.color(color) #Set the door to be the switches colour
206.
207.         switchesCreated.append(self) #Add the switch to our list
208.
211.
212. class LevelManager:
213.     def LoadLevel(self, levelNumber):
214.         self.ClearLevel() #Clear any previous level
215.         viztask.schedule( CheckDisplayMessage() ) #Display the appropirate message for the level
216.         global ground
217.         global levelEnvironment
218.         global currentLevel
219.         ####SET UP THE LEVELS####
220.         if levelNumber == 0:
221.             ground = viz.addChild('ground.osgb')
222.             ground.collidePlane()
223.
224.             box1 = MaterialObject([0, 1, 0], material_aluminium)
225.             box1 = MaterialObject([4, 1 ,0], material_copper)
226.
227.             door_1 = self.AddDoor([4.0, 1.0, 1.0], [0, 0, 0])
228.             switch_1 = self.AddFloorSwitch([4, 0.05, -1.5], [0, 0, 0], viz.GREEN, False, door_1)
229.             view.setPosition(8, 10, 0)
230.             view.lookAt([0, 0, 0])
231.
232.             currentLevel = 0
233.
234.         if levelNumber == 1:
235.             view.setPosition(8, 18, 0)
236.             view.lookAt([4, 0, 0])
237.
238.             levelEnvironment = viz.addChild('Level1.fbx')
239.             ground = viz.addChild('ground.osgb')
240.             ground.collidePlane()
241.             levelEnvironment.collideMesh()
242.             Level1Door = self.AddDoor([0, 3, 4.1], [90, 0, 0])
243.             Level1Switch = self.AddFloorSwitch([5, 0.2, 5], [0, 0, 0], viz.GREEN, False, Level1Door)
244.             Level1ExitSwitch = self.AddExitSwitch([-3.5, 0.05, 0], [0, 0, 0], viz.RED)
245.
246.             box = MaterialObject([5, 2, 0], material_aluminium)
247.
248.             button_startGame.visible(viz.OFF)
249.
250.             currentLevel = 1
251.
252.         elif levelNumber == 2:
253.             view.setPosition(8, 20, 0)
254.             view.lookAt([4, 0, 0])
255.
256.             levelEnvironment = viz.addChild('Level2.fbx')
257.             ground = viz.addChild('ground.osgb')
258.             ground.setScale([2.0, 2.0, 2.0])
259.             ground.collidePlane()
260.             levelEnvironment.collideMesh()
261.             Level2Door = self.AddDoor([8.8, 3, -4.5], [90, 0, 0])
262.             Level2Switch = self.AddFloorSwitch([5, 0.2, 5], [0, 0, 0], viz.GREEN, False, Level2Door)
263.             Level2Door2 = self.AddDoor([20, 3, -0.2], [90, 0, 0])
264.             Level2Switch2 = self.AddFloorSwitch([15, 0.05, 0], [0, 0, 0], viz.BLUE, False, Level2Door2)
265.
266.
267.             Level2ExitSwitch = self.AddExitSwitch([24, 0.05, 0], [0, 0, 0], viz.RED)
268.
269.             box = MaterialObject([5, 2, -3], material_aluminium)
270.
271.             button_startGame.visible(viz.OFF)
272.
273.             currentLevel = 2
274.
275.         elif levelNumber == 3:
276.             view.setPosition(8, 20, 0)
277.             view.lookAt([4, 0, 0])
278.
279.             levelEnvironment = viz.addChild('Level3.fbx')
280.             ground = viz.addChild('ground.osgb')
281.             ground.setScale([2.0, 2.0, 2.0])
282.             ground.collidePlane()
283.             levelEnvironment.collideMesh()
284.             Level3Door = self.AddDoor([8.8, 3, -2.5], [90, 0, 0])
285.             Level3Switch = self.AddFloorSwitch([-5, 0.2, -2], [0, 0, 0], viz.GREEN, True, Level3Door)
286.
287.             Level3ExitSwitch = self.AddExitSwitch([24, 0.05, 0], [0, 0, 0], viz.RED)
288.
289.             box = MaterialObject([5, 2, -3], material_aluminium)
290.             box2 = MaterialObject([2, 2, -3], material_iron)
291.
292.             button_startGame.visible(viz.OFF)
293.
294.             currentLevel = 3
295.         return
296.
297.     def AddPointLight(self, position, intensity):
298.         levelLight = viz.addLight()
299.         levelLight.enable()
300.         levelLight.position(position[0], position[1], position[2])
301.         levelLight.intensity(intensity)
302.         return levelLight
303.
304.     def AddFloorSwitch(self, position, rotation, color, holdSwitch, linkedObject):
305.         levelFloorSwitch = FloorSwitch(position, rotation, color, holdSwitch, linkedObject)
306.         return levelFloorSwitch
307.
308.     def AddExitSwitch(self, position, rotataion, color):
309.         exitLevelSwitch = FloorSwitch(position, rotataion, viz.RED, False, 0)
310.         return exitLevelSwitch
311.
312.     def AddDoor(self, position, rotation):
313.         levelDoor = Door(position, rotation)
314.         return levelDoor
315.
316.     def ClearLevel(self):
317.         global switchesCreated
318.         global objectsCreated
319.         global objectSelected
320.         global doorsCreated
321.         global levelEnvironment
322.         global ground
323.
324.         if switchesCreated.count > 0:
325.             for switches in switchesCreated:
326.                 switches.object.remove(children = True)
327.                 switchesCreated= []
328.
329.         if doorsCreated.count > 0:
330.             for doors in doorsCreated:
331.                 doors.object.remove(children = True)
332.                 doorsCreated= []
333.
334.         if objectsCreated.count > 0:
335.             for objects in objectsCreated:
336.                 objects.object.remove(children = True)
337.                 objectsCreated= []
338.                 objectsCreated = []
339.
340.         if objectSelected != 0:
341.             objectSelected = 0
342.
343.         ground.remove()
344.         levelEnvironment.remove()
345.
346.         arrow.visible(viz.OFF)
347.
348.         viz.clearCache(viz.NODE_CACHE)
349.
350.         return
351.
352. #################### GAME SETUP####################
353. tex_aluminium = viz.addTexture('aluminium.png') #Load in our textures
354. tex_copper = viz.addTexture('copper.tga')
355. tex_iron = viz.addTexture('iron.tga')
356. tex_gold = viz.addTexture('gold.tga')
357.
358. myext = viz.add('myextension.dle') #Add in our plugin
359. phidgetSensor = myext.addMySensor(speed = 180, radius = 1)
360.
361. view = viz.MainView
362. view.move([0, 0, -7])
363. viz.clearcolor(viz.SKYBLUE) #make the skybox blue
364.
365. textScreen = viz.addText('',viz.SCREEN)
366. desPanel = vizinfo.InfoPanel(' ',align=viz.ALIGN_CENTER_TOP,fontSize=22,icon=False,key=None)
367.
368. objectsCreated = [] #Create the lists we need
369. switchesCreated = []
370. doorsCreated = []
371. objectSelected = 0
372.
373. ###Define our material properties###
374. material_aluminium = MaterialType('Aluminium', tex_aluminium, 300, False)
375. material_iron = MaterialType('Iron', tex_iron, 600, True)
376. material_copper = MaterialType('Copper', tex_copper, 700, False)
377. material_gold = MaterialType('Gold', tex_gold, 5000, False)
378.
379. materials = [material_aluminium, material_copper, material_iron, material_gold] ##Add them to our list
380.
381. button_reset = viz.addButton() #Add a button.
382. button_reset.setPosition(0.5,0.8) #Set its position.
383. button_reset.setScale(3,3) #Scale it.
384.
385. button_startGame = viz.addButton()
386. button_startGame.setPosition(0.2, 0.8)
387. button_startGame.setScale(3, 3)
388. button_startGame.color(viz.GREEN)
389.
390. #Define our level manager
391. myLevelManager = LevelManager()
392.
393. ####################FUNCTIONS####################
394. def onButton(obj,state):
395.     if obj == button_reset: #If its the reset button
396.         if state == viz.DOWN:
397.             for objects in objectsCreated:
398.                 objects.SetPosition(objects.initPosition) #Move objects back to their original positions
399.                 objects.selected = False #Remove selection
400.                 objects.object.reset() #Remove any phyics on the object
401.         else:
402.             return
403.     elif obj == button_startGame: #if its the start game button
405.
406. def setClickedObject(pickedObject):
407.     global objectSelected
408.     if objectSelected != 0: #If we already have an object selected
409.         objectSelected.selected = False #Remove selection
410.     objectSelected = pickedObject #Get the clicked object
411.     objectSelected.selected = True #Set object to selected
412.
414.     object = viz.pick() #get the node object we hovered over
415.     if object is None: #If there isn't anything there
416.         textScreen.message('') #Clear the text
417.         return
418.     if object.valid: #otherwise if there is
419.         for myObjects in objectsCreated: #Go through our list of objects
420.             if myObjects.object == object: #If this object matches an object in our list
421.                 name = myObjects.GetName() #get the name of this material
422.                 if mouseState & viz.MOUSEBUTTON_LEFT: #If we left click
423.                     setClickedObject(myObjects) #Select it
424.                 if myObjects.selected == True: #If its selected
425.                     textScreen.color(viz.GREEN) #Set the text to green
426.                 else:
427.                     textScreen.color(viz.WHITE) #otherwise white
428.                 textScreen.message(name) #Put the name of the object on our screen
429.                 return
430.             else:
431.                 name = ('') #If this object isnt in our list (i.e. a switch or a door) remove the name
432.         if 'name' not in locals():
433.             textScreen.message('')
434.             return
435.         else:
436.             textScreen.message(name)
437.     else:
438.         textScreen.message('')
439.         return
440.
441. def CheckSwitches():
442.     for switches in switchesCreated: #For each of our switches
443.         intersections = viz.phys.intersectNode(switches.collisionShape) #Get any and all intersections with its collide mesh
444.         if len(intersections) > 0: #If there are any
445.             for IntersectObject in intersections: #For each one
446.                 for objectsInList in objectsCreated: #Go through our objects
447.                     if objectsInList.object == IntersectObject: #If one of these objects matches the object that has intersected the node
448.                         if objectsInList.material.density > 4999: #if this object is heavy enough
449.                             switches.active = True   #Activate the switch
450.
451.         if switches.holdSwitch == True and switches.active == False:
452.             switches.myLinkedObject.object.enable(viz.RENDERING) #Remove the door by disabling its renderer
453.             switches.myLinkedObject.object.enable(viz.PHYSICS) #And disabling its physics so we don't collide with it anymore
454.
455.         if switches.active: #If any of the switches are active
456.             if switches.myLinkedObject == 0: #If this switch is an exit level switch (i.e its linked object == 0)
457.                 global currentLevel #get the current level global
458.                 currentLevel += 1 #Add 1 onto it for the next level
459.                 if currentLevel is not totalLevels: #If this number is the last level
461.                 else:
462.                     myLevelManager.LoadLevel(0) #Otherwise if we have completed the final level, load the original level
463.             elif switches.myLinkedObject != 0: #otherwise if this is a regular door switch
464.                 switches.myLinkedObject.object.disable(viz.RENDERING) #Remove the door by disabling its renderer
465.                 switches.myLinkedObject.object.disable(viz.PHYSICS) #And disabling its physics so we don't collide with it anymore
466.                 switches.active = False #Deactivate the switch
467.
468. def ChangeMaterialControl(dir):
469.     global objectSelected
470.     if objectSelected != 0: #if there's an object selected
471.         for index, currentMaterial in enumerate(materials): #Go through all of our materials
472.             if index == materials.index(objectSelected.material): #If the index matches our current material
473.                 if dir > 0: #if mouse wheel up
474.                     if index == len(materials) - 1: #If at the end of the list
475.                         objectSelected.ChangeMaterial(materials[0]) #Change it to the first material in the list
476.                         break
477.                     else:
478.                         objectSelected.ChangeMaterial(materials[index + 1]) #Otherwise go up to the next material in the list
479.                         break
480.                 elif dir < 0: #if mouse wheel down
481.                     if index == 0: # If at the start of the list
482.                         objectSelected.ChangeMaterial(materials[-1]) #Go down a material
483.                         break
484.                     else:
485.                         objectSelected.ChangeMaterial(materials[index - 1]) #otherwise go to the last material in the list
486.                         break
487.
488. def DisplayMessage(message):
489.     panel = vizinfo.InfoPanel(message,align=viz.ALIGN_CENTER,fontSize=22,icon=False,key=None) #Add the level instructions
490.     yield viztask.waitMouseDown(viz.MOUSEBUTTON_LEFT) #Remove it at a mouse click
491.     panel.remove()
492.
493. def CheckDisplayMessage():
494.     global currentLevel
495.     if currentLevel == 0:
496.         yield DisplayMessage(INSTRUCTIONS)
497.     elif currentLevel == 1:
498.         yield DisplayMessage(INSTRUCTIONS1)
499.     elif currentLevel == 2:
500.         yield DisplayMessage(INSTRUCTIONS2)
501.     elif currentLevel == 3:
502.         yield DisplayMessage(INSTRUCTIONS3)
503.
504. def updateDescriptionText():
505.     desPanel.visible(viz.OFF)
506.     global objectSelected
507.     if objectSelected != 0:
508.         desPanel.visible(viz.ON)
509.         name = objectSelected.GetName()
510.         if name == 'Aluminium':
511.             message = """Aluminium is a VERY LIGHT metal. It is very easy to move around! It is NOT MAGNETIC."""
512.
513.         elif name == 'Iron':
514.             message = """Iron(Fe) is HEAVY metal. You might not be able to move it just by yourself, luckily Iron is MAGNETIC!"""
515.
516.         elif name == 'Copper':
517.             message = """Copper(Cu) is a HEAVY metal. It's heavier than IRON, but not as heavy as GOLD. You might be able to wobble it, but it's NOT MAGNETIC."""
518.
519.         elif name == 'Gold':
520.             message = """Gold(Au) is a VERY HEAVY metal. You probably won't able to move it, and it's NOT MAGNETIC. It can help you activate those switches!"""
521.
522.         if name is not None:
523.             desPanel.setText(message)
524.
525.
526. ####################STARTING THE GAME####################
527. if choice == 0:
528.     if fullscreen == 1:
529.         viz.go(viz.FULLSCREEN | viz.EMBEDDED)
530.     else:
531.         viz.go(viz.EMBEDDED)
532. elif choice == 1:
533.     if fullscreen == 1:
534.         viz.go(viz.STEREO_HORZ | viz.FULLSCREEN | viz.EMBEDDED)
535.     else:
536.         viz.go(viz.STEREO_HORZ | viz.EMBEDDED)
537.
538. elif choice == 2:
539.     if fullscreen == 1:
540.         viz.go(viz.STEREO_VERT | viz.FULLSCREEN | viz.EMBEDDED)
541.     else:
542.         viz.go(viz.STEREO_VERT | viz.EMBEDDED)
543.
544. elif choice == 3:
545.     if fullscreen == 1:
546.         viz.go(viz.ANAGLYPHIC | viz.FULLSCREEN | viz.EMBEDDED)
547.     else:
548.         viz.go(viz.ANAGLYPHIC | viz.EMBEDDED)
549.
550. elif choice == 4:
551.     if fullscreen == 1:
552.         viz.go(viz.INTERLACE_HORZ | viz.FULLSCREEN | viz.EMBEDDED)
553.     else:
554.         viz.go(viz.INTERLACE_HORZ | viz.EMBEDDED)
555.
556. elif choice == 5:
557.     if fullscreen == 1:
558.         viz.go(viz.INTERLACE_VERT | viz.FULLSCREEN | viz.EMBEDDED)
559.     else:
560.         viz.go(viz.INTERLACE_VERT | viz.EMBEDDED)
561.
563.
564.
565. ####MAIN LOOP#####
566. while not viz.done():
567.
568.     mouseState = viz.mouse.getState() #Get the mouse location and state
569.
570.     if objectSelected != 0: #if we have an object selected
571.         objectSelected.RotateCamera() #Rotate the camera
572.         objectSelected.DoPhysics() #Activate the physics
573.         objectSelected.SetScale() #Set the scale
574.         viz.callback(viz.MOUSEWHEEL_EVENT, ChangeMaterialControl) #Check if we move the mouse wheel
575.
576.     CheckSwitches() #Check all our switches
577.
578.     updateScreenText() #Update the text on screen
579.     updateDescriptionText() #Update the material description
580.     viz.callback(viz.BUTTON_EVENT,onButton) #Check the button presses
581.     viz.frame() #Go the next frame