29 {
"lego black", 0x21, 0x21, 0x21, 0}, {
"lego black f", 0x21, 0x21, 0x21, 0},
30 {
"lego black flat", 0x21, 0x21, 0x21, 0}, {
"lego blue", 0x00, 0x54, 0x8c, 0},
31 {
"lego blue flat", 0x00, 0x54, 0x8c, 0}, {
"lego brown", 0x4a, 0x23, 0x1a, 0},
32 {
"lego brown flt", 0x4a, 0x23, 0x1a, 0}, {
"lego brown flat", 0x4a, 0x23, 0x1a, 0},
33 {
"lego drk grey", 0x40, 0x40, 0x40, 0}, {
"lego drk grey flt", 0x40, 0x40, 0x40, 0},
34 {
"lego dk grey flt", 0x40, 0x40, 0x40, 0}, {
"lego green", 0x00, 0x78, 0x2d, 0},
35 {
"lego green flat", 0x00, 0x78, 0x2d, 0}, {
"lego lt grey", 0x82, 0x82, 0x82, 0},
36 {
"lego lt grey flt", 0x82, 0x82, 0x82, 0}, {
"lego lt grey fla", 0x82, 0x82, 0x82, 0},
37 {
"lego red", 0xcb, 0x12, 0x20, 0}, {
"lego red flat", 0xcb, 0x12, 0x20, 0},
38 {
"lego white", 0xfa, 0xfa, 0xfa, 0}, {
"lego white flat", 0xfa, 0xfa, 0xfa, 0},
39 {
"lego yellow", 0xff, 0xb9, 0x00, 0}, {
"lego yellow flat", 0xff, 0xb9, 0x00, 0},
52const char*
g_unk0x10101390[] = {
"rcuser",
"jsuser",
"dunebugy",
"chtrblad",
"chtrbody",
"chtrshld",
NULL};
91 CompoundObject::iterator iterator;
93 for (iterator =
comp->begin(); !(iterator ==
comp->end()); ++iterator) {
94 ROI* child = *iterator;
131 if (p_storage->
Read(&length,
sizeof(length)) !=
SUCCESS) {
138 m_name[length] =
'\0';
156 if (p_storage->
Read(&length,
sizeof(length)) !=
SUCCESS) {
161 textureName =
new LegoChar[length + 1];
162 if (p_storage->
Read(textureName, length) !=
SUCCESS) {
165 textureName[length] =
'\0';
172 if (p_storage->
Read(&m_unk0x100,
sizeof(m_unk0x100)) !=
SUCCESS) {
177 for (roiLength = strlen(m_name); roiLength; roiLength--) {
178 if (m_name[roiLength - 1] <
'0' || m_name[roiLength - 1] >
'9') {
183 roiName =
new LegoChar[roiLength + 1];
184 memcpy(roiName, m_name, roiLength);
185 roiName[roiLength] =
'\0';
187 lodList = p_viewLODListManager->
Lookup(roiName);
190 if (lodList ==
NULL) {
195 if (p_storage->
Read(&numLODs,
sizeof(numLODs)) !=
SUCCESS) {
206 if (p_storage->
Read(&offset,
sizeof(offset)) !=
SUCCESS) {
235 if ((lodList = p_viewLODListManager->
Lookup(roiName))) {
243 while (lodList->
Size()) {
247 for (j = 0; j < numLODs; j++) {
249 if (lod->
Read(p_renderer, p_textureContainer, p_storage) !=
SUCCESS) {
264 for (i = 0; i < numLODs; i++) {
266 if (lod->
Read(p_renderer, p_textureContainer, p_storage) !=
SUCCESS) {
276 if (i == 0 && (lodList = p_viewLODListManager->
Create(roiName, numLODs)) ==
NULL) {
290 if (lodList !=
NULL) {
294 if (textureName !=
NULL) {
295 if (!strnicmp(textureName,
"t_", 2)) {
296 textureInfo = p_textureContainer->
Get(textureName + 2);
298 if (textureInfo ==
NULL) {
315 if (p_storage->
Read(&numROIs,
sizeof(numROIs)) !=
SUCCESS) {
323 for (i = 0; i < numROIs; i++) {
326 if (roi->
Read(
this, p_renderer, p_viewLODListManager, p_textureContainer, p_storage) !=
SUCCESS) {
330 comp->push_back(roi);
351 CompoundObject::iterator it;
354 if (name !=
NULL && *name !=
'\0' && !strcmpi(name, p_name)) {
360 for (it =
comp->begin(); it !=
comp->end(); it++) {
364 if (name !=
NULL && *name !=
'\0' && !strcmpi(name, p_name)) {
369 for (it =
comp->begin(); it !=
comp->end(); it++) {
435 local2world.
Product(mat, p_matrix);
462 local2world.
Product(mat, p_matrix);
487 CompoundObject::iterator it;
490 for (
LegoU32 i = 0; i < lodCount; i++) {
499 for (it =
comp->begin(); it !=
comp->end(); it++) {
500 if (((
LegoROI*) *it)->SetLodColor(p_red, p_green, p_blue, p_alpha) !=
SUCCESS) {
513 CompoundObject::iterator it;
516 for (
LegoU32 i = 0; i < lodCount; i++) {
525 for (it =
comp->begin(); it !=
comp->end(); it++) {
539 CompoundObject::iterator it;
542 for (
LegoU32 i = 0; i < lodCount; i++) {
551 for (it =
comp->begin(); it !=
comp->end(); it++) {
565 return SetLodColor(p_red, p_green, p_blue, p_alpha);
572 MxFloat red, green, blue, alpha;
584 MxFloat red, green, blue, alpha;
623 localc0[3] = local9c[3] = local168[3] = 1.0f;
641 for (i = 0; i < 6; i++) {
645 local150[i][3] = -local58.
Dot(local58, local150[i]);
648 local150[i][3] = -locala8.
Dot(locala8, local150[i]);
651 if (local150[i][3] + local38.
Dot(local38, local150[i]) < 0.0f) {
652 local150[i] *= -1.0f;
656 for (i = 0; i < 6; i++) {
657 float local50 = p_v2.
Dot(p_v2, local150[i]);
659 if (local50 >= 0.01 || local50 < -0.01) {
660 local50 = -((local150[i][3] + local4c.
Dot(local4c, local150[i])) / local50);
662 if (local50 >= 0.0f && local50 <= p_f1) {
668 for (j = 0; j < 6; j++) {
669 if (i != j && i - j != 3 && j - i != 3) {
670 if (local150[j][3] + local17c.
Dot(local17c, local150[j]) < 0.0f) {
688 float local8 = p_v2.
Dot(p_v2, p_v2);
689 float localc = p_v2.
Dot(p_v2, v1) * 2.0f;
690 float local14 = v1.
Dot(v1, v1) - (local10 * local10);
692 if (local8 >= 0.001 || local8 <= -0.001) {
693 float local1c = -1.0f;
694 float local18 = (localc * localc) - (local14 * local8 * 4.0f);
696 if (local18 >= -0.001) {
700 if (local18 > 0.0f) {
701 local18 = sqrt(local18);
702 float local184 = (localc + local18) / local8;
703 float local188 = (localc - local18) / local8;
705 if (local184 > 0.0f && local188 > local184) {
708 else if (local188 > 0.0f) {
716 local1c = localc / local8;
719 if (local1c >= 0.0f && p_f1 >= local1c) {
750 targetPosition -= vec;
751 targetPosition /= time / 1000.0;
760 if (p_name ==
NULL) {
764 char p_updatedName[32];
767 p_name = p_updatedName;
794 if (p_name ==
NULL) {
803 paletteEntries[0] =
'\0';
816 if (m_name !=
NULL) {
820 if (p_name !=
NULL) {
821 m_name =
new LegoChar[strlen(p_name) + 1];
822 strcpy(m_name, p_name);
835 for (
LegoS32 i = 0; i < lodCount; i++) {
const Vector3 & Min() const
[AI] Const accessor for the minimum corner of the bounding box.
const Vector3 & Max() const
[AI] Const accessor for the maximum corner of the bounding box.
const float & Radius() const
[AI] Const accessor for the sphere radius.
const Vector3 & Center() const
[AI] Const accessor for the center of the sphere.
size_t Size() const
[AI] Returns the current number of LODObject pointers contained.
const T * PushBack(const T *)
[AI] Typed append.
const T * PopBack()
[AI] Typed remove.
[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.
LegoBool FUN_100a0990(LegoFloat p_time)
[AI] Evaluates morph keys at the given animation time and returns result (typically affects mesh shap...
LegoU16 GetUnknown0x20()
[AI] Unknown, used in scene/camera calculations (purpose unclear).
LegoChar * GetName()
[AI] Name of this animation node (used for lookup/mapping to scene graph).
[AI] Root class for all node-based animation blending/structure.
[AI] Represents an axis-aligned 3D bounding box, defined by minimum and maximum corners.
LegoResult Read(LegoStorage *p_storage)
[AI] Reads the bounding box data from a LegoStorage stream.
LegoVertex & GetMax()
[AI] Returns a reference to the maximum vertex of the box.
LegoVertex & GetMin()
[AI] Returns a reference to the minimum vertex of the box.
T * Get(const char *p_name)
Retrieve the element mapped to the given name, or nullptr if missing.
[AI] Level-Of-Detail (LOD) object used for rendering and managing polygonal mesh data with LOD switch...
void ClearMeshOffset()
[AI] Reset mesh offset index to start at 0, affecting which meshes are updated by future color/textur...
LegoResult SetTextureInfo(LegoTextureInfo *p_textureInfo)
[AI] Assigns the same texture group to all textured meshes in this LOD.
LegoResult SetColor(LegoFloat p_red, LegoFloat p_green, LegoFloat p_blue, LegoFloat p_alpha)
[AI] Overrides the color of all non-textured mesh parts for this LOD.
LegoResult GetTextureInfo(LegoTextureInfo *&p_textureInfo)
[AI] Retrieves the texture info/group of the first mesh with group texture in this LOD.
LegoResult Read(Tgl::Renderer *p_renderer, LegoTextureContainer *p_textureContainer, LegoStorage *p_storage)
[AI] Load LOD geometry and material info from storage, building Tgl::Mesh group(s).
[AI] Represents a Real-time Object Instance enriched with LEGO-specific functionality.
LegoResult FUN_100a8da0(LegoTreeNode *p_node, const Matrix4 &p_matrix, LegoTime p_time, LegoROI *p_roi)
[AI] [Unknown function.
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.
LegoResult FUN_100a93b0(const LegoChar *p_name)
[AI] Like SetLodColor, but uses a different implementation or legacy style.
static void FUN_100a8e80(LegoTreeNode *p_node, Matrix4 &p_matrix, LegoTime p_time, LegoROI **p_roiMap)
[AI] [Static] Recursively evaluates animation nodes, updating the transformation matrices and visibil...
~LegoROI() override
[AI] Destroys the LegoROI, cleaning up children and name resources.
static void configureLegoROI(int p_roi)
[AI] [Static] Configures the global ROI loading limit, controlling max LODs at load time.
LegoResult GetTextureInfo(LegoTextureInfo *&p_textureInfo)
[AI] Attempts to retrieve a texture info pointer used by any LOD in this ROI or its children.
LegoROI(Tgl::Renderer *p_renderer)
[AI] Constructs a new LegoROI for a given renderer.
LegoResult SetTextureInfo(LegoTextureInfo *p_textureInfo)
[AI] Associates every LOD in this ROI (and sub-ROIs) with a given texture (palette/material informati...
static void SetColorOverride(ColorOverride p_colorOverride)
[AI] [Static] Sets the global color override callback function to allow palette remapping or customiz...
LegoROI * FindChildROI(const LegoChar *p_name, LegoROI *p_roi)
[AI] Recursively searches for a child ROI by name, starting at the given ROI.
void ClearMeshOffset()
[AI] Resets mesh offset for all LODs in this ROI.
static LegoResult FUN_100a8cb0(LegoAnimNodeData *p_data, LegoTime p_time, Matrix4 &p_matrix)
[AI] [Static] Sets the transform matrix for a given animation node at a specific time.
LegoResult FUN_100a9330(LegoFloat p_red, LegoFloat p_green, LegoFloat p_blue, LegoFloat p_alpha)
[AI] Alias to SetLodColor; applies color to all LODs and children.
LegoResult SetFrame(LegoAnim *p_anim, LegoTime p_time)
[AI] Sets the current animation frame for this ROI based on a parsed animation structure.
static LegoBool ColorAliasLookup(const LegoChar *p_param, float &p_red, float &p_green, float &p_blue, float &p_alpha)
[AI] [Static] Looks up a color alias in the static alias table and sets p_red/p_green/p_blue/p_alpha ...
void UpdateWorldBoundingVolumes() override
[AI] Updates this ROI's world-space bounding volumes based on its local-to-world transform.
LegoResult SetLodColor(LegoFloat p_red, LegoFloat p_green, LegoFloat p_blue, LegoFloat p_alpha)
[AI] Sets the RGBA color for all LODs and recursively for all children.
static void FUN_100a8fd0(LegoTreeNode *p_node, Matrix4 &p_matrix, LegoTime p_time, LegoROI **p_roiMap)
[AI] [Static] Similar to FUN_100a8e80, but only updates transformation matrices, not visibility or in...
static void FUN_100a81b0(const LegoChar *p_error, const LegoChar *p_name)
[AI] [Static] Prints or logs an error message about missing ROI for animation (no-op in release).
static LegoBool GetPaletteEntries(const LegoChar *p_name, unsigned char *paletteEntries, LegoU32 p_numEntries)
[AI] [Static] Fetches palette entries for a named texture using current texture handler.
float IntrinsicImportance() const override
[AI] Returns the importance rating for LOD/visibility management (fixed value).
LegoResult Read(OrientableROI *p_unk0xd4, Tgl::Renderer *p_renderer, ViewLODListManager *p_viewLODListManager, LegoTextureContainer *p_textureContainer, LegoStorage *p_storage)
[AI] Reads and initializes this ROI from a LEGO project resource stream, populating geometry,...
void SetDisplayBB(int p_displayBB)
[AI] Sets whether to display or hide the bounding box.
const LegoChar * GetName() const
[AI] Gets this ROI's name.
void SetName(const LegoChar *p_name)
[AI] Sets this ROI's name, replacing the previous (converted to lower-case).
static LegoBool GetRGBAColor(const LegoChar *p_name, float &p_red, float &p_green, float &p_blue, float &p_alpha)
[AI] [Static] Resolves a logical color alias into RGBA floats.
[AI] Represents a sphere in 3D space, used for bounding volume calculations and spatial queries.
LegoFloat GetRadius()
[AI] Retrieves the current radius of the sphere.
LegoVertex & GetCenter()
[AI] Returns a reference to the center vertex of the sphere.
LegoResult Read(LegoStorage *p_storage)
[AI] Reads the center and radius of the sphere from a binary storage source.
Abstract base class providing an interface for file-like storage with binary and text read/write oper...
virtual LegoResult SetPosition(LegoU32 p_position)=0
Set current read/write position in stream.
virtual LegoResult Read(void *p_buffer, LegoU32 p_size)=0
Read bytes from storage into buffer.
Specialized LegoContainer handling LegoTextureInfo objects and their DirectDraw/Direct3D caching.
[AI] Contains DirectDraw and Direct3DRM handles and metadata for a texture used in the LEGO Island re...
[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]
4x4 Matrix class with virtual interface for manipulation and transformation.
virtual float(* GetData())[4]
Gets modifiable access to the 4x4 float matrix.
virtual void Product(float(*p_a)[4], float(*p_b)[4])
Multiplies two 4x4 float matrices, storing result in this.
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] 4D point class for floating point values.
[AI] Represents a 4x4 transformation matrix, specialized for the LEGO Island engine and derived from ...
[AI] Represents an ROI (Real-time Object Instance) that can be oriented in world space,...
const BoundingSphere & GetWorldBoundingSphere() const override
Returns the object's bounding sphere in world coordinates.
BoundingBox m_world_bounding_box
The object's axis-aligned bounding box in world space, recalculated as needed.
BoundingBox m_unk0x80
An unknown bounding box; usage unclear, could be related to extended collision or volume testing.
void FUN_100a5a30(const Vector3 &p_world_velocity)
Sets the world velocity to the provided vector.
MxMatrix m_local2world
The transform from local to world space; 4x4 transformation matrix.
OrientableROI * m_parentROI
If non-null, points to the parent OrientableROI for local/world transformation hierarchy.
BoundingSphere m_world_bounding_sphere
The object's bounding sphere in world space, recalculated from m_local2world.
[AI] Abstract base class for Real-time Object Instances (ROI) in the world.
CompoundObject * comp
[AI] List of sub-ROIs composing this ROI (compound object), or NULL. [AI]
void SetVisibility(unsigned char p_visible)
[AI] Sets the visibility flag to the provided value.
int GetLODCount() const
[AI] Returns the number of available LODs for this ROI.
const LODObject * GetLOD(int i) const
[AI] Returns the LODObject at the specified index.
[AI] Main interface/factory for rendering resources and scene graphs.
[AI] An extension of LegoROI that adds support for keeping and applying a base time reference (used f...
void FUN_100a9b40(Matrix4 &p_matrix, LegoTime p_time)
[AI] Updates animated position/offset by integrating movement since last update (applying time delta)...
TimeROI(Tgl::Renderer *p_renderer, ViewLODList *p_lodList, LegoTime p_time)
[AI] Creates a TimeROI with reference time and LOD geometry.
virtual float Dot(const float *p_a, const float *p_b) const
[AI] Compute the dot product of the two float arrays interpreted as vectors of 2 elements.
[AI] 3D vector class, providing vector and cross-product operations in 3D space.
virtual void SetMatrixProduct(const float *p_vec, const float *p_mat)
[AI] Set this vector to the result of a matrix-vector product: result = p_mat * p_vec.
[AI] Manages the lifecycle, lookup, and sharing of ViewLODList instances for different ROI names.
ViewLODList * Create(const ROIName &rROIName, int lodCount)
[AI] Creates and registers a new ViewLODList for a named ROI, with space for the specified number of ...
ViewLODList * Lookup(const ROIName &) const
[AI] Looks up an existing ViewLODList by ROI name, incrementing its reference count.
[AI] Reference-counted list of Level-of-Detail (LOD) objects associated with a single ROI (Realtime O...
int Release()
[AI] Decrements the reference count.
[AI] Represents a Level of Detail (LOD) object for rendering, implemented with a mesh builder and sup...
unsigned char GetUnknown0x08Test8()
[AI] Performs a bitwise AND (mask) with value 0xffffff08 on the internal flag, returning result as an...
[AI] ViewROI objects represent viewable and placeable objects in the scene, each holding their own tr...
void VTable0x1c() override
[AI] Updates internal state, potentially related to animation or LOD switching (exact purpose unclear...
void SetLODList(ViewLODList *lodList)
[AI] Sets the ViewLODList for this ROI, managing reference counting.
#define DECOMP_SIZE_ASSERT(T, S)
const char * g_unk0x10101370[]
ColorOverride g_colorOverride
ROIColorAlias g_roiColorAliases[22]
const char * g_unk0x10101390[]
const char * g_unk0x10101380[]
TextureHandler g_textureHandler
unsigned char(* ColorOverride)(const char *, char *, unsigned int)
[AI] Function pointer type for overriding color.
unsigned char(* TextureHandler)(const char *, unsigned char *, unsigned int)
[AI] Function pointer type for custom palette lookup or texture palette fetching.
#define NULL
[AI] Null pointer value (C/C++ semantics).
unsigned long LegoU32
[AI] Unsigned 32-bit integer type for cross-platform compatibility.
LegoS32 LegoTime
[AI] Time value, typically used for tick counts, durations, or timing; defined as a signed 32-bit int...
char LegoChar
[AI] Alias for char, for use in character/byte data and string handling.
#define FAILURE
[AI] Used to indicate a failed operation in result codes.
LegoS32 LegoResult
[AI] Function result type (return code): typically SUCCESS (0) or FAILURE (-1).
long LegoS32
[AI] Signed 32-bit integer type for cross-platform compatibility.
#define SUCCESS
[AI] Used to indicate a successful operation in result codes.
float LegoFloat
[AI] Floating point type used throughout LEGO Island.
LegoU8 LegoBool
[AI] Boolean value used throughout the codebase.
void CalcWorldBoundingVolumes(const BoundingSphere &modelling_sphere, const Matrix4 &local2world, BoundingBox &world_bounding_box, BoundingSphere &world_bounding_sphere)
[AI] Computes the world-space bounding box and bounding sphere for an ROI using a modeling sphere and...
list< ROI * > CompoundObject