Isle
Loading...
Searching...
No Matches
legoutils.h File Reference
#include "actionsfwd.h"
#include "decomp.h"
#include "extra.h"
#include "mxtypes.h"
#include <windows.h>
Include dependency graph for legoutils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define WM_ISLE_SETCURSOR   0x5400
 [AI] Custom Windows message for setting the cursor in LEGO Island. Used with PostMessage. [AI] More...
 
#define DS_NOT_A_STREAM   -1
 [AI] Special stream ID indicating that the current stream is not valid. More...
 

Enumerations

enum  Cursor {
  e_cursorArrow = 0 , e_cursorBusy , e_cursorNo , e_cursorUnused3 ,
  e_cursorUnused4 , e_cursorUnused5 , e_cursorUnused6 , e_cursorUnused7 ,
  e_cursorUnused8 , e_cursorUnused9 , e_cursorUnused10 , e_cursorNone
}
 [AI] Enum representing cursor icons usable within the LEGO Island engine for custom cursor management. More...
 

Functions

LegoEntityPickEntity (MxLong p_x, MxLong p_y)
 [AI] Picks the LEGO entity root at the given screen coordinates. More...
 
LegoROIPickROI (MxLong p_x, MxLong p_y)
 [AI] Picks the ROI (Renderable Object Instance) at screen coordinates. More...
 
LegoROIPickRootROI (MxLong p_x, MxLong p_y)
 [AI] Picks the root ROI at the given screen coordinates by traversing up the ROI parent tree. More...
 
void RotateY (LegoROI *p_roi, MxFloat p_angle)
 [AI] Rotates the given ROI around the Y axis in world space. More...
 
MxBool SpheresIntersect (const BoundingSphere &p_sphere1, const BoundingSphere &p_sphere2)
 [AI] Tests if two bounding spheres in the 3D world intersect. More...
 
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. More...
 
MxBool TransformWorldToScreen (const MxFloat p_world[3], MxFloat p_screen[4])
 [AI] Projects a world-space point into normalized screen coordinates. More...
 
MxS16 CountTotalTreeNodes (LegoTreeNode *p_node)
 [AI] Recursively counts the number of nodes (including the root) in a tree hierarchy rooted at the specified LegoTreeNode. More...
 
LegoTreeNodeGetTreeNode (LegoTreeNode *p_node, MxU32 p_index)
 [AI] Retrieves the nth node in tree traversal order (preorder) from a LegoTreeNode root. More...
 
void FUN_1003e050 (LegoAnimPresenter *p_presenter)
 [AI] Repositions the camera and updates the view matrix using a LegoAnimPresenter's animation nodes named "CAM" and "TARGET". More...
 
Extra::ActionType MatchActionString (const char *)
 [AI] Parses an action string to determine the corresponding action type. More...
 
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. More...
 
void SetCameraControllerFromIsle ()
 [AI] Updates the current camera controller to the main ISLE camera specified in the global script. More...
 
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). More...
 
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 triggers. More...
 
void FUN_1003eda0 ()
 [AI] Updates sound listener position to follow the view ROI's transform. More...
 
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 EndAction or deletes it. More...
 
void EnableAnimations (MxBool p_enable)
 [AI] Enables or disables animation playback globally. More...
 
void SetAppCursor (Cursor p_cursor)
 [AI] Sets the in-game cursor to a specified type. More...
 
MxBool FUN_1003ef60 ()
 [AI] Determines if the current actor can exit their area, based on state/zone/vehicle. More...
 
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 EndActions. More...
 
MxS32 UpdateLightPosition (MxS32 p_increase)
 [AI] Steps or resets the in-game light position; wraps and saves in global variables; updates lighting matrix. More...
 
void SetLightPosition (MxS32 p_index)
 [AI] Sets the world space position and direction of the in-game directional light, based on a preset index. More...
 
LegoNamedTextureReadNamedTexture (LegoStorage *p_storage)
 [AI] Reads a named texture and its associated image data from storage. More...
 
void WriteDefaultTexture (LegoStorage *p_storage, const char *p_name)
 [AI] Writes a default texture by name (and its image/palette) to storage for serialization. More...
 
void WriteNamedTexture (LegoStorage *p_storage, LegoNamedTexture *p_namedTexture)
 [AI] Writes a LegoNamedTexture and its associated image to storage. More...
 
void FUN_1003f930 (LegoNamedTexture *p_namedTexture)
 [AI] Applies the image bits of a named texture to its associated texture info container entry. More...
 
