Isle
Loading...
Searching...
No Matches
group.cpp
Go to the documentation of this file.
1#include "impl.h"
2
3using namespace TglImpl;
4
5// FUNCTION: LEGO1 0x100a31d0
6// FUNCTION: BETA10 0x1016a480
8{
9 return reinterpret_cast<void*>(&m_data);
10}
11
12// FUNCTION: LEGO1 0x100a31e0
14{
15 D3DRMMATRIX4D helper;
16 D3DRMMATRIX4D* d3dMatrix = Translate(matrix, helper);
17 return ResultVal(m_data->AddTransform(D3DRMCOMBINE_REPLACE, *d3dMatrix));
18}
19
20// FUNCTION: LEGO1 0x100a3240
21Result GroupImpl::SetColor(float r, float g, float b, float a)
22{
23 // The first instruction makes no sense here:
24 // cmp dword ptr [esp + 0x10], 0
25 // This compares a, which we know is a float because it immediately
26 // gets passed into D3DRMCreateColorRGBA, but does the comparison
27 // as though it's an int??
28 if (*reinterpret_cast<int*>(&a) > 0) {
29 D3DCOLOR color = D3DRMCreateColorRGBA(r, g, b, a);
30 return ResultVal(m_data->SetColor(color));
31 }
32 else {
33 return ResultVal(m_data->SetColorRGB(r, a, b));
34 }
35}
36
37// FUNCTION: LEGO1 0x100a32b0
39{
40 IDirect3DRMTexture* pD3DTexture = pTexture ? static_cast<const TextureImpl*>(pTexture)->ImplementationData() : NULL;
41 return ResultVal(m_data->SetTexture(pD3DTexture));
42}
43
44// FUNCTION: LEGO1 0x100a32e0
46{
47 IDirect3DRMTexture* pD3DTexture;
48 TextureImpl* holder = new TextureImpl();
49 Result result = ResultVal(m_data->GetTexture(&pD3DTexture));
50 if (result) {
51 // Seems to actually call the first virtual method of holder here
52 // but that doesn't make any sense since it passes three arguments
53 // to the method (self + string constant? + an offset?).
54
55 // This line makes the start of the function match and is what I
56 // would expect to see there but it clearly isn't what's actually
57 // there.
58 holder->SetImplementation(pD3DTexture);
59 }
60 pTexture = holder;
61 return Success;
62}
63
64// FUNCTION: LEGO1 0x100a33c0
66{
67 D3DRMMATERIALMODE d3dMode;
68 switch (mode) {
69 case FromParent:
71 break;
72 case FromFrame:
74 break;
75 case FromMesh:
76 d3dMode = D3DRMMATERIAL_FROMMESH;
77 break;
78 }
79 return ResultVal(m_data->SetMaterialMode(d3dMode));
80}
81
82// FUNCTION: LEGO1 0x100a3410
84{
85 const GroupImpl* pGroupImpl = static_cast<const GroupImpl*>(pGroup);
86 return ResultVal(m_data->AddVisual(pGroupImpl->m_data));
87}
88
89// FUNCTION: LEGO1 0x100a3430
90Result GroupImpl::Add(const MeshBuilder* pMeshBuilder)
91{
92 const MeshBuilderImpl* pMeshBuilderImpl = static_cast<const MeshBuilderImpl*>(pMeshBuilder);
93 return ResultVal(m_data->AddVisual(pMeshBuilderImpl->ImplementationData()));
94}
95
96// FUNCTION: LEGO1 0x100a3450
98{
99 const MeshBuilderImpl* pMeshBuilderImpl = static_cast<const MeshBuilderImpl*>(pMeshBuilder);
100 return ResultVal(m_data->DeleteVisual(pMeshBuilderImpl->ImplementationData()));
101}
102
103// FUNCTION: LEGO1 0x100a3480
105{
106 const GroupImpl* pGroupImpl = static_cast<const GroupImpl*>(pGroup);
107 return ResultVal(m_data->DeleteVisual(pGroupImpl->m_data));
108}
109
110// FUNCTION: LEGO1 0x100a34b0
112{
113 IDirect3DRMVisualArray* visuals;
114 IDirect3DRMFrame2* frame = m_data;
115 Result result = (Result) SUCCEEDED(frame->GetVisuals(&visuals));
116
117 if (result == Success) {
118 for (int i = 0; i < (int) visuals->GetSize(); i++) {
119 IDirect3DRMVisual* visual;
120
121 result = (Result) SUCCEEDED(visuals->GetElement(i, &visual));
122 frame->DeleteVisual(visual);
123 visual->Release();
124 }
125
126 visuals->Release();
127 }
128
129 return result;
130}
131
132// FUNCTION: LEGO1 0x100a3540
134{
135 D3DRMBOX size;
136 IDirect3DRMFrame2* frame = m_data;
137
138 size.min.x = 88888.f;
139 size.min.y = 88888.f;
140 size.min.z = 88888.f;
141 size.max.x = -88888.f;
142 size.max.y = -88888.f;
143 size.max.z = -88888.f;
144
145 IDirect3DRMVisualArray* visuals;
146 Result result = (Result) SUCCEEDED(frame->GetVisuals(&visuals));
147
148 if (result == Success) {
149 int i;
150 for (i = 0; i < (int) visuals->GetSize(); i++) {
151 IDirect3DRMVisual* visual;
152 visuals->GetElement(i, &visual);
153 IDirect3DRMMesh* mesh;
154 /*
155 * BUG: should be:
156 * visual->QueryInterface(IID_IDirect3DRMMesh, (void**)&mesh));
157 */
158 result = (Result) SUCCEEDED(visual->QueryInterface(IID_IDirect3DRMMeshBuilder, (void**) &mesh));
159
160 if (result == Success) {
161 D3DRMBOX box;
162 result = (Result) SUCCEEDED(mesh->GetBox(&box));
163
164 if (size.max.y < box.max.y) {
165 size.max.y = box.max.y;
166 }
167 if (size.max.z < box.max.z) {
168 size.max.z = box.max.z;
169 }
170 if (box.min.x < size.min.x) {
171 size.min.x = box.min.x;
172 }
173 if (box.min.y < size.min.y) {
174 size.min.y = box.min.y;
175 }
176 if (box.min.z < size.min.z) {
177 size.min.z = box.min.z;
178 }
179 if (size.max.x < box.max.x) {
180 size.max.x = box.max.x;
181 }
182
183 mesh->Release();
184 }
185
186 visual->Release();
187 }
188
189 visuals->Release();
190 }
191
192 *p_min = size.min;
193 *p_max = size.max;
194 return result;
195}
[AI] Implementation of Tgl::Group, wraps a Direct3DRMFrame2 and provides scene graph and transformati...
Definition: impl.h:944
Result SetTransformation(FloatMatrix4 &) override
Sets transformation matrix for group [AI].
Definition: group.cpp:13
Result Add(const Group *) override
Adds a child group [AI].
Definition: group.cpp:83
Result Bounds(D3DVECTOR *p_min, D3DVECTOR *p_max) override
Returns bounding box in world space [AI].
Definition: group.cpp:133
const GroupDataType & ImplementationData() const
Gets internal group/frame pointer, const [AI].
Definition: impl.h:1036
Result GetTexture(Texture *&) override
Gets texture from group [AI].
Definition: group.cpp:45
Result SetTexture(const Texture *) override
Sets texture for all group geometry [AI].
Definition: group.cpp:38
Result SetMaterialMode(MaterialMode) override
Sets usage/staging of group as a material [AI].
Definition: group.cpp:65
Result Remove(const Group *) override
Removes a child group [AI].
Definition: group.cpp:104
Result SetColor(float r, float g, float b, float a) override
Sets color and alpha for the group [AI].
Definition: group.cpp:21
Result RemoveAll() override
Removes all contained groups and meshes [AI].
Definition: group.cpp:111
void * ImplementationDataPtr() override
Returns group implementation pointer [AI].
Definition: group.cpp:7
[AI] Implements Tgl::MeshBuilder, manages mesh construction and provides the interface for creating g...
Definition: impl.h:1081
const MeshBuilderDataType & ImplementationData() const
Gets mesh builder pointer (const) [AI].
Definition: impl.h:1138
[AI] Implements Tgl::Texture using a Direct3DRMTexture; provides upload and palette control [AI]
Definition: impl.h:1268
void SetImplementation(IDirect3DRMTexture *pData)
Replaces implementation pointer [AI].
Definition: impl.h:1349
[AI] Scene graph node for parental transforms/color/material/texture; can hold meshes or other groups...
Definition: tgl.h:669
[AI] Builder class for assembling mesh data and extracting mesh objects.
Definition: tgl.h:768
[AI] Represents a GPU or system memory texture for use in rendering.
Definition: tgl.h:826
enum _D3DRMMATERIALMODE D3DRMMATERIALMODE
@ D3DRMCOMBINE_REPLACE
Definition: d3drmdef.h:109
D3DVALUE D3DRMMATRIX4D[4][4]
Definition: d3drmdef.h:35
D3DCOLOR D3DRMAPI D3DRMCreateColorRGBA(D3DVALUE red, D3DVALUE green, D3DVALUE blue, D3DVALUE alpha)
@ D3DRMMATERIAL_FROMPARENT
Definition: d3drmdef.h:206
@ D3DRMMATERIAL_FROMMESH
Definition: d3drmdef.h:205
@ D3DRMMATERIAL_FROMFRAME
Definition: d3drmdef.h:207
DWORD D3DCOLOR
Definition: d3dtypes.h:103
#define NULL
[AI] Null pointer value (C/C++ semantics).
Definition: legotypes.h:26
[AI] Forward declaration for Direct3DRMTexture interface [AI]
Definition: impl.h:23
Result ResultVal(HRESULT result)
Returns a Tgl Result value for HRESULT [AI].
Definition: impl.h:35
D3DRMRENDERQUALITY Translate(ShadingModel tglShadingModel)
Converts Tgl shading model enum to D3DRM enum [AI].
Definition: impl.h:1398
Result
[AI] Result type used throughout the Tgl API to report operation success or failure.
Definition: tgl.h:126
@ Success
[AI] Operation succeeded. [AI]
Definition: tgl.h:128
float FloatMatrix4[4][4]
[AI] Represents a 4x4 matrix of single-precision floating point values.
Definition: tglvector.h:53
MaterialMode
[AI] Determines how material properties are sourced for a group/mesh.
Definition: tgl.h:75
@ FromMesh
[AI] Use material specified at the mesh level. [AI]
Definition: tgl.h:78
@ FromFrame
[AI] Use material from the current frame. [AI]
Definition: tgl.h:77
@ FromParent
[AI] Inherit material from parent. [AI]
Definition: tgl.h:76
D3DVECTOR min
Definition: d3drmdef.h:48
D3DVECTOR max
Definition: d3drmdef.h:48
D3DVALUE z
Definition: d3dtypes.h:157
D3DVALUE y
Definition: d3dtypes.h:153
D3DVALUE x
Definition: d3dtypes.h:149