Isle
Loading...
Searching...
No Matches
legoutils.cpp
Go to the documentation of this file.
1#include "legoutils.h"
2
4#include "anim/legoanim.h"
5#include "isle.h"
6#include "isle_actions.h"
7#include "islepathactor.h"
9#include "legoanimpresenter.h"
10#include "legogamestate.h"
11#include "legoinputmanager.h"
12#include "legomain.h"
13#include "legonamedtexture.h"
14#include "legopathstruct.h"
15#include "legosoundmanager.h"
16#include "legovideomanager.h"
17#include "legoworld.h"
18#include "legoworldlist.h"
19#include "misc.h"
20#include "misc/legocontainer.h"
21#include "misc/legoimage.h"
22#include "misc/legotree.h"
23#include "mxdsaction.h"
24#include "mxmisc.h"
26#include "mxstreamer.h"
27#include "mxtypes.h"
28#include "mxutilities.h"
29#include "mxvariabletable.h"
30#include "realtime/realtime.h"
31#include "scripts.h"
32
33#include <process.h>
34#include <string.h>
35#include <vec.h>
36
37// FUNCTION: LEGO1 0x1003dd70
38// FUNCTION: BETA10 0x100d3410
40{
41 LegoVideoManager* videoManager = VideoManager();
42 Lego3DView* view = videoManager->Get3DManager()->GetLego3DView();
43 return (LegoROI*) view->Pick(p_x, p_y);
44}
45
46// FUNCTION: LEGO1 0x1003dd90
47// FUNCTION: BETA10 0x100d3449
49{
50 LegoVideoManager* videoManager = VideoManager();
51 Lego3DView* view = videoManager->Get3DManager()->GetLego3DView();
52 LegoROI* roi = (LegoROI*) view->Pick(p_x, p_y);
53
54 while (roi != NULL && roi->GetParentROI() != NULL) {
55 roi = (LegoROI*) roi->GetParentROI();
56 }
57
58 return roi;
59}
60
61// FUNCTION: LEGO1 0x1003ddc0
63{
64 LegoROI* roi = PickRootROI(p_x, p_y);
65
66 if (roi == NULL) {
67 return NULL;
68 }
69
70 return roi->GetEntity();
71}
72
73// FUNCTION: LEGO1 0x1003dde0
74// FUNCTION: BETA10 0x100d358e
75void RotateY(LegoROI* p_roi, MxFloat p_angle)
76{
77 MxMatrix mat;
78 const Matrix4& local2world = p_roi->GetLocal2World();
79 mat = local2world;
80
81 float fsin = sin(p_angle);
82 float fcos = cos(p_angle);
83
84 for (MxS32 i = 0; i < 3; i++) {
85 mat[i][0] = (local2world[i][0] * fcos) + (local2world[i][2] * fsin);
86 mat[i][2] = (local2world[i][2] * fcos) - (local2world[i][0] * fsin);
87 }
88
89 p_roi->WrappedSetLocalTransform(mat);
90}
91
92// FUNCTION: LEGO1 0x1003de80
93MxBool SpheresIntersect(const BoundingSphere& p_sphere1, const BoundingSphere& p_sphere2)
94{
95 // This doesn't look clean, but it matches.
96 // p_sphere1.Center().GetData() doesn't work out
97 return sqrt(DISTSQRD3(&p_sphere1.Center()[0], &p_sphere2.Center()[0])) < p_sphere1.Radius() + p_sphere2.Radius();
98}
99
100// FUNCTION: LEGO1 0x1003ded0
101// FUNCTION: BETA10 0x100d3802
102MxBool FUN_1003ded0(MxFloat p_param1[2], MxFloat p_param2[3], MxFloat p_param3[3])
103{
104 MxFloat local1c[4];
105 MxFloat local10[3];
106
108
109 local1c[0] = p_param1[0];
110 local1c[1] = p_param1[1];
111 local1c[2] = 1.0f;
112 local1c[3] = 1.0f;
113
114 view->TransformScreenToWorld(local1c, p_param3);
115
116 local1c[0] *= 2.0;
117 local1c[1] *= 2.0;
118 local1c[3] = 2.0;
119
120 view->TransformScreenToWorld(local1c, local10);
121
122 p_param2[0] = local10[0] - p_param3[0];
123 p_param2[1] = local10[1] - p_param3[1];
124 p_param2[2] = local10[2] - p_param3[2];
125 return TRUE;
126}
127
128// FUNCTION: LEGO1 0x1003df70
129// FUNCTION: BETA10 0x100d38cb
130MxBool TransformWorldToScreen(const MxFloat p_world[3], MxFloat p_screen[4])
131{
133 return TRUE;
134}
135
136// FUNCTION: LEGO1 0x1003df90
137// FUNCTION: BETA10 0x100d39a3
139{
140 MxS16 result = 1;
141
142 for (LegoU32 i = 0; i < p_node->GetNumChildren(); i++) {
143 result += CountTotalTreeNodes(p_node->GetChild(i));
144 }
145
146 return result;
147}
148
149// FUNCTION: LEGO1 0x1003dfd0
150// FUNCTION: BETA10 0x100d3a09
152{
153 LegoTreeNode* result = NULL;
154
155 if (p_index == 0) {
156 result = p_node;
157 }
158 else {
159 for (LegoU32 i = 0; i < p_node->GetNumChildren(); i++) {
160 MxS16 count = CountTotalTreeNodes(p_node->GetChild(i));
161 if (p_index > count) {
162 p_index -= count;
163 }
164 else {
165 result = GetTreeNode(p_node->GetChild(i), p_index - 1);
166 break;
167 }
168 }
169 }
170
171 return result;
172}
173
174// FUNCTION: LEGO1 0x1003e050
175// FUNCTION: BETA10 0x100d3abc
177{
178 MxMatrix viewMatrix;
179 LegoTreeNode* rootNode = p_presenter->GetAnimation()->GetRoot();
180 LegoAnimNodeData* camData = NULL;
181 LegoAnimNodeData* targetData = NULL;
182 MxS16 nodesCount = CountTotalTreeNodes(rootNode);
183
184 MxFloat cam;
185 for (MxS16 i = 0; i < nodesCount; i++) {
186 if (camData && targetData) {
187 break;
188 }
189
190 LegoAnimNodeData* data = (LegoAnimNodeData*) GetTreeNode(rootNode, i)->GetData();
191
192 if (!strnicmp(data->GetName(), "CAM", strlen("CAM"))) {
193 camData = data;
194 cam = atof(&data->GetName()[strlen(data->GetName()) - 2]);
195 }
196 else if (!strcmpi(data->GetName(), "TARGET")) {
197 targetData = data;
198 }
199 }
200
201 MxMatrix matrixCam;
202 MxMatrix matrixTarget;
203 matrixCam.SetIdentity();
204 matrixTarget.SetIdentity();
205
206 camData->CreateLocalTransform(0.0f, matrixCam);
207 targetData->CreateLocalTransform(0.0f, matrixTarget);
208
209 Mx3DPointFloat dir;
210 dir[0] = matrixTarget[3][0] - matrixCam[3][0];
211 dir[1] = matrixTarget[3][1] - matrixCam[3][1];
212 dir[2] = matrixTarget[3][2] - matrixCam[3][2];
213 dir.Unitize();
214
215 CalcLocalTransform(matrixCam[3], dir, matrixCam[1], viewMatrix);
216
218 LegoROI* roi = video->GetViewROI();
219 Lego3DView* view = video->Get3DManager()->GetLego3DView();
220
221 roi->WrappedSetLocalTransform(viewMatrix);
222 view->Moved(*roi);
223 FUN_1003eda0();
224 video->Get3DManager()->SetFrustrum(cam, 0.1, 250.0);
225}
226
227// FUNCTION: LEGO1 0x1003e300
229{
231
232 if (!strcmpi("openram", p_str)) {
234 }
235 else if (!strcmpi("opendisk", p_str)) {
237 }
238 else if (!strcmpi("close", p_str)) {
240 }
241 else if (!strcmpi("start", p_str)) {
243 }
244 else if (!strcmpi("stop", p_str)) {
246 }
247 else if (!strcmpi("run", p_str)) {
249 }
250 else if (!strcmpi("exit", p_str)) {
252 }
253 else if (!strcmpi("enable", p_str)) {
255 }
256 else if (!strcmpi("disable", p_str)) {
258 }
259 else if (!strcmpi("notify", p_str)) {
261 }
262
263 return result;
264}
265
266MxBool CheckIfEntityExists(MxBool p_enable, const char* p_filename, MxS32 p_entityId);
267void NotifyEntity(const char* p_filename, MxS32 p_entityId, LegoEntity* p_sender);
268
269// FUNCTION: LEGO1 0x1003e430
270// FUNCTION: BETA10 0x100d3fda
271void InvokeAction(Extra::ActionType p_actionId, const MxAtomId& p_pAtom, MxS32 p_streamId, LegoEntity* p_sender)
272{
273 MxDSAction action;
274 action.SetAtomId(p_pAtom);
275 action.SetObjectId(p_streamId);
276
277 switch (p_actionId) {
279 assert(p_streamId != DS_NOT_A_STREAM);
280
281 if (!CheckIfEntityExists(TRUE, p_pAtom.GetInternal(), p_streamId)) {
283 Start(&action);
284 }
285
286 break;
288 assert(p_streamId != DS_NOT_A_STREAM);
289
290 if (!CheckIfEntityExists(TRUE, p_pAtom.GetInternal(), p_streamId)) {
292 Start(&action);
293 }
294
295 break;
297 action.SetUnknown24(-2);
298 DeleteObject(action);
299 Streamer()->Close(p_pAtom.GetInternal());
300 break;
302 assert(p_streamId != DS_NOT_A_STREAM);
303
304 if (!CheckIfEntityExists(TRUE, p_pAtom.GetInternal(), p_streamId)) {
305 Start(&action);
306 }
307
308 break;
310 assert(p_streamId != DS_NOT_A_STREAM);
311 action.SetUnknown24(-2);
312
313 if (!RemoveFromCurrentWorld(p_pAtom, p_streamId)) {
314 DeleteObject(action);
315 }
316
317 break;
319 _spawnl(0, "\\lego\\sources\\main\\main.exe", "\\lego\\sources\\main\\main.exe", "/script", &p_pAtom, 0);
320 break;
322 assert(p_streamId != DS_NOT_A_STREAM);
323 CheckIfEntityExists(TRUE, p_pAtom.GetInternal(), p_streamId);
324 break;
326 assert(p_streamId != DS_NOT_A_STREAM);
327 CheckIfEntityExists(FALSE, p_pAtom.GetInternal(), p_streamId);
328 break;
330 Lego()->SetExit(TRUE);
331 break;
333 assert(p_streamId != DS_NOT_A_STREAM);
334 NotifyEntity(p_pAtom.GetInternal(), p_streamId, p_sender);
335 break;
336 default:
337 assert("Invalid Action Control" == NULL);
338 }
339}
340
341// FUNCTION: LEGO1 0x1003e670
342// FUNCTION: BETA10 0x100d43f2
343MxBool CheckIfEntityExists(MxBool p_enable, const char* p_filename, MxS32 p_entityId)
344{
345 LegoWorld* world = FindWorld(MxAtomId(p_filename, e_lowerCase2), p_entityId);
346
347 if (world) {
348 world->Enable(p_enable);
349 return TRUE;
350 }
351 else {
352 return FALSE;
353 }
354}
355
356// FUNCTION: LEGO1 0x1003e700
357// FUNCTION: BETA10 0x100d448a
358void NotifyEntity(const char* p_filename, MxS32 p_entityId, LegoEntity* p_sender)
359{
360 MxAtomId atom(p_filename, e_lowerCase2);
361 LegoEntity* entity = FindWorld(atom, p_entityId);
362
363 if (entity == NULL) {
364 LegoWorldListCursor cursor(Lego()->GetWorldList());
365 LegoWorld* world;
366
367 while (cursor.Next(world)) {
368 entity = (LegoEntity*) world->Find(atom, p_entityId);
369
370 if (entity != NULL) {
371 break;
372 }
373 }
374 }
375
376 if (entity != NULL) {
378 }
379}
380
381// FUNCTION: LEGO1 0x1003eab0
383{
385}
386
387// FUNCTION: LEGO1 0x1003eae0
388void ConvertHSVToRGB(float p_h, float p_s, float p_v, float* p_rOut, float* p_bOut, float* p_gOut)
389{
390 double calc;
391 double p;
392 MxLong hueIndex;
393 double v9;
394 double v12;
395 double v13;
396
397 double sDbl = p_s;
398
399 if (p_s > 0.5f) {
400 calc = (1.0f - p_v) * p_s + p_v;
401 }
402 else {
403 calc = (p_v + 1.0) * sDbl;
404 }
405 if (calc <= 0.0) {
406 *p_gOut = 0.0f;
407 *p_bOut = 0.0f;
408 *p_rOut = 0.0f;
409 return;
410 }
411 p = p_s * 2.0f - calc;
412 hueIndex = p_h * 6.0;
413 v9 = (p_h * 6.0 - (float) hueIndex) * ((calc - p) / calc) * calc;
414 v12 = p + v9;
415 v13 = calc - v9;
416 switch (hueIndex) {
417 case 0:
418 *p_rOut = calc;
419 *p_bOut = v12;
420 *p_gOut = p;
421 break;
422 case 1:
423 *p_rOut = v13;
424 *p_bOut = calc;
425 *p_gOut = p;
426 break;
427 case 2:
428 *p_rOut = p;
429 *p_bOut = calc;
430 *p_gOut = v12;
431 break;
432 case 3:
433 *p_rOut = p;
434 *p_bOut = v13;
435 *p_gOut = calc;
436 break;
437 case 4:
438 *p_rOut = v12;
439 *p_bOut = p;
440 *p_gOut = calc;
441 break;
442 case 5:
443 *p_rOut = calc;
444 *p_bOut = p;
445 *p_gOut = v13;
446 break;
447 case 6:
448 *p_rOut = calc;
449 *p_bOut = p;
450 *p_gOut = v13;
451 break;
452 default:
453 return;
454 }
455}
456
457// FUNCTION: LEGO1 0x1003ecc0
458// FUNCTION: BETA10 0x100d4b38
459void PlayCamAnim(LegoPathActor* p_actor, MxBool p_unused, MxU32 p_location, MxBool p_bool)
460{
461 LegoWorld* world = CurrentWorld();
462 MxLong result = 0;
463
464 if (world != NULL) {
466 result = world->Notify(param);
467 }
468
469 if (result == 0) {
470 AnimationManager()->CameraTriggerFire(p_actor, p_unused, p_location, p_bool);
471 }
472}
473
474// FUNCTION: LEGO1 0x1003eda0
475// FUNCTION: BETA10 0x100d4bf4
477{
478 Mx3DPointFloat vec;
479 vec.Clear();
480
481 LegoROI* viewROI = VideoManager()->GetViewROI();
482 if (viewROI) {
483 viewROI->FUN_100a5a30(vec);
485 viewROI->GetWorldPosition(),
486 viewROI->GetWorldDirection(),
487 viewROI->GetWorldUp(),
488 viewROI->GetWorldVelocity()
489 );
490 }
491}
492
493// FUNCTION: LEGO1 0x1003ee00
494// FUNCTION: BETA10 0x100d4c6f
496{
497 LegoWorld* world = CurrentWorld();
498
499 if (world) {
500 MxCore* object = world->Find(p_atomId, p_id);
501
502 if (object) {
503 world->Remove(object);
504
505 if (!object->IsA("MxPresenter")) {
506 delete object;
507 }
508 else {
509 if (((MxPresenter*) object)->GetAction()) {
510 FUN_100b7220(((MxPresenter*) object)->GetAction(), MxDSAction::c_world, FALSE);
511 }
512
513 ((MxPresenter*) object)->EndAction();
514 }
515
516 return TRUE;
517 }
518 }
519
520 return FALSE;
521}
522
523// FUNCTION: LEGO1 0x1003ee80
524MxBool RemoveFromWorld(MxAtomId& p_entityAtom, MxS32 p_entityId, MxAtomId& p_worldAtom, MxS32 p_worldEntityId)
525{
526 LegoWorld* world = FindWorld(p_worldAtom, p_worldEntityId);
527
528 if (world) {
529 MxCore* object = world->Find(p_entityAtom, p_entityId);
530
531 if (object) {
532 world->Remove(object);
533
534 if (!object->IsA("MxPresenter")) {
535 delete object;
536 }
537 else {
538 if (((MxPresenter*) object)->GetAction()) {
539 FUN_100b7220(((MxPresenter*) object)->GetAction(), MxDSAction::c_world, FALSE);
540 }
541
542 ((MxPresenter*) object)->EndAction();
543 }
544
545 return TRUE;
546 }
547 }
548
549 return FALSE;
550}
551
552// FUNCTION: LEGO1 0x1003ef00
553// FUNCTION: BETA10 0x100d4e1e
555{
556 if (p_enable) {
558 }
559
560 AnimationManager()->FUN_1005f6d0(p_enable);
561 AnimationManager()->FUN_10060540(p_enable);
562 AnimationManager()->FUN_100604d0(p_enable);
563}
564
565// FUNCTION: LEGO1 0x1003ef40
566void SetAppCursor(Cursor p_cursor)
567{
568 PostMessageA(MxOmni::GetInstance()->GetWindowHandle(), WM_ISLE_SETCURSOR, p_cursor, 0);
569}
570
571// FUNCTION: LEGO1 0x1003ef60
573{
574 Act1State* act1State = (Act1State*) GameState()->GetState("Act1State");
575
584 if (UserActor() == NULL || !UserActor()->IsA("TowTrack")) {
585 if (UserActor() == NULL || !UserActor()->IsA("Ambulance")) {
586 MxU32 unk0x18 = act1State->GetUnknown18();
587
588 if (unk0x18 != 10 && unk0x18 != 8 && unk0x18 != 3) {
589 return TRUE;
590 }
591 }
592 }
593 }
594
595 return FALSE;
596}
597
598// FUNCTION: LEGO1 0x1003f050
600{
601 MxS32 lightPosition = atoi(VariableTable()->GetVariable("lightposition"));
602
603 // Only ever increases by 1 irrespective of p_increase
604 if (p_increase > 0) {
605 lightPosition += 1;
606 if (lightPosition > 5) {
607 lightPosition = 5;
608 }
609 }
610 else {
611 lightPosition -= 1;
612 if (lightPosition < 0) {
613 lightPosition = 0;
614 }
615 }
616
617 SetLightPosition(lightPosition);
618
619 char lightPositionBuffer[32];
620 sprintf(lightPositionBuffer, "%d", lightPosition);
621
622 VariableTable()->SetVariable("lightposition", lightPositionBuffer);
623
624 return lightPosition;
625}
626
627// FUNCTION: LEGO1 0x1003f0d0
629{
630 float lights[6][6] = {
631 {1.0, 0.0, 0.0, -150.0, 50.0, -50.0},
632 {0.809, -0.588, 0.0, -75.0, 50.0, -50.0},
633 {0.0, -1.0, 0.0, 0.0, 150.0, -150.0},
634 {-0.309, -0.951, 0.0, 25.0, 50.0, -50.0},
635 {-0.809, -0.588, 0.0, 75.0, 50.0, -50.0},
636 {-1.0, 0.0, 0.0, 150.0, 50.0, -50.0}
637 };
638
639 Mx3DPointFloat up(1.0, 0.0, 0.0);
640 Mx3DPointFloat direction;
641 Mx3DPointFloat position;
642
643 Tgl::FloatMatrix4 matrix;
644 Matrix4 in(matrix);
645 MxMatrix transform;
646
647 if (p_index < 0) {
648 p_index = 0;
649 }
650 else if (p_index > 5) {
651 p_index = 5;
652 }
653
654 direction = lights[p_index];
655 position = &lights[p_index][3];
656
657 CalcLocalTransform(position, direction, up, transform);
658 SETMAT4(in, transform);
659
662}
663
664// FUNCTION: LEGO1 0x1003f3b0
666{
667 LegoTexture* texture = NULL;
668 LegoNamedTexture* namedTexture = NULL;
669 MxString string;
670
671 p_storage->ReadMxString(string);
672
673 texture = new LegoTexture();
674 if (texture != NULL) {
675 if (texture->Read(p_storage, 0) != SUCCESS) {
676 delete texture;
677 return namedTexture;
678 }
679
680 namedTexture = new LegoNamedTexture(string.GetData(), texture);
681 if (namedTexture == NULL) {
682 delete texture;
683 }
684 }
685
686 return namedTexture;
687}
688
689// FUNCTION: LEGO1 0x1003f540
690void WriteDefaultTexture(LegoStorage* p_storage, const char* p_name)
691{
692 MxString name(p_name);
693 LegoTextureInfo* textureInfo = TextureContainer()->Get(p_name);
694
695 if (textureInfo != NULL) {
696 DDSURFACEDESC desc;
697 LegoPaletteEntry paletteEntries[256];
698
699 LPDIRECTDRAWSURFACE surface = textureInfo->m_surface;
700 memset(&desc, 0, sizeof(desc));
701 desc.dwSize = sizeof(desc);
702
703 if (surface->Lock(NULL, &desc, DDLOCK_SURFACEMEMORYPTR, NULL) == DD_OK) {
704 LegoImage* image = new LegoImage(desc.dwWidth, desc.dwHeight);
705
706 if (image != NULL) {
707 if (desc.dwWidth == desc.lPitch) {
708 memcpy(desc.lpSurface, image->GetBits(), desc.dwWidth * desc.dwHeight);
709 }
710 else {
711 MxU8* surface = (MxU8*) desc.lpSurface;
712 const LegoU8* bits = image->GetBits();
713
714 for (MxS32 i = 0; i < desc.dwHeight; i++) {
715 memcpy(surface, bits, desc.dwWidth);
716 surface += desc.lPitch;
717 bits += desc.dwWidth;
718 }
719 }
720
721 surface->Unlock(desc.lpSurface);
722
723 PALETTEENTRY entries[256];
724 if (textureInfo->m_palette->GetEntries(0, 0, sizeOfArray(entries), entries) == DD_OK) {
725 MxS32 i;
726 for (i = 0; i < sizeOfArray(entries); i++) {
727 if (entries[i].peFlags != 0) {
728 break;
729 }
730
731 paletteEntries[i].SetRed(entries[i].peRed);
732 paletteEntries[i].SetGreen(entries[i].peGreen);
733 paletteEntries[i].SetBlue(entries[i].peBlue);
734 }
735
736 image->SetCount(i);
737
738 if (i > 0) {
739 // Note: this appears to be a bug. size should be i * sizeof(LegoPaletteEntry)
740 memcpy(image->GetPalette(), paletteEntries, i);
741 }
742
743 LegoTexture texture;
744 texture.SetImage(image);
745
746 p_storage->WriteMxString(name);
747 texture.Write(p_storage);
748 }
749 else {
750 delete image;
751 }
752 }
753 else {
754 surface->Unlock(desc.lpSurface);
755 }
756 }
757 }
758}
759
760// FUNCTION: LEGO1 0x1003f8a0
761void WriteNamedTexture(LegoStorage* p_storage, LegoNamedTexture* p_namedTexture)
762{
763 p_storage->WriteMxString(*p_namedTexture->GetName());
764 p_namedTexture->GetTexture()->Write(p_storage);
765}
766
767// FUNCTION: LEGO1 0x1003f930
768void FUN_1003f930(LegoNamedTexture* p_namedTexture)
769{
770 LegoTextureInfo* textureInfo = TextureContainer()->Get(p_namedTexture->GetName()->GetData());
771
772 if (textureInfo != NULL) {
773 textureInfo->FUN_10066010(p_namedTexture->GetTexture()->GetImage()->GetBits());
774 }
775}
[AI] Holds state and transient gameplay data for the first act on Lego Island.
Definition: isle.h:29
MxU32 GetUnknown18()
[AI] Retrieves the internal state variable at offset 0x018 (purpose: current major state,...
Definition: isle.h:68
[AI] Represents a bounding sphere in 3D space with center and radius.
Definition: roi.h:56
const float & Radius() const
[AI] Const accessor for the sphere radius.
Definition: roi.h:72
const Vector3 & Center() const
[AI] Const accessor for the center of the sphere.
Definition: roi.h:62
int SetFrustrum(float p_fov, float p_front, float p_back)
[AI] Sets the 3D perspective frustum parameters for camera and view.
Lego3DView * GetLego3DView()
[AI] Returns the encapsulated Lego3DView instance.
[AI] Represents a 3D view for rendering and managing LEGO game objects in a 3D scene.
Definition: lego3dview.h:20
BOOL Moved(ViewROI &rROI)
[AI] Notifies the view that a ViewROI has moved.
Definition: lego3dview.cpp:126
ViewROI * Pick(unsigned long x, unsigned long y)
[AI] Picks (selects) a ViewROI in the scene by screen-space coordinates.
Definition: lego3dview.cpp:157
[AI] Holds per-node animation data for a model's animation tree.
Definition: legoanim.h:144
LegoResult CreateLocalTransform(LegoFloat p_time, Matrix4 &p_matrix)
[AI] Computes the interpolated local transformation matrix for this node at the given animation time.
Definition: legoanim.cpp:728
LegoChar * GetName()
[AI] Name of this animation node (used for lookup/mapping to scene graph).
Definition: legoanim.h:163
[AI] Handles playback and synchronization of animated LEGO objects, including variable substitution,...
LegoAnim * GetAnimation()
[AI] Returns the current animation resource in use.
void FUN_10060540(MxBool p_unk0x29)
[AI] Sets the 'enabled for random camera animation' flag for all animations.
void Resume()
[AI] Resumes animation manager from suspension, restoring all previously suspended state.
void FUN_100604d0(MxBool p_unk0x08)
[AI] Sets the m_unk0x08 flag for all characters.
void CameraTriggerFire(LegoPathActor *p_actor, MxBool, MxU32 p_location, MxBool p_bool)
[AI] Triggers a camera animation based on user and location state.
void FUN_1005f6d0(MxBool p_unk0x400)
[AI] Enables or disables extras (extra actors).
T * Get(const char *p_name)
Retrieve the element mapped to the given name, or nullptr if missing.
Definition: legocontainer.h:92
[AI] Represents an entity that can be placed and managed in the LEGO Island world.
Definition: legoentity.h:16
Area m_currentArea
Area/world the player is presently in. [AI].
LegoState * GetState(const char *p_stateName)
Find an existing state (LegoState-derived) object by its registered script/class name.
@ e_elevdown
Elevator moving down (animated). [AI].
@ e_elevride2
Elevator ride/cab down (animated). [AI].
@ e_garadoor
Garage door or doorway. [AI].
@ e_polidoor
Police Station door. [AI].
@ e_elevride
Elevator ride/cab up (animated). [AI].
@ e_observe
Observatory interior. [AI].
@ e_seaview
Ocean-side view at observatory. [AI].
@ e_elevopen
Elevator doors open. [AI].
[AI] Class representing an 8-bit palettized image with up to 256 palette entries and indexed pixel da...
Definition: legoimage.h:68
void SetCount(LegoU32 p_count)
[AI] Sets the palette color count (number of valid entries in m_palette).
Definition: legoimage.h:100
LegoU8 * GetBits()
[AI] Returns pointer to the buffer containing indexed pixel data.
Definition: legoimage.h:116
LegoPaletteEntry * GetPalette()
[AI] Returns the pointer to the start of the palette array (256 entries).
Definition: legoimage.h:103
void SetCamera(LegoCameraController *p_camera)
[AI] Assigns a new camera controller for mouse/look operations.
[AI] Associates a named string with a LegoTexture instance, allowing textures to be referenced symbol...
LegoTexture * GetTexture()
[AI] Returns a pointer to the owned LegoTexture instance.
const MxString * GetName() const
[AI] Returns a pointer to the name string associated with this texture.
void SetExit(MxBool p_exit)
[AI] Signals the engine to exit/game quit procedure.
Definition: legomain.h:461
[AI] Represents a single entry in an 8-bit RGB palette with red, green, and blue components.
Definition: legoimage.h:12
void SetBlue(LegoU8 p_blue)
[AI] Sets the blue color intensity.
Definition: legoimage.h:44
void SetGreen(LegoU8 p_green)
[AI] Sets the green color intensity.
Definition: legoimage.h:37
void SetRed(LegoU8 p_red)
[AI] Sets the red color intensity.
Definition: legoimage.h:30
[AI] An actor that moves along a predefined path, supporting boundary transitions,...
Definition: legopathactor.h:32
MxBool IsA(const char *p_name) const override
[AI] RTTI-like check, matches against own or base class name for IsA hierarchy checks.
[AI] Specialized notification parameter used for path structure related events in LEGO Island.
@ c_camAnim
[AI] Camera animation trigger.
[AI] Represents a Real-time Object Instance enriched with LEGO-specific functionality.
Definition: legoroi.h:43
LegoEntity * GetEntity()
[AI] Gets the entity associated with this ROI (or NULL).
Definition: legoroi.h:293
void UpdateListener(const float *p_position, const float *p_direction, const float *p_up, const float *p_velocity)
[AI] Updates the 3D sound listener properties in DirectSound, reflecting player/world changes.
Abstract base class providing an interface for file-like storage with binary and text read/write oper...
Definition: legostorage.h:16
LegoStorage * ReadMxString(MxString &p_data)
Reads a length-prefixed string and stores it in an MxString object.
Definition: legostorage.h:287
LegoStorage * WriteMxString(MxString p_data)
Writes a length-prefixed MxString to storage.
Definition: legostorage.h:180
[AI] Contains DirectDraw and Direct3DRM handles and metadata for a texture used in the LEGO Island re...
LegoResult FUN_10066010(const LegoU8 *p_bits)
[AI] Updates the pixel bits for the current surface/texture with the provided bitmap data.
LPDIRECTDRAWPALETTE m_palette
[AI] DirectDraw palette object (8-bit) assigned to the m_surface.
LPDIRECTDRAWSURFACE m_surface
[AI] DirectDraw surface holding the 8-bit indexed image for the texture.
[AI] Represents a texture which wraps a LegoImage and provides loading/saving functionality.
Definition: legotexture.h:15
LegoResult Read(LegoStorage *p_storage, LegoU32 p_square)
[AI] Reads texture data from a LegoStorage.
Definition: legotexture.cpp:22
LegoImage * GetImage()
[AI] Returns the associated image used by this texture.
Definition: legotexture.h:25
LegoResult Write(LegoStorage *p_storage)
[AI] Writes texture data to a LegoStorage.
Definition: legotexture.cpp:28
void SetImage(LegoImage *p_image)
[AI] Sets the associated image for this texture.
Definition: legotexture.h:29
[AI] Represents a node within a general, N-ary tree structure.
Definition: legotree.h:44
LegoTreeNodeData * GetData()
[AI] Returns the data payload stored at this node (may be nullptr). [AI]
Definition: legotree.h:54
LegoU32 GetNumChildren()
[AI] Returns the number of direct children of this node. [AI]
Definition: legotree.h:63
LegoTreeNode * GetChild(LegoU32 p_i)
[AI] Gets the child node at the specified index (no bounds checking).
Definition: legotree.h:72
LegoTreeNode * GetRoot()
[AI] Returns a pointer to the root node of the tree. [AI]
Definition: legotree.h:112
[AI] Extends the functionality of MxVideoManager to provide LEGO Island–specific video and 3D graphic...
Lego3DManager * Get3DManager()
[AI] Returns the Lego3DManager for this manager, which owns all 3D scene representations and view con...
LegoROI * GetViewROI()
[AI] Returns the viewpoint ROI for the current view/camera.
void SetLightTransform(BOOL bDirectionalLight, Tgl::FloatMatrix4 &rMatrix)
[AI] Sets the transformation matrix (position/orientation) for either the sun or directional light.
Definition: legoview1.cpp:200
Provides iteration access to a LegoWorldList.
Definition: legoworldlist.h:33
Represents the active 3D world, holding all entity, animation, sound, path, and ROI objects.
Definition: legoworld.h:49
void Remove(MxCore *p_object)
Removes an object from all relevant world-managed lists or sets, and also detaches if needed.
Definition: legoworld.cpp:508
virtual void Enable(MxBool p_enable)
Enables or disables (pauses) the world and its main components.
Definition: legoworld.cpp:684
MxCore * Find(const char *p_class, const char *p_name)
Finds an object of a given class and name in the world.
Definition: legoworld.cpp:573
MxLong Notify(MxParam &p_param) override
Notification callback responding to registered events such as EndAction and NewPresenter.
Definition: legoworld.cpp:212
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] Atomized (unique) string identifier, managed by reference counting.
Definition: mxatom.h:124
const char * GetInternal() const
[AI] Returns a pointer to the internal string, or nullptr if not set.
Definition: mxatom.h:194
[AI] Base virtual class for all Mindscape engine (Mx) objects.
Definition: mxcore.h:15
virtual MxBool IsA(const char *p_name) const
[AI] Checks whether this object's class type or parents match the given name.
Definition: mxcore.h:46
[AI] Represents an action deserialized from SI chunks, holding key animation or script parameters suc...
Definition: mxdsaction.h:17
@ c_world
[AI] Action is described in world-space coordinates [AI]
Definition: mxdsaction.h:27
virtual void SetAtomId(MxAtomId p_atomId)
[AI] Sets the atom id for this object instance, used for indexing or lookup.
Definition: mxdsobject.h:118
void SetUnknown24(MxS16 p_unk0x24)
[AI] Sets the unknown field at 0x24 (possibly version/state).
Definition: mxdsobject.h:151
void SetObjectId(MxU32 p_objectId)
[AI] Sets the object id (for serialization or lookup).
Definition: mxdsobject.h:147
MxBool Next()
[AI]
[AI] Represents a 4x4 transformation matrix, specialized for the LEGO Island engine and derived from ...
Definition: mxmatrix.h:16
MxResult Send(MxCore *p_listener, const MxNotificationParam &p_param)
[AI] Queues a notification to be sent to a specific registered listener.
[AI] Parameter object representing a single notification or event, carrying an identifier and sender ...
static MxOmni * GetInstance()
[AI] Returns the singleton instance of the MxOmni subsystem coordinator.
Definition: mxomni.cpp:289
[AI] Abstract base class for all presenter types in the LEGO Island engine, responsible for managing ...
Definition: mxpresenter.h:20
MxStreamController * Open(const char *p_name, MxU16 p_openMode)
Open a stream, returning a controller for further access [AI].
Definition: mxstreamer.cpp:62
MxLong Close(const char *p_name)
Close a named stream and remove its controller from the open list [AI].
Definition: mxstreamer.cpp:98
@ e_diskStream
Load streaming resource from disk [AI].
Definition: mxstreamer.h:71
@ e_RAMStream
Load streaming resource fully to RAM [AI].
Definition: mxstreamer.h:72
Mindscape custom string class for managing dynamic C-strings within the game engine.
Definition: mxstring.h:14
char * GetData() const
Returns a pointer to the internal character buffer.
Definition: mxstring.h:110
void SetVariable(const char *p_key, const char *p_value)
Sets a variable by key and value, replacing or updating if it exists.
const float * GetWorldUp() const
Returns a pointer to the world up vector from the transformation matrix.
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.
void FUN_100a5a30(const Vector3 &p_world_velocity)
Sets the world velocity to the provided vector.
const float * GetWorldVelocity() const override
Returns a pointer to the object's velocity vector in world space.
OrientableROI * GetParentROI() const
Accessor for the parent ROI in the transformation hierarchy.
Tgl::View * GetView() const
[AI] Gets the current view/camera for this surface.
Definition: tglsurface.h:108
[AI] Represents a rendering viewport and drawing context.
Definition: tgl.h:397
virtual Result TransformScreenToWorld(const float screen[4], float world[3])=0
[AI] Converts screen coordinate back to world position.
virtual Result TransformWorldToScreen(const float world[3], float screen[4])=0
[AI] Transforms a world-space position to screen coordinates.
virtual int Unitize()
[AI] Scales the vector so its norm is 1 (unit vector).
void Clear() override
[AI] Sets every coordinate (x, y, z) to zero.
#define TRUE
Definition: d3drmdef.h:28
#define FALSE
Definition: d3drmdef.h:27
struct IDirectDrawSurface FAR * LPDIRECTDRAWSURFACE
Definition: ddraw.h:74
#define DD_OK
Definition: ddraw.h:3166
#define DDLOCK_SURFACEMEMORYPTR
Definition: ddraw.h:2909
#define sizeOfArray(arr)
Definition: decomp.h:23
#define NULL
[AI] Null pointer value (C/C++ semantics).
Definition: legotypes.h:26
unsigned long LegoU32
[AI] Unsigned 32-bit integer type for cross-platform compatibility.
Definition: legotypes.h:71
unsigned char LegoU8
[AI] Unsigned 8-bit integer type used throughout LEGO Island.
Definition: legotypes.h:47
#define SUCCESS
[AI] Used to indicate a successful operation in result codes.
Definition: legotypes.h:30
void EnableAnimations(MxBool p_enable)
[AI] Enables or disables animation playback globally.
Definition: legoutils.cpp:554
void InvokeAction(Extra::ActionType p_actionId, const MxAtomId &p_pAtom, MxS32 p_streamId, LegoEntity *p_sender)
[AI] Dispatches and triggers a game action on the given script or object.
Definition: legoutils.cpp:271
MxBool RemoveFromWorld(MxAtomId &p_entityAtom, MxS32 p_entityId, MxAtomId &p_worldAtom, MxS32 p_worldEntityId)
[AI] Removes a game object referenced by atom/id from a specific world, handling presenters and EndAc...
Definition: legoutils.cpp:524
LegoNamedTexture * ReadNamedTexture(LegoStorage *p_storage)
[AI] Reads a named texture and its associated image data from storage.
Definition: legoutils.cpp:665
MxBool TransformWorldToScreen(const MxFloat p_world[3], MxFloat p_screen[4])
[AI] Projects a world-space point into normalized screen coordinates.
Definition: legoutils.cpp:130
MxBool CheckIfEntityExists(MxBool p_enable, const char *p_filename, MxS32 p_entityId)
[AI] Parses a string for entity existence and enables/disables it accordingly.
Definition: legoutils.cpp:343
MxBool RemoveFromCurrentWorld(const MxAtomId &p_atomId, MxS32 p_id)
[AI] Removes an entity or presenter with specified AtomId and ID from the current world; triggers End...
Definition: legoutils.cpp:495
LegoROI * PickROI(MxLong p_x, MxLong p_y)
[AI] Picks the ROI (Renderable Object Instance) at screen coordinates.
Definition: legoutils.cpp:39
MxBool FUN_1003ef60()
[AI] Determines if the current actor can exit their area, based on state/zone/vehicle.
Definition: legoutils.cpp:572
LegoTreeNode * GetTreeNode(LegoTreeNode *p_node, MxU32 p_index)
[AI] Retrieves the nth node in tree traversal order (preorder) from a LegoTreeNode root.
Definition: legoutils.cpp:151
MxS32 UpdateLightPosition(MxS32 p_increase)
[AI] Steps or resets the in-game light position; wraps and saves in global variables; updates lightin...
Definition: legoutils.cpp:599
void FUN_1003eda0()
[AI] Updates sound listener position to follow the view ROI's transform.
Definition: legoutils.cpp:476
void SetCameraControllerFromIsle()
[AI] Updates the current camera controller to the main ISLE camera specified in the global script.
Definition: legoutils.cpp:382
void ConvertHSVToRGB(float p_h, float p_s, float p_v, float *p_rOut, float *p_bOut, float *p_gOut)
[AI] Converts HSV color (hue/saturation/value) to RGB (red/green/blue).
Definition: legoutils.cpp:388
LegoEntity * PickEntity(MxLong p_x, MxLong p_y)
[AI] Picks the LEGO entity root at the given screen coordinates.
Definition: legoutils.cpp:62
void PlayCamAnim(LegoPathActor *p_actor, MxBool p_unused, MxU32 p_location, MxBool p_bool)
[AI] Initiates a camera animation for a specific path actor, or falls back to default animation trigg...
Definition: legoutils.cpp:459
void NotifyEntity(const char *p_filename, MxS32 p_entityId, LegoEntity *p_sender)
[AI] Sends a notification to the specified entity in all known worlds.
Definition: legoutils.cpp:358
void SetAppCursor(Cursor p_cursor)
[AI] Sets the in-game cursor to a specified type.
Definition: legoutils.cpp:566
void RotateY(LegoROI *p_roi, MxFloat p_angle)
[AI] Rotates the given ROI around the Y axis in world space.
Definition: legoutils.cpp:75
LegoROI * PickRootROI(MxLong p_x, MxLong p_y)
[AI] Picks the root ROI at the given screen coordinates by traversing up the ROI parent tree.
Definition: legoutils.cpp:48
void FUN_1003f930(LegoNamedTexture *p_namedTexture)
[AI] Applies the image bits of a named texture to its associated texture info container entry.
Definition: legoutils.cpp:768
Extra::ActionType MatchActionString(const char *p_str)
[AI] Parses an action string to determine the corresponding action type.
Definition: legoutils.cpp:228
MxS16 CountTotalTreeNodes(LegoTreeNode *p_node)
[AI] Recursively counts the number of nodes (including the root) in a tree hierarchy rooted at the sp...
Definition: legoutils.cpp:138
void FUN_1003e050(LegoAnimPresenter *p_presenter)
[AI] Repositions the camera and updates the view matrix using a LegoAnimPresenter's animation nodes n...
Definition: legoutils.cpp:176
MxBool SpheresIntersect(const BoundingSphere &p_sphere1, const BoundingSphere &p_sphere2)
[AI] Tests if two bounding spheres in the 3D world intersect.
Definition: legoutils.cpp:93
void WriteDefaultTexture(LegoStorage *p_storage, const char *p_name)
[AI] Writes a default texture by name (and its image/palette) to storage for serialization.
Definition: legoutils.cpp:690
void WriteNamedTexture(LegoStorage *p_storage, LegoNamedTexture *p_namedTexture)
[AI] Writes a LegoNamedTexture and its associated image to storage.
Definition: legoutils.cpp:761
MxBool FUN_1003ded0(MxFloat p_param1[2], MxFloat p_param2[3], MxFloat p_param3[3])
[AI] Calculates a ray starting at a screen location and outputs its world origin and direction.
Definition: legoutils.cpp:102
void SetLightPosition(MxS32 p_index)
[AI] Sets the world space position and direction of the in-game directional light,...
Definition: legoutils.cpp:628
#define DS_NOT_A_STREAM
[AI] Special stream ID indicating that the current stream is not valid.
Definition: legoutils.h:16
#define WM_ISLE_SETCURSOR
[AI] Custom Windows message for setting the cursor in LEGO Island. Used with PostMessage....
Definition: legoutils.h:11
Cursor
[AI] Enum representing cursor icons usable within the LEGO Island engine for custom cursor management...
Definition: legoutils.h:22
MxAtomId * g_isleScript
[AI] Node used in hierarchical scene graphs and animation trees. [AI]
Definition: scripts.cpp:32
LegoGameState * GameState()
[AI] Accessor for the game's central game state controller. [AI]
Definition: misc.cpp:61
LegoVideoManager * VideoManager()
[AI] Accessor for the game's LegoVideoManager subsystem. Used for managing 3D/video hardware....
Definition: misc.cpp:29
LegoAnimationManager * AnimationManager()
[AI] Accessor for the animation manager, which controls Lego character/world animation state....
Definition: misc.cpp:69
LegoSoundManager * SoundManager()
[AI] Accessor for the game's LegoSoundManager subsystem from the global LegoOmni instance....
Definition: misc.cpp:22
LegoWorld * FindWorld(const MxAtomId &p_atom, MxS32 p_entityid)
[AI] Searches for or retrieves a LegoWorld instance based on an atom id and entity id.
Definition: misc.cpp:188
LegoWorld * CurrentWorld()
[AI] Accessor for the currently active LegoWorld instance. [AI]
Definition: misc.cpp:93
LegoOmni * Lego()
[AI] Retrieves the global LegoOmni singleton instance, providing access to core subsystems.
Definition: misc.cpp:16
LegoTextureContainer * TextureContainer()
[AI] Accessor for the texture container used for global texture management. [AI]
Definition: misc.cpp:130
LegoPathActor * UserActor()
[AI] Accessor for the user (player-controllable) LegoPathActor. [AI]
Definition: misc.cpp:85
LegoInputManager * InputManager()
[AI] Accessor for the input manager, which handles keyboard, mouse, and controller input....
Definition: misc.cpp:45
@ e_lowerCase2
[AI] Alternative or legacy lower case mode, functionally equivalent to e_lowerCase.
Definition: mxatom.h:109
MxResult Start(MxDSAction *p_dsAction)
[AI] Schedules and initiates execution of a script action.
Definition: mxmisc.cpp:97
MxVariableTable * VariableTable()
[AI] Returns the variable table used for script variables and global key/value state.
Definition: mxmisc.cpp:73
MxStreamer * Streamer()
[AI] Returns the global streamer used for all chunked media streaming (SI file, audio,...
Definition: mxmisc.cpp:49
void DeleteObject(MxDSAction &p_dsAction)
[AI] Deletes the specified action object, removing it from the global action list.
Definition: mxmisc.cpp:105
MxNotificationManager * NotificationManager()
[AI] Returns the notification manager for system-wide state/update notifications.
Definition: mxmisc.cpp:17
@ c_notificationType0
[AI] Undefined/Generic notification type [AI]
@ c_notificationPathStruct
[AI] Data related to a path structure [AI]
MxU8 MxBool
[AI]
Definition: mxtypes.h:124
int MxLong
[AI]
Definition: mxtypes.h:83
signed short MxS16
[AI]
Definition: mxtypes.h:26
float MxFloat
[AI]
Definition: mxtypes.h:68
unsigned char MxU8
[AI]
Definition: mxtypes.h:8
signed int MxS32
[AI]
Definition: mxtypes.h:38
unsigned int MxU32
[AI]
Definition: mxtypes.h:32
void FUN_100b7220(MxDSAction *p_action, MxU32 p_newFlags, MxBool p_setFlags)
Recursively sets or clears flags for an MxDSAction and all sub-actions if applicable.
float FloatMatrix4[4][4]
[AI] Represents a 4x4 matrix of single-precision floating point values.
Definition: tglvector.h:53
void CalcLocalTransform(const Vector3 &p_posVec, const Vector3 &p_dirVec, const Vector3 &p_upVec, Matrix4 &p_outMatrix)
[AI] Computes a transformation matrix based on a position, direction, and up vector.
Definition: realtime.cpp:7
[AI] Contains global script AtomId pointers and utility functions for managing script AtomIds in LEGO...
ActionType
[AI] Enumerates the possible operation types that may appear as actions in the "Extra" key-value stri...
Definition: extra.h:25
@ e_opendisk
[AI] Open resource from disk [AI]
Definition: extra.h:27
@ e_stop
[AI] Stop an activity or playback [AI]
Definition: extra.h:31
@ e_exit
[AI] Exit an activity, context or resource [AI]
Definition: extra.h:33
@ e_enable
[AI] Enable a capability or flag [AI]
Definition: extra.h:34
@ e_run
[AI] Run (execute) an operation [AI]
Definition: extra.h:32
@ e_start
[AI] Start an activity or playback [AI]
Definition: extra.h:30
@ e_close
[AI] Close the resource or action [AI]
Definition: extra.h:29
@ e_openram
[AI] Open resource from RAM [AI]
Definition: extra.h:28
@ e_notify
[AI] Notify observers or listeners [AI]
Definition: extra.h:36
@ e_unknown
[AI] Unrecognized or unclassified action [AI]
Definition: extra.h:37
@ e_disable
[AI] Disable a capability or flag [AI]
Definition: extra.h:35
LPVOID lpSurface
Definition: ddraw.h:1152
LONG lPitch
Definition: ddraw.h:1140
DWORD dwSize
Definition: ddraw.h:1134
DWORD dwWidth
Definition: ddraw.h:1137
DWORD dwHeight
Definition: ddraw.h:1136
#define DISTSQRD3(v, w)
Definition: vec.h:478
#define SETMAT4(to, from)
Definition: vec.h:547