MxBool CheckIfEntityExists (MxBool p_enable, const char *p_filename, MxS32 p_entityId)
 [AI] Parses a string for entity existence and enables/disables it accordingly. More...
 
void NotifyEntity (const char *p_filename, MxS32 p_entityId, LegoEntity *p_sender)
 [AI] Sends a notification to the specified entity in all known worlds. More...
 
void StartIsleAction (IsleScript::Script p_objectId)
 [AI] Helper to invoke a 'start' action for an Isle script object by its script ID. More...
 

Variables

MxAtomIdg_isleScript
 [AI] Node used in hierarchical scene graphs and animation trees. [AI] More...
 

Macro Definition Documentation

◆ DS_NOT_A_STREAM

#define DS_NOT_A_STREAM   -1

[AI] Special stream ID indicating that the current stream is not valid.

Used to check against invalid stream references. [AI]

Definition at line 16 of file legoutils.h.

◆ WM_ISLE_SETCURSOR

#define WM_ISLE_SETCURSOR   0x5400

[AI] Custom Windows message for setting the cursor in LEGO Island. Used with PostMessage. [AI]

Definition at line 11 of file legoutils.h.

Enumeration Type Documentation

◆ Cursor

enum Cursor

[AI] Enum representing cursor icons usable within the LEGO Island engine for custom cursor management.

[AI]

Enumerator
e_cursorArrow 

[AI] Standard arrow cursor. [AI]

e_cursorBusy 

[AI] Busy or loading cursor (e.g., hourglass). [AI]

e_cursorNo 

[AI] 'Not allowed' cursor. [AI]

e_cursorUnused3 

[AI] Reserved slot. Not used. [AI]

e_cursorUnused4 

[AI] Reserved slot. Not used. [AI]

e_cursorUnused5 

[AI] Reserved slot. Not used. [AI]

e_cursorUnused6 

[AI] Reserved slot. Not used. [AI]

e_cursorUnused7 

[AI] Reserved slot. Not used. [AI]

e_cursorUnused8 

[AI] Reserved slot. Not used. [AI]

e_cursorUnused9 

[AI] Reserved slot. Not used. [AI]

e_cursorUnused10 

[AI] Reserved slot. Not used. [AI]

e_cursorNone 

[AI] No cursor (invisible or hidden). [AI]

Definition at line 22 of file legoutils.h.

Function Documentation

◆ CheckIfEntityExists()

MxBool CheckIfEntityExists ( MxBool  p_enable,
const char *  p_filename,
MxS32  p_entityId 
)

[AI] Parses a string for entity existence and enables/disables it accordingly.

[AI]

Parameters
p_enableEnable or disable the entity. [AI]
p_filenameEntity resource filename to search. [AI]
p_entityIdTarget entity identifier within the world. [AI]
Returns
TRUE if entity was found and enabled/disabled, otherwise FALSE. [AI]

Definition at line 343 of file legoutils.cpp.

◆ ConvertHSVToRGB()

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).

[AI]

Parameters
p_hHue, float in [0,1]. [AI]
p_sSaturation, float in [0,1]. [AI]
p_vValue, float in [0,1]. [AI]
p_rOutOutput pointer for red result. [AI]
p_bOutOutput pointer for blue result. [AI]
p_gOutOutput pointer for green result. [AI]

Definition at line 388 of file legoutils.cpp.

◆ CountTotalTreeNodes()

MxS16 CountTotalTreeNodes ( LegoTreeNode p_node)

[AI] Recursively counts the number of nodes (including the root) in a tree hierarchy rooted at the specified LegoTreeNode.

[AI]

Parameters
p_nodeRoot node to start counting from. [AI]
Returns
Number of tree nodes including root. [AI]

Definition at line 138 of file legoutils.cpp.

◆ EnableAnimations()

void EnableAnimations ( MxBool  p_enable)

[AI] Enables or disables animation playback globally.

Triggers resume and additional handler methods. [AI]

Parameters
p_enableEnable/disable flag for animations. [AI]

Definition at line 554 of file legoutils.cpp.

◆ FUN_1003ded0()

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.

[AI]

Parameters
p_param1Screen coordinates (x, y). [AI]
p_param2Output world-space ray direction (length 3). [AI]
p_param3Output world-space ray origin (length 3). [AI]
Returns
TRUE always. [AI]

Definition at line 102 of file legoutils.cpp.

◆ FUN_1003e050()

void FUN_1003e050 ( LegoAnimPresenter p_presenter)

[AI] Repositions the camera and updates the view matrix using a LegoAnimPresenter's animation nodes named "CAM" and "TARGET".

[AI]

Parameters
p_presenterAnimation presenter used to locate camera and target. [AI]

Definition at line 176 of file legoutils.cpp.

◆ FUN_1003eda0()

void FUN_1003eda0 ( )

[AI] Updates sound listener position to follow the view ROI's transform.

[AI]

Definition at line 476 of file legoutils.cpp.

◆ FUN_1003ef60()

MxBool FUN_1003ef60 ( )

[AI] Determines if the current actor can exit their area, based on state/zone/vehicle.

[AI]

Returns
TRUE if allowed to leave the area, FALSE otherwise. [AI]

Definition at line 572 of file legoutils.cpp.

◆ FUN_1003f930()

void FUN_1003f930 ( LegoNamedTexture p_namedTexture)

[AI] Applies the image bits of a named texture to its associated texture info container entry.

[AI]

Parameters
p_namedTextureTarget named texture whose data will be uploaded. [AI]

Definition at line 768 of file legoutils.cpp.

◆ GetTreeNode()

LegoTreeNode * GetTreeNode ( LegoTreeNode p_node,
MxU32  p_index 
)

[AI] Retrieves the nth node in tree traversal order (preorder) from a LegoTreeNode root.

[AI]

Parameters
p_nodeRoot node to start searching from. [AI]
p_indexThe 0-based index into the tree traversal. [AI]
Returns
The LegoTreeNode pointer if found, otherwise NULL. [AI]

Definition at line 151 of file legoutils.cpp.

◆ InvokeAction()

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.

[AI]

Parameters
p_actionIdType of action to invoke. [AI]
p_pAtomID of the target script/entity. [AI]
p_streamIdAssociated stream ID for the action (if applicable). [AI]
p_senderOptional pointer to the sender entity (can be NULL). [AI]

Definition at line 271 of file legoutils.cpp.

◆ MatchActionString()

Extra::ActionType MatchActionString ( const char *  p_str)

[AI] Parses an action string to determine the corresponding action type.

[AI]

Parameters
StrNull-terminated string to evaluate. [AI]
Returns
Matching action type. [AI]

Definition at line 228 of file legoutils.cpp.

◆ NotifyEntity()

void NotifyEntity ( const char *  p_filename,
MxS32  p_entityId,
LegoEntity p_sender 
)

[AI] Sends a notification to the specified entity in all known worlds.

[AI]

Parameters
p_filenameEntity resource filename. [AI]
p_entityIdID of the target entity. [AI]
p_senderSender entity reference, may be NULL. [AI]

Definition at line 358 of file legoutils.cpp.

◆ PickEntity()

LegoEntity * PickEntity ( MxLong  p_x,
MxLong  p_y 
)

[AI] Picks the LEGO entity root at the given screen coordinates.

[AI]

Parameters
p_xX screen coordinate. [AI]
p_yY screen coordinate. [AI]
Returns
Pointer to LegoEntity at the location (or nullptr if none). [AI]

Definition at line 62 of file legoutils.cpp.

◆ PickROI()

LegoROI * PickROI ( MxLong  p_x,
MxLong  p_y 
)

[AI] Picks the ROI (Renderable Object Instance) at screen coordinates.

[AI]

Parameters
p_xX screen coordinate. [AI]
p_yY screen coordinate. [AI]
Returns
Pointer to LegoROI at the location (or nullptr if none). [AI]

Definition at line 39 of file legoutils.cpp.

◆ PickRootROI()

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.

[AI]

Parameters
p_xX screen coordinate. [AI]
p_yY screen coordinate. [AI]
Returns
Pointer to the root LegoROI (or nullptr if none). [AI]

Definition at line 48 of file legoutils.cpp.

◆ PlayCamAnim()

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 triggers.

[AI]

Parameters
p_actorPath actor to play camera animation for. [AI]
p_unusedNot used in logic (placeholder for extended parameters). [AI]
p_locationCamera location index/ID. [AI]
p_boolBoolean flag, often controlling secondary behavior. [AI]

Definition at line 459 of file legoutils.cpp.

◆ ReadNamedTexture()

LegoNamedTexture * ReadNamedTexture ( LegoStorage p_storage)

[AI] Reads a named texture and its associated image data from storage.

[AI]

Parameters
p_storageSource storage for reading (disk or memory representation). [AI]
Returns
Pointer to allocated LegoNamedTexture, or NULL if failed. [AI]

Definition at line 665 of file legoutils.cpp.

