21inline IDirect3DRM2*
GetD3DRM(
Tgl::Renderer* pRenderer);
58 float(*normals)[3] =
NULL;
59 float(*vertices)[3] =
NULL;
60 float(*textureVertices)[2] =
NULL;
69 LegoU32 i, meshUnd1, meshUnd2, tempNumVertsAndNormals;
70 unsigned char paletteEntries[256];
99 if (p_storage->
Read(&tempNumVertsAndNormals,
sizeof(tempNumVertsAndNormals)) !=
SUCCESS) {
103 numVerts = *((
LegoU16*) &tempNumVertsAndNormals) & MAXSHORT;
104 numNormals = (*((
LegoU16*) &tempNumVertsAndNormals + 1) >> 1) & MAXSHORT;
106 if (p_storage->
Read(&numTextureVertices,
sizeof(numTextureVertices)) !=
SUCCESS) {
111 vertices =
new float[numVerts][
sizeOfArray(*vertices)];
112 if (p_storage->
Read(vertices, numVerts *
sizeof(*vertices)) !=
SUCCESS) {
117 if (numNormals > 0) {
118 normals =
new float[numNormals][
sizeOfArray(*normals)];
119 if (p_storage->
Read(normals, numNormals *
sizeof(*normals)) !=
SUCCESS) {
124 if (numTextureVertices > 0) {
125 textureVertices =
new float[numTextureVertices][
sizeOfArray(*textureVertices)];
126 if (p_storage->
Read(textureVertices, numTextureVertices *
sizeof(*textureVertices)) !=
SUCCESS) {
132 LegoU32 numPolys, numVertices, numTextureIndices, meshIndex;
133 const LegoChar *textureName, *materialName;
147 if (p_storage->
Read(polyIndices, (numPolys & USHRT_MAX) *
sizeof(*polyIndices)) !=
SUCCESS) {
151 if (p_storage->
Read(&numTextureIndices,
sizeof(numTextureIndices)) !=
SUCCESS) {
155 if (numTextureIndices > 0) {
157 if (p_storage->
Read(textureIndices, (numPolys & USHRT_MAX) *
sizeof(*textureIndices)) !=
SUCCESS) {
162 textureIndices =
NULL;
188 meshIndex = meshUnd1;
192 meshIndex = meshUnd2;
197 numPolys & USHRT_MAX,
198 numVertices & USHRT_MAX,
213 if (textureName !=
NULL) {
220 if (textureInfo ==
NULL) {
248 IDirect3DRMMesh* mesh;
258 if (polyIndices !=
NULL) {
259 delete[] polyIndices;
262 if (textureIndices !=
NULL) {
263 delete[] textureIndices;
264 textureIndices =
NULL;
270 if (textureVertices !=
NULL) {
271 delete[] textureVertices;
273 if (normals !=
NULL) {
276 if (vertices !=
NULL) {
283 if (normals !=
NULL) {
286 if (vertices !=
NULL) {
289 if (textureVertices !=
NULL) {
290 delete[] textureVertices;
295 if (polyIndices !=
NULL) {
296 delete[] polyIndices;
298 if (textureIndices !=
NULL) {
299 delete[] textureIndices;
382 if (p_name !=
NULL) {
[AI] Abstract base class for a Level-of-Detail (LOD) variant of a geometric object.
LegoU8 GetRed()
Get the red channel value.
LegoU8 GetGreen()
Get the green channel value.
LegoU8 GetBlue()
Get the blue channel value.
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...
LegoResult FUN_100aad70(LegoTextureInfo *p_textureInfo)
[AI] Assigns the group texture to all textured meshes, but does NOT override mesh color.
void ClearMeshOffset()
[AI] Reset mesh offset index to start at 0, affecting which meshes are updated by future color/textur...
LegoU32 m_numPolys
Total number of polygons (faces) across all meshes (NumPolys implementation). [AI].
LegoU32 m_meshOffset
Internal mesh starting index for iteration; used for color/texture selective assignment....
~LegoLOD() override
[AI] Destructor.
LegoLOD * Clone(Tgl::Renderer *p_renderer)
[AI] Create an exact copy of this LOD, including cloned meshes, for another (or the same) renderer.
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.
LegoU32 m_numVertices
Total number of vertices across all mesh parts. Used for stats and validation. [AI].
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).
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...
LegoU32 m_numMeshes
Number of sub-meshes held in m_melems. [AI].
Mesh * m_melems
Array of mesh struct objects representing all mesh parts that make up this LOD. [AI].
[AI] Represents the rendering attributes and state of a LEGO mesh, including color,...
LegoFloat GetAlpha()
[AI] Gets the mesh's transparency alpha value.
@ e_flat
[AI] Use flat shading (per-polygon color).
@ e_wireframe
[AI] Use wireframe rendering.
LegoResult Read(LegoStorage *p_storage)
[AI] Reads mesh properties (color, alpha, shading, flags, names) from the given storage stream.
LegoU8 GetUnknown0x0d()
[AI] Returns the value of an unknown flag or property at offset 0x0d.
LegoColor GetColor()
[AI] Returns the mesh's primary color.
LegoU8 GetShading()
[AI] Gets the shading mode of the mesh.
LegoBool GetUnknown0x21()
[AI] Returns the value of an unknown boolean at offset 0x21.
const LegoChar * GetTextureName()
[AI] Returns the texture resource name associated with the mesh.
const LegoChar * GetMaterialName()
[AI] Returns the material resource name for the mesh.
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.
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.
Abstract base class providing an interface for file-like storage with binary and text read/write oper...
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...
static BOOL GetGroupTexture(Tgl::Mesh *pMesh, LegoTextureInfo *&p_textureInfo)
[AI] Retrieves the LegoTextureInfo currently attached to the supplied mesh group.
static BOOL SetGroupTexture(Tgl::Mesh *pMesh, LegoTextureInfo *p_textureInfo)
[AI] Assigns a Direct3DRM texture group from a LegoTextureInfo to a mesh group via the Tgl/Microsoft ...
[AI] Implementation of Tgl::Mesh, manages a mesh object and geometry data with group index [AI]
[AI] Implements Tgl::MeshBuilder; facilitates mesh construction [AI]
virtual MeshBuilder * Clone()=0
[AI] Makes a copy of the mesh builder instance (deep copy).
virtual Mesh * CreateMesh(unsigned long faceCount, unsigned long vertexCount, float(*pPositions)[3], float(*pNormals)[3], float(*pTextureCoordinates)[2], unsigned long(*pFaceIndices)[3], unsigned long(*pTextureIndices)[3], ShadingModel shadingModel)=0
[AI] Creates a mesh from supplied geometry data.
[AI] Represents a renderable 3D mesh.
virtual Result SetShadingModel(ShadingModel)=0
[AI] Sets the mesh's shading model (e.g., Gouraud, Phong).
virtual Mesh * ShallowClone(MeshBuilder *)=0
[AI] Performs a shallow clone—new wrapper, same mesh data.
virtual Result SetColor(float r, float g, float b, float a)=0
[AI] Sets the color and transparency for the mesh.
[AI] Main interface/factory for rendering resources and scene graphs.
virtual MeshBuilder * CreateMeshBuilder()=0
[AI] Creates a new mesh builder.
[AI] Represents a Level of Detail (LOD) object for rendering, implemented with a mesh builder and sup...
Tgl::MeshBuilder * m_meshBuilder
[AI] Points to a mesh builder instance for constructing or managing polygonal mesh data for this LOD.
@ c_bit4
[AI] Flag value for bit 4 mask operation.
void ClearFlag(unsigned char p_flag)
[AI] Clears a given flag in the internal flags (m_unk0x08) using bitwise AND with negated p_flag.
undefined4 m_unk0x08
[AI] Internal bitfield for flag/status storage controlling LOD state and behavior.
void SetFlag(unsigned char p_flag)
[AI] Sets a given flag in the internal flags (m_unk0x08) using bitwise OR.
unsigned char GetUnknown0x08Test4()
[AI] Performs a bitwise AND (mask) with value 0xffffff04 on the internal flag, returning result as an...
#define DECOMP_SIZE_ASSERT(T, S)
BOOL GetMeshData(IDirect3DRMMesh *&mesh, D3DRMGROUPINDEX &index, Tgl::Mesh *pMesh)
const char * g_unk0x101013dc
LPDIRECT3DRMMATERIAL g_unk0x101013d4
IDirect3DRM2 * GetD3DRM(Tgl::Renderer *pRenderer)
#define NULL
[AI] Null pointer value (C/C++ semantics).
unsigned long LegoU32
[AI] Unsigned 32-bit integer type for cross-platform compatibility.
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.
unsigned short LegoU16
[AI] Unsigned 16-bit integer type for cross-platform compatibility.
float LegoFloat
[AI] Floating point type used throughout LEGO Island.
LegoU8 LegoBool
[AI] Boolean value used throughout the codebase.
[AI] Namespace containing all classes related to the 3D graphics abstraction/rendering engine.
ShadingModel
[AI] Represents shading models available for rendering geometry.
@ Flat
[AI] Flat shaded, possibly single color per polygon with lighting. [AI]
@ Gouraud
[AI] Gouraud (vertex-interpolated) shading. [AI]
@ Wireframe
[AI] No shading; renders only mesh edges. [AI]
[AI] Structure representing a sub-mesh and its texturization flag.
BOOL m_unk0x04
Indicates if this mesh has a texture group assigned (TRUE = textured). [AI].
Tgl::Mesh * m_tglMesh
Pointer to the mesh object for rendering. [AI].