Isle
Loading...
Searching...
No Matches
LegoLOD Class Reference

[AI] Level-Of-Detail (LOD) object used for rendering and managing polygonal mesh data with LOD switching. More...

#include <legolod.h>

Inheritance diagram for LegoLOD:
Collaboration diagram for LegoLOD:

Classes

struct  Mesh
 [AI] Structure representing a sub-mesh and its texturization flag. More...
 

Public Member Functions

 LegoLOD (Tgl::Renderer *)
 [AI] Constructor. More...
 
 ~LegoLOD () override
 [AI] Destructor. More...
 
int NumPolys () const override
 [AI] Get number of polygons (faces) for this LOD. More...
 
float VTable0x10 () override
 [AI] Reserved LOD callback, returns zero. More...
 
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). More...
 
LegoLODClone (Tgl::Renderer *p_renderer)
 [AI] Create an exact copy of this LOD, including cloned meshes, for another (or the same) renderer. More...
 
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. More...
 
LegoResult SetTextureInfo (LegoTextureInfo *p_textureInfo)
 [AI] Assigns the same texture group to all textured meshes in this LOD. More...
 
LegoResult FUN_100aad70 (LegoTextureInfo *p_textureInfo)
 [AI] Assigns the group texture to all textured meshes, but does NOT override mesh color. More...
 
void ClearMeshOffset ()
 [AI] Reset mesh offset index to start at 0, affecting which meshes are updated by future color/texture calls. More...
 
LegoResult GetTextureInfo (LegoTextureInfo *&p_textureInfo)
 [AI] Retrieves the texture info/group of the first mesh with group texture in this LOD. More...
 
- Public Member Functions inherited from ViewLOD
 ViewLOD (Tgl::Renderer *pRenderer)
 [AI] Constructs a ViewLOD using the provided Tgl Renderer. More...
 
 ~ViewLOD () override
 [AI] Destructor, deletes the owned mesh builder if present. More...
 
double AveragePolyArea () const override
 [AI] Approximates the average area of polygons within this LOD. More...
 
int NVerts () const override
 [AI] Returns the estimated number of vertices in this LOD. More...
 
Tgl::MeshBuilderGetMeshBuilder ()
 [AI] Returns a pointer to the mesh builder associated with this LOD. More...
 
const Tgl::MeshBuilderGetMeshBuilder () const
 [AI] Returns a const pointer to the mesh builder for this LOD. More...
 
undefined4 GetUnknown0x08 ()
 [AI] Returns the internal flag value m_unk0x08. More...
 
unsigned char GetUnknown0x08Test4 ()
 [AI] Performs a bitwise AND (mask) with value 0xffffff04 on the internal flag, returning result as an unsigned char. More...
 
unsigned char GetUnknown0x08Test8 ()
 [AI] Performs a bitwise AND (mask) with value 0xffffff08 on the internal flag, returning result as an unsigned char. More...
 
void SetFlag (unsigned char p_flag)
 [AI] Sets a given flag in the internal flags (m_unk0x08) using bitwise OR. More...
 
void ClearFlag (unsigned char p_flag)
 [AI] Clears a given flag in the internal flags (m_unk0x08) using bitwise AND with negated p_flag. More...
 
- Public Member Functions inherited from LODObject
virtual ~LODObject ()
 
virtual double AveragePolyArea () const =0
 [AI] Returns the average polygon area for this LOD. More...
 
virtual int NVerts () const =0
 [AI] Returns the number of vertices for this LOD. More...
 
virtual int NumPolys () const =0
 [AI] Returns the number of polygons for this LOD. More...
 
virtual float VTable0x10 ()=0
 [AI] Unknown method related to the LOD. More...
 

Static Public Member Functions

static LegoBool FUN_100aae20 (const LegoChar *p_name)
 [AI] Helper to check if a mesh/material name matches the "inh" group, which separates non-inheritable types. More...
 

Protected Attributes

Meshm_melems
 Array of mesh struct objects representing all mesh parts that make up this LOD. [AI]. More...
 
LegoU32 m_numMeshes
 Number of sub-meshes held in m_melems. [AI]. More...
 
LegoU32 m_numVertices
 Total number of vertices across all mesh parts. Used for stats and validation. [AI]. More...
 
LegoU32 m_numPolys
 Total number of polygons (faces) across all meshes (NumPolys implementation). [AI]. More...
 
LegoU32 m_meshOffset
 Internal mesh starting index for iteration; used for color/texture selective assignment. [AI]. More...
 
- Protected Attributes inherited from ViewLOD
Tgl::MeshBuilderm_meshBuilder
 [AI] Points to a mesh builder instance for constructing or managing polygonal mesh data for this LOD. More...
 
undefined4 m_unk0x08
 [AI] Internal bitfield for flag/status storage controlling LOD state and behavior. More...
 

Additional Inherited Members

- Public Types inherited from ViewLOD
enum  { c_bit4 = 0x10 }
 

Detailed Description

[AI] Level-Of-Detail (LOD) object used for rendering and managing polygonal mesh data with LOD switching.

LegoLOD extends ViewLOD to provide support for handling multiple Tgl::Mesh objects, each potentially representing a different material/texture within a single LOD, as used in LEGO Island's 3D engine. Provides mesh management, LOD data loading, cloning, color and texture assignment. Deserialization from storage populates mesh arrays and applies material/texture as needed.

Typical usage: constructed and filled by the resource system (LegoROI and friends) to store mesh geometry of an object at a specific LOD.

Meshes may be indexed/colorized or texturized depending on geometry/material; supports group color/texture assignment for variants.

Note
[AI] Deletion of this object will clean up allocated meshes and mesh arrays.

Definition at line 27 of file legolod.h.

