shuvit 3 weeks ago
parent
commit
d3f5d16463
4 changed files with 12 additions and 84 deletions
  1. 3
    0
      assets/roads_bak.blend
  2. 3
    0
      characters/annie_actions.blend
  3. 3
    0
      characters/annie_actions1.blend
  4. 3
    84
      scripts/StatesCar.py

+ 3
- 0
assets/roads_bak.blend View File

@@ -0,0 +1,3 @@
1
+version https://git-lfs.github.com/spec/v1
2
+oid sha256:784809674b518a6435240657168d882fc30d0dace8f4fdd643ecc4dc0189b4e4
3
+size 83642732

+ 3
- 0
characters/annie_actions.blend View File

@@ -0,0 +1,3 @@
1
+version https://git-lfs.github.com/spec/v1
2
+oid sha256:79b18251c91fea0da8010ccbc3999a6038753731fcd1707eedc026af6fdce1a8
3
+size 12021164

+ 3
- 0
characters/annie_actions1.blend View File

@@ -0,0 +1,3 @@
1
+version https://git-lfs.github.com/spec/v1
2
+oid sha256:04b45c642e23d76d6526d7f4da8fb61ee1c2b6a48ae95cf4228647cf0bd122f8
3
+size 12504512

+ 3
- 84
scripts/StatesCar.py View File

@@ -7,7 +7,6 @@ from mathutils import Vector
7 7
 
8 8
 def mark_path(path, y):
9 9
     iter_ = 0
10
-
11 10
     for x in path:
12 11
         pm = bge.logic.getCurrentScene().addObject('path_marker', y.obj, 0)
13 12
         pm.worldPosition = path[iter_]    
@@ -21,9 +20,6 @@ def mark_path(path, y):
21 20
         y.path_display.append(pm)
22 21
 
23 22
 def clear_markers(self):
24
-    # for x in bge.logic.getCurrentScene().objects:
25
-    #     if 'path_marker' in x.name:
26
-    #         x.endObject()
27 23
     for x in self.FSM.owner.path_display:
28 24
         try:
29 25
             x.endObject()
@@ -81,10 +77,7 @@ def find_new_parking(self):
81 77
         self.FSM.FSM.ToTransition('toEnterParallelPark')
82 78
 
83 79
 def get_lane_point(self):
84
-
85
-
86 80
     self.point = self.path[self.path_index]
87
-    #print(self.path_index, 'path index')
88 81
     if self.point != self.last_lane_point:
89 82
         v = Vector([self.last_lane_point.x - self.point.x, self.last_lane_point.y - self.point.y, 0])
90 83
         tv = v.normalized()
@@ -92,25 +85,19 @@ def get_lane_point(self):
92 85
         self.last_lane_point = self.lane_point
93 86
         self.lane_point = self.point + self.manager.lane_position * nv
94 87
 
95
-
96
-
97 88
 def update_point(self):
98 89
     
99 90
     if self.path_index >= (len(self.path) ):
100 91
         self.FSM.FSM.ToTransition('toEnterParallelPark')
101 92
     else:
102 93
         dist = self.obj.getDistanceTo(self.lane_point)
103
-        #print(dist, self.path_index)
104 94
         self.point = self.path[self.path_index]
105 95
         if dist < 2.5:
106 96
             get_lane_point(self)   
107 97
             if self.path_index > (len(self.path)):
108 98
                 pass
109 99
             else:
110
-                
111 100
                 self.path_index += 1
112
-            
113
-
114 101
          
115 102
 def align_to_point(self):
116 103
     v = self.obj.getVectTo(self.lane_point)[1]
@@ -119,14 +106,11 @@ def align_to_point(self):
119 106
 
120 107
 def delta_to_vect(self):
121 108
     v = self.obj.getVectTo(self.lane_point)[1]
122
-    #vt = Vector([self.last_lane_point.x - self.lane_point.x, self.last_lane_point.y - self.lane_point.y, 0])
123
-
124 109
     delta = self.last_lane_point - self.lane_point
125 110
     delta = delta.cross(v)
126 111
     delta_mult = -.1
127 112
     mult = 1.0
128 113
     deltamove = delta[2] * delta_mult
129
-    #self.obj.applyMovement([0, deltamove, 0], True)
130 114
     f = deltamove * 5000
131 115
     self.obj.applyForce([0, f, 0], True)
132 116
             
@@ -167,16 +151,7 @@ class Example(State):
167 151
     def Execute(self):
168 152
         self.FSM.stateLife += 1
169 153
         print('doing example')
170
-        #o = self.FSM.owner
171
-        #g = o.me['game']
172
-        #self.FSM.ToTransition('toActivate')
173
-        #print(self.FSM.owner)
174
-        #self.FSM.owner.applyRotation([0,0,.01], True)
175
-        #self.FSM.owner.worldPosition.z = 0
176
-        #self.FSM.owner.worldPosition.z += 0.1
177
-        #self.FSM.owner.worldPosition.x += 1.1
178
-        #print(self.FSM.owner.children)
179
-
154
+        
180 155
     def Exit(self):
181 156
         pass
182 157
 
@@ -195,20 +170,16 @@ class ExitParallelPark(State):
195 170
         self.FSM.owner.target.status = 'targetted'
196 171
         self.FSM.owner.start_empty.status = 'available'
197 172
         
198
-        #print('target is', self.FSM.owner.target)
199 173
         print('physics resumed')
200 174
         super(ExitParallelPark, self).Enter()        
201 175
         
202 176
     def Execute(self):
203 177
         self.FSM.stateLife += 1
204
-        #print('doing ExitParallelPark')
205 178
         v = self.FSM.owner.obj.getVectTo(self.FSM.owner.path[0])
