Browse Source

cam_linting

shuvit 5 years ago
parent
commit
7232b459f9
5 changed files with 108 additions and 151 deletions
  1. 2
    2
      assets/kits/base_kit.blend
  2. 2
    2
      assets/materials/base_m_kit.blend
  3. 2
    2
      assets/user2.blend
  4. 100
    143
      scripts/camera.py
  5. 2
    2
      shuvit.blend

+ 2
- 2
assets/kits/base_kit.blend View File

@@ -1,3 +1,3 @@
1 1
 version https://git-lfs.github.com/spec/v1
2
-oid sha256:e1d3fa914e577d76f1aafa98bb2c4eb255af844b759d277c13d8d075a28d3dff
3
-size 20186144
2
+oid sha256:62549263728c2ef7660fbcdce7d2b5b9619860e5d4627d6610562078ce8e1891
3
+size 26221544

+ 2
- 2
assets/materials/base_m_kit.blend View File

@@ -1,3 +1,3 @@
1 1
 version https://git-lfs.github.com/spec/v1
2
-oid sha256:da2b7a5bdd1d133e398ceb3abdfaeca7d98b3f1092ef55adf0589756a1528a5a
3
-size 18290540
2
+oid sha256:50c185109ee56fcb1bbbba94987bdd7ae0ea73ab2e35ad91a7af8b0a758a57f6
3
+size 22674664

+ 2
- 2
assets/user2.blend View File

@@ -1,3 +1,3 @@
1 1
 version https://git-lfs.github.com/spec/v1
2
-oid sha256:6bfcbe11735b600e9920ff042ea0093c974a8f42f8a66943da148a70b178a8ed
3
-size 36542248
2
+oid sha256:5463f5a80d4070c362d7d2b03aaab46ee722af0993cade6b8f3961187adbb1f2
3
+size 36552232

+ 100
- 143
scripts/camera.py View File

@@ -4,17 +4,14 @@ import mathutils
4 4
 from mathutils import *
5 5
 scene = bge.logic.getCurrentScene()
6 6
 import camFSM
7
-#cont = bge.logic.getCurrentController()
8
-#own = cont.owner
7
+
9 8
 def main(cont):
10 9
     #camFSM.main(cont)
11 10
     own = cont.owner
12
-    dict = bge.logic.globalDict 
11
+    dict = bge.logic.globalDict
13 12
     camempty = scene.objects['camEmpty.001']
14 13
     controlcube = scene.objects['control_cube.002']
15
-    
16 14
     camCube = scene.objects['camCube']
17
-    
18 15
     dropinCol = controlcube.sensors['dropinCol']
19 16
     LAST_GRIND = controlcube['LAST_GRIND']
20 17
     up = cont.sensors['up']
@@ -26,14 +23,11 @@ def main(cont):
26 23
     cam = cont.actuators["Camera"]
27 24
     near = cont.sensors["Near"]
28 25
     move = own.actuators["move"]
29
-    #match camera actuaotor
30
-    cam_def_height = dict['cam_height'] #-.1 #-.6
31
-    #cam_def_min = 1.6
32
-    #cam_def_max = 2.4
26
+    cam_def_height = dict['cam_height']
33 27
     cam_def_min = dict['cam_min']
34 28
     cam_def_max = dict['cam_max']
35
-    cam_height = cam.height 
36
-    cam_min = cam.min   
29
+    cam_height = cam.height
30
+    cam_min = cam.min
37 31
     cam_max = cam.max
38 32
     lasty = controlcube['lasty']
39 33
     cam_moved = 0
@@ -44,14 +38,12 @@ def main(cont):
44 38
     ccheight = controlcube.worldPosition[2]
45 39
     camwpz = own.worldPosition[2]
46 40
     zdist = camwpz - ccheight
47
-    
48 41
     cam1 = scene.objects['Camera.003']
49 42
     cam2 = scene.objects['freecam']
50 43
     cam3 = scene.objects['followcam']
51
-    
52 44
     camList = scene.cameras