Constructor & Destructor Documentation

◆ LegoLOD()

LegoLOD::LegoLOD ( Tgl::Renderer p_renderer)

[AI] Constructor.

Initializes this LOD for a given Tgl::Renderer. Allocates no meshes.

Parameters
p_rendererRenderer to associate materials/meshes with. [AI]

Definition at line 25 of file legolod.cpp.

◆ ~LegoLOD()

LegoLOD::~LegoLOD ( )
override

[AI] Destructor.

Frees all allocated meshes and mesh arrays. [AI]

Definition at line 39 of file legolod.cpp.

Member Function Documentation

◆ ClearMeshOffset()

void LegoLOD::ClearMeshOffset ( )

[AI] Reset mesh offset index to start at 0, affecting which meshes are updated by future color/texture calls.

Definition at line 393 of file legolod.cpp.

◆ Clone()

LegoLOD * LegoLOD::Clone ( Tgl::Renderer p_renderer)

[AI] Create an exact copy of this LOD, including cloned meshes, for another (or the same) renderer.

All internal meshes are shallow cloned onto the new mesh builder for the target renderer.

Parameters
p_rendererRenderer to use for duplicated resources. [AI]
Returns
New LegoLOD with duplicated (but non-deep) resources. [AI]

Definition at line 306 of file legolod.cpp.

◆ FUN_100aad70()

LegoResult LegoLOD::FUN_100aad70 ( LegoTextureInfo p_textureInfo)

[AI] Assigns the group texture to all textured meshes, but does NOT override mesh color.

Use when only switching texture, but not the per-mesh color.

Parameters
p_textureInfoTexture group to assign. [AI]
Returns
Success/failure code. [AI]

Definition at line 354 of file legolod.cpp.

◆ FUN_100aae20()

LegoBool LegoLOD::FUN_100aae20 ( const LegoChar p_name)
static

[AI] Helper to check if a mesh/material name matches the "inh" group, which separates non-inheritable types.

Used internally to split mesh arrays/grouping between texture- and color-based segments.

Parameters
p_nameName to check (usually a mesh or material name). [AI]
Return values
TRUEif the name matches "inh" group. [AI]

Definition at line 380 of file legolod.cpp.

◆ GetTextureInfo()

LegoResult LegoLOD::GetTextureInfo ( LegoTextureInfo *&  p_textureInfo)

[AI] Retrieves the texture info/group of the first mesh with group texture in this LOD.

Used to get the current texture group in use, e.g., for variant logic or serialization.

Parameters
[out]p_textureInfoReference to pointer that receives the found texture info/group. [AI]
Returns
Success if found and assigned, FAILURE if not present. [AI]

Definition at line 366 of file legolod.cpp.

◆ NumPolys()

int LegoLOD::NumPolys ( ) const
inlineoverridevirtual

[AI] Get number of polygons (faces) for this LOD.

Implements LODObject.

Definition at line 55 of file legolod.h.

◆ Read()

LegoResult LegoLOD::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).

Reads geometry/mesh data, materials, textures, palette, and builds meshes as needed. Associates meshes with correct renderer/textures.

Parameters
p_rendererRenderer to allocate resources for. [AI]
p_textureContainerContainer to look up (by name) textures/material groups. [AI]
p_storageStream/storage to read LOD binary data from. [AI]
Returns
Result code indicating success/failure of load. [AI]

Definition at line 56 of file legolod.cpp.

◆ SetColor()

LegoResult LegoLOD::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.

All sub-meshes without a group texture/m_unk0x04==FALSE will have their color set as provided (RGBA floats).

Parameters
p_redRed component (0.0 - 1.0). [AI]
p_greenGreen component (0.0 - 1.0). [AI]
p_blueBlue component (0.0 - 1.0). [AI]
p_alphaAlpha component. [AI]
Returns
Success or failure code. [AI]

Definition at line 328 of file legolod.cpp.

◆ SetTextureInfo()

LegoResult LegoLOD::SetTextureInfo ( LegoTextureInfo p_textureInfo)

[AI] Assigns the same texture group to all textured meshes in this LOD.

All meshes with m_unk0x04==TRUE will have their group texture set to the provided texture info. Used when switching/animating texture variants. Also sets mesh color to (1,1,1,0) for those meshes.

Parameters
p_textureInfoPointer to desired texture info/group. [AI]
Returns
Success/failure code. [AI]

Definition at line 340 of file legolod.cpp.

◆ VTable0x10()

float LegoLOD::VTable0x10 ( )
inlineoverridevirtual

[AI] Reserved LOD callback, returns zero.

Implements LODObject.

Definition at line 60 of file legolod.h.

Member Data Documentation

◆ m_melems

Mesh* LegoLOD::m_melems
protected

Array of mesh struct objects representing all mesh parts that make up this LOD. [AI].

Definition at line 147 of file legolod.h.

◆ m_meshOffset

LegoU32 LegoLOD::m_meshOffset
protected

Internal mesh starting index for iteration; used for color/texture selective assignment. [AI].

Definition at line 151 of file legolod.h.

◆ m_numMeshes

LegoU32 LegoLOD::m_numMeshes
protected

Number of sub-meshes held in m_melems. [AI].

Definition at line 148 of file legolod.h.

◆ m_numPolys

LegoU32 LegoLOD::m_numPolys
protected

Total number of polygons (faces) across all meshes (NumPolys implementation). [AI].

Definition at line 150 of file legolod.h.

◆ m_numVertices

LegoU32 LegoLOD::m_numVertices
protected

Total number of vertices across all mesh parts. Used for stats and validation. [AI].

Definition at line 149 of file legolod.h.


The documentation for this class was generated from the following files: