/
MayaTestNew.py
160 lines (116 loc) · 4.22 KB
/
MayaTestNew.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
from __future__ import print_function;
import viz
import vizact
import vizcam
import vizshape
import vizinfo
viz.setMultiSample(4)
viz.fov(60)
viz.go()
class Torch:
def __init__(self, start, mylight):
self.start = start
self.mylight = mylight
self.setup()
return ( None );
#tini
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
#putes
## CALLBACK FUNCTION FOR CHANGING BRIGHTNESS
def changeBrightness( self, amount ):
prior = self.start;
self.start += amount;
if ( self.start < 0 ):
self.start = 0;
#fi
if ( self.start >= 7 ):
self.start = 7
#fi
self.mylight.intensity( self.start );
print( 'Starting intensity is: ' +
str( prior ) +
'Final is: ' +
str( self.start ), end= "\n" );
return ( None );
#ssenthgirbegnahc
#hcrot
################################# Script ##############################################
#Test Object
torchy = Torch(start= 7, mylight= 0)
#Add special tesselated room
wall = viz.addChild('E:\Users\VicMcG\Documents\maya\projects\default\scenes\TestingMaze2.obj')
wall.setPosition([0, -70, 0])
viz.MainView.setPosition([0,0,0])
############################## Keyboard ###############################################
#Torch keydown functions
vizact.onkeydown('l', torchy.mylight.enable)
vizact.onkeydown('k', torchy.mylight.disable)
#Torch keydown functions
vizact.onkeydown('v', torchy.changeBrightness, 1)
vizact.onkeydown('c', torchy.changeBrightness, -1)
#Screen recording keydown functions
vizact.onkeydown('p', viz.window.toggleRecording, 'test.avi')
vizact.onkeydown('o', viz.window.stopRecording)
################################ Wii #################################################
#Wiimote extension
wii = viz.add('wiimote.dle')
wiimote = wii.addWiimote()
wiimote.led = wii.LED_1 | wii.LED_4
#when program closes/Wiimote disconnects
vizact.onexit(wiimote.remove)
##mask Wiimote 1 & 2 to turn on or off the light
vizact.onsensordown(wiimote, wii.BUTTON_1, torchy.mylight.enable)
vizact.onsensordown(wiimote, wii.BUTTON_2, torchy.mylight.disable)
#mask Wiimote + & - to dim or brighten the light to a limit
vizact.onsensordown(wiimote, wii.BUTTON_MINUS, torchy.changeBrightness, -3)
vizact.onsensordown(wiimote, wii.BUTTON_PLUS, torchy.changeBrightness, 3)
############################### Mocap #################################################
from mocapInterfaceNew import mocapInterface
phaseSpaceIP = '192.168.1.230'
owlParamMarkerCount = 20
# Dir where textures and rb files are located
phaseSpaceFilePath = 'Resources/'
# Rb files in phaseSpaceFilePath
rigidFileNames_ridx = ['hmd-nvis.rb','torch.rb']
# Shapes defined in rigidbody._createVizNode()
# Look there to see what shapes are accepted, or add more shapes
rigidBodyShapes_ridx = ['sphere','cylinder']
# Sizes must correspond to parameters for the vizshape in rigidBodyShapes_ridx
rigidBodySizes_ridx = [[.1],[.15,.03]]
# Is the rigid body visible on startup?
rigidBodyToggleVisibility_ridx = [0,1]
# Start up the motion capture server
mocap = mocapInterface(phaseSpaceIP, phaseSpaceFilePath,
owlParamMarkerCount, rigidFileNames_ridx, rigidBodyShapes_ridx,
rigidBodySizes_ridx, rigidBodyToggleVisibility_ridx)
torchRigid = mocap.returnPointerToRigid('torch')
torchLink = viz.link( torchRigid.vizNode, torchy.mylight )
torchLink.preAxisAngle([0,1,0,-90])
vizact.onkeydown('h', mocap.resetRigid,'torch')
############################# Camera Moves ############################################
""" camera game like mode """
camera = vizcam.FlyNavigate(
forward = 'w',
backward = 's',
left = 'a',
right = 'd',
up = ' ',
down = viz.KEY_CONTROL_L
)
camera.MOVE_SPEED = 50
camera.sensitivity(5.0, 2.0)