53
-    freecam = camList["freecam"]     
54
-    
45
+    freecam = camList["freecam"]
46
+
55 47
     if 'init' not in own:
56 48
         own['init'] = 1
57 49
         own['last_move_x'] = 0
@@ -61,65 +53,56 @@ def main(cont):
61 53
         own['last_rot_y'] = 0
62 54
         own['last_rot_z'] = 0
63 55
         own['idlecampos_x'] = 0
64
-        own['speed_mult'] = 1.00 
65
-        controlcube['driving'] = False  
56
+        own['speed_mult'] = 1.00
57
+        controlcube['driving'] = False
66 58
         dict['cur_ccH_min'] = dict['cam_walk_min']
67 59
         dict['cur_ccH_max'] = dict['cam_walk_max']
68 60
         cam.height = dict['cam_height']
69 61
     acam = scene.active_camera
70 62
 
71
-
72
-    
73
-    #if 1 == 1:
74
-    #if own['playback'] == False:
75 63
     if controlcube['driving'] == False:
76 64
         LAST_GRIND = False
77 65
         if down.triggered == True and LAST_GRIND == False and walk == 0:
78 66
             hitPosition = down.hitPosition
79 67
             distance = own.getDistanceTo(hitPosition)
80
-            cam_moved = 1  
81
-            if 'vert' not in down.hitObject:     
68
+            cam_moved = 1
69
+            if 'vert' not in down.hitObject:
82 70
                 if distance < .2:
83 71
                     camempty['hitdown'] = True
84 72
                     cam.height = cam_height + .3
85
-                    cam.damping = .0 
73
+                    cam.damping = .0
86 74
                     print("raise cam")
87 75
                 if zdist < -.2:
88 76
                     cam.height = lastCamheight + .01
89 77
                     cam.damping = .0
90
-                    raised = 1    
78
+                    raised = 1
91 79
                 if (distance > .4 and distance < .6) and zdist > -.2 and raised == 0:
92 80
                     camheight2 = cam.height - .001
93
-                    if cam.height < .2: 
81
+                    if cam.height < .2:
94 82
                         cam.height = camheight2
95
-                        #print("slow lower")
96 83
                 if distance >= .6 and zdist > -.2 and raised == 0:
97 84
                     cam.height = cam.height - .02
98
-                    #print("slow lower2")           
99 85
         if down.triggered == False and LAST_GRIND == False and cam_moved == 0 and walk == 0:
100 86
             camempty['hitdown'] = False
101 87
             if cam_height > (cam_def_height + .06) and zdist > -.2 and raised == 0:
102 88
                 cam.height = cam_height - .02
103 89
         if cam_height < -.6 and cam_moved == 0 and LAST_GRIND == False and zdist > -.2 and raised == 0 and walk == 0:
104
-            cam_height = .1  
90
+            cam_height = .1
105 91
         if LAST_GRIND == True and walk == 0:
106 92
             if cam.height < -.5 or zdist < -.2:
107 93
                 cam.height = cam.height + .013
108 94
             if cam.height >= -.5 and not down.triggered:
109 95
                 pass
110
-        
96
+
111 97
         if walk == 1:
112 98
             if dropinCol.positive == True and lasty == True:
113
-                pass 
99
+                pass
114 100
             else:
115
-                pass   
116
-        controlcube['lastCamheight'] = cam.height    
117
-        #########
118
-        #cam.min = dict['cam_min']
119
-        #cam.max = dict['cam_max']
120
-        cont.activate(own.actuators['Camera'])  
121
-        ########
122
-        
101
+                pass
102
+        controlcube['lastCamheight'] = cam.height
103
+        #activating######
104
+        cont.activate(own.actuators['Camera'])
105
+        #################
123 106
         if near.triggered == True and walk == 0:
124 107
             #print("near")
125 108
             if cam.min < 1:
@@ -129,29 +112,24 @@ def main(cont):
129 112
             print('moving cam up')
130 113
             cam.damping = .001
131 114
             cont.activate(move)
132
-            
115
+
133 116
         else:
134 117
             #print("far")
135 118
             cont.deactivate(move)