206
-        #v.z = 0
207 179
         self.FSM.owner.obj.alignAxisToVect(v[1], 0, .01)
208 180
         self.FSM.owner.obj.alignAxisToVect([0,0,1], 2, 1)
209 181
         if self.FSM.stateLife > 220:
210 182
             self.FSM.ToTransition('toNavigateToTarget')
211
-        #self.FSM.owner.obj.applyForce([6, 0, 0], True)
212 183
 
213 184
     def Exit(self):
214 185
         pass        
@@ -216,8 +187,7 @@ class ExitParallelPark(State):
216 187
 #====================================  
217 188
             
218 189
 class EnterParallelPark(State):
219
-    def __init__(self,FSM):
220
-        
190
+    def __init__(self,FSM):        
221 191
         super(EnterParallelPark, self).__init__(FSM)    
222 192
         
223 193
     def Enter(self):
@@ -244,8 +214,6 @@ class EnterParallelPark(State):
244 214
         self.FSM.stateLife += 1
245 215
         if self.FSM.stateLife == 2:
246 216
             self.FSM.owner.manager.cars_active.remove(self.FSM.owner)
247
-        #self.FSM.ToTransition('toActivate')
248
-        
249 217
 
250 218
     def Exit(self):
251 219
         pass
@@ -270,16 +238,11 @@ class NavigateToTarget(State):
270 238
         set_height(self.FSM.owner)
271 239
         delta_to_vect(self.FSM.owner)
272 240
         apply_gas(self.FSM.owner)
273
-        #print('target', self.FSM.owner.target.obj.worldPosition)
274 241
 
275 242
         #emergency exit
276 243
         if self.FSM.stateLife > 30 * 60:
277 244
             self.FSM.ToTransition('toEnterParallelPark')
278 245
 
279
-        #print('doing NavigateToTarget')
280
-
281
-        #self.FSM.owner.obj.applyForce([6, 0, 0], True)
282
-
283 246
     def Exit(self):
284 247
         pass        
285 248
 
@@ -291,47 +254,10 @@ class Activate(State):
291 254
         
292 255
     def Enter(self):
293 256
         self.FSM.stateLife = 1
294
-        # self.FSM.owner.restorePhysics()
295
-        # self.FSM.owner.restoreDynamics()
296
-        # self.FSM.owner.worldPosition.z = 2
297
-        # self.FSM.curTarget = None
298
-        # self.FSM.last_target = None
299
-        # #self.FSM.path = None
300
-        # self.point = None
301
-        # self.last_point = self.FSM.owner.worldPosition.copy()
302
-        # self.last_pos = self.FSM.owner.worldPosition.copy()
303
-        # self.backup = 0
304
-        # self.lane_point = None
305
-        # self.last_lane_point = self.last_pos
306
-        # self.lane_position = 1.75
307
-        # self.pos_his = []
308
-        # self.max_speed = 5.0
309
-        # self.FSM.path = None
310
-        # print('physics resumed')
311 257
         super(Activate, self).Enter()        
312 258
         
313 259
     def find_target(self):
314 260
         pass
315
-        # if self.FSM.curTarget == None:
316
-        #     choices = self.FSM.owner['manager'].targets
317
-        #     if self.FSM.last_target in choices:
318
-        #         choices.remove(self.FSM.last_target)
319
-        #     if choices:    
320
-        #         self.FSM.curTarget = random.choice(choices)
321
-        #         self.FSM.path = self.FSM.owner['manager'].navmesh.findPath(self.FSM.owner.worldPosition, self.FSM.curTarget.worldPosition)
322
-        #         self.FSM.path.remove(self.FSM.path[0])
323
-        #         self.point = self.FSM.path[0]
324
-        #         vt = Vector([self.last_point.x - self.point.x, self.last_point.y - self.point.y, 0])
325
-        #         tv = vt.normalized()
326
-        #         #rotate 90 degrees
327
-        #         nv = Vector([-tv.y, tv.x, 0])
328
-        #         distance = 3.5
329
-        #         self.lane_point = self.point + self.lane_position * nv
330
-        #     else:
331
-        #         print('no fucking choices')
332
-        #     return False
333
-        # else:
334
-        #     return True  
335 261
 
336 262
     def drive_to_point(self):
337 263
         if self.FSM.path:
@@ -414,7 +340,7 @@ class Activate(State):
414 340
             self.pos_his.append(self.FSM.owner.worldPosition.copy())
415 341
             pos_his_len = len(self.pos_his)
416 342
             if pos_his_len > 200:
417
-                #sum_ = abs(self.FSM.owner.worldPosition.x) + abs(self.pos_his[-1][0]) + abs(self.FSM.owner.worldPosition.y) + abs(self.pos_his[-1][1]) 
343
+                
418 344
                 sum_ = abs(self.FSM.owner.worldPosition.x - self.pos_his[0][0]) + abs(self.FSM.owner.worldPosition.y - self.pos_his[0][1])
419 345
                 #print(sum_, 'sum')
420 346
                 if sum_ < .05:
@@ -426,13 +352,6 @@ class Activate(State):
426 352
     def Execute(self):
427 353
         self.FSM.stateLife += 1
428 354
 
429
-        #if self.find_target():
430
-            #self.drive_to_point()
431
-
432
-        #self.FSM.owner.linearVelocity.y = 0
433
-        #self.last_pos = self.FSM.owner.worldPosition.copy()
434
-        #self.FSM.owner['manager'].target_loc.worldPosition = self.lane_point
435
-
436 355
     def Exit(self):
437 356
         pass
438 357
 

Loading…
Cancel
Save