-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
79 lines (62 loc) · 2.05 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
from math import *
global left #= False
left = False
def toggleCamera():
camera.setPosition(-5, 0, 0)
#
scene = getSceneManager()
camera = getDefaultCamera()
print camera.getCameraId()
mm = MenuManager.createAndInitialize()
appMenu = mm.createMenu("contolPanel")
appMenu.addButton("toggle", "toggleCamera()")
appMenu.addButton("toggle2", "toggleCamera()")
appMenu.addButton("toggle3", "toggleCamera()")
#camera = getOrCreateCamera("top")
#camera.setPosition(Vector3(0, 20, 0))
#camera.setPitchYawRoll(Vector3(-3.14/180*90,0, 0))
sphere1 = SphereShape.create(1,4)
sphere1.setPosition ( Vector3( 5, 0, -20 ))
sphere1.setEffect("colored -d green")
sphere2 = SphereShape.create(1,4)
sphere2.setPosition ( Vector3( -5, 0, -20 ))
sphere2.setEffect("colored -d red")
light = Light.create()
light.setPosition( Vector3(0, 0, -20))
light.setEnabled( True)
# Animate the model
def onUpdate():
e = getEvent()
type = e.getServiceType()
if ( type == ServiceType.Keyboard ):
if ( e.isKeyDown(ord('x'))):
camera.setPosition(-5, 0, 0)
if ( e.isKeyDown(ord('z'))):
camera.setPosition(5, 0, 0)
if ( type == ServiceType.Pointer ):
#if (e.getType() == EventFlags.Down)
print "down"
#print "Keyboard"
#camera.setPosition( Vector3( -5, 0, 0))
#camera.setPosition( Vector3( 5, 0, 0))
#elif (e.isKeyDown('b')):
# print "b is pressed"
#--------------------------------------------------------------------------------------------------
def onEvent():
e = getEvent()
print e
if(e.getServiceType() == ServiceType.Pointer or e.getServiceType() == ServiceType.Wand):
# Button mappings are different when using wand or mouse
print "button"
confirmButton = EventFlags.Button2
if(e.getServiceType() == ServiceType.Wand): confirmButton = EventFlags.Button5
# When the confirm button is pressed:
if(e.isButtonDown(confirmButton)):
print "confirm1"
camera.setPosition(-5, 0, 0)
appMenu.getContainer().setPosition(e.getPosition())
appMenu.show()
if(e.isButtonDown(EventFlags.Button1)):
print "confirm2"
camera.setPosition(5, 0, 0)
setEventFunction(onEvent)