136 119
             if cam.min > cam_def_min:
137 120
                 cam.min = cam.min - .05
138
-                cam.max = cam.max - .05 
139
-            cam.damping = .0          
121
+                cam.max = cam.max - .05
122
+            cam.damping = .0
140 123
         if cam.damping != 0 and down.triggered == False and near.triggered == False:
141
-            cam.damping = 0.91             
124
+            cam.damping = 0.91
142 125
 
143 126
         obj = cont.owner
144 127
         cube = controlcube
145 128
         to = cube
146
-        #print(to.worldPosition)
147 129
         to2 = to.worldPosition
148 130
         pos = [to.worldPosition.x, to.worldPosition.y, to.worldPosition.z]
149
-        
150 131
         pos[2] = pos[2] - .2
151
-        #print(pos)
152
-
153 132
         from2 = obj
154
-        #print(from2)
155 133
         from3 = [from2.worldPosition.x, from2.worldPosition.y, from2.worldPosition.z]
156 134
         from3[2] = from3[2] - .2
157 135
         distance = 0.0
@@ -160,86 +138,81 @@ def main(cont):
160 138
         xray = 0
161 139
         poly = 0
162 140
         hit = obj.rayCast( pos, from3, distance, property, face, xray, poly)
163
-        #bge.render.drawLine(pos,from3, [1,0,0])
164 141
         control = "control_cube.002"
165 142
         hitobj = hit[0]
166 143
         hitobj = str(hitobj)
144
+        if 'ragdoll_active' not in controlcube:
145
+            controlcube['ragdoll_active'] = False
167 146
         if hit[0]:
168 147
             if hitobj != control and walk == 0 and 'vert' not in hit[0] and 'ground' in hit[0] and controlcube['ragdoll_active'] == False:
169
-                
170
-                cam.damping = .0 
148
+                cam.damping = .0
171 149
                 if cam.height < 2:
172 150
                     cam.height = cam_height + .1
173 151
                     cam.max = cam.max - .2
174 152
                     print('small move')
175 153
                 elif cam.height >= 2 and cam.height < 4:
176 154
                     cam.height = cam_height + .05
177
-                    cam.max = cam.max - .05                
155
+                    cam.max = cam.max - .05
178 156
                     print('big move')
179
-        
157
+
180 158
     if dict['menu_idle_timer'] > 300:
181 159
         move_len = 2048
182 160
         if own['idlecampos_x'] < move_len:
183 161
             own['idlecampos_x'] += 1
184 162
         if own['idlecampos_x'] == move_len:
185
-           own['idlecampos_x'] = 0     
186
-            
163
+           own['idlecampos_x'] = 0
164
+
187 165
         if own['idlecampos_x'] < (move_len / 2):
188 166
             move = [.0001, 0, 0]
189 167
             freecam.applyMovement( move, True)
190
-            freecam.applyRotation([.0001, 0, .0001],True)
168
+            freecam.applyRotation([.0001, 0, .0001], True)
191 169
         if own['idlecampos_x'] > (move_len / 2):
192 170
             move = [-.0001, 0, 0]
193
-            freecam.applyMovement( move, True)
194
-            freecam.applyRotation([-.0001, 0, -.0001],True)        
195
-        
171
+            freecam.applyMovement(move, True)
172
+            freecam.applyRotation([-.0001, 0, -.0001], True)
173
+
196 174
     if dict['npause'] == True:
197 175
         cont.deactivate(own.actuators['Camera'])
198 176
         controlcube['camera'] = 2
199 177
     if controlcube['camera'] == 2 and dict['joy_con'] == 1:
200 178
         cont.deactivate(own.actuators['Camera'])
201
-        scene.active_camera = freecam 
202
-        cont.activate(cube.actuators['freecam']) 
203
-        #print('activating camera', freecam)  
204
-#####        
205
-    #get value 0-100    
179
+        scene.active_camera = freecam
180
+        cont.activate(cube.actuators['freecam'])
206 181
         lLR = dict['lLR'] / .082 * 100
