81 float fsin = sin(p_angle);
82 float fcos = cos(p_angle);
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);
109 local1c[0] = p_param1[0];
110 local1c[1] = p_param1[1];
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];
161 if (p_index > count) {
185 for (
MxS16 i = 0; i < nodesCount; i++) {
186 if (camData && targetData) {
192 if (!strnicmp(data->
GetName(),
"CAM", strlen(
"CAM"))) {
196 else if (!strcmpi(data->
GetName(),
"TARGET")) {
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];
232 if (!strcmpi(
"openram", p_str)) {
235 else if (!strcmpi(
"opendisk", p_str)) {
238 else if (!strcmpi(
"close", p_str)) {
241 else if (!strcmpi(
"start", p_str)) {
244 else if (!strcmpi(
"stop", p_str)) {
247 else if (!strcmpi(
"run", p_str)) {
250 else if (!strcmpi(
"exit", p_str)) {
253 else if (!strcmpi(
"enable", p_str)) {
256 else if (!strcmpi(
"disable", p_str)) {
259 else if (!strcmpi(
"notify", p_str)) {
277 switch (p_actionId) {
319 _spawnl(0,
"\\lego\\sources\\main\\main.exe",
"\\lego\\sources\\main\\main.exe",
"/script", &p_pAtom, 0);
337 assert(
"Invalid Action Control" ==
NULL);
363 if (entity ==
NULL) {
367 while (cursor.
Next(world)) {
370 if (entity !=
NULL) {
376 if (entity !=
NULL) {
388void ConvertHSVToRGB(
float p_h,
float p_s,
float p_v,
float* p_rOut,
float* p_bOut,
float* p_gOut)
400 calc = (1.0f - p_v) * p_s + p_v;
403 calc = (p_v + 1.0) * sDbl;
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;
466 result = world->
Notify(param);
505 if (!object->
IsA(
"MxPresenter")) {
529 MxCore*
object = world->
Find(p_entityAtom, p_entityId);
534 if (!object->
IsA(
"MxPresenter")) {
588 if (unk0x18 != 10 && unk0x18 != 8 && unk0x18 != 3) {
604 if (p_increase > 0) {
606 if (lightPosition > 5) {
612 if (lightPosition < 0) {
619 char lightPositionBuffer[32];
620 sprintf(lightPositionBuffer,
"%d", lightPosition);
624 return lightPosition;
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}
650 else if (p_index > 5) {
654 direction = lights[p_index];
655 position = &lights[p_index][3];
674 if (texture !=
NULL) {
681 if (namedTexture ==
NULL) {
695 if (textureInfo !=
NULL) {
700 memset(&desc, 0,
sizeof(desc));
701 desc.
dwSize =
sizeof(desc);
715 memcpy(surface, bits, desc.
dwWidth);
723 PALETTEENTRY entries[256];
727 if (entries[i].peFlags != 0) {
731 paletteEntries[i].
SetRed(entries[i].peRed);
732 paletteEntries[i].
SetGreen(entries[i].peGreen);
733 paletteEntries[i].
SetBlue(entries[i].peBlue);
740 memcpy(image->
GetPalette(), paletteEntries, i);
747 texture.
Write(p_storage);
772 if (textureInfo !=
NULL) {
[AI] Holds state and transient gameplay data for the first act on Lego Island.
MxU32 GetUnknown18()
[AI] Retrieves the internal state variable at offset 0x018 (purpose: current major state,...
[AI] Represents a bounding sphere in 3D space with center and radius.
const float & Radius() const
[AI] Const accessor for the sphere radius.
const Vector3 & Center() const
[AI] Const accessor for the center of the sphere.
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.
BOOL Moved(ViewROI &rROI)
[AI] Notifies the view that a ViewROI has moved.
ViewROI * Pick(unsigned long x, unsigned long y)
[AI] Picks (selects) a ViewROI in the scene by screen-space coordinates.
[AI] Holds per-node animation data for a model's animation tree.
LegoResult CreateLocalTransform(LegoFloat p_time, Matrix4 &p_matrix)
[AI] Computes the interpolated local transformation matrix for this node at the given animation time.
LegoChar * GetName()
[AI] Name of this animation node (used for lookup/mapping to scene graph).
[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.
[AI] Represents an entity that can be placed and managed in the LEGO Island world.
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...
void SetCount(LegoU32 p_count)
[AI] Sets the palette color count (number of valid entries in m_palette).
LegoU8 * GetBits()
[AI] Returns pointer to the buffer containing indexed pixel data.
LegoPaletteEntry * GetPalette()
[AI] Returns the pointer to the start of the palette array (256 entries).
[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.
[AI] Represents a single entry in an 8-bit RGB palette with red, green, and blue components.
void SetBlue(LegoU8 p_blue)
[AI] Sets the blue color intensity.
void SetGreen(LegoU8 p_green)
[AI] Sets the green color intensity.
void SetRed(LegoU8 p_red)
[AI] Sets the red color intensity.
[AI] An actor that moves along a predefined path, supporting boundary transitions,...
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.
LegoEntity * GetEntity()
[AI] Gets the entity associated with this ROI (or NULL).
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...
LegoStorage * ReadMxString(MxString &p_data)
Reads a length-prefixed string and stores it in an MxString object.
LegoStorage * WriteMxString(MxString p_data)
Writes a length-prefixed MxString to storage.
[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.
LegoResult Read(LegoStorage *p_storage, LegoU32 p_square)
[AI] Reads texture data from a LegoStorage.
LegoImage * GetImage()
[AI] Returns the associated image used by this texture.
LegoResult Write(LegoStorage *p_storage)
[AI] Writes texture data to a LegoStorage.
void SetImage(LegoImage *p_image)
[AI] Sets the associated image for this texture.
[AI] Represents a node within a general, N-ary tree structure.
LegoTreeNodeData * GetData()
[AI] Returns the data payload stored at this node (may be nullptr). [AI]
LegoU32 GetNumChildren()
[AI] Returns the number of direct children of this node. [AI]
LegoTreeNode * GetChild(LegoU32 p_i)
[AI] Gets the child node at the specified index (no bounds checking).
LegoTreeNode * GetRoot()
[AI] Returns a pointer to the root node of the tree. [AI]
[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.
Provides iteration access to a LegoWorldList.
Represents the active 3D world, holding all entity, animation, sound, path, and ROI objects.
void Remove(MxCore *p_object)
Removes an object from all relevant world-managed lists or sets, and also detaches if needed.
virtual void Enable(MxBool p_enable)
Enables or disables (pauses) the world and its main components.
MxCore * Find(const char *p_class, const char *p_name)
Finds an object of a given class and name in the world.
MxLong Notify(MxParam &p_param) override
Notification callback responding to registered events such as EndAction and NewPresenter.
4x4 Matrix class with virtual interface for manipulation and transformation.
virtual void SetIdentity()
Sets this matrix to identity (diagonal 1, others 0).
[AI] Represents a 3D point with floating-point precision, inheriting from Vector3.
[AI] Atomized (unique) string identifier, managed by reference counting.
const char * GetInternal() const
[AI] Returns a pointer to the internal string, or nullptr if not set.
[AI] Base virtual class for all Mindscape engine (Mx) objects.
virtual MxBool IsA(const char *p_name) const
[AI] Checks whether this object's class type or parents match the given name.
[AI] Represents an action deserialized from SI chunks, holding key animation or script parameters suc...
@ c_world
[AI] Action is described in world-space coordinates [AI]
virtual void SetAtomId(MxAtomId p_atomId)
[AI] Sets the atom id for this object instance, used for indexing or lookup.
void SetUnknown24(MxS16 p_unk0x24)
[AI] Sets the unknown field at 0x24 (possibly version/state).
void SetObjectId(MxU32 p_objectId)
[AI] Sets the object id (for serialization or lookup).
[AI] Represents a 4x4 transformation matrix, specialized for the LEGO Island engine and derived from ...
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.
[AI] Abstract base class for all presenter types in the LEGO Island engine, responsible for managing ...
MxStreamController * Open(const char *p_name, MxU16 p_openMode)
Open a stream, returning a controller for further access [AI].
MxLong Close(const char *p_name)
Close a named stream and remove its controller from the open list [AI].
@ e_diskStream
Load streaming resource from disk [AI].
@ e_RAMStream
Load streaming resource fully to RAM [AI].
Mindscape custom string class for managing dynamic C-strings within the game engine.
char * GetData() const
Returns a pointer to the internal character buffer.
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.
[AI] Represents a rendering viewport and drawing context.
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.
struct IDirectDrawSurface FAR * LPDIRECTDRAWSURFACE
#define DDLOCK_SURFACEMEMORYPTR
#define NULL
[AI] Null pointer value (C/C++ semantics).
unsigned long LegoU32
[AI] Unsigned 32-bit integer type for cross-platform compatibility.
unsigned char LegoU8
[AI] Unsigned 8-bit integer type used throughout LEGO Island.
#define SUCCESS
[AI] Used to indicate a successful operation in result codes.
void EnableAnimations(MxBool p_enable)
[AI] Enables or disables animation playback globally.
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.
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...
LegoNamedTexture * ReadNamedTexture(LegoStorage *p_storage)
[AI] Reads a named texture and its associated image data from storage.
MxBool TransformWorldToScreen(const MxFloat p_world[3], MxFloat p_screen[4])
[AI] Projects a world-space point into normalized screen coordinates.
MxBool CheckIfEntityExists(MxBool p_enable, const char *p_filename, MxS32 p_entityId)
[AI] Parses a string for entity existence and enables/disables it accordingly.
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...
LegoROI * PickROI(MxLong p_x, MxLong p_y)
[AI] Picks the ROI (Renderable Object Instance) at screen coordinates.
MxBool FUN_1003ef60()
[AI] Determines if the current actor can exit their area, based on state/zone/vehicle.
LegoTreeNode * GetTreeNode(LegoTreeNode *p_node, MxU32 p_index)
[AI] Retrieves the nth node in tree traversal order (preorder) from a LegoTreeNode root.
MxS32 UpdateLightPosition(MxS32 p_increase)
[AI] Steps or resets the in-game light position; wraps and saves in global variables; updates lightin...
void FUN_1003eda0()
[AI] Updates sound listener position to follow the view ROI's transform.
void SetCameraControllerFromIsle()
[AI] Updates the current camera controller to the main ISLE camera specified in the global script.
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).
LegoEntity * PickEntity(MxLong p_x, MxLong p_y)
[AI] Picks the LEGO entity root at the given screen coordinates.
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...
void NotifyEntity(const char *p_filename, MxS32 p_entityId, LegoEntity *p_sender)
[AI] Sends a notification to the specified entity in all known worlds.
void SetAppCursor(Cursor p_cursor)
[AI] Sets the in-game cursor to a specified type.
void RotateY(LegoROI *p_roi, MxFloat p_angle)
[AI] Rotates the given ROI around the Y axis in world space.
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.
void FUN_1003f930(LegoNamedTexture *p_namedTexture)
[AI] Applies the image bits of a named texture to its associated texture info container entry.
Extra::ActionType MatchActionString(const char *p_str)
[AI] Parses an action string to determine the corresponding action type.
MxS16 CountTotalTreeNodes(LegoTreeNode *p_node)
[AI] Recursively counts the number of nodes (including the root) in a tree hierarchy rooted at the sp...
void FUN_1003e050(LegoAnimPresenter *p_presenter)
[AI] Repositions the camera and updates the view matrix using a LegoAnimPresenter's animation nodes n...
MxBool SpheresIntersect(const BoundingSphere &p_sphere1, const BoundingSphere &p_sphere2)
[AI] Tests if two bounding spheres in the 3D world intersect.
void WriteDefaultTexture(LegoStorage *p_storage, const char *p_name)
[AI] Writes a default texture by name (and its image/palette) to storage for serialization.
void WriteNamedTexture(LegoStorage *p_storage, LegoNamedTexture *p_namedTexture)
[AI] Writes a LegoNamedTexture and its associated image to storage.
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.
void SetLightPosition(MxS32 p_index)
[AI] Sets the world space position and direction of the in-game directional light,...
#define DS_NOT_A_STREAM
[AI] Special stream ID indicating that the current stream is not valid.
#define WM_ISLE_SETCURSOR
[AI] Custom Windows message for setting the cursor in LEGO Island. Used with PostMessage....
Cursor
[AI] Enum representing cursor icons usable within the LEGO Island engine for custom cursor management...
MxAtomId * g_isleScript
[AI] Node used in hierarchical scene graphs and animation trees. [AI]
LegoGameState * GameState()
[AI] Accessor for the game's central game state controller. [AI]
LegoVideoManager * VideoManager()
[AI] Accessor for the game's LegoVideoManager subsystem. Used for managing 3D/video hardware....
LegoAnimationManager * AnimationManager()
[AI] Accessor for the animation manager, which controls Lego character/world animation state....
LegoSoundManager * SoundManager()
[AI] Accessor for the game's LegoSoundManager subsystem from the global LegoOmni instance....
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.
LegoWorld * CurrentWorld()
[AI] Accessor for the currently active LegoWorld instance. [AI]
LegoOmni * Lego()
[AI] Retrieves the global LegoOmni singleton instance, providing access to core subsystems.
LegoTextureContainer * TextureContainer()
[AI] Accessor for the texture container used for global texture management. [AI]
LegoPathActor * UserActor()
[AI] Accessor for the user (player-controllable) LegoPathActor. [AI]
LegoInputManager * InputManager()
[AI] Accessor for the input manager, which handles keyboard, mouse, and controller input....
@ e_lowerCase2
[AI] Alternative or legacy lower case mode, functionally equivalent to e_lowerCase.
MxResult Start(MxDSAction *p_dsAction)
[AI] Schedules and initiates execution of a script action.
MxVariableTable * VariableTable()
[AI] Returns the variable table used for script variables and global key/value state.
MxStreamer * Streamer()
[AI] Returns the global streamer used for all chunked media streaming (SI file, audio,...
void DeleteObject(MxDSAction &p_dsAction)
[AI] Deletes the specified action object, removing it from the global action list.
MxNotificationManager * NotificationManager()
[AI] Returns the notification manager for system-wide state/update notifications.
@ c_notificationType0
[AI] Undefined/Generic notification type [AI]
@ c_notificationPathStruct
[AI] Data related to a path structure [AI]
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.
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.
[AI] Contains global script AtomId pointers and utility functions for managing script AtomIds in LEGO...
#define SETMAT4(to, from)