◆ RemoveFromCurrentWorld()

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 EndAction or deletes it.

[AI]

Parameters
p_atomIdAtomId of the object to remove. [AI]
p_idObject identifier within the world. [AI]
Returns
TRUE if object was found and removed, FALSE otherwise. [AI]

Definition at line 495 of file legoutils.cpp.

◆ RemoveFromWorld()

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 EndActions.

[AI]

Parameters
p_entityAtomAtomId for the target object. [AI]
p_entityIdID for the target object. [AI]
p_worldAtomAtomId for the world containing the object. [AI]
p_worldEntityIdID for the world. [AI]
Returns
TRUE if removed, FALSE otherwise. [AI]

Definition at line 524 of file legoutils.cpp.

◆ RotateY()

void RotateY ( LegoROI p_roi,
MxFloat  p_angle 
)

[AI] Rotates the given ROI around the Y axis in world space.

[AI]

Parameters
p_roiROI to rotate. [AI]
p_angleAngle in radians. [AI]

Definition at line 75 of file legoutils.cpp.

◆ SetAppCursor()

void SetAppCursor ( Cursor  p_cursor)

[AI] Sets the in-game cursor to a specified type.

[AI]

Parameters
p_cursorCursor enum value (e.g., arrow, busy, none). [AI]

Definition at line 566 of file legoutils.cpp.

◆ SetCameraControllerFromIsle()

void SetCameraControllerFromIsle ( )

[AI] Updates the current camera controller to the main ISLE camera specified in the global script.

[AI]

Definition at line 382 of file legoutils.cpp.

◆ SetLightPosition()

void SetLightPosition ( MxS32  p_index)

[AI] Sets the world space position and direction of the in-game directional light, based on a preset index.

[AI]

Parameters
p_indexLighting index (clamped to valid range). [AI]

Definition at line 628 of file legoutils.cpp.

◆ SpheresIntersect()

MxBool SpheresIntersect ( const BoundingSphere p_sphere1,
const BoundingSphere p_sphere2 
)

[AI] Tests if two bounding spheres in the 3D world intersect.

[AI]

Parameters
p_sphere1First bounding sphere for intersection. [AI]
p_sphere2Second bounding sphere for intersection. [AI]

Definition at line 93 of file legoutils.cpp.

◆ StartIsleAction()

void StartIsleAction ( IsleScript::Script  p_objectId)
inline

[AI] Helper to invoke a 'start' action for an Isle script object by its script ID.

[AI]

Parameters
p_objectIdIsleScript script object identifier. [AI]

Definition at line 268 of file legoutils.h.

◆ TransformWorldToScreen()

MxBool TransformWorldToScreen ( const MxFloat  p_world[3],
MxFloat  p_screen[4] 
)

[AI] Projects a world-space point into normalized screen coordinates.

[AI]

Parameters
p_worldInput world coordinates (length 3). [AI]
p_screenOutput screen coordinates (length 4 for homogeneous coordinates). [AI]
Returns
TRUE always. [AI]

Definition at line 130 of file legoutils.cpp.

◆ UpdateLightPosition()

MxS32 UpdateLightPosition ( MxS32  p_increase)

[AI] Steps or resets the in-game light position; wraps and saves in global variables; updates lighting matrix.

[AI]

Parameters
p_increaseIncrements light position if positive; decrements otherwise. [AI]
Returns
Updated light position index. [AI]

Definition at line 599 of file legoutils.cpp.

◆ WriteDefaultTexture()

void WriteDefaultTexture ( LegoStorage p_storage,
const char *  p_name 
)

[AI] Writes a default texture by name (and its image/palette) to storage for serialization.

[AI]

Parameters
p_storageTarget storage for writing. [AI]
p_nameName of the texture/resource to write. [AI]

Definition at line 690 of file legoutils.cpp.

◆ WriteNamedTexture()

void WriteNamedTexture ( LegoStorage p_storage,
LegoNamedTexture p_namedTexture 
)

[AI] Writes a LegoNamedTexture and its associated image to storage.

[AI]

Parameters
p_storageTarget storage for writing. [AI]
p_namedTexturePointer to the LegoNamedTexture to serialize. [AI]

Definition at line 761 of file legoutils.cpp.

Variable Documentation

◆ g_isleScript

MxAtomId* g_isleScript
extern

[AI] Node used in hierarchical scene graphs and animation trees. [AI]

[AI] Global script identifier for the main Isle game script resource. [AI]

Definition at line 32 of file scripts.cpp.