207 182
         lUD = dict['lUD'] / .082 * 100 - 20 / 80
208 183
         rLR = dict['rLR'] / .082 * 100 - 20 / 80
209 184
         rUD = dict['rUD'] / .082 * 100 - 20 / 80
210 185
         lTrig = dict['lTrig'] / .082 * 100 - 20 / 80
211 186
         rTrig = dict['rTrig'] / .082 * 100 - 20 / 80
212
-#        lBump = dict['lBump']
213
-#        rBump = dict['rBump']
214
-        
187
+
215 188
         if lLR < -20:
216
-            lmLR = round((lLR + 20) / 80 * 100, 0) 
189
+            lmLR = round((lLR + 20) / 80 * 100, 0)
217 190
         elif lLR > 20:
218 191
             lmLR = round((lLR - 20) / 80 * 100, 0)
219
-        else: lmLR = 0  
220
-              
192
+        else: lmLR = 0
193
+
221 194
         if lUD > 20:
222 195
             lmUD = round((lUD - 20) / 80 * 100, 0)
223 196
         elif lUD < -20:
224 197
             lmUD = round((lUD + 20) / 80 * 100, 0)
225
-        else: lmUD = 0 
198
+        else: lmUD = 0
226 199
 
227 200
         if rLR < -20:
228 201
             rmLR = round((rLR + 20) / 80 * 100, 0)
229 202
         elif rLR > 20:
230 203
             rmLR = round((rLR - 20) / 80 * 100, 0)
231
-        else: rmLR = 0         
232
-        
204
+        else: rmLR = 0
205
+
233 206
         if rUD > 20:
234 207
             rmUD = round((rUD - 20) / 80 * 100, 0)
235 208
         elif rUD < -20:
236 209
             rmUD = round((rUD + 20) / 80 * 100, 0)
237
-        else: rmUD = 0 
238
-      
210
+        else: rmUD = 0
211
+
239 212
         if lTrig > 3:
240 213
             mTrig = lTrig * -1
241 214
         elif rTrig > 3:
242
-            mTrig = rTrig    
215
+            mTrig = rTrig
243 216
         else: mTrig = 0
244 217
 
245 218
         #move camera
@@ -249,87 +222,80 @@ def main(cont):
249 222
         move_x = lmUD * mult
250 223
         move_y = lmLR * mult
251 224
         move_z = (mTrig * -mult) / 2#4
252
-        
225
+
253 226
         rot_mult = -.00015 * own['speed_mult']
254 227
         rot_x = rmUD * rot_mult
255 228
         rot_y = rmLR * rot_mult
256
-        
229
+
257 230
         if move_x == 0 and own['last_move_x'] != 0:
258 231
             move_x = own['last_move_x'] * damping
259 232
         if move_y == 0 and own['last_move_y'] != 0:
260
-            move_y = own['last_move_y'] * damping 
233
+            move_y = own['last_move_y'] * damping
261 234
         if move_z == 0 and own['last_move_z'] != 0:
262
-            move_z = own['last_move_z'] * damping         
235
+            move_z = own['last_move_z'] * damping
263 236
         if rot_x == 0 and own['last_rot_x'] != 0:
264 237
             rot_x = own['last_rot_x'] * damping
265 238
         if rot_y == 0 and own['last_rot_y'] != 0:
266
-            rot_y = own['last_rot_y'] * damping         
267
-                             
239
+            rot_y = own['last_rot_y'] * damping
240
+
268 241
         move = [move_y, 0, move_x]
269
-        freecam.applyMovement( move, True)
270
-        freecam.applyMovement([0, 0, move_z], False)    
271
-        freecam.applyRotation([rot_x, 0, 0],True)
272
-        freecam.applyRotation([0, 0, rot_y],False)
273
-       
274
-        
275
-################    
276
-    #print(dict['walk'], 'walk')
242
+        freecam.applyMovement(move, True)
243
+        freecam.applyMovement([0, 0, move_z], False)
244
+        freecam.applyRotation([rot_x, 0, 0], True)
245
+        freecam.applyRotation([0, 0, rot_y], False)
246
+
247
+
248
+################
277 249
     multer = .02
