1
2
3
4
5
6
7
8
9
10 package
11 cz.cuni.amis.pogamut.udk.communication.messages.gbinfomessages;
12 import java.util.*;
13 import javax.vecmath.*;
14 import cz.cuni.amis.pogamut.base.communication.messages.*;
15 import cz.cuni.amis.pogamut.base.communication.worldview.*;
16 import cz.cuni.amis.pogamut.base.communication.worldview.event.*;
17 import cz.cuni.amis.pogamut.base.communication.worldview.object.*;
18 import cz.cuni.amis.pogamut.base.communication.translator.event.*;
19 import cz.cuni.amis.pogamut.base3d.worldview.object.*;
20 import cz.cuni.amis.pogamut.base3d.worldview.object.event.*;
21 import cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId;
22 import cz.cuni.amis.pogamut.udk.communication.messages.*;
23 import cz.cuni.amis.pogamut.udk.communication.worldview.objects.*;
24 import cz.cuni.amis.pogamut.udk.communication.translator.itemdescriptor.*;
25 import cz.cuni.amis.pogamut.udk.communication.messages.ItemType.Category;
26 import cz.cuni.amis.utils.exception.*;
27 import cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result;
28 import cz.cuni.amis.utils.SafeEquals;
29 import cz.cuni.amis.pogamut.multi.communication.worldview.object.*;
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44 public class
45 AutoTraceRay
46 extends GBObjectUpdate
47
48 implements IGBWorldObjectEvent, IWorldObject
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 public AutoTraceRay(
102 UnrealId Id, Location From, Location To, boolean FastTrace, boolean FloorCorrection, boolean Result, Vector3d HitNormal, Location HitLocation, boolean TraceActors, UnrealId HitId) {
103
104 this.Id = Id;
105
106 this.From = From;
107
108 this.To = To;
109
110 this.FastTrace = FastTrace;
111
112 this.FloorCorrection = FloorCorrection;
113
114 this.Result = Result;
115
116 this.HitNormal = HitNormal;
117
118 this.HitLocation = HitLocation;
119
120 this.TraceActors = TraceActors;
121
122 this.HitId = HitId;
123
124 }
125
126
127
128 public static final String PROTOTYPE =
129 "ATR {Id unreal_id} {From 0,0,0} {To 0,0,0} {FastTrace False} {FloorCorrection False} {Result False} {HitNormal 0,0,0} {HitLocation 0,0,0} {TraceActors False} {HitId unreal_id}";
130
131
132
133
134
135
136
137
138
139 protected
140 UnrealId Id =
141 null;
142
143
144
145
146
147
148
149 public
150 UnrealId getId() {
151 return
152 Id;
153 }
154
155
156
157
158
159
160
161 protected
162 Location From =
163 null;
164
165
166
167
168
169
170 public
171 Location getFrom() {
172 return
173 From;
174 }
175
176
177
178
179
180
181
182 protected
183 Location To =
184 null;
185
186
187
188
189
190
191 public
192 Location getTo() {
193 return
194 To;
195 }
196
197
198
199
200
201
202
203
204
205
206 protected
207 boolean FastTrace =
208 false;
209
210
211
212
213
214
215
216
217
218 public
219 boolean isFastTrace() {
220 return
221 FastTrace;
222 }
223
224
225
226
227
228
229
230 protected
231 boolean FloorCorrection =
232 false;
233
234
235
236
237
238
239 public
240 boolean isFloorCorrection() {
241 return
242 FloorCorrection;
243 }
244
245
246
247
248
249
250
251 protected
252 boolean Result =
253 false;
254
255
256
257
258
259
260 public
261 boolean isResult() {
262 return
263 Result;
264 }
265
266
267
268
269
270
271
272
273 protected
274 Vector3d HitNormal =
275 null;
276
277
278
279
280
281
282
283 public
284 Vector3d getHitNormal() {
285 return
286 HitNormal;
287 }
288
289
290
291
292
293
294
295
296 protected
297 Location HitLocation =
298 null;
299
300
301
302
303
304
305
306 public
307 Location getHitLocation() {
308 return
309 HitLocation;
310 }
311
312
313
314
315
316
317
318
319
320 protected
321 boolean TraceActors =
322 false;
323
324
325
326
327
328
329
330
331 public
332 boolean isTraceActors() {
333 return
334 TraceActors;
335 }
336
337
338
339
340
341
342
343
344 protected
345 UnrealId HitId =
346 null;
347
348
349
350
351
352
353
354 public
355 UnrealId getHitId() {
356 return
357 HitId;
358 }
359
360
361
362
363
364
365
366
367
368 protected double Time = 0;
369
370 protected double getTime() {
371 return Time;
372 }
373
374 protected void setTime(double time) {
375 this.Time = time;
376 }
377
378 public double getLastSeenTime() {
379 return Time;
380 }
381
382
383 public ILocalWorldObject getLocal() {
384 return null;
385 }
386
387 public ISharedWorldObject getShared() {
388 return null;
389 }
390
391 public IStaticWorldObject getStatic() {
392 return null;
393 }
394
395 @Override
396 public long getSimTime() {
397 return (long)getLastSeenTime();
398 }
399
400 public boolean equals(Object obj) {
401 if (!(obj instanceof AutoTraceRay)) return false;
402 AutoTraceRay cast = (AutoTraceRay)obj;
403 if (this.getId() != null) return this.getId().equals(cast.getId());
404 else return cast.getId() == null;
405 }
406
407 public int hashCode() {
408 if (getId() != null) return getId().hashCode();
409 return 0;
410 }
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428 public AutoTraceRay(AutoTraceRay original) {
429
430 this.Id=original.Id;
431
432 this.From=original.From;
433
434 this.To=original.To;
435
436 this.FastTrace=original.FastTrace;
437
438 this.FloorCorrection=original.FloorCorrection;
439
440 this.Result=original.Result;
441
442 this.HitNormal=original.HitNormal;
443
444 this.HitLocation=original.HitLocation;
445
446 this.TraceActors=original.TraceActors;
447
448 this.HitId=original.HitId;
449
450 }
451
452
453
454
455
456 public AutoTraceRay() {
457 }
458
459
460
461
462
463 private IWorldObject orig = null;
464
465 public IWorldObjectUpdateResult update(IWorldObject obj) {
466 if(obj == null) {
467 orig = this;
468 return new IWorldObjectUpdateResult.WorldObjectUpdateResult(cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result.CREATED, this);
469 }
470 orig = obj;
471
472 AutoTraceRay o = (AutoTraceRay)obj;
473
474 boolean updated = false;
475
476
477 if (!SafeEquals.equals(o.From, From)) {
478 o.From=From;
479 updated = true;
480 }
481
482 if (!SafeEquals.equals(o.To, To)) {
483 o.To=To;
484 updated = true;
485 }
486
487 if (o.FastTrace != FastTrace) {
488 o.FastTrace=FastTrace;
489 updated = true;
490 }
491
492 if (o.FloorCorrection != FloorCorrection) {
493 o.FloorCorrection=FloorCorrection;
494 updated = true;
495 }
496
497 if (o.Result != Result) {
498 o.Result=Result;
499 updated = true;
500 }
501
502 if (!SafeEquals.equals(o.HitNormal, HitNormal)) {
503 o.HitNormal=HitNormal;
504 updated = true;
505 }
506
507 if (!SafeEquals.equals(o.HitLocation, HitLocation)) {
508 o.HitLocation=HitLocation;
509 updated = true;
510 }
511
512 if (o.TraceActors != TraceActors) {
513 o.TraceActors=TraceActors;
514 updated = true;
515 }
516
517 if (!SafeEquals.equals(o.HitId, HitId)) {
518 o.HitId=HitId;
519 updated = true;
520 }
521
522 o.Time = Time;
523
524
525 if (updated) {
526 return new IWorldObjectUpdateResult.WorldObjectUpdateResult(cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result.UPDATED, o);
527 } else {
528 return new IWorldObjectUpdateResult.WorldObjectUpdateResult(cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result.SAME, o);
529 }
530 }
531
532
533
534
535
536 public IWorldObject getObject() {
537 if (orig == null) return this;
538 return orig;
539 }
540
541
542
543 public String toString() {
544 return
545
546 super.toString() + " | " +
547
548 "Id = " +
549 String.valueOf(Id) + " | " +
550
551 "From = " +
552 String.valueOf(From) + " | " +
553
554 "To = " +
555 String.valueOf(To) + " | " +
556
557 "FastTrace = " +
558 String.valueOf(FastTrace) + " | " +
559
560 "FloorCorrection = " +
561 String.valueOf(FloorCorrection) + " | " +
562
563 "Result = " +
564 String.valueOf(Result) + " | " +
565
566 "HitNormal = " +
567 String.valueOf(HitNormal) + " | " +
568
569 "HitLocation = " +
570 String.valueOf(HitLocation) + " | " +
571
572 "TraceActors = " +
573 String.valueOf(TraceActors) + " | " +
574
575 "HitId = " +
576 String.valueOf(HitId) + " | " +
577 "";
578
579 }
580
581 public String toHtmlString() {
582 return super.toString() +
583
584 "<b>Id</b> : " +
585 String.valueOf(Id) +
586 " <br/> " +
587
588 "<b>From</b> : " +
589 String.valueOf(From) +
590 " <br/> " +
591
592 "<b>To</b> : " +
593 String.valueOf(To) +
594 " <br/> " +
595
596 "<b>FastTrace</b> : " +
597 String.valueOf(FastTrace) +
598 " <br/> " +
599
600 "<b>FloorCorrection</b> : " +
601 String.valueOf(FloorCorrection) +
602 " <br/> " +
603
604 "<b>Result</b> : " +
605 String.valueOf(Result) +
606 " <br/> " +
607
608 "<b>HitNormal</b> : " +
609 String.valueOf(HitNormal) +
610 " <br/> " +
611
612 "<b>HitLocation</b> : " +
613 String.valueOf(HitLocation) +
614 " <br/> " +
615
616 "<b>TraceActors</b> : " +
617 String.valueOf(TraceActors) +
618 " <br/> " +
619
620 "<b>HitId</b> : " +
621 String.valueOf(HitId) +
622 " <br/> " +
623 "";
624 }
625
626
627
628 }
629
630