Isle
Loading...
Searching...
No Matches
legopathactor.cpp
Go to the documentation of this file.
1#include "legopathactor.h"
2
3#include "define.h"
7#include "legonamedplane.h"
8#include "legonavcontroller.h"
9#include "legopathboundary.h"
11#include "legosoundmanager.h"
12#include "legoworld.h"
13#include "misc.h"
14#include "mxmisc.h"
15#include "mxtimer.h"
16#include "mxutilities.h"
17#include "mxvariabletable.h"
18
19#include <mxdebug.h>
20#include <vec.h>
21
24
25#ifndef M_PI
26#define M_PI 3.1416
27#endif
28#ifdef DTOR
29#undef DTOR
30#endif
31#define DTOR(angle) ((angle) * M_PI / 180.)
32
33// GLOBAL: LEGO1 0x100f3304
34// STRING: LEGO1 0x100f32f4
35const char* g_strHIT_WALL_SOUND = "HIT_WALL_SOUND";
36
37// GLOBAL: LEGO1 0x100f3308
38// GLOBAL: BETA10 0x101f1e1c
40
41// FUNCTION: LEGO1 0x1002d700
42// FUNCTION: BETA10 0x100ae6e0
44{
46 m_actorTime = 0;
47 m_lastTime = 0;
48 m_unk0x7c = 0;
51 m_grec = NULL;
54 m_unk0x148 = 0;
55 m_unk0x14c = 0;
56 m_unk0x140 = 0.0099999999f;
57 m_unk0x144 = 0.8f;
58 m_unk0x150 = 2.0f;
59}
60
61// FUNCTION: LEGO1 0x1002d820
62// FUNCTION: BETA10 0x100ae80e
64{
65 if (m_grec) {
66 delete m_grec;
67 }
68}
69
70// FUNCTION: LEGO1 0x1002d8d0
71MxResult LegoPathActor::VTable0x80(const Vector3& p_point1, Vector3& p_point2, Vector3& p_point3, Vector3& p_point4)
72{
73 Mx3DPointFloat p1, p2, p3;
74
75 p1 = p_point3;
76 p1 -= p_point1;
78
79 if (m_BADuration > 0.0f) {
81 p2 = p_point2;
82 p3 = p_point4;
83 m_unk0x8c.FUN_1009a140(p_point1, p2, p_point3, p3);
84 m_BADuration /= 0.001;
85 return SUCCESS;
86 }
87
88 return FAILURE;
89}
90
91// FUNCTION: LEGO1 0x1002d9c0
92// FUNCTION: BETA10 0x100ae9da
94 LegoPathBoundary* p_boundary,
95 float p_time,
96 LegoEdge& p_srcEdge,
97 float p_srcScale,
98 LegoUnknown100db7f4& p_destEdge,
99 float p_destScale
100)
101{
102 Vector3* v1 = p_srcEdge.CWVertex(*p_boundary);
103 Vector3* v2 = p_srcEdge.CCWVertex(*p_boundary);
104 Vector3* v3 = p_destEdge.CWVertex(*p_boundary);
105 Vector3* v4 = p_destEdge.CCWVertex(*p_boundary);
106
107 Mx3DPointFloat p1, p2, p3, p4, p5;
108
109 p1 = *v2;
110 p1 -= *v1;
111 p1 *= p_srcScale;
112 p1 += *v1;
113
114 p2 = *v4;
115 p2 -= *v3;
116 p2 *= p_destScale;
117 p2 += *v3;
118
119 m_boundary = p_boundary;
120 m_destEdge = &p_destEdge;
121 m_unk0xe4 = p_destScale;
122 m_unk0x7c = 0;
123 m_lastTime = p_time;
124 m_actorTime = p_time;
125 p_destEdge.FUN_1002ddc0(*p_boundary, p3);
126
127 p4 = p2;
128 p4 -= p1;
129 p4.Unitize();
130
131 MxMatrix matrix;
132 Vector3 pos(matrix[3]);
133 Vector3 dir(matrix[2]);
134 Vector3 up(matrix[1]);
135 Vector3 right(matrix[0]);
136
137 matrix.SetIdentity();
138 pos = p1;
139 dir = p4;
140 up = *m_boundary->GetUnknown0x14();
141
142 if (!m_cameraFlag || !m_userNavFlag) {
143 dir *= -1.0f;
144 }
145
146 right.EqualsCross(up, dir);
148
149 if (!m_cameraFlag || !m_userNavFlag) {
150 p5.EqualsCross(*p_boundary->GetUnknown0x14(), p3);
151 p5.Unitize();
152
153 if (VTable0x80(p1, p4, p2, p5) == SUCCESS) {
154 m_boundary->AddActor(this);
155 }
156 else {
157 return FAILURE;
158 }
159 }
160 else {
161 m_boundary->AddActor(this);
162 FUN_10010c30();
163 }
164
166 return SUCCESS;
167}
168
169// FUNCTION: LEGO1 0x1002de10
171 LegoPathBoundary* p_boundary,
172 float p_time,
173 Vector3& p_p1,
174 Vector3& p_p4,
175 LegoUnknown100db7f4& p_destEdge,
176 float p_destScale
177)
178{
179 Vector3* v3 = p_destEdge.CWVertex(*p_boundary);
180 Vector3* v4 = p_destEdge.CCWVertex(*p_boundary);
181
182 Mx3DPointFloat p2, p3, p5;
183
184 p2 = *v4;
185 p2 -= *v3;
186 p2 *= p_destScale;
187 p2 += *v3;
188
189 m_boundary = p_boundary;
190 m_destEdge = &p_destEdge;
191 m_unk0xe4 = p_destScale;
192 m_unk0x7c = 0;
193 m_lastTime = p_time;
194 m_actorTime = p_time;
195 p_destEdge.FUN_1002ddc0(*p_boundary, p3);
196
197 MxMatrix matrix;
198 Vector3 pos(matrix[3]);
199 Vector3 dir(matrix[2]);
200 Vector3 up(matrix[1]);
201 Vector3 right(matrix[0]);
202
203 matrix.SetIdentity();
204 pos = p_p1;
205 dir = p_p4;
206 up = *m_boundary->GetUnknown0x14();
207
208 if (!m_cameraFlag || !m_userNavFlag) {
209 dir *= -1.0f;
210 }
211
212 right.EqualsCross(up, dir);
214
215 if (!m_cameraFlag || !m_userNavFlag) {
216 p5.EqualsCross(*p_boundary->GetUnknown0x14(), p3);
217 p5.Unitize();
218
219 if (VTable0x80(p_p1, p_p4, p2, p5) == SUCCESS) {
220 m_boundary->AddActor(this);
221 }
222 else {
223 return FAILURE;
224 }
225 }
226 else {
227 m_boundary->AddActor(this);
228 FUN_10010c30();
229 }
230
232 return SUCCESS;
233}
234
235// FUNCTION: LEGO1 0x1002e100
236// FUNCTION: BETA10 0x100b0520
237MxS32 LegoPathActor::VTable0x8c(float p_time, Matrix4& p_transform)
238{
240 m_lastTime = p_time;
241
242 Mx3DPointFloat p1, p2, p3, p4, p5;
245
247 assert(nav);
248
249 m_worldSpeed = nav->GetLinearVel();
250
251 if (nav->CalculateNewPosDir(p4, p5, p2, p1, m_boundary->GetUnknown0x14())) {
253 p6 = p2;
254 MxS32 result = 0;
255
257 if (m_unk0xe9 == -1) {
258 MxTrace("Intersect returned -1\n");
259 return -1;
260 }
261 else {
262 if (m_unk0xe9 != 0) {
263 p2 = p3;
264 }
265 }
266
267 result = VTable0x68(p4, p2, p3);
268
269 if (result > 0) {
270 p2 = p4;
271 m_unk0xe9 = 0;
272 result = 0;
273 }
274 else {
275 m_boundary->FUN_100575b0(p4, p2, this);
276 }
277
278 LegoPathBoundary* oldBoundary = m_boundary;
279
280 if (m_unk0xe9 != 0) {
281 VTable0x9c();
282
283 if (m_boundary == oldBoundary) {
284 MxLong time = Timer()->GetTime();
285
286 if (time - g_unk0x100f3308 > 1000) {
287 g_unk0x100f3308 = time;
288 const char* var = VariableTable()->GetVariable(g_strHIT_WALL_SOUND);
289
290 if (var && var[0] != 0) {
292 }
293 }
294
297 Mx3DPointFloat p7(p2);
298 p7 -= p6;
299
300 if (p7.Unitize() == 0) {
301 float f = sqrt(p1.LenSquared()) * m_unk0x140;
302 p7 *= f;
303 p1 += p7;
304 }
305 }
306 }
307
308 p_transform.SetIdentity();
309
310 Vector3 right(p_transform[0]);
311 Vector3 up(p_transform[1]);
312 Vector3 dir(p_transform[2]);
313 Vector3 pos(p_transform[3]);
314
315 dir = p1;
316 up = *m_boundary->GetUnknown0x14();
317 right.EqualsCross(up, dir);
318
319 MxS32 res = right.Unitize();
320 assert(res == 0);
321
322 dir.EqualsCross(right, up);
323 pos = p2;
324 return result;
325 }
326 else {
327 return -1;
328 }
329 }
330 else if (p_time >= 0 && m_worldSpeed > 0) {
332
333 if (f < p_time) {
335 m_unk0xe9 = 1;
336 }
337 else {
338 f = p_time;
340 m_unk0xe9 = 0;
341 }
342
344 m_lastTime = f;
345 p_transform.SetIdentity();
346
347 LegoResult r;
348 if (m_userNavFlag) {
350 }
351 else {
353 }
354
355 assert(r == 0); // SUCCESS
356
357 Vector3 pos1(p_transform[3]);
358 Vector3 pos2(m_unk0xec[3]);
360
361 if (VTable0x68(pos2, pos1, p1) > 0) {
362 m_lastTime = p_time;
363 return 1;
364 }
365 else {
366 m_boundary->FUN_100575b0(pos2, pos1, this);
367 pos2 = pos1;
368 }
369
370 if (m_unk0xe9 != 0) {
371 VTable0x9c();
372 }
373 }
374 else {
375 return -1;
376 }
377
378 return 0;
379}
380
381// FUNCTION: LEGO1 0x1002e740
383{
384 if (m_userNavFlag) {
385 m_roi->WrappedSetLocalTransform(p_transform);
386 FUN_10010c30();
387 }
388 else {
389 m_roi->WrappedSetLocalTransform(p_transform);
390 m_roi->VTable0x14();
391
392 if (m_cameraFlag) {
393 FUN_10010c30();
394 }
395 }
396}
397
398// FUNCTION: LEGO1 0x1002e790
399// FUNCTION: BETA10 0x100af208
400void LegoPathActor::Animate(float p_time)
401{
402 MxMatrix transform;
403 MxU32 b = FALSE;
404
405 while (m_lastTime < p_time) {
406 if (m_actorState != c_initial && !VTable0x90(p_time, transform)) {
407 return;
408 }
409
410 if (VTable0x8c(p_time, transform) != 0) {
411 break;
412 }
413
414 m_unk0xec = transform;
415 b = TRUE;
416
417 if (m_unk0xe9 != 0) {
418 break;
419 }
420 }
421
422 if (m_userNavFlag && m_unk0x148) {
424 float vel = (nav->GetLinearVel() > 0)
425 ? -(nav->GetRotationalVel() / (nav->GetMaxLinearVel() * m_unk0x150) * nav->GetLinearVel())
426 : 0;
427
428 if ((MxS32) vel != m_unk0x14c) {
429 m_unk0x14c = vel;
430 LegoWorld* world = CurrentWorld();
431
432 if (world) {
434 }
435 }
436 }
437
438 if (b) {
439 VTable0x74(transform);
440 }
441}
442
443// FUNCTION: LEGO1 0x1002e8b0
444// FUNCTION: BETA10 0x100af2f7
445void LegoPathActor::SwitchBoundary(LegoPathBoundary*& p_boundary, LegoUnknown100db7f4*& p_edge, float& p_unk0xe4)
446{
447 assert(m_boundary);
448 m_boundary->SwitchBoundary(this, p_boundary, p_edge, p_unk0xe4);
449}
450
451// FUNCTION: LEGO1 0x1002e8d0
452// FUNCTION: BETA10 0x100b1010
454 LegoPathBoundary* p_boundary,
455 Vector3& p_v1,
456 Vector3& p_v2,
457 float p_f1,
458 float p_f2,
459 Vector3& p_v3
460)
461{
462 LegoAnimPresenterSet& presenters = p_boundary->GetPresenters();
463
464 for (LegoAnimPresenterSet::iterator itap = presenters.begin(); itap != presenters.end(); itap++) {
465 if ((*itap)->VTable0x94(p_v1, p_v2, p_f1, p_f2, p_v3)) {
466 return 1;
467 }
468 }
469
470 LegoPathActorSet& plpas = p_boundary->GetActors();
471 LegoPathActorSet lpas(plpas);
472
473 for (LegoPathActorSet::iterator itpa = lpas.begin(); itpa != lpas.end(); itpa++) {
474 if (plpas.find(*itpa) != plpas.end()) {
475 LegoPathActor* actor = *itpa;
476
477 if (this != actor && !(actor->GetActorState() & LegoPathActor::c_noCollide)) {
478 LegoROI* roi = actor->GetROI();
479
480 if (roi != NULL && (roi->GetVisibility() || actor->GetCameraFlag())) {
481 if (roi->FUN_100a9410(p_v1, p_v2, p_f1, p_f2, p_v3, m_collideBox && actor->m_collideBox)) {
482 HitActor(actor, TRUE);
483 actor->HitActor(this, FALSE);
484 return 2;
485 }
486 }
487 }
488 }
489 }
490
491 return 0;
492}
493
495 list<LegoPathBoundary*>& p_boundaries,
496 LegoPathBoundary* p_boundary,
497 Vector3& p_v1,
498 Vector3& p_v2,
499 float p_f1,
500 float p_f2,
501 Vector3& p_v3,
502 MxS32 p_und
503)
504{
505 MxU32 result = VTable0x6c(p_boundary, p_v1, p_v2, p_f1, p_f2, p_v3);
506
507 if (result != 0) {
508 return result;
509 }
510
511 p_boundaries.push_back(p_boundary);
512
513 if (p_und >= 2) {
514 return 0;
515 }
516
517 LegoS32 numEdges = p_boundary->GetNumEdges();
518 for (MxS32 i = 0; i < numEdges; i++) {
519 LegoUnknown100db7f4* edge = p_boundary->GetEdges()[i];
520 LegoPathBoundary* boundary = (LegoPathBoundary*) edge->OtherFace(p_boundary);
521
522 if (boundary != NULL) {
523 list<LegoPathBoundary*>::const_iterator it;
524
525 for (it = p_boundaries.begin(); !(it == p_boundaries.end()); it++) {
526 if ((*it) == boundary) {
527 break;
528 }
529 }
530
531 if (it == p_boundaries.end()) {
532 result = FUN_1002edd0(p_boundaries, boundary, p_v1, p_v2, p_f1, p_f2, p_v3, p_und + 1);
533
534 if (result != 0) {
535 return result;
536 }
537 }
538 }
539 }
540
541 return 0;
542}
543
544// FUNCTION: LEGO1 0x1002ebe0
545// FUNCTION: BETA10 0x100af35e
547{
548 assert(m_boundary && m_roi);
549
550 Mx3DPointFloat v2(p_v2);
551 v2 -= p_v1;
552
553 float len = v2.LenSquared();
554
555 if (len <= 0.001) {
556 return 0;
557 }
558
559 len = sqrt((double) len);
560 v2 /= len;
561
562 float radius = m_roi->GetWorldBoundingSphere().Radius();
563 list<LegoPathBoundary*> boundaries;
564
565 return FUN_1002edd0(boundaries, m_boundary, p_v1, v2, len, radius, p_v3, 0);
566}
567
568// FUNCTION: LEGO1 0x1002f020
569// FUNCTION: BETA10 0x100af54a
570void LegoPathActor::ParseAction(char* p_extra)
571{
572 LegoActor::ParseAction(p_extra);
573
574 char value[256];
575 value[0] = '\0';
576
577 if (KeyValueStringParse(value, g_strPERMIT_NAVIGATE, p_extra)) {
580 SetUserActor(this);
581 }
582
583 char* token;
584 if (KeyValueStringParse(value, g_strPATH, p_extra)) {
585 char name[12];
586
587 token = strtok(value, g_parseExtraTokens);
588 strcpy(name, token);
589
590 token = strtok(NULL, g_parseExtraTokens);
591 MxS32 src = atoi(token);
592
593 token = strtok(NULL, g_parseExtraTokens);
594 float srcScale = atof(token);
595
596 token = strtok(NULL, g_parseExtraTokens);
597 MxS32 dest = atoi(token);
598
599 token = strtok(NULL, g_parseExtraTokens);
600 float destScale = atof(token);
601
602 LegoWorld* world = CurrentWorld();
603 if (world != NULL) {
604 world->PlaceActor(this, name, src, srcScale, dest, destScale);
605 }
606 }
607
608 if (KeyValueStringParse(value, g_strCOLLIDEBOX, p_extra)) {
609 token = strtok(value, g_parseExtraTokens);
610 m_collideBox = atoi(token);
611 }
612}
613
614// FUNCTION: LEGO1 0x1002f1b0
615// FUNCTION: BETA10 0x100af899
617{
618 Mx3DPointFloat local34;
619 Mx3DPointFloat local48;
620 MxU32 local1c = 1;
621 MxU32 local20 = 1;
622
623 if (m_grec != NULL) {
624 if (m_grec->GetBit1()) {
625 local1c = 0;
626 local20 = 0;
627
628 Mx3DPointFloat vec;
629 switch (m_pathController->FUN_1004a240(*m_grec, local34, local48, m_unk0xe4, m_destEdge, m_boundary)) {
630 case 0:
631 case 1:
632 break;
633 default:
634 return FAILURE;
635 }
636 }
637 else {
638 delete m_grec;
639 m_grec = NULL;
640 }
641 }
642
643 if (local1c != 0) {
645 }
646
647 if (local20 != 0) {
648 Mx3DPointFloat local78;
649
652
653 LERP3(local34, v1, v2, m_unk0xe4);
654
656 local48.EqualsCross(*m_boundary->GetUnknown0x14(), local78);
657 local48.Unitize();
658 }
659
660 Vector3 rightRef(m_unk0xec[0]);
661 Vector3 upRef(m_unk0xec[1]);
662 Vector3 dirRef(m_unk0xec[2]);
663
664 upRef = *m_boundary->GetUnknown0x14();
665
666 rightRef.EqualsCross(upRef, dirRef);
667 rightRef.Unitize();
668
669 dirRef.EqualsCross(rightRef, upRef);
670 dirRef.Unitize();
671
672 Mx3DPointFloat localc0(m_unk0xec[3]);
673 Mx3DPointFloat local84(m_unk0xec[2]);
674 Mx3DPointFloat local70(local34);
675
676 local70 -= localc0;
677 float len = local70.LenSquared();
678 if (len >= 0.0f) {
679 len = sqrt(len);
680 local84 *= len;
681 local48 *= len;
682 }
683
684 if (!m_userNavFlag) {
685 local84 *= -1.0f;
686 }
687
688 if (VTable0x80(localc0, local84, local34, local48) != SUCCESS) {
689 return FAILURE;
690 }
691
692 m_unk0x7c = 0.0f;
693 return SUCCESS;
694}
695
696// FUNCTION: LEGO1 0x1002f650
697// FUNCTION: BETA10 0x100afd67
699{
700 switch (GetActorId()) {
701 case c_pepper:
702 p_und1 = TRUE;
703 p_und2 = 2;
704 break;
705 case c_mama:
706 p_und1 = FALSE;
707 p_und2 = 1;
708 break;
709 case c_papa:
710 p_und1 = TRUE;
711 p_und2 = 1;
712 break;
713 case c_nick:
714 case c_brickster:
715 p_und1 = TRUE;
716 p_und2 = rand() % p_und2 + 1;
717 break;
718 case c_laura:
719 p_und1 = FALSE;
720 p_und2 = 2;
721 break;
722 default:
723 p_und1 = TRUE;
724 p_und2 = 1;
725 break;
726 }
727}
728
729// FUNCTION: LEGO1 0x1002f700
730// FUNCTION: BETA10 0x100afe4c
732{
733 m_lastTime = Timer()->GetTime();
735 m_roi->VTable0x14();
736
737 if (m_userNavFlag) {
739 FUN_10010c30();
740 }
741}
742
743// FUNCTION: LEGO1 0x1002f770
745{
746 p_namedPlane.SetName(m_boundary->GetName());
747 p_namedPlane.SetPosition(GetWorldPosition());
748 p_namedPlane.SetDirection(GetWorldDirection());
749 p_namedPlane.SetUp(GetWorldUp());
750}
751
752// FUNCTION: LEGO1 0x1002f830
754{
755 if (p_namedPlane.IsPresent()) {
756 LegoWorld* world = CurrentWorld();
757 world->PlaceActor(this, p_namedPlane.GetName(), 0, 0.5f, 1, 0.5f);
758 SetLocation(p_namedPlane.GetPosition(), p_namedPlane.GetDirection(), p_namedPlane.GetUp(), TRUE);
759 }
760}
const float & Radius() const
[AI] Const accessor for the sphere radius.
Definition: roi.h:72
@ c_nick
Nick ([AI])
Definition: legoactor.h:20
@ c_laura
Laura ([AI])
Definition: legoactor.h:21
@ c_mama
Mama ([AI])
Definition: legoactor.h:18
@ c_brickster
The Brickster ([AI])
Definition: legoactor.h:22
@ c_pepper
Pepper Roni ([AI])
Definition: legoactor.h:17
@ c_papa
Papa ([AI])
Definition: legoactor.h:19
virtual MxU8 GetActorId()
[AI] Gets this actor's numeric ID, corresponding to a known enumeration/actor.
Definition: legoactor.h:77
void ParseAction(char *p_extra) override
[AI] Parses an action string and applies parsed behaviors to the actor.
Definition: legoactor.cpp:34
LegoCacheSound * Play(const char *p_key, const char *p_name, MxBool p_looping)
[AI] Plays a sound identified by key, with the given playback name and looping flag.
void FUN_10012290(float p_angle)
Rotates the current camera transformation by a given angle around the Z axis.
void SetLocation(const Vector3 &p_location, const Vector3 &p_direction, const Vector3 &p_up, MxBool p_und)
[AI] Sets the world-space location, direction, and up, applying normalization and transformation.
Definition: legoentity.cpp:158
Mx3DPointFloat GetWorldDirection()
[AI] Gets the normalized world-space direction vector, optionally updating from ROI....
Definition: legoentity.cpp:202
LegoROI * GetROI()
[AI] Gets the ROI (Realtime Object Instance) associated with this entity. [AI]
Definition: legoentity.h:161
void FUN_10010c30()
[AI] Updates the camera transformation when this entity is the camera target. Used after movement or ...
Definition: legoentity.cpp:192
MxBool m_cameraFlag
[AI] Set to TRUE if this entity is currently the camera target. [AI]
Definition: legoentity.h:218
MxFloat m_worldSpeed
[AI] World-relative speed (can affect animation/movement logic). [AI]
Definition: legoentity.h:212
LegoROI * m_roi
[AI] Pointer to this entity's currently assigned ROI (3D instance in the world). [AI]
Definition: legoentity.h:215
Mx3DPointFloat GetWorldUp()
[AI] Gets the normalized world-space up vector, optionally updating from ROI. [AI]
Definition: legoentity.cpp:213
MxBool GetCameraFlag()
[AI] Returns whether this entity is flagged as camera (affects world/camera synchronization)....
Definition: legoentity.h:167
Mx3DPointFloat GetWorldPosition()
[AI] Gets the world-space position vector, optionally updating from ROI. [AI]
Definition: legoentity.cpp:224
[AI] Handles user navigation input (keyboard and joystick) and determines avatar movement and directi...
void ResetMaxLinearVel(MxFloat p_maxLinearVel)
[AI] Resets the maximum allowed linear velocity and marks controller as using custom parameters.
void SetLinearVel(MxFloat p_linearVel)
[AI] Sets the current linear velocity for user navigation.
MxFloat GetMaxLinearVel()
[AI] Returns the current maximum linear velocity (units per sec).
MxBool CalculateNewPosDir(const Vector3 &p_curPos, const Vector3 &p_curDir, Vector3 &p_newPos, Vector3 &p_newDir, const Vector3 *p_und)
[AI] Calculates the new position and direction vectors based on input, current velocity,...
MxFloat GetRotationalVel()
[AI] Returns the current rotational velocity (degrees per sec).
MxFloat GetLinearVel()
[AI] Returns the current linear velocity (units per sec).
[AI] An actor that moves along a predefined path, supporting boundary transitions,...
Definition: legopathactor.h:32
virtual MxResult VTable0x80(const Vector3 &p_point1, Vector3 &p_point2, Vector3 &p_point3, Vector3 &p_point4)
[AI] Calculates path interpolation for a set of points, updates state for path animation,...
MxFloat m_actorTime
[AI] Animation time for current path segment. [AI]
virtual MxResult VTable0x88(LegoPathBoundary *p_boundary, float p_time, LegoEdge &p_srcEdge, float p_srcScale, LegoUnknown100db7f4 &p_destEdge, float p_destScale)
[AI] Moves the actor between two edges across a boundary, recalculates placement and orientation.
virtual void Animate(float p_time)
[AI] Per-frame animation update.
MxU32 GetActorState()
[AI] Gets the current navigation/animation state of the actor.
virtual MxU32 VTable0x90(float, Matrix4 &)
[AI] Placeholder for custom logic during per-timestep simulation for non-user-controlled animation.
LegoUnknown100db7f4 * m_destEdge
[AI] Current or target edge for path traversal. [AI]
virtual MxU32 VTable0x6c(LegoPathBoundary *p_boundary, Vector3 &p_v1, Vector3 &p_v2, float p_f1, float p_f2, Vector3 &p_v3)
[AI] Trace movement or collision through presenters (edge test), then through other actors.
MxFloat m_unk0x144
[AI] Damping factor for velocity after collision ("bounce" friction). [AI]
virtual MxS32 VTable0x8c(float p_time, Matrix4 &p_transform)
[AI] Advance actor's position/state along the path for a given timeslice.
virtual void SwitchBoundary(LegoPathBoundary *&p_boundary, LegoUnknown100db7f4 *&p_edge, float &p_unk0xe4)
[AI] Switches current path boundary and destination edge, typically called on transitions or respawns...
LegoPathBoundary * m_boundary
[AI] Current boundary the actor is navigating on. [AI]
MxU32 m_actorState
[AI] State and flags bitfield for path following logic. [AI]
MxFloat m_unk0x7c
[AI] Interpolator/progress state along curve segment. [AI]
MxFloat m_unk0xe4
[AI] Position scalar on destination edge (0-1 across the edge). [AI]
virtual void SetUserNavFlag(MxBool p_userNavFlag)
[AI] Sets whether the actor is controlled by user navigation.
void ParseAction(char *p_extra) override
[AI] Parses a set of key-value action commands and configures path navigation and collision for this ...
MxFloat m_unk0x140
[AI] Scaling factor for fallback/collision response logic. [AI]
virtual void VTable0x74(Matrix4 &p_transform)
[AI] Updates the ROI's transformation (typically matrix) with new values, applies world position/orie...
MxS32 m_unk0x14c
[AI] Rolling angle delta (variant for camera logic). [AI]
LegoPathController * m_pathController
[AI] Path controller/manages permitted boundaries for transitions. [AI]
MxU32 FUN_1002edd0(list< LegoPathBoundary * > &p_boundaries, LegoPathBoundary *p_boundary, Vector3 &p_v1, Vector3 &p_v2, float p_f1, float p_f2, Vector3 &p_v3, MxS32 p_und)
[AI] Recursively checks boundaries for collisions or collision path propagation up to a certain recur...
@ c_initial
[AI] Default state upon creation or reset. [AI]
Definition: legopathactor.h:37
@ c_noCollide
[AI] Disables collision for this actor (e.g. ghosts, debug). [AI]
Definition: legopathactor.h:45
MxU8 m_unk0x148
[AI] Angle/animation mode for rolling/camera tilting. [AI]
virtual MxResult VTable0x9c()
[AI] Handles exit transition and next-edge search logic; also used for collision reaction and fallbac...
virtual MxResult VTable0x84(LegoPathBoundary *p_boundary, float p_time, Vector3 &p_p1, Vector3 &p_p4, LegoUnknown100db7f4 &p_destEdge, float p_destScale)
[AI] Moves actor to a destination edge.
MxMatrix m_unk0xec
[AI] World-to-local transformation matrix for this actor/ROI. [AI]
virtual void VTable0xa8()
[AI] Re-applies transform to ROI, updates camera if needed, and processes per-actor tick actions.
MxBool m_userNavFlag
[AI] TRUE if this actor is currently user/player controlled. [AI]
LegoPathEdgeContainer * m_grec
[AI] Edge/boundary helper for tracking transitions and stateful animation. [AI]
void PlaceActor(LegoNamedPlane &p_namedPlane)
[AI] Places this actor into the world at the given plane's name, location, and orientation.
void UpdatePlane(LegoNamedPlane &p_namedPlane)
[AI] Updates a named plane to match this actor's world position, direction, and up vector.
LegoUnknown m_unk0x8c
[AI] Helper object for path curve interpolation and evaluation. [AI]
MxFloat m_unk0x150
[AI] Scalar factor for camera turn velocity logic. [AI]
virtual void VTable0xa4(MxBool &p_und1, MxS32 &p_und2)
[AI] Returns information depending on actor type.
MxBool m_collideBox
[AI] Use bounding-box for more accurate collision. [AI]
virtual MxS32 VTable0x68(Vector3 &p_v1, Vector3 &p_v2, Vector3 &p_v3)
[AI] Checks for collision/intersection with boundaries, geometry, and other actors along a traced seg...
LegoPathActor()
[AI] Initializes the path actor, setting up default state and references. [AI]
virtual MxResult HitActor(LegoPathActor *, MxBool)
[AI] Handles logic when this actor hits (collides with) another path actor; can be overridden for cus...
MxBool m_unk0xe9
[AI] Stores latest intersection/collision status/type. [AI]
MxFloat m_BADuration
[AI] Duration of current Bezier arc (distance along path/current edge). [AI]
MxFloat m_lastTime
[AI] Time of last update (used for delta calculations). [AI]
~LegoPathActor() override
[AI] Destructor, cleans up allocated containers. [AI]
[AI] Represents a path segment or boundary in the navigation network for actors (vehicles,...
void FUN_100575b0(Vector3 &p_point1, Vector3 &p_point2, LegoPathActor *p_actor)
[AI] Handles processing path triggers along this boundary as an actor moves from p_point1 to p_point2...
LegoAnimPresenterSet & GetPresenters()
[AI] Direct access to the animation presenter set for this boundary.
LegoPathActorSet & GetActors()
[AI] Direct access to the actor set for this boundary.
MxResult AddActor(LegoPathActor *p_actor)
[AI] Adds the given actor to this path boundary and sets its boundary pointer.
void SwitchBoundary(LegoPathActor *p_actor, LegoPathBoundary *&p_boundary, LegoUnknown100db7f4 *&p_edge, float &p_unk0xe4)
[AI] Switches the boundary that the actor is associated with based on edge traversal.
MxU32 Intersect(float p_scale, Vector3 &p_point1, Vector3 &p_point2, Vector3 &p_point3, LegoUnknown100db7f4 *&p_edge)
[AI] Tests for intersection between a path and this boundary; finds the first edge hit and intersecti...
MxS32 FUN_1004a240(LegoPathEdgeContainer &p_grec, Vector3 &p_v1, Vector3 &p_v2, float p_f1, LegoUnknown100db7f4 *&p_edge, LegoPathBoundary *&p_boundary)
[AI] Computes path vector and orientation for an actor given a transition along the resolved edge con...
[AI] Represents a Real-time Object Instance enriched with LEGO-specific functionality.
Definition: legoroi.h:43
LegoU32 FUN_100a9410(Vector3 &p_v1, Vector3 &p_v2, float p_f1, float p_f2, Vector3 &p_v3, LegoBool p_collideBox)
[AI] Tests for collision along or within sphere/box, and computes intersection point as needed.
Definition: legoroi.cpp:594
LegoCacheSoundManager * GetCacheSoundManager()
[AI] Returns the cache sound manager used to cache and reuse sound effects.
LegoResult FUN_1009a1e0(float p_f1, Matrix4 &p_mat, Vector3 &p_v, LegoU32 p_und)
[AI] Evaluates the curve and its tangent at p_f1 and computes the local orthonormal frame.
Definition: legounknown.cpp:40
void FUN_1009a140(const Vector3 &p_point1, const Vector3 &p_point2, const Vector3 &p_point3, const Vector3 &p_point4)
[AI] Configure internal curve control points.
Definition: legounknown.cpp:22
LegoU8 GetNumEdges()
[AI] Returns the number of edge elements assigned to this face.
Definition: legoweedge.h:43
LegoUnknown100db7f4 ** GetEdges()
[AI] Gets the array of pointers to the edge objects that form this face.
Definition: legoweedge.h:49
const LegoChar * GetName()
[AI] Returns the name string of this edge, typically used for debugging and lookup.
Definition: legowegedge.h:79
Mx4DPointFloat * GetUnknown0x14()
[AI] Returns a pointer to the cached 4D normal or reference plane for the edge.
Definition: legowegedge.h:70
Represents the active 3D world, holding all entity, animation, sound, path, and ROI objects.
Definition: legoworld.h:49
MxResult PlaceActor(LegoPathActor *p_actor, const char *p_name, MxS32 p_src, float p_srcScale, MxS32 p_dest, float p_destScale)
Places an actor along a path, from source to destination, using named references and scaling.
Definition: legoworld.cpp:267
LegoCameraController * GetCameraController()
Returns the current camera controller for the world.
Definition: legoworld.h:277
4x4 Matrix class with virtual interface for manipulation and transformation.
Definition: matrix.h:24
virtual void SetIdentity()
Sets this matrix to identity (diagonal 1, others 0).
[AI] Represents a 3D point with floating-point precision, inheriting from Vector3.
Definition: mxgeometry3d.h:14
[AI] Represents a 4x4 transformation matrix, specialized for the LEGO Island engine and derived from ...
Definition: mxmatrix.h:16
MxLong GetTime()
Returns the current timer value in ms, depending on running state.
Definition: mxtimer.h:50
const char * GetVariable(const char *p_key)
Returns the value for the variable with a given key, or an empty string if not found.
const BoundingSphere & GetWorldBoundingSphere() const override
Returns the object's bounding sphere in world coordinates.
const float * GetWorldPosition() const
Returns a pointer to the world position from the transformation matrix (translation row).
const float * GetWorldDirection() const
Returns a pointer to the world direction vector (forward axis) from the transformation matrix.
const Matrix4 & GetLocal2World() const
Accessor for the current local-to-world transformation matrix.
void WrappedSetLocalTransform(const Matrix4 &p_transform)
Wraps SetLocalTransform, for possible override or interface uniformity.
virtual void VTable0x14()
[AI] Calls VTable0x1c().
Definition: orientableroi.h:64
void FUN_100a58f0(const Matrix4 &p_transform)
Assigns the given matrix as the local-to-world transformation and enables some internal flags.
void UpdateTransformationRelativeToParent(const Matrix4 &p_transform)
Calculates and updates the world transform relative to this object's parent, then calls UpdateWorldDa...
unsigned char GetVisibility()
[AI] Returns the visibility flag; true if visible, false if hidden.
Definition: roi.h:228
virtual int Unitize()
[AI] Scales the vector so its norm is 1 (unit vector).
[AI] 3D vector class, providing vector and cross-product operations in 3D space.
Definition: vector.h:249
float LenSquared() const override
[AI] Computes the squared magnitude (x^2 + y^2 + z^2) of this vector.
virtual void EqualsCross(const Vector3 &p_a, const Vector3 &p_b)
[AI] Sets this vector to be the cross product of p_a and p_b.
#define TRUE
Definition: d3drmdef.h:28
#define FALSE
Definition: d3drmdef.h:27
#define DECOMP_SIZE_ASSERT(T, S)
Definition: decomp.h:19
const char * g_strPATH
[AI] Name of a path for moving actors, objects or camera in the world scripting system.
Definition: define.cpp:77
const char * g_parseExtraTokens
[AI] Delimiter tokens for parsing extra parameters in scripts or command strings.
Definition: define.cpp:141
const char * g_strPERMIT_NAVIGATE
[AI] Script key for allowing or restricting player/entity navigation in a context.
Definition: define.cpp:81
const char * g_strCOLLIDEBOX
[AI] Denotes the collision box; used to specify bounding volume for collision in the world/entities.
Definition: define.cpp:25
#define DTOR(angle)
const char * g_strHIT_WALL_SOUND
[AI] Variable table name for the wall hit sound [AI]
MxLong g_unk0x100f3308
[AI] Timer for wall hit sound playback throttling in navigation [AI]
const char * g_strHIT_WALL_SOUND
[AI] Variable table name for the wall hit sound [AI]
MxLong g_unk0x100f3308
[AI] Timer for wall hit sound playback throttling in navigation [AI]
set< LegoAnimPresenter *, LegoAnimPresenterSetCompare > LegoAnimPresenterSet
[AI] Defines a set of LegoAnimPresenter pointers, ordered by pointer value using LegoAnimPresenterSet...
set< LegoPathActor *, LegoPathActorSetCompare > LegoPathActorSet
[AI] Defines a set of LegoPathActor pointers, ordered by pointer value using LegoPathActorSetCompare.
#define NULL
[AI] Null pointer value (C/C++ semantics).
Definition: legotypes.h:26
#define FAILURE
[AI] Used to indicate a failed operation in result codes.
Definition: legotypes.h:34
LegoS32 LegoResult
[AI] Function result type (return code): typically SUCCESS (0) or FAILURE (-1).
Definition: legotypes.h:101
long LegoS32
[AI] Signed 32-bit integer type for cross-platform compatibility.
Definition: legotypes.h:65
#define SUCCESS
[AI] Used to indicate a successful operation in result codes.
Definition: legotypes.h:30
LegoSoundManager * SoundManager()
[AI] Accessor for the game's LegoSoundManager subsystem from the global LegoOmni instance....
Definition: misc.cpp:22
void SetUserActor(LegoPathActor *p_userActor)
[AI] Sets the user-controlled LegoPathActor in the engine.
Definition: misc.cpp:168
LegoWorld * CurrentWorld()
[AI] Accessor for the currently active LegoWorld instance. [AI]
Definition: misc.cpp:93
LegoNavController * NavController()
[AI] Accessor for the navigation controller, managing player/camera navigation. [AI]
Definition: misc.cpp:77
#define MxTrace(args)
[AI] Macro for trace logging (non-variadic version, MSVC compatibility), expands to nothing.
Definition: mxdebug.h:55
MxTimer * Timer()
[AI] Returns the global simulation timer.
Definition: mxmisc.cpp:33
MxVariableTable * VariableTable()
[AI] Returns the variable table used for script variables and global key/value state.
Definition: mxmisc.cpp:73
MxU8 MxBool
[AI]
Definition: mxtypes.h:124
MxLong MxResult
[AI]
Definition: mxtypes.h:106
int MxLong
[AI]
Definition: mxtypes.h:83
signed int MxS32
[AI]
Definition: mxtypes.h:38
unsigned int MxU32
[AI]
Definition: mxtypes.h:32
MxBool KeyValueStringParse(char *, const char *, const char *)
Searches p_string for a key command and copies its associated value to p_output.
Definition: mxutilities.cpp:85
[AI] Represents an edge in the LEGO world geometry graph.
Definition: legoedge.h:16
Vector3 * CWVertex(LegoWEEdge &p_face)
[AI] Returns the "clockwise" endpoint of this edge with respect to a given face.
Definition: legoedge.cpp:56
Vector3 * CCWVertex(LegoWEEdge &p_face)
[AI] Returns the "counterclockwise" endpoint of this edge with respect to a given face.
Definition: legoedge.cpp:69
[AI] Represents a named 3D plane with orientation and position, used to describe places or camera tar...
void SetUp(const Mx3DPointFloat &p_up)
[AI] Set the "up" vector of the plane.
const char * GetName() const
[AI] Default destructor (implementation likely trivial).
void SetName(const char *p_name)
[AI] Set the name identifier for this plane.
const Mx3DPointFloat & GetPosition()
[AI] Get the 3D position of this plane in world coordinates.
MxBool IsPresent()
[AI] Determines whether the plane instance is valid (present) based on its name.
const Mx3DPointFloat & GetDirection()
[AI] Get the normalized direction (forward) vector of the plane.
const Mx3DPointFloat & GetUp()
[AI] Get the normalized "up" vector of the plane, defining its orientation.
void SetDirection(const Mx3DPointFloat &p_direction)
[AI] Set the direction (forward) vector of the plane.
void SetPosition(const Mx3DPointFloat &p_position)
[AI] Set the 3D position of the plane.
[AI] Container for path boundary edges, also stores position, direction, and flags.
MxU32 GetBit1()
[AI] Query if the c_bit1 flag is set.
[AI] Represents an advanced edge in the LEGO Island geometry system, with direction,...
LegoWEEdge * OtherFace(LegoWEEdge *p_other)
[AI] Returns the opposite face pointer to the one passed in.
LegoResult FUN_1002ddc0(LegoWEEdge &p_f, Vector3 &p_point) const
[AI] Calculates the edge normal for use from the given face, negating it if called from faceA.
#define LERP3(to, v0, v1, t)
Definition: vec.h:462