278
-    if dict['walk'] == 1 and controlcube['ragdoll_active'] == False:
250
+    if dict['walk'] == 1 and not controlcube['ragdoll_active']:
279 251
         if dict['cur_ccH_targetHeight'] < dict['cam_walk_height']:
280 252
             dist = dict['cam_walk_height'] - dict['cur_ccH_targetHeight']
281
-            
253
+
282 254
             dict['cur_ccH_targetHeight'] = dict['cur_ccH_targetHeight'] + (dist * multer)
283 255
             if dict['cur_ccH_targetHeight'] > dict['cam_walk_height']:
284 256
                 dict['cur_ccH_targetHeight'] = dict['cam_walk_height']
285
-                
286
-        cam.min = dict['cam_walk_min'] 
287
-        cam.max = dict['cam_walk_max'] 
288 257
 
289
-        #print('walk cam')       
290
-        #ccH_targetHeight = .9
291
-    else:  
258
+        cam.min = dict['cam_walk_min']
259
+        cam.max = dict['cam_walk_max']
260
+
261
+    else:
292 262
 
293 263
         if dict['cur_ccH_targetHeight'] < dict['cch_targetHeight']:
294 264
             dist = dict['cur_ccH_targetHeight'] - dict['cch_targetHeight']
295 265
             dict['cur_ccH_targetHeight'] = dict['cur_ccH_targetHeight'] - (dist * multer)
296 266
             if dict['cur_ccH_targetHeight'] > dict['cch_targetHeight'] - .001:
297
-                dict['cur_ccH_targetHeight'] = dict['cch_targetHeight']             
267
+                dict['cur_ccH_targetHeight'] = dict['cch_targetHeight']
298 268
 
299 269
         if dict['cur_ccH_targetHeight'] > dict['cch_targetHeight']:
300
-            dist = dict['cch_targetHeight'] - dict['cur_ccH_targetHeight'] 
270
+            dist = dict['cch_targetHeight'] - dict['cur_ccH_targetHeight']
301 271
             dict['cur_ccH_targetHeight'] = dict['cur_ccH_targetHeight'] + (dist * multer)
302 272
             if dict['cur_ccH_targetHeight'] < dict['cch_targetHeight'] + .001:
303
-                dict['cur_ccH_targetHeight'] = dict['cch_targetHeight']             
304
-        
305
-        
306
-    ccH_targetHeight = dict['cur_ccH_targetHeight']  
307
-    #print(dict['cur_ccH_targetHeight'])    
308
-    #dict['cur_ccH_targetHeight'] =            
309
-    #ccH_targetHeight = .3
273
+                dict['cur_ccH_targetHeight'] = dict['cch_targetHeight']
274
+
275
+
276
+    ccH_targetHeight = dict['cur_ccH_targetHeight']
277
+
310 278
     ccH = camCube.worldPosition.z
311 279
     pH = camCube.parent.worldPosition.z
312 280
     ccheight = (round((ccH - pH), 2) - .4)
313
-    #print(ccheight, 'camera target height')
314
-    
281
+
315 282
     localPos = camCube.localPosition.z
316
-    #print(localPos, 'local position')
317 283
     if localPos != ccH_targetHeight:
318 284
         num = ccH_targetHeight - localPos
319 285
         camCube.localPosition.z += num
320 286
     #if camHeightSet not in own:
321
-    if 1 == 1:    
287
+    if 1 == 1:
322 288
         num = ccH_targetHeight - ccheight
323 289
     else:
324
-        own['camHeightSet'] = True    
325
-    try:       
290
+        own['camHeightSet'] = True
291
+    try:
326 292
         if dict['npause'] == False and controlcube['ragdoll_active'] == False:
327
-            cont.activate(own.actuators['Camera']) 
328
-            controlcube['camera'] = 0    
293
+            cont.activate(own.actuators['Camera'])
294
+            controlcube['camera'] = 0
329 295
         if controlcube['ragdoll_active'] == True:
330 296
             #print('ragdoll_camera', own.actuators['Camera'].object)
