Isle
Loading...
Searching...
No Matches
legomesh.cpp
Go to the documentation of this file.
1#include "legomesh.h"
2
3#include "misc/legostorage.h"
4
7
8// FUNCTION: LEGO1 0x100d3810
10{
11 m_alpha = 0.0F;
12 m_shading = e_flat;
13 m_unk0x14 = 0;
14 m_textureName = NULL;
15 m_unk0x0d = 0;
16 m_unk0x10 = NULL;
17 m_unk0x20 = 0;
18 m_unk0x21 = FALSE;
19 m_materialName = NULL;
20}
21
22// FUNCTION: LEGO1 0x100d3860
24{
25 if (m_textureName != NULL) {
26 delete[] m_textureName;
27 }
28
29 if (m_materialName != NULL) {
30 delete[] m_materialName;
31 }
32
33 if (m_unk0x10 != NULL) {
34 delete m_unk0x10;
35 }
36}
37
38// FUNCTION: LEGO1 0x100d38f0
40{
41 LegoResult result;
42 LegoU32 textureLength, materialLength;
43 if ((result = m_color.Read(p_storage)) != SUCCESS) {
44 return result;
45 }
46 if ((result = p_storage->Read(&m_alpha, sizeof(m_alpha))) != SUCCESS) {
47 return result;
48 }
49 if ((result = p_storage->Read(&m_shading, sizeof(m_shading))) != SUCCESS) {
50 return result;
51 }
52 if ((result = p_storage->Read(&m_unk0x0d, sizeof(m_unk0x0d))) != SUCCESS) {
53 return result;
54 }
55 if ((result = p_storage->Read(&m_unk0x20, sizeof(m_unk0x20))) != SUCCESS) {
56 return result;
57 }
58 if ((result = p_storage->Read(&m_unk0x21, sizeof(m_unk0x21))) != SUCCESS) {
59 return result;
60 }
61
62 if ((result = p_storage->Read(&textureLength, sizeof(textureLength))) != SUCCESS) {
63 return result;
64 }
65 if (textureLength) {
66 m_textureName = new LegoChar[textureLength + 1];
67
68 if ((result = p_storage->Read(m_textureName, textureLength)) != SUCCESS) {
69 return result;
70 }
71
72 m_textureName[textureLength] = '\0';
73 strlwr(m_textureName);
74 }
75
76 if ((result = p_storage->Read(&materialLength, sizeof(materialLength))) != SUCCESS) {
77 return result;
78 }
79 if (materialLength) {
80 m_materialName = new LegoChar[materialLength + 1];
81
82 if ((result = p_storage->Read(m_materialName, materialLength)) != SUCCESS) {
83 return result;
84 }
85
86 m_materialName[materialLength] = '\0';
87 strlwr(m_materialName);
88 }
89
90 return SUCCESS;
91}
LegoResult Read(LegoStorage *p_storage)
Read the color from a storage object in the order red, green, blue (each as a byte).
Definition: legocolor.cpp:9
[AI] Represents the rendering attributes and state of a LEGO mesh, including color,...
Definition: legomesh.h:51
LegoFloat m_alpha
[AI] Mesh transparency (0=transparent, 1=opaque).
Definition: legomesh.h:131
LegoResult Read(LegoStorage *p_storage)
[AI] Reads mesh properties (color, alpha, shading, flags, names) from the given storage stream.
Definition: legomesh.cpp:39
LegoChar * m_materialName
[AI] Name of material resource, null if none; string is lowercase.
Definition: legomesh.h:137
LegoBool m_unk0x21
[AI] Unknown boolean property; function unknown.
Definition: legomesh.h:139
virtual ~LegoMesh()
Definition: legomesh.cpp:23
LegoChar * m_textureName
[AI] Name of texture resource, null if none; string is lowercase.
Definition: legomesh.h:136
LegoMeshUnkComponent * m_unk0x10
[AI] Unknown pointer; owned; deleted in destructor. [AI]
Definition: legomesh.h:134
undefined m_unk0x20
[AI] Single unused/padding byte.
Definition: legomesh.h:138
LegoColor m_color
[AI] The main (diffuse) color of the mesh.
Definition: legomesh.h:130
LegoU8 m_shading
[AI] Shading mode (see enum above).
Definition: legomesh.h:132
LegoU8 m_unk0x0d
[AI] Unknown property/flag at offset 0x0d.
Definition: legomesh.h:133
Abstract base class providing an interface for file-like storage with binary and text read/write oper...
Definition: legostorage.h:16
virtual LegoResult Read(void *p_buffer, LegoU32 p_size)=0
Read bytes from storage into buffer.
#define FALSE
Definition: d3drmdef.h:27
#define DECOMP_SIZE_ASSERT(T, S)
Definition: decomp.h:19
#define NULL
[AI] Null pointer value (C/C++ semantics).
Definition: legotypes.h:26
unsigned long LegoU32
[AI] Unsigned 32-bit integer type for cross-platform compatibility.
Definition: legotypes.h:71
char LegoChar
[AI] Alias for char, for use in character/byte data and string handling.
Definition: legotypes.h:83
LegoS32 LegoResult
[AI] Function result type (return code): typically SUCCESS (0) or FAILURE (-1).
Definition: legotypes.h:101
#define SUCCESS
[AI] Used to indicate a successful operation in result codes.
Definition: legotypes.h:30
[AI] Unknown mesh sub-component structure possibly used for materials or textures.
Definition: legomesh.h:16