331 297
             own.actuators['Camera'].object = scene.objects['ragdoll_parent']
332
-            cont.activate(own.actuators['Camera']) 
298
+            cont.activate(own.actuators['Camera'])
333 299
             controlcube['camera'] = 0
334 300
     except:
335 301
         pass
@@ -337,7 +303,6 @@ def main(cont):
337 303
     cur_lens = cam1.lens
338 304
     cur_min = cam.min
339 305
     cur_max = cam.max
340
-    #print(cur_lens)
341 306
     inc = .025
342 307
     if walk == 1:
343 308
         #lens
@@ -345,53 +310,45 @@ def main(cont):
345 310
             new_lens = cur_lens + inc
346 311
         else:
347 312
             new_lens = cur_lens - inc
348
-        if cur_lens  > (dict['walk_focal_length'] - .1) and cur_lens  < (dict['walk_focal_length'] + .1):
349
-            new_lens = dict['walk_focal_length']  
350
-            
351
-        #distance      
352
-        inc = .025   
313
+        if cur_lens > (dict['walk_focal_length'] - .1) and cur_lens < (dict['walk_focal_length'] + .1):
314
+            new_lens = dict['walk_focal_length']
315
+
316
+        #distance
317
+        inc = .025
353 318
         if cur_min > (dict['cam_walk_min'] - inc):
354 319
             new_min = cur_min - inc
355 320
         if cur_min < (dict['cam_walk_min'] + inc):
356
-            new_min = cur_min + inc 
321
+            new_min = cur_min + inc
357 322
         if cur_max > (dict['cam_walk_max'] - inc):
358 323
             new_max = cur_min - inc
359 324
         if cur_max < (dict['cam_walk_max'] + inc):
360
-            new_max = cur_min + inc           
325
+            new_max = cur_min + inc
361 326
     else:
362 327
         #lens
363 328
         if dict['focal_length'] > cur_lens:
364 329
             new_lens = cur_lens + inc
365 330
         else:
366
-            new_lens = cur_lens - inc 
367
-        if cur_lens  > (dict['focal_length'] - .1) and cur_lens  < (dict['focal_length'] + .1):
368
-            new_lens = dict['focal_length'] 
369
-            
370
-        #distance  
371
-        inc = .025   
331
+            new_lens = cur_lens - inc
332
+        if cur_lens > (dict['focal_length'] - .1) and cur_lens < (dict['focal_length'] + .1):
333
+            new_lens = dict['focal_length']
334
+
335
+        #distance
336
+        inc = .025
372 337
         if cur_min > (dict['cam_min'] - inc):
373 338
             new_min = cur_min - inc
374 339
         if cur_min < (dict['cam_min'] + inc):
375
-            new_min = cur_min + inc 
340
+            new_min = cur_min + inc
376 341
         if cur_max > (dict['cam_max'] - inc):
377 342
             new_max = cur_min - inc
378 343
         if cur_max < (dict['cam_max'] + inc):
379
-            new_max = cur_min + inc        
380
-            
381
-        
382
-            
383
-                                         
384
-        
344
+            new_max = cur_min + inc
345
+
385 346
     focallength = new_lens
386 347
     cam1.lens = focallength
387 348
     cam2.lens = focallength
388 349
     cam3.lens = focallength
389 350
     try:
390 351
         cam.min = new_min
391
-        cam.max = new_max  
392
-        #print(new_min, new_max)     
352
+        cam.max = new_max
393 353
     except:
394
-        pass    
395
-    
396
-                    
397
-#main()
354
+        pass

+ 2
- 2
shuvit.blend View File

@@ -1,3 +1,3 @@
1 1
 version https://git-lfs.github.com/spec/v1
2
-oid sha256:bdeaa0427d6e0e146db9c836a1d79536092099f6776c06faae6236b91d1c00fd
3
-size 144952188
2
+oid sha256:146e177ff6c51f8476150c3ae08c0df75f7274c9893e79a4fbab99622939c07f
3
+size 145082860

Loading…
Cancel
Save