Merge branch 'd3drm' of https://github.com/stravant/isle into d3drm

This commit is contained in:
Christian Semmler 2023-11-30 10:57:32 -05:00
commit 068358b36c
14 changed files with 432 additions and 433 deletions

View File

@ -216,7 +216,7 @@ add_library(lego1 SHARED
LEGO1/tgl/d3drm/light.cpp LEGO1/tgl/d3drm/light.cpp
LEGO1/tgl/d3drm/mesh.cpp LEGO1/tgl/d3drm/mesh.cpp
LEGO1/tgl/d3drm/renderer.cpp LEGO1/tgl/d3drm/renderer.cpp
LEGO1/tgl/d3drm/something.cpp LEGO1/tgl/d3drm/unk.cpp
LEGO1/tgl/d3drm/texture.cpp LEGO1/tgl/d3drm/texture.cpp
LEGO1/tgl/d3drm/view.cpp LEGO1/tgl/d3drm/view.cpp
LEGO1/towtrack.cpp LEGO1/towtrack.cpp

View File

@ -21,10 +21,10 @@ void* CameraImpl::ImplementationDataPtr()
} }
// OFFSET: LEGO1 0x100a3700 // OFFSET: LEGO1 0x100a3700
Result CameraImpl::SetTransformation(const FloatMatrix4& p_matrix) Result CameraImpl::SetTransformation(const FloatMatrix4& matrix)
{ {
D3DRMMATRIX4D helper; D3DRMMATRIX4D helper;
D3DRMMATRIX4D* pTransformation = Translate(p_matrix, helper); D3DRMMATRIX4D* pTransformation = Translate(matrix, helper);
D3DVECTOR position; D3DVECTOR position;
Result result; Result result;

View File

@ -38,24 +38,24 @@ Result DeviceImpl::SetColorModel(ColorModel)
} }
// OFFSET: LEGO1 0x100a2c30 // OFFSET: LEGO1 0x100a2c30
Result DeviceImpl::SetShadingModel(ShadingModel p_model) Result DeviceImpl::SetShadingModel(ShadingModel model)
{ {
// Doesn't match well even though we know this is exactly // Doesn't match well even though we know this is exactly
// the original code thanks to the jump table. // the original code thanks to the jump table.
D3DRMRENDERQUALITY renderQuality = Translate(p_model); D3DRMRENDERQUALITY renderQuality = Translate(model);
return ResultVal(m_data->SetQuality(renderQuality)); return ResultVal(m_data->SetQuality(renderQuality));
} }
// OFFSET: LEGO1 0x100a2ca0 // OFFSET: LEGO1 0x100a2ca0
Result DeviceImpl::SetShadeCount(unsigned long p_shadeCount) Result DeviceImpl::SetShadeCount(unsigned long shadeCount)
{ {
return ResultVal(m_data->SetShades(p_shadeCount)); return ResultVal(m_data->SetShades(shadeCount));
} }
// OFFSET: LEGO1 0x100a2cc0 // OFFSET: LEGO1 0x100a2cc0
Result DeviceImpl::SetDither(int p_dither) Result DeviceImpl::SetDither(int dither)
{ {
return ResultVal(m_data->SetDither(p_dither)); return ResultVal(m_data->SetDither(dither));
} }
// Probably wrong, not sure what's going on in this method. // Probably wrong, not sure what's going on in this method.

View File

@ -6,7 +6,7 @@ using namespace TglImpl;
GroupImpl::~GroupImpl() GroupImpl::~GroupImpl()
{ {
if (m_data) { if (m_data) {
free(m_data); m_data->Release();
m_data = NULL; m_data = NULL;
} }
} }
@ -18,43 +18,43 @@ void* GroupImpl::ImplementationDataPtr()
} }
// OFFSET: LEGO1 0x100a31e0 // OFFSET: LEGO1 0x100a31e0
Result GroupImpl::SetTransformation(const FloatMatrix4& p_matrix) Result GroupImpl::SetTransformation(const FloatMatrix4& matrix)
{ {
D3DRMMATRIX4D helper; D3DRMMATRIX4D helper;
D3DRMMATRIX4D* matrix = Translate(p_matrix, helper); D3DRMMATRIX4D* d3dMatrix = Translate(matrix, helper);
return ResultVal(m_data->AddTransform(D3DRMCOMBINE_REPLACE, *matrix)); return ResultVal(m_data->AddTransform(D3DRMCOMBINE_REPLACE, *d3dMatrix));
} }
// OFFSET: LEGO1 0x100a3240 // OFFSET: LEGO1 0x100a3240
Result GroupImpl::SetColor(float p_r, float p_g, float p_b, float p_a) Result GroupImpl::SetColor(float r, float g, float b, float a)
{ {
// The first instruction makes no sense here: // The first instruction makes no sense here:
// cmp dword ptr [esp + 0x10], 0 // cmp dword ptr [esp + 0x10], 0
// This compares a, which we know is a float because it immediately // This compares a, which we know is a float because it immediately
// gets passed into D3DRMCreateColorRGBA, but does the comparison // gets passed into D3DRMCreateColorRGBA, but does the comparison
// as though it's an int?? // as though it's an int??
if (*reinterpret_cast<int*>(&p_a) > 0) { if (*reinterpret_cast<int*>(&a) > 0) {
D3DCOLOR color = D3DRMCreateColorRGBA(p_r, p_g, p_b, p_a); D3DCOLOR color = D3DRMCreateColorRGBA(r, g, b, a);
return ResultVal(m_data->SetColor(color)); return ResultVal(m_data->SetColor(color));
} }
else { else {
return ResultVal(m_data->SetColorRGB(p_r, p_a, p_b)); return ResultVal(m_data->SetColorRGB(r, a, b));
} }
} }
// OFFSET: LEGO1 0x100a32b0 // OFFSET: LEGO1 0x100a32b0
Result GroupImpl::SetTexture(const Texture* p_texture) Result GroupImpl::SetTexture(const Texture* pTexture)
{ {
IDirect3DRMTexture* texture = p_texture ? static_cast<const TextureImpl*>(p_texture)->ImplementationData() : NULL; IDirect3DRMTexture* pD3DTexture = pTexture ? static_cast<const TextureImpl*>(pTexture)->ImplementationData() : NULL;
return ResultVal(m_data->SetTexture(texture)); return ResultVal(m_data->SetTexture(pD3DTexture));
} }
// OFFSET: LEGO1 0x100a32e0 // OFFSET: LEGO1 0x100a32e0
Result GroupImpl::GetTexture(Texture*& p_texture) Result GroupImpl::GetTexture(Texture*& pTexture)
{ {
IDirect3DRMTexture* texture; IDirect3DRMTexture* pD3DTexture;
TextureImpl* holder = new TextureImpl(); TextureImpl* holder = new TextureImpl();
Result result = ResultVal(m_data->GetTexture(&texture)); Result result = ResultVal(m_data->GetTexture(&pD3DTexture));
if (result) { if (result) {
// Seems to actually call the first virtual method of holder here // Seems to actually call the first virtual method of holder here
// but that doesn't make any sense since it passes three arguments // but that doesn't make any sense since it passes three arguments
@ -63,57 +63,57 @@ Result GroupImpl::GetTexture(Texture*& p_texture)
// This line makes the start of the function match and is what I // This line makes the start of the function match and is what I
// would expect to see there but it clearly isn't what's actually // would expect to see there but it clearly isn't what's actually
// there. // there.
holder->SetImplementation(texture); holder->SetImplementation(pD3DTexture);
} }
p_texture = holder; pTexture = holder;
return Success; return Success;
} }
// OFFSET: LEGO1 0x100a33c0 // OFFSET: LEGO1 0x100a33c0
Result GroupImpl::SetMaterialMode(MaterialMode p_mode) Result GroupImpl::SetMaterialMode(MaterialMode mode)
{ {
D3DRMMATERIALMODE mode; D3DRMMATERIALMODE d3dMode;
switch (p_mode) switch (mode)
{ {
case FromParent: case FromParent:
mode = D3DRMMATERIAL_FROMPARENT; d3dMode = D3DRMMATERIAL_FROMPARENT;
break; break;
case FromFrame: case FromFrame:
mode = D3DRMMATERIAL_FROMFRAME; d3dMode = D3DRMMATERIAL_FROMFRAME;
break; break;
case FromMesh: case FromMesh:
mode = D3DRMMATERIAL_FROMMESH; d3dMode = D3DRMMATERIAL_FROMMESH;
break; break;
} }
return ResultVal(m_data->SetMaterialMode(mode)); return ResultVal(m_data->SetMaterialMode(d3dMode));
} }
// OFFSET: LEGO1 0x100a3410 // OFFSET: LEGO1 0x100a3410
Result GroupImpl::Add(const Mesh* p_mesh) Result GroupImpl::Add(const Mesh* pMesh)
{ {
const MeshImpl* mesh = static_cast<const MeshImpl*>(p_mesh); const MeshImpl* pMeshImpl = static_cast<const MeshImpl*>(pMesh);
return ResultVal(m_data->AddVisual(mesh->ImplementationData()->groupMesh)); return ResultVal(m_data->AddVisual(pMeshImpl->ImplementationData()->groupMesh));
} }
// OFFSET: LEGO1 0x100a3430 // OFFSET: LEGO1 0x100a3430
Result GroupImpl::Add(const Group* p_group) Result GroupImpl::Add(const Group* pGroup)
{ {
const GroupImpl* group = static_cast<const GroupImpl*>(p_group); const GroupImpl* pGroupImpl = static_cast<const GroupImpl*>(pGroup);
return ResultVal(m_data->AddVisual(group->m_data)); return ResultVal(m_data->AddVisual(pGroupImpl->m_data));
} }
// OFFSET: LEGO1 0x100a3450 // OFFSET: LEGO1 0x100a3450
Result GroupImpl::Remove(const Group* p_group) Result GroupImpl::Remove(const Group* pGroup)
{ {
const GroupImpl* group = static_cast<const GroupImpl*>(p_group); const GroupImpl* pGroupImpl = static_cast<const GroupImpl*>(pGroup);
return ResultVal(m_data->DeleteVisual(group->m_data)); return ResultVal(m_data->DeleteVisual(pGroupImpl->m_data));
} }
// OFFSET: LEGO1 0x100a3480 // OFFSET: LEGO1 0x100a3480
Result GroupImpl::Remove(const Mesh* p_mesh) Result GroupImpl::Remove(const Mesh* pMesh)
{ {
const MeshImpl* mesh = static_cast<const MeshImpl*>(p_mesh); const MeshImpl* pMeshImpl = static_cast<const MeshImpl*>(pMesh);
return ResultVal(m_data->DeleteVisual(mesh->ImplementationData()->groupMesh)); return ResultVal(m_data->DeleteVisual(pMeshImpl->ImplementationData()->groupMesh));
} }
// OFFSET: LEGO1 0x100a34b0 STUB // OFFSET: LEGO1 0x100a34b0 STUB

View File

@ -19,9 +19,9 @@ namespace TglImpl
using namespace Tgl; using namespace Tgl;
// Utility function used by implementations // Utility function used by implementations
inline Result ResultVal(HRESULT p_result) inline Result ResultVal(HRESULT result)
{ {
return SUCCEEDED(p_result) ? Success : Error; return SUCCEEDED(result) ? Success : Error;
} }
// Forward declare implementations // Forward declare implementations
@ -33,6 +33,7 @@ class CameraImpl;
class GroupImpl; class GroupImpl;
class MeshImpl; class MeshImpl;
class TextureImpl; class TextureImpl;
class UnkImpl;
// VTABLE 0x100db910 // VTABLE 0x100db910
class RendererImpl : public Renderer { class RendererImpl : public Renderer {
@ -50,26 +51,26 @@ class RendererImpl : public Renderer {
virtual View* CreateView( virtual View* CreateView(
const Device*, const Device*,
const Camera*, const Camera*,
unsigned long p_x, unsigned long x,
unsigned long p_y, unsigned long y,
unsigned long p_width, unsigned long width,
unsigned long p_height unsigned long height
); );
virtual Camera* CreateCamera(); virtual Camera* CreateCamera();
virtual Light* CreateLight(LightType, float p_r, float p_g, float p_b); virtual Light* CreateLight(LightType, float r, float g, float b);
virtual Group* CreateGroup(const Group* p_parent); virtual Group* CreateGroup(const Group* pParent);
// vtable+0x20 // vtable+0x20
virtual Something* CreateSomething(); virtual Unk* CreateUnk();
virtual Texture* CreateTexture(); virtual Texture* CreateTexture();
virtual Texture* CreateTexture( virtual Texture* CreateTexture(
int p_width, int width,
int p_height, int height,
int p_bitsPerTexel, int bitsPerTexel,
const void* p_pTexels, const void* pTexels,
int p_pTexelsArePersistent, int pTexelsArePersistent,
int p_paletteEntryCount, int paletteEntryCount,
const PaletteEntry* p_pEntries const PaletteEntry* pEntries
); );
virtual Result SetTextureDefaultShadeCount(unsigned long); virtual Result SetTextureDefaultShadeCount(unsigned long);
@ -130,11 +131,11 @@ class ViewImpl : public View {
// vtable+0x10 // vtable+0x10
virtual Result SetCamera(const Camera*); virtual Result SetCamera(const Camera*);
virtual Result SetProjection(ProjectionType); virtual Result SetProjection(ProjectionType);
virtual Result SetFrustrum(float p_frontClippingDistance, float p_backClippingDistance, float p_degrees); virtual Result SetFrustrum(float frontClippingDistance, float backClippingDistance, float degrees);
virtual Result SetBackgroundColor(float p_r, float p_g, float p_b); virtual Result SetBackgroundColor(float r, float g, float b);
// vtable+0x20 // vtable+0x20
virtual Result GetBackgroundColor(float* p_r, float* p_g, float* p_b); virtual Result GetBackgroundColor(float* r, float* g, float* b);
virtual Result Clear(); virtual Result Clear();
virtual Result Render(const Light*); virtual Result Render(const Light*);
virtual Result ForceUpdate(unsigned long x, unsigned long y, unsigned long width, unsigned long height); virtual Result ForceUpdate(unsigned long x, unsigned long y, unsigned long width, unsigned long height);
@ -143,12 +144,12 @@ class ViewImpl : public View {
virtual Result TransformWorldToScreen(const float world[3], float screen[4]); virtual Result TransformWorldToScreen(const float world[3], float screen[4]);
virtual Result TransformScreenToWorld(const float screen[4], float world[3]); virtual Result TransformScreenToWorld(const float screen[4], float world[3]);
virtual Result Pick( virtual Result Pick(
unsigned long p_x, unsigned long x,
unsigned long p_y, unsigned long y,
const Group** p_ppGroupsToPickFrom, const Group** ppGroupsToPickFrom,
int p_groupsToPickFromCount, int groupsToPickFromCount,
const Group**& p_rppPickedGroups, const Group**& rppPickedGroups,
int& p_rPickedGroupCount int& rPickedGroupCount
); );
inline IDirect3DRMViewport* ImplementationData() const { return m_data; } inline IDirect3DRMViewport* ImplementationData() const { return m_data; }
@ -190,7 +191,7 @@ class LightImpl : public Light {
// vtable+0x08 // vtable+0x08
virtual Result SetTransformation(const FloatMatrix4&); virtual Result SetTransformation(const FloatMatrix4&);
virtual Result SetColor(float p_r, float p_g, float p_b); virtual Result SetColor(float r, float g, float b);
inline IDirect3DRMFrame* ImplementationData() const { return m_data; } inline IDirect3DRMFrame* ImplementationData() const { return m_data; }
@ -215,17 +216,17 @@ class MeshImpl : public Mesh {
virtual void* ImplementationDataPtr(); virtual void* ImplementationDataPtr();
// vtable+0x08 // vtable+0x08
virtual Result SetColor(float p_r, float p_g, float p_b, float p_a); virtual Result SetColor(float r, float g, float b, float a);
virtual Result SetTexture(const Texture*); virtual Result SetTexture(const Texture*);
// vtable+0x10 // vtable+0x10
virtual Result GetTexture(Texture*&); virtual Result GetTexture(Texture*&);
virtual Result SetTextureMappingMode(ProjectionType); virtual Result SetTextureMappingMode(ProjectionType);
virtual Result SetShadingModel(ShadingModel); virtual Result SetShadingModel(ShadingModel);
virtual Mesh* DeepClone(Something*); virtual Mesh* DeepClone(Unk*);
// vtable+0x20 // vtable+0x20
virtual Mesh* ShallowClone(Something*); virtual Mesh* ShallowClone(Unk*);
struct MeshData { struct MeshData {
IDirect3DRMMesh* groupMesh; IDirect3DRMMesh* groupMesh;
@ -250,7 +251,7 @@ class GroupImpl : public Group {
// vtable+0x08 // vtable+0x08
virtual Result SetTransformation(const FloatMatrix4&); virtual Result SetTransformation(const FloatMatrix4&);
virtual Result SetColor(float p_r, float p_g, float p_b, float p_a); virtual Result SetColor(float r, float g, float b, float a);
// vtable+0x10 // vtable+0x10
virtual Result SetTexture(const Texture*); virtual Result SetTexture(const Texture*);
@ -274,27 +275,27 @@ class GroupImpl : public Group {
}; };
// VTABLE 0x100dbb18 // VTABLE 0x100dbb18
class SomethingImpl : public Something { class UnkImpl : public Unk {
public: public:
SomethingImpl() : m_data(0) {} UnkImpl() : m_data(0) {}
~SomethingImpl(); ~UnkImpl();
virtual void* ImplementationDataPtr(); virtual void* ImplementationDataPtr();
// vtable+0x08 // vtable+0x08
virtual Result SetMeshData( virtual Result SetMeshData(
unsigned long p_faceCount, unsigned long faceCount,
unsigned long p_vertexCount, unsigned long vertexCount,
const float (*p_positions)[3], const float (*pPositions)[3],
const float (*p_normals)[3], const float (*pNormals)[3],
const float (*p_textureCoordinates)[2], const float (*pTextureCoordinates)[2],
unsigned long p_vertexPerFaceCount, unsigned long vertexPerFaceCount,
unsigned long* p_faceData unsigned long* pFaceData
); );
virtual Result GetBoundingBox(float p_min[3], float p_max[3]); virtual Result GetBoundingBox(float min[3], float max[3]);
// vtable+0x10 // vtable+0x10
virtual Something* Clone(); virtual Unk* Clone();
inline IDirect3DRMMesh* ImplementationData() const { return m_data; } inline IDirect3DRMMesh* ImplementationData() const { return m_data; }
@ -308,20 +309,20 @@ class SomethingImpl : public Something {
class TglD3DRMIMAGE { class TglD3DRMIMAGE {
public: public:
TglD3DRMIMAGE( TglD3DRMIMAGE(
int p_width, int width,
int p_height, int height,
int p_depth, int depth,
void* p_buffer, void* pBuffer,
int p_useBuffer, int useBuffer,
int p_paletteSize, int paletteSize,
PaletteEntry* p_palette PaletteEntry* pEntries
); );
~TglD3DRMIMAGE() { Destroy(); } ~TglD3DRMIMAGE() { Destroy(); }
Result CreateBuffer(int p_width, int p_height, int p_depth, void* p_buffer, int p_useBuffer); Result CreateBuffer(int width, int height, int depth, void* pBuffer, int useBuffer);
void Destroy(); void Destroy();
void FillRowsOfTexture(int p_y, int p_height, char* p_content); void FillRowsOfTexture(int y, int height, char* content);
Result InitializePalette(int p_paletteSize, PaletteEntry* p_palette); Result InitializePalette(int paletteSize, PaletteEntry* pEntries);
D3DRMIMAGE m_image; D3DRMIMAGE m_image;
int m_texelsAllocatedByClient; int m_texelsAllocatedByClient;
@ -336,38 +337,38 @@ class TextureImpl : public Texture {
virtual void* ImplementationDataPtr(); virtual void* ImplementationDataPtr();
// vtable+0x08 // vtable+0x08
virtual Result SetTexels(int p_width, int p_height, int p_bitsPerTexel, void* p_texels); virtual Result SetTexels(int width, int height, int bitsPerTexel, void* pTexels);
virtual void FillRowsOfTexture(int p_y, int p_height, void* p_buffer); virtual void FillRowsOfTexture(int y, int height, void* pBuffer);
// vtable+0x10 // vtable+0x10
virtual Result Changed(int p_texelsChanged, int p_paletteChanged); virtual Result Changed(int texelsChanged, int paletteChanged);
virtual Result GetBufferAndPalette( virtual Result GetBufferAndPalette(
int* p_width, int* pWidth,
int* p_height, int* pHeight,
int* p_depth, int* pDepth,
void** p_buffer, void** ppBuffer,
int* p_paletteSize, int* ppPaletteSize,
PaletteEntry** p_palette PaletteEntry** ppPalette
); );
virtual Result SetPalette(int p_entryCount, PaletteEntry* p_entries); virtual Result SetPalette(int entryCount, PaletteEntry* entries);
inline IDirect3DRMTexture* ImplementationData() const { return m_data; } inline IDirect3DRMTexture* ImplementationData() const { return m_data; }
inline void SetImplementation(IDirect3DRMTexture* data) { m_data = data; } inline void SetImplementation(IDirect3DRMTexture* pData) { m_data = pData; }
friend class RendererImpl; friend class RendererImpl;
static Result SetImage(IDirect3DRMTexture* p_self, TglD3DRMIMAGE* p_image); static Result SetImage(IDirect3DRMTexture* pSelf, TglD3DRMIMAGE* pImage);
private: private:
IDirect3DRMTexture* m_data; IDirect3DRMTexture* m_data;
}; };
// Translation helpers // Translation helpers
inline D3DRMRENDERQUALITY Translate(ShadingModel p_tglShadingModel) inline D3DRMRENDERQUALITY Translate(ShadingModel tglShadingModel)
{ {
D3DRMRENDERQUALITY renderQuality; D3DRMRENDERQUALITY renderQuality;
switch (p_tglShadingModel) { switch (tglShadingModel) {
case Wireframe: case Wireframe:
renderQuality = D3DRMRENDER_WIREFRAME; renderQuality = D3DRMRENDER_WIREFRAME;
break; break;
@ -391,10 +392,10 @@ inline D3DRMRENDERQUALITY Translate(ShadingModel p_tglShadingModel)
return renderQuality; return renderQuality;
} }
inline D3DRMPROJECTIONTYPE Translate(ProjectionType p_tglProjectionType) inline D3DRMPROJECTIONTYPE Translate(ProjectionType tglProjectionType)
{ {
D3DRMPROJECTIONTYPE projectionType; D3DRMPROJECTIONTYPE projectionType;
switch (p_tglProjectionType) { switch (tglProjectionType) {
case Perspective: case Perspective:
projectionType = D3DRMPROJECT_PERSPECTIVE; projectionType = D3DRMPROJECT_PERSPECTIVE;
break; break;

View File

@ -21,19 +21,19 @@ void* LightImpl::ImplementationDataPtr()
} }
// OFFSET: LEGO1 0x100a3780 // OFFSET: LEGO1 0x100a3780
Result LightImpl::SetTransformation(const FloatMatrix4& p_matrix) Result LightImpl::SetTransformation(const FloatMatrix4& matrix)
{ {
D3DRMMATRIX4D helper; D3DRMMATRIX4D helper;
D3DRMMATRIX4D* matrix = Translate(p_matrix, helper); D3DRMMATRIX4D* d3dMatrix = Translate(matrix, helper);
return ResultVal(m_data->AddTransform(D3DRMCOMBINE_REPLACE, *matrix)); return ResultVal(m_data->AddTransform(D3DRMCOMBINE_REPLACE, *d3dMatrix));
} }
// OFFSET: LEGO1 0x100a37e0 // OFFSET: LEGO1 0x100a37e0
Result LightImpl::SetColor(float p_r, float p_g, float p_b) Result LightImpl::SetColor(float r, float g, float b)
{ {
IDirect3DRMLightArray* lightArray; IDirect3DRMLightArray* lightArray;
IDirect3DRMLight* light; IDirect3DRMLight* light;
m_data->GetLights(&lightArray); m_data->GetLights(&lightArray);
lightArray->GetElement(0, &light); lightArray->GetElement(0, &light);
return ResultVal(light->SetColorRGB(p_r, p_g, p_b)); return ResultVal(light->SetColorRGB(r, g, b));
} }

View File

@ -14,19 +14,19 @@ void* MeshImpl::ImplementationDataPtr()
} }
// OFFSET: LEGO1 0x100a3ee0 // OFFSET: LEGO1 0x100a3ee0
Result MeshImpl::SetColor(float p_r, float p_g, float p_b, float p_a) Result MeshImpl::SetColor(float r, float g, float b, float a)
{ {
// The first instruction makes no sense here: // The first instruction makes no sense here:
// cmp dword ptr [esp + 0x10], 0 // cmp dword ptr [esp + 0x10], 0
// This compares a, which we know is a float because it immediately // This compares a, which we know is a float because it immediately
// gets passed into D3DRMCreateColorRGBA, but does the comparison // gets passed into D3DRMCreateColorRGBA, but does the comparison
// as though it's an int?? // as though it's an int??
if (*reinterpret_cast<int*>(&p_a) > 0) { if (*reinterpret_cast<int*>(&a) > 0) {
D3DCOLOR color = D3DRMCreateColorRGBA(p_r, p_g, p_b, p_a); D3DCOLOR color = D3DRMCreateColorRGBA(r, g, b, a);
return ResultVal(m_data->groupMesh->SetGroupColor(m_data->groupIndex, color)); return ResultVal(m_data->groupMesh->SetGroupColor(m_data->groupIndex, color));
} }
else { else {
return ResultVal(m_data->groupMesh->SetGroupColorRGB(m_data->groupIndex, p_r, p_g, p_b)); return ResultVal(m_data->groupMesh->SetGroupColorRGB(m_data->groupIndex, r, g, b));
} }
} }
@ -34,16 +34,16 @@ Result MeshImpl::SetColor(float p_r, float p_g, float p_b, float p_a)
// TglImpl::MeshImpl::`scalar deleting destructor' // TglImpl::MeshImpl::`scalar deleting destructor'
// OFFSET: LEGO1 0x100a3f50 // OFFSET: LEGO1 0x100a3f50
Result MeshImpl::SetTexture(const Texture* p_texture) Result MeshImpl::SetTexture(const Texture* pTexture)
{ {
IDirect3DRMTexture* texture = p_texture ? static_cast<const TextureImpl*>(p_texture)->ImplementationData() : NULL; IDirect3DRMTexture* texture = pTexture ? static_cast<const TextureImpl*>(pTexture)->ImplementationData() : NULL;
return ResultVal(m_data->groupMesh->SetGroupTexture(m_data->groupIndex, texture)); return ResultVal(m_data->groupMesh->SetGroupTexture(m_data->groupIndex, texture));
} }
// OFFSET: LEGO1 0x100a3f80 // OFFSET: LEGO1 0x100a3f80
Result MeshImpl::SetTextureMappingMode(ProjectionType p_projType) Result MeshImpl::SetTextureMappingMode(ProjectionType projType)
{ {
if (p_projType == Perspective) { if (projType == Perspective) {
return ResultVal(m_data->groupMesh->SetGroupMapping(m_data->groupIndex, D3DRMMAP_PERSPCORRECT)); return ResultVal(m_data->groupMesh->SetGroupMapping(m_data->groupIndex, D3DRMMAP_PERSPCORRECT));
} }
else { else {
@ -52,10 +52,10 @@ Result MeshImpl::SetTextureMappingMode(ProjectionType p_projType)
} }
// OFFSET: LEGO1 0x100a3fc0 // OFFSET: LEGO1 0x100a3fc0
Result MeshImpl::SetShadingModel(ShadingModel p_model) Result MeshImpl::SetShadingModel(ShadingModel model)
{ {
D3DRMRENDERQUALITY mode; D3DRMRENDERQUALITY mode;
switch (p_model) { switch (model) {
case Wireframe: case Wireframe:
mode = D3DRMRENDER_WIREFRAME; mode = D3DRMRENDER_WIREFRAME;
break; break;
@ -76,21 +76,21 @@ Result MeshImpl::SetShadingModel(ShadingModel p_model)
} }
// OFFSET: LEGO1 0x100a4030 // OFFSET: LEGO1 0x100a4030
Mesh* MeshImpl::DeepClone(Something* p_mesh) Mesh* MeshImpl::DeepClone(Unk* pUnk)
{ {
// Create group // Create group
MeshImpl* newSomething = new MeshImpl(); MeshImpl* newMesh = new MeshImpl();
MeshData* data = new MeshData(); MeshData* data = new MeshData();
newSomething->m_data = data; newMesh->m_data = data;
// Query information from old group // Query information from old group
DWORD dataSize; DWORD dataSize;
unsigned int vcount, fcount, vperface; unsigned int vcount, fcount, vperface;
m_data->groupMesh->GetGroup(m_data->groupIndex, &vcount, &fcount, &vperface, &dataSize, NULL); m_data->groupMesh->GetGroup(m_data->groupIndex, &vcount, &fcount, &vperface, &dataSize, NULL);
unsigned int* faceBuffer = (unsigned int*) malloc(dataSize * sizeof(unsigned int)); unsigned int* faceBuffer = new unsigned int[dataSize];
m_data->groupMesh->GetGroup(m_data->groupIndex, &vcount, &fcount, &vperface, &dataSize, faceBuffer); m_data->groupMesh->GetGroup(m_data->groupIndex, &vcount, &fcount, &vperface, &dataSize, faceBuffer);
// We expect vertex to be sized 0x24, checked at start of file. // We expect vertex to be sized 0x24, checked at start of file.
D3DRMVERTEX* vertexBuffer = (D3DRMVERTEX*) malloc(vcount * sizeof(D3DRMVERTEX)); D3DRMVERTEX* vertexBuffer = new D3DRMVERTEX[vcount];
m_data->groupMesh->GetVertices(m_data->groupIndex, 0, vcount, vertexBuffer); m_data->groupMesh->GetVertices(m_data->groupIndex, 0, vcount, vertexBuffer);
LPDIRECT3DRMTEXTURE textureRef; LPDIRECT3DRMTEXTURE textureRef;
m_data->groupMesh->GetGroupTexture(m_data->groupIndex, &textureRef); m_data->groupMesh->GetGroupTexture(m_data->groupIndex, &textureRef);
@ -99,10 +99,10 @@ Mesh* MeshImpl::DeepClone(Something* p_mesh)
D3DCOLOR color = m_data->groupMesh->GetGroupColor(m_data->groupIndex); D3DCOLOR color = m_data->groupMesh->GetGroupColor(m_data->groupIndex);
// Push information to new group // Push information to new group
SomethingImpl* target = static_cast<SomethingImpl*>(p_mesh); UnkImpl* target = static_cast<UnkImpl*>(pUnk);
D3DRMGROUPINDEX index; D3DRMGROUPINDEX index;
target->ImplementationData()->AddGroup(vcount, fcount, vperface, faceBuffer, &index); target->ImplementationData()->AddGroup(vcount, fcount, vperface, faceBuffer, &index);
newSomething->m_data->groupIndex = index; newMesh->m_data->groupIndex = index;
target->ImplementationData()->SetVertices(index, 0, vcount, vertexBuffer); target->ImplementationData()->SetVertices(index, 0, vcount, vertexBuffer);
target->ImplementationData()->SetGroupTexture(index, textureRef); target->ImplementationData()->SetGroupTexture(index, textureRef);
target->ImplementationData()->SetGroupMapping(index, mapping); target->ImplementationData()->SetGroupMapping(index, mapping);
@ -110,27 +110,25 @@ Mesh* MeshImpl::DeepClone(Something* p_mesh)
Result result = ResultVal(target->ImplementationData()->SetGroupColor(index, color)); Result result = ResultVal(target->ImplementationData()->SetGroupColor(index, color));
// Cleanup // Cleanup
if (faceBuffer) delete[] faceBuffer;
free(faceBuffer); delete[] vertexBuffer;
if (vertexBuffer)
free(vertexBuffer);
if (result == Error) { if (result == Error) {
delete newSomething; delete newMesh;
newSomething = NULL; newMesh = NULL;
} }
return newSomething; return newMesh;
} }
// OFFSET: LEGO1 0x100a4240 // OFFSET: LEGO1 0x100a4240
Mesh* MeshImpl::ShallowClone(Something* p_mesh) Mesh* MeshImpl::ShallowClone(Unk* pUnk)
{ {
MeshImpl* newGroup = new MeshImpl(); MeshImpl* newGroup = new MeshImpl();
MeshData* newData = new MeshData(); MeshData* newData = new MeshData();
newGroup->m_data = newData; newGroup->m_data = newData;
if (newData) { if (newData) {
newData->groupIndex = m_data->groupIndex; newData->groupIndex = m_data->groupIndex;
newData->groupMesh = static_cast<SomethingImpl*>(p_mesh)->ImplementationData(); newData->groupMesh = static_cast<UnkImpl*>(pUnk)->ImplementationData();
} }
else { else {
delete newGroup; delete newGroup;
@ -140,7 +138,7 @@ Mesh* MeshImpl::ShallowClone(Something* p_mesh)
} }
// OFFSET: LEGO1 0x100a4330 // OFFSET: LEGO1 0x100a4330
Result MeshImpl::GetTexture(Texture*& p_texture) Result MeshImpl::GetTexture(Texture*& rpTexture)
{ {
IDirect3DRMTexture* texture; IDirect3DRMTexture* texture;
TextureImpl* holder = new TextureImpl(); TextureImpl* holder = new TextureImpl();
@ -155,6 +153,6 @@ Result MeshImpl::GetTexture(Texture*& p_texture)
// there. // there.
holder->SetImplementation(texture); holder->SetImplementation(texture);
} }
p_texture = holder; rpTexture = holder;
return Success; return Success;
} }

View File

@ -3,7 +3,7 @@
using namespace TglImpl; using namespace TglImpl;
// OFFSET: LEGO1 0x100a15e0 // OFFSET: LEGO1 0x100a15e0
Renderer* CreateRenderer() Renderer* Tgl::CreateRenderer()
{ {
RendererImpl* renderer = new RendererImpl(); RendererImpl* renderer = new RendererImpl();
if (!renderer->Create()) { if (!renderer->Create()) {
@ -42,10 +42,10 @@ void RendererImpl::Destroy()
} }
// OFFSET: LEGO1 0x100a1894 // OFFSET: LEGO1 0x100a1894
Device* RendererImpl::CreateDevice(const DeviceDirect3DCreateData& p_data) Device* RendererImpl::CreateDevice(const DeviceDirect3DCreateData& data)
{ {
DeviceImpl* device = new DeviceImpl(); DeviceImpl* device = new DeviceImpl();
HRESULT result = m_data->CreateDeviceFromD3D(p_data.m_pDirect3D, p_data.m_pDirect3DDevice, &device->m_data); HRESULT result = m_data->CreateDeviceFromD3D(data.m_pDirect3D, data.m_pDirect3DDevice, &device->m_data);
if (!SUCCEEDED(result)) { if (!SUCCEEDED(result)) {
delete device; delete device;
device = NULL; device = NULL;
@ -57,16 +57,16 @@ Device* RendererImpl::CreateDevice(const DeviceDirect3DCreateData& p_data)
static int gSetBufferCount = 1; static int gSetBufferCount = 1;
// OFFSET: LEGO1 0x100a1900 // OFFSET: LEGO1 0x100a1900
Device* RendererImpl::CreateDevice(const DeviceDirectDrawCreateData& p_data) Device* RendererImpl::CreateDevice(const DeviceDirectDrawCreateData& data)
{ {
DeviceImpl* device = new DeviceImpl(); DeviceImpl* device = new DeviceImpl();
HRESULT result = m_data->CreateDeviceFromSurface( HRESULT result = m_data->CreateDeviceFromSurface(
const_cast<LPGUID>(p_data.m_driverGUID), const_cast<LPGUID>(data.m_driverGUID),
p_data.m_pDirectDraw, data.m_pDirectDraw,
p_data.m_pBackBuffer, data.m_pBackBuffer,
&device->m_data &device->m_data
); );
if (SUCCEEDED(result) && p_data.m_pBackBuffer && gSetBufferCount) { if (SUCCEEDED(result) && data.m_pBackBuffer && gSetBufferCount) {
device->m_data->SetBufferCount(2); device->m_data->SetBufferCount(2);
} }
if (!SUCCEEDED(result)) { if (!SUCCEEDED(result)) {
@ -77,22 +77,22 @@ Device* RendererImpl::CreateDevice(const DeviceDirectDrawCreateData& p_data)
} }
inline Result RendererCreateView( inline Result RendererCreateView(
IDirect3DRM* p_renderer, IDirect3DRM* pRenderer,
IDirect3DRMDevice* p_device, IDirect3DRMDevice* pDevice,
IDirect3DRMFrame* p_camera, IDirect3DRMFrame* pCamera,
IDirect3DRMViewport*& p_view, IDirect3DRMViewport*& rpView,
unsigned long p_x, unsigned long x,
unsigned long p_y, unsigned long y,
unsigned long p_width, unsigned long width,
unsigned long p_height unsigned long height
) )
{ {
Result result = ResultVal(p_renderer->CreateViewport(p_device, p_camera, p_x, p_y, p_width, p_height, &p_view)); Result result = ResultVal(pRenderer->CreateViewport(pDevice, pCamera, x, y, width, height, &rpView));
if (Succeeded(result)) { if (Succeeded(result)) {
result = ViewImpl::ViewportCreateAppData(p_renderer, p_view, p_camera); result = ViewImpl::ViewportCreateAppData(pRenderer, rpView, pCamera);
if (!Succeeded(result)) { if (!Succeeded(result)) {
p_view->Release(); rpView->Release();
p_view = NULL; rpView = NULL;
} }
} }
return result; return result;
@ -100,24 +100,24 @@ inline Result RendererCreateView(
// OFFSET: LEGO1 0x100a1a00 // OFFSET: LEGO1 0x100a1a00
View* RendererImpl::CreateView( View* RendererImpl::CreateView(
const Device* p_device, const Device* pDevice,
const Camera* p_camera, const Camera* pCamera,
unsigned long p_x, unsigned long x,
unsigned long p_y, unsigned long y,
unsigned long p_width, unsigned long width,
unsigned long p_height unsigned long height
) )
{ {
ViewImpl* view = new ViewImpl(); ViewImpl* view = new ViewImpl();
Result result = RendererCreateView( Result result = RendererCreateView(
m_data, m_data,
static_cast<const DeviceImpl*>(p_device)->m_data, static_cast<const DeviceImpl*>(pDevice)->m_data,
static_cast<const CameraImpl*>(p_camera)->m_data, static_cast<const CameraImpl*>(pCamera)->m_data,
view->m_data, view->m_data,
p_x, x,
p_y, y,
p_width, width,
p_height height
); );
if (!result) { if (!result) {
delete view; delete view;
@ -126,25 +126,25 @@ View* RendererImpl::CreateView(
return view; return view;
} }
inline Result RendererCreateGroup(IDirect3DRM* p_renderer, IDirect3DRMFrame* p_parent, IDirect3DRMFrame*& p_group) inline Result RendererCreateGroup(IDirect3DRM* pRenderer, IDirect3DRMFrame* pParent, IDirect3DRMFrame*& rpGroup)
{ {
Result result = ResultVal(p_renderer->CreateFrame(NULL, &p_group)); Result result = ResultVal(pRenderer->CreateFrame(NULL, &rpGroup));
if (Succeeded(result) && p_parent) { if (Succeeded(result) && pParent) {
result = ResultVal(p_parent->AddVisual(p_group)); result = ResultVal(pParent->AddVisual(rpGroup));
if (!Succeeded(result)) { if (!Succeeded(result)) {
p_group->Release(); rpGroup->Release();
p_group = NULL; rpGroup = NULL;
} }
} }
return result; return result;
} }
// OFFSET: LEGO1 0x100a1b20 // OFFSET: LEGO1 0x100a1b20
Group* RendererImpl::CreateGroup(const Group* p_parent) Group* RendererImpl::CreateGroup(const Group* pParent)
{ {
GroupImpl* group = new GroupImpl(); GroupImpl* group = new GroupImpl();
Result result = Result result =
RendererCreateGroup(m_data, p_parent ? static_cast<const GroupImpl*>(p_parent)->m_data : NULL, group->m_data); RendererCreateGroup(m_data, pParent ? static_cast<const GroupImpl*>(pParent)->m_data : NULL, group->m_data);
if (!result) { if (!result) {
delete group; delete group;
group = NULL; group = NULL;
@ -164,11 +164,11 @@ Camera* RendererImpl::CreateCamera()
} }
// OFFSET: LEGO1 0x100a1cf0 // OFFSET: LEGO1 0x100a1cf0
Light* RendererImpl::CreateLight(LightType p_type, float p_r, float p_g, float p_b) Light* RendererImpl::CreateLight(LightType type, float r, float g, float b)
{ {
LightImpl* newLight = new LightImpl(); LightImpl* newLight = new LightImpl();
D3DRMLIGHTTYPE translatedType; D3DRMLIGHTTYPE translatedType;
switch (p_type) { switch (type) {
case Ambient: case Ambient:
translatedType = D3DRMLIGHT_AMBIENT; translatedType = D3DRMLIGHT_AMBIENT;
break; break;
@ -192,7 +192,7 @@ Light* RendererImpl::CreateLight(LightType p_type, float p_r, float p_g, float p
Result result = ResultVal(m_data->CreateFrame(NULL, &frame)); Result result = ResultVal(m_data->CreateFrame(NULL, &frame));
if (Succeeded(result)) { if (Succeeded(result)) {
LPDIRECT3DRMLIGHT d3dLight; LPDIRECT3DRMLIGHT d3dLight;
result = ResultVal(m_data->CreateLightRGB(translatedType, p_r, p_g, p_b, &d3dLight)); result = ResultVal(m_data->CreateLightRGB(translatedType, r, g, b, &d3dLight));
if (!Succeeded(result)) { if (!Succeeded(result)) {
frame->Release(); frame->Release();
} }
@ -216,44 +216,44 @@ Light* RendererImpl::CreateLight(LightType p_type, float p_r, float p_g, float p
} }
// OFFSET: LEGO1 0x100a1e90 // OFFSET: LEGO1 0x100a1e90
Something* RendererImpl::CreateSomething() Unk* RendererImpl::CreateUnk()
{ {
// Note: I'm fairly certain that Something is not what Tgl calls a // Note: I'm fairly certain that Unknown is not what Tgl calls a
// "Mesh", because the methods on Mesh in the Tgl leak line up much // "Mesh", because the methods on Mesh in the Tgl leak line up much
// more closely with a different vtable than the one assigned in // more closely with a different vtable than the one assigned in
// this method (meaning this method is not creating a Mesh). // this method (meaning this method is not creating a Mesh).
// Maybe this method is something like CreateMeshBuilder where the // Maybe this method is something like CreateMeshBuilder where the
// Mesh data type in the Tgl leak was split into builder/result? // Mesh data type in the Tgl leak was split into builder/result?
SomethingImpl* something = new SomethingImpl(); UnkImpl* unknown = new UnkImpl();
if (FAILED(m_data->CreateMesh(&something->m_data))) { if (FAILED(m_data->CreateMesh(&unknown->m_data))) {
delete something; delete unknown;
something = NULL; unknown = NULL;
} }
return something; return unknown;
} }
inline Result RendererCreateTexture( inline Result RendererCreateTexture(
IDirect3DRM* p_renderer, IDirect3DRM* renderer,
IDirect3DRMTexture*& p_texture, IDirect3DRMTexture*& texture,
int p_width, int width,
int p_height, int height,
int p_bytesPerPixel, int bytesPerPixel,
void* p_buffer, void* pBuffer,
int p_useBuffer, int useBuffer,
int p_paletteSize, int paletteSize,
PaletteEntry* p_palette PaletteEntry* pEntries
) )
{ {
TglD3DRMIMAGE* image; TglD3DRMIMAGE* image;
Result result; Result result;
image = new TglD3DRMIMAGE(p_width, p_height, p_bytesPerPixel, p_buffer, p_useBuffer, p_paletteSize, p_palette); image = new TglD3DRMIMAGE(width, height, bytesPerPixel, pBuffer, useBuffer, paletteSize, pEntries);
result = ResultVal(p_renderer->CreateTexture(&image->m_image, &p_texture)); result = ResultVal(renderer->CreateTexture(&image->m_image, &texture));
if (Succeeded(result)) { if (Succeeded(result)) {
result = TextureImpl::SetImage(p_texture, image); result = TextureImpl::SetImage(texture, image);
if (!Succeeded(result)) { if (!Succeeded(result)) {
p_texture->Release(); texture->Release();
p_texture = NULL; texture = NULL;
delete image; delete image;
} }
} }
@ -265,26 +265,26 @@ inline Result RendererCreateTexture(
// OFFSET: LEGO1 0x100a1f50 // OFFSET: LEGO1 0x100a1f50
Texture* RendererImpl::CreateTexture( Texture* RendererImpl::CreateTexture(
int p_width, int width,
int p_height, int height,
int p_bitsPerTexel, int bitsPerTexel,
const void* p_pTexels, const void* pTexels,
int p_texelsArePersistent, int texelsArePersistent,
int p_paletteEntryCount, int paletteEntryCount,
const PaletteEntry* p_pEntries const PaletteEntry* pEntries
) )
{ {
TextureImpl* texture = new TextureImpl(); TextureImpl* texture = new TextureImpl();
if (!Succeeded(RendererCreateTexture( if (!Succeeded(RendererCreateTexture(
m_data, m_data,
texture->m_data, texture->m_data,
p_width, width,
p_height, height,
p_bitsPerTexel, bitsPerTexel,
const_cast<void*>(p_pTexels), const_cast<void*>(pTexels),
p_texelsArePersistent, texelsArePersistent,
p_paletteEntryCount, paletteEntryCount,
const_cast<PaletteEntry*>(p_pEntries) const_cast<PaletteEntry*>(pEntries)
))) { ))) {
delete texture; delete texture;
texture = NULL; texture = NULL;
@ -305,15 +305,15 @@ Texture* RendererImpl::CreateTexture()
// OFFSET: LEGO1 0x100a2270 // OFFSET: LEGO1 0x100a2270
Result RendererImpl::SetTextureDefaultShadeCount(unsigned long p_shadeCount) Result RendererImpl::SetTextureDefaultShadeCount(unsigned long shadeCount)
{ {
return ResultVal(m_data->SetDefaultTextureShades(p_shadeCount)); return ResultVal(m_data->SetDefaultTextureShades(shadeCount));
} }
// OFFSET: LEGO1 0x100a2290 // OFFSET: LEGO1 0x100a2290
Result RendererImpl::SetTextureDefaultColorCount(unsigned long p_colorCount) Result RendererImpl::SetTextureDefaultColorCount(unsigned long colorCount)
{ {
return ResultVal(m_data->SetDefaultTextureColors(p_colorCount)); return ResultVal(m_data->SetDefaultTextureColors(colorCount));
} }
// OFFSET: LEGO1 0x100a22b0 // OFFSET: LEGO1 0x100a22b0

View File

@ -1,63 +0,0 @@
#include "impl.h"
using namespace TglImpl;
DECOMP_SIZE_ASSERT(Something, 0x4);
DECOMP_SIZE_ASSERT(SomethingImpl, 0x8);
// Inlined only
SomethingImpl::~SomethingImpl()
{
if (m_data) {
m_data->Release();
m_data = NULL;
}
}
// OFFSET: LEGO1 0x100a3830
void* SomethingImpl::ImplementationDataPtr()
{
return reinterpret_cast<void*>(&m_data);
}
// OFFSET: LEGO1 0x100a3840 STUB
Result SomethingImpl::SetMeshData(
unsigned long p_faceCount,
unsigned long p_vertexCount,
const float (*p_positions)[3],
const float (*p_normals)[3],
const float (*p_textureCoordinates)[2],
unsigned long p_vertexPerFaceCount,
unsigned long* p_faceData
)
{
return Error;
}
// OFFSET: LEGO1 0x100a3ae0
Result SomethingImpl::GetBoundingBox(float p_min[3], float p_max[3])
{
D3DRMBOX box;
Result result = ResultVal(m_data->GetBox(&box));
if (result == Success) {
p_min[0] = box.min.x;
p_min[1] = box.min.y;
p_min[2] = box.min.z;
p_max[0] = box.max.x;
p_max[1] = box.max.y;
p_max[2] = box.max.z;
}
return result;
}
// OFFSET: LEGO1 0x100a3b40
Something* SomethingImpl::Clone()
{
SomethingImpl* mesh = new SomethingImpl();
int ret = m_data->Clone(0, IID_IDirect3DRMMeshBuilder, (void**) &mesh->m_data);
if (ret < 0) {
delete mesh;
mesh = NULL;
}
return mesh;
}

View File

@ -4,31 +4,31 @@ using namespace TglImpl;
DECOMP_SIZE_ASSERT(TglD3DRMIMAGE, 0x40); DECOMP_SIZE_ASSERT(TglD3DRMIMAGE, 0x40);
inline TglD3DRMIMAGE* TextureGetImage(IDirect3DRMTexture* p_texture) inline TglD3DRMIMAGE* TextureGetImage(IDirect3DRMTexture* pTexture)
{ {
return reinterpret_cast<TglD3DRMIMAGE*>(p_texture->GetAppData()); return reinterpret_cast<TglD3DRMIMAGE*>(pTexture->GetAppData());
} }
// Forward declare to satisfy order check // Forward declare to satisfy order check
void TextureDestroyCallback(IDirect3DRMObject* pObject, void* pArg); void TextureDestroyCallback(IDirect3DRMObject* pObject, void* pArg);
// OFFSET: LEGO1 0x100a12a0 // OFFSET: LEGO1 0x100a12a0
Result TextureImpl::SetImage(IDirect3DRMTexture* p_self, TglD3DRMIMAGE* p_image) Result TextureImpl::SetImage(IDirect3DRMTexture* pSelf, TglD3DRMIMAGE* pImage)
{ {
unsigned long appData; unsigned long appData;
Result result; Result result;
appData = reinterpret_cast<unsigned long>(p_image); appData = reinterpret_cast<unsigned long>(pImage);
// This is here because in the original code they asserted // This is here because in the original code they asserted
// on the return value being NULL. // on the return value being NULL.
TextureGetImage(p_self); TextureGetImage(pSelf);
result = ResultVal(p_self->SetAppData(appData)); result = ResultVal(pSelf->SetAppData(appData));
if (Succeeded(result) && p_image) { if (Succeeded(result) && pImage) {
result = ResultVal(p_self->AddDestroyCallback(TextureDestroyCallback, NULL)); result = ResultVal(pSelf->AddDestroyCallback(TextureDestroyCallback, NULL));
if (!Succeeded(result)) { if (!Succeeded(result)) {
p_self->SetAppData(0); pSelf->SetAppData(0);
} }
} }
return result; return result;
@ -44,13 +44,13 @@ void TextureDestroyCallback(IDirect3DRMObject* pObject, void* pArg)
// OFFSET: LEGO1 0x100a1330 // OFFSET: LEGO1 0x100a1330
TglD3DRMIMAGE::TglD3DRMIMAGE( TglD3DRMIMAGE::TglD3DRMIMAGE(
int p_width, int width,
int p_height, int height,
int p_depth, int depth,
void* p_buffer, void* pBuffer,
int p_useBuffer, int useBuffer,
int p_paletteSize, int paletteSize,
PaletteEntry* p_palette PaletteEntry* pEntries
) )
{ {
m_image.aspectx = 1; m_image.aspectx = 1;
@ -69,11 +69,11 @@ TglD3DRMIMAGE::TglD3DRMIMAGE(
m_image.palette_size = 0; m_image.palette_size = 0;
m_image.palette = NULL; m_image.palette = NULL;
m_texelsAllocatedByClient = 0; m_texelsAllocatedByClient = 0;
if (p_buffer != NULL) { if (pBuffer != NULL) {
CreateBuffer(p_width, p_height, p_depth, p_buffer, p_useBuffer); CreateBuffer(width, height, depth, pBuffer, useBuffer);
} }
if (p_palette != NULL) { if (pEntries != NULL) {
InitializePalette(p_paletteSize, p_palette); InitializePalette(paletteSize, pEntries);
} }
} }
@ -87,39 +87,39 @@ void TglD3DRMIMAGE::Destroy()
} }
// OFFSET: LEGO1 0x100a13e0 STUB // OFFSET: LEGO1 0x100a13e0 STUB
Result TglD3DRMIMAGE::CreateBuffer(int p_width, int p_height, int p_depth, void* p_buffer, int p_useBuffer) Result TglD3DRMIMAGE::CreateBuffer(int width, int height, int depth, void* pBuffer, int useBuffer)
{ {
return Error; return Error;
} }
// OFFSET: LEGO1 0x100a1510 // OFFSET: LEGO1 0x100a1510
void TglD3DRMIMAGE::FillRowsOfTexture(int p_y, int p_height, char* p_content) void TglD3DRMIMAGE::FillRowsOfTexture(int y, int height, char* pContent)
{ {
// The purpose is clearly this but I can't get the assembly to line up. // The purpose is clearly this but I can't get the assembly to line up.
memcpy((char*) m_image.buffer1 + (p_y * m_image.bytes_per_line), p_content, p_height * m_image.bytes_per_line); memcpy((char*) m_image.buffer1 + (y * m_image.bytes_per_line), pContent, height * m_image.bytes_per_line);
} }
// OFFSET: LEGO1 0x100a1550 // OFFSET: LEGO1 0x100a1550
Result TglD3DRMIMAGE::InitializePalette(int p_paletteSize, PaletteEntry* p_palette) Result TglD3DRMIMAGE::InitializePalette(int paletteSize, PaletteEntry* pEntries)
{ {
// This function is a 100% match if the PaletteEntry class is copied // This function is a 100% match if the PaletteEntry class is copied
// into into the TglD3DRMIMAGE class instead of being a global struct. // into into the TglD3DRMIMAGE class instead of being a global struct.
if (m_image.palette_size != p_paletteSize) { if (m_image.palette_size != paletteSize) {
if (m_image.palette != NULL) { if (m_image.palette != NULL) {
free(m_image.palette); free(m_image.palette);
m_image.palette = NULL; m_image.palette = NULL;
m_image.palette_size = 0; m_image.palette_size = 0;
} }
if (p_paletteSize > 0) { if (paletteSize > 0) {
m_image.palette = (D3DRMPALETTEENTRY*) malloc(4 * p_paletteSize); m_image.palette = (D3DRMPALETTEENTRY*) malloc(4 * paletteSize);
m_image.palette_size = p_paletteSize; m_image.palette_size = paletteSize;
} }
} }
if (p_paletteSize > 0) { if (paletteSize > 0) {
for (int i = 0; i < p_paletteSize; i++) { for (int i = 0; i < paletteSize; i++) {
m_image.palette[i].red = p_palette[i].m_red; m_image.palette[i].red = pEntries[i].m_red;
m_image.palette[i].green = p_palette[i].m_green; m_image.palette[i].green = pEntries[i].m_green;
m_image.palette[i].blue = p_palette[i].m_blue; m_image.palette[i].blue = pEntries[i].m_blue;
m_image.palette[i].flags = D3DRMPALETTE_READONLY; m_image.palette[i].flags = D3DRMPALETTE_READONLY;
} }
} }
@ -136,10 +136,10 @@ TextureImpl::~TextureImpl()
} }
// OFFSET: LEGO1 0x100a3c10 // OFFSET: LEGO1 0x100a3c10
Result TextureImpl::SetTexels(int p_width, int p_height, int p_bitsPerTexel, void* p_texels) Result TextureImpl::SetTexels(int width, int height, int bitsPerTexel, void* pTexels)
{ {
TglD3DRMIMAGE* image = TextureGetImage(m_data); TglD3DRMIMAGE* image = TextureGetImage(m_data);
Result result = image->CreateBuffer(p_width, p_height, p_bitsPerTexel, p_texels, TRUE); Result result = image->CreateBuffer(width, height, bitsPerTexel, pTexels, TRUE);
if (Succeeded(result)) { if (Succeeded(result)) {
result = ResultVal(m_data->Changed(TRUE, FALSE)); result = ResultVal(m_data->Changed(TRUE, FALSE));
} }
@ -147,50 +147,50 @@ Result TextureImpl::SetTexels(int p_width, int p_height, int p_bitsPerTexel, voi
} }
// OFFSET: LEGO1 0x100a3c60 // OFFSET: LEGO1 0x100a3c60
void TextureImpl::FillRowsOfTexture(int p_y, int p_height, void* p_buffer) void TextureImpl::FillRowsOfTexture(int y, int height, void* pBuffer)
{ {
TglD3DRMIMAGE* image = TextureGetImage(m_data); TglD3DRMIMAGE* image = TextureGetImage(m_data);
image->FillRowsOfTexture(p_y, p_height, (char*) p_buffer); image->FillRowsOfTexture(y, height, (char*) pBuffer);
} }
// OFFSET: LEGO1 0x100a3c90 // OFFSET: LEGO1 0x100a3c90
Result TextureImpl::Changed(int p_texelsChanged, int p_paletteChanged) Result TextureImpl::Changed(int texelsChanged, int paletteChanged)
{ {
return ResultVal(m_data->Changed(p_texelsChanged, p_paletteChanged)); return ResultVal(m_data->Changed(texelsChanged, paletteChanged));
} }
// OFFSET: LEGO1 0x100a3d00 // OFFSET: LEGO1 0x100a3d00
Result TextureImpl::GetBufferAndPalette( Result TextureImpl::GetBufferAndPalette(
int* p_width, int* width,
int* p_height, int* height,
int* p_depth, int* depth,
void** p_buffer, void** pBuffer,
int* p_paletteSize, int* paletteSize,
PaletteEntry** p_palette PaletteEntry** pEntries
) )
{ {
// Something really doesn't match here, not sure what's up. // Something really doesn't match here, not sure what's up.
TglD3DRMIMAGE* image = TextureGetImage(m_data); TglD3DRMIMAGE* image = TextureGetImage(m_data);
*p_width = image->m_image.width; *width = image->m_image.width;
*p_height = image->m_image.height; *height = image->m_image.height;
*p_depth = image->m_image.depth; *depth = image->m_image.depth;
*p_buffer = image->m_image.buffer1; *pBuffer = image->m_image.buffer1;
*p_paletteSize = image->m_image.palette_size; *paletteSize = image->m_image.palette_size;
for (int i = 0; i < image->m_image.palette_size; i++) { for (int i = 0; i < image->m_image.palette_size; i++) {
p_palette[i]->m_red = image->m_image.palette[i].red; pEntries[i]->m_red = image->m_image.palette[i].red;
p_palette[i]->m_green = image->m_image.palette[i].green; pEntries[i]->m_green = image->m_image.palette[i].green;
p_palette[i]->m_blue = image->m_image.palette[i].blue; pEntries[i]->m_blue = image->m_image.palette[i].blue;
} }
return Success; return Success;
} }
// OFFSET: LEGO1 0x100a3d40 // OFFSET: LEGO1 0x100a3d40
Result TextureImpl::SetPalette(int p_entryCount, PaletteEntry* p_entries) Result TextureImpl::SetPalette(int entryCount, PaletteEntry* pEntries)
{ {
// Not 100% confident this is supposed to directly be forwarding arguments, // Not 100% confident this is supposed to directly be forwarding arguments,
// but it probably is given FillRowsOfTexture matches doing that. // but it probably is given FillRowsOfTexture matches doing that.
TglD3DRMIMAGE* image = TextureGetImage(m_data); TglD3DRMIMAGE* image = TextureGetImage(m_data);
image->InitializePalette(p_entryCount, p_entries); image->InitializePalette(entryCount, pEntries);
m_data->Changed(FALSE, TRUE); m_data->Changed(FALSE, TRUE);
return Success; return Success;
} }

63
LEGO1/tgl/d3drm/unk.cpp Normal file
View File

@ -0,0 +1,63 @@
#include "impl.h"
using namespace TglImpl;
DECOMP_SIZE_ASSERT(Unk, 0x4);
DECOMP_SIZE_ASSERT(UnkImpl, 0x8);
// Inlined only
UnkImpl::~UnkImpl()
{
if (m_data) {
m_data->Release();
m_data = NULL;
}
}
// OFFSET: LEGO1 0x100a3830
void* UnkImpl::ImplementationDataPtr()
{
return reinterpret_cast<void*>(&m_data);
}
// OFFSET: LEGO1 0x100a3840 STUB
Result UnkImpl::SetMeshData(
unsigned long faceCount,
unsigned long vertexCount,
const float (*pPositions)[3],
const float (*pNormals)[3],
const float (*pTextureCoordinates)[2],
unsigned long vertexPerFaceCount,
unsigned long* pFaceData
)
{
return Error;
}
// OFFSET: LEGO1 0x100a3ae0
Result UnkImpl::GetBoundingBox(float min[3], float max[3])
{
D3DRMBOX box;
Result result = ResultVal(m_data->GetBox(&box));
if (result == Success) {
min[0] = box.min.x;
min[1] = box.min.y;
min[2] = box.min.z;
max[0] = box.max.x;
max[1] = box.max.y;
max[2] = box.max.z;
}
return result;
}
// OFFSET: LEGO1 0x100a3b40
Unk* UnkImpl::Clone()
{
UnkImpl* mesh = new UnkImpl();
int ret = m_data->Clone(0, IID_IDirect3DRMMeshBuilder, (void**) &mesh->m_data);
if (ret < 0) {
delete mesh;
mesh = NULL;
}
return mesh;
}

View File

@ -3,7 +3,7 @@
using namespace TglImpl; using namespace TglImpl;
struct ViewportAppData { struct ViewportAppData {
ViewportAppData(IDirect3DRM* p_renderer); ViewportAppData(IDirect3DRM* pRenderer);
~ViewportAppData(); ~ViewportAppData();
IDirect3DRMFrame* m_pLightFrame; IDirect3DRMFrame* m_pLightFrame;
@ -17,9 +17,9 @@ struct ViewportAppData {
DECOMP_SIZE_ASSERT(ViewportAppData, 0x18); DECOMP_SIZE_ASSERT(ViewportAppData, 0x18);
// OFFSET: LEGO1 0x100a10b0 // OFFSET: LEGO1 0x100a10b0
ViewportAppData::ViewportAppData(IDirect3DRM* p_renderer) ViewportAppData::ViewportAppData(IDirect3DRM* pRenderer)
{ {
p_renderer->CreateFrame(NULL, &m_pLightFrame); pRenderer->CreateFrame(NULL, &m_pLightFrame);
m_pCamera = NULL; m_pCamera = NULL;
m_pLastRenderedFrame = NULL; m_pLastRenderedFrame = NULL;
m_backgroundColorRed = 0.0f; m_backgroundColorRed = 0.0f;
@ -43,20 +43,20 @@ ViewportAppData::~ViewportAppData()
} }
// Forward declare to satisfy order check // Forward declare to satisfy order check
void ViewportDestroyCallback(IDirect3DRMObject* p_object, void* p_arg); void ViewportDestroyCallback(IDirect3DRMObject* pObject, void* pArg);
// OFFSET: LEGO1 0x100a1160 // OFFSET: LEGO1 0x100a1160
Result ViewImpl::ViewportCreateAppData(IDirect3DRM* p_device, IDirect3DRMViewport* p_view, IDirect3DRMFrame* p_camera) Result ViewImpl::ViewportCreateAppData(IDirect3DRM* pDevice, IDirect3DRMViewport* pView, IDirect3DRMFrame* pCamera)
{ {
ViewportAppData* data = new ViewportAppData(p_device); ViewportAppData* data = new ViewportAppData(pDevice);
data->m_pCamera = p_camera; data->m_pCamera = pCamera;
Result result = ResultVal(p_view->SetAppData(reinterpret_cast<unsigned long>(data))); Result result = ResultVal(pView->SetAppData(reinterpret_cast<unsigned long>(data)));
if (Succeeded(result)) { if (Succeeded(result)) {
result = ResultVal(p_view->AddDestroyCallback(ViewportDestroyCallback, data)); result = ResultVal(pView->AddDestroyCallback(ViewportDestroyCallback, data));
} }
if (!Succeeded(result)) { if (!Succeeded(result)) {
delete data; delete data;
p_view->SetAppData(0); pView->SetAppData(0);
} }
return result; return result;
} }
@ -81,9 +81,9 @@ inline Result ViewRestoreFrameAfterRender(
} }
// OFFSET: LEGO1 0x100a1240 // OFFSET: LEGO1 0x100a1240
void ViewportDestroyCallback(IDirect3DRMObject* p_object, void* p_arg) void ViewportDestroyCallback(IDirect3DRMObject* pObject, void* pArg)
{ {
ViewportAppData* pViewportAppData = reinterpret_cast<ViewportAppData*>(p_arg); ViewportAppData* pViewportAppData = reinterpret_cast<ViewportAppData*>(pArg);
ViewRestoreFrameAfterRender( ViewRestoreFrameAfterRender(
pViewportAppData->m_pLastRenderedFrame, pViewportAppData->m_pLastRenderedFrame,
@ -96,7 +96,7 @@ void ViewportDestroyCallback(IDirect3DRMObject* p_object, void* p_arg)
// OFFSET: LEGO1 0x100a1290 // OFFSET: LEGO1 0x100a1290
Result ViewportPickImpl( Result ViewportPickImpl(
IDirect3DRMViewport* p_viewport, IDirect3DRMViewport* pViewport,
int x, int x,
int y, int y,
const Group** ppGroupsToPickFrom, const Group** ppGroupsToPickFrom,
@ -109,14 +109,14 @@ Result ViewportPickImpl(
return Error; return Error;
} }
inline ViewportAppData* ViewportGetData(IDirect3DRMViewport* p_viewport) inline ViewportAppData* ViewportGetData(IDirect3DRMViewport* pViewport)
{ {
return reinterpret_cast<ViewportAppData*>(p_viewport->GetAppData()); return reinterpret_cast<ViewportAppData*>(pViewport->GetAppData());
} }
inline IDirect3DRMFrame* ViewportGetLightFrame(IDirect3DRMViewport* p_viewport) inline IDirect3DRMFrame* ViewportGetLightFrame(IDirect3DRMViewport* pViewport)
{ {
return ViewportGetData(p_viewport)->m_pLightFrame; return ViewportGetData(pViewport)->m_pLightFrame;
} }
// Inlined only // Inlined only
@ -135,25 +135,25 @@ void* ViewImpl::ImplementationDataPtr()
} }
// OFFSET: LEGO1 0x100a2d90 // OFFSET: LEGO1 0x100a2d90
Result ViewImpl::Add(const Light* p_light) Result ViewImpl::Add(const Light* pLight)
{ {
const LightImpl* light = static_cast<const LightImpl*>(p_light); const LightImpl* light = static_cast<const LightImpl*>(pLight);
IDirect3DRMFrame* frame = light->ImplementationData(); IDirect3DRMFrame* frame = light->ImplementationData();
return ResultVal(ViewportGetLightFrame(m_data)->AddChild(frame)); return ResultVal(ViewportGetLightFrame(m_data)->AddChild(frame));
} }
// OFFSET: LEGO1 0x100a2dc0 // OFFSET: LEGO1 0x100a2dc0
Result ViewImpl::Remove(const Light* p_light) Result ViewImpl::Remove(const Light* pLight)
{ {
const LightImpl* light = static_cast<const LightImpl*>(p_light); const LightImpl* light = static_cast<const LightImpl*>(pLight);
IDirect3DRMFrame* frame = light->ImplementationData(); IDirect3DRMFrame* frame = light->ImplementationData();
return ResultVal(ViewportGetLightFrame(m_data)->DeleteChild(frame)); return ResultVal(ViewportGetLightFrame(m_data)->DeleteChild(frame));
} }
// OFFSET: LEGO1 0x100a2df0 // OFFSET: LEGO1 0x100a2df0
Result ViewImpl::SetCamera(const Camera* p_camera) Result ViewImpl::SetCamera(const Camera* pCamera)
{ {
const CameraImpl* camera = static_cast<const CameraImpl*>(p_camera); const CameraImpl* camera = static_cast<const CameraImpl*>(pCamera);
IDirect3DRMFrame* frame = camera->ImplementationData(); IDirect3DRMFrame* frame = camera->ImplementationData();
ViewportAppData* pViewportAppData; ViewportAppData* pViewportAppData;
@ -172,19 +172,19 @@ Result ViewImpl::SetCamera(const Camera* p_camera)
} }
// OFFSET: LEGO1 0x100a2e70 // OFFSET: LEGO1 0x100a2e70
Result ViewImpl::SetProjection(ProjectionType p_type) Result ViewImpl::SetProjection(ProjectionType type)
{ {
return ResultVal(m_data->SetProjection(Translate(p_type))); return ResultVal(m_data->SetProjection(Translate(type)));
} }
// OFFSET: LEGO1 0x100a2eb0 // OFFSET: LEGO1 0x100a2eb0
Result ViewImpl::SetFrustrum(float p_frontClippingDistance, float p_backClippingDistance, float p_degrees) Result ViewImpl::SetFrustrum(float frontClippingDistance, float backClippingDistance, float degrees)
{ {
float field = p_frontClippingDistance * tan(DegreesToRadians(p_degrees / 2)); float field = frontClippingDistance * tan(DegreesToRadians(degrees / 2));
Result result; Result result;
result = ResultVal(m_data->SetFront(p_frontClippingDistance)); result = ResultVal(m_data->SetFront(frontClippingDistance));
if (Succeeded(result)) { if (Succeeded(result)) {
result = ResultVal(m_data->SetBack(p_backClippingDistance)); result = ResultVal(m_data->SetBack(backClippingDistance));
} }
if (Succeeded(result)) { if (Succeeded(result)) {
result = ResultVal(m_data->SetField(field)); result = ResultVal(m_data->SetField(field));
@ -194,28 +194,28 @@ Result ViewImpl::SetFrustrum(float p_frontClippingDistance, float p_backClipping
} }
// OFFSET: LEGO1 0x100a2f30 // OFFSET: LEGO1 0x100a2f30
Result ViewImpl::SetBackgroundColor(float p_r, float p_g, float p_b) Result ViewImpl::SetBackgroundColor(float r, float g, float b)
{ {
Result ret = Success; Result ret = Success;
// Note, this method in the shipped game is very diverged from // Note, this method in the shipped game is very diverged from
// the Tgl leak code. // the Tgl leak code.
ViewportAppData* data = ViewportGetData(m_data); ViewportAppData* data = ViewportGetData(m_data);
data->m_backgroundColorRed = p_r; data->m_backgroundColorRed = r;
data->m_backgroundColorGreen = p_g; data->m_backgroundColorGreen = g;
data->m_backgroundColorBlue = p_b; data->m_backgroundColorBlue = b;
if (data->m_pLastRenderedFrame) { if (data->m_pLastRenderedFrame) {
ret = ResultVal(data->m_pLastRenderedFrame->SetSceneBackgroundRGB(p_r, p_g, p_b)); ret = ResultVal(data->m_pLastRenderedFrame->SetSceneBackgroundRGB(r, g, b));
} }
return ret; return ret;
} }
// OFFSET: LEGO1 0x100a2f80 // OFFSET: LEGO1 0x100a2f80
Result ViewImpl::GetBackgroundColor(float* p_r, float* p_g, float* p_b) Result ViewImpl::GetBackgroundColor(float* r, float* g, float* b)
{ {
ViewportAppData* data = ViewportGetData(m_data); ViewportAppData* data = ViewportGetData(m_data);
*p_r = data->m_backgroundColorRed; *r = data->m_backgroundColorRed;
*p_g = data->m_backgroundColorGreen; *g = data->m_backgroundColorGreen;
*p_b = data->m_backgroundColorBlue; *b = data->m_backgroundColorBlue;
return Success; return Success;
} }
@ -254,11 +254,11 @@ inline Result ViewPrepareFrameForRender(
} }
// OFFSET: LEGO1 0x100a2fd0 // OFFSET: LEGO1 0x100a2fd0
Result ViewImpl::Render(const Light* p_camera) Result ViewImpl::Render(const Light* pCamera)
{ {
ViewportAppData* appdata = ViewportGetData(m_data); ViewportAppData* appdata = ViewportGetData(m_data);
IDirect3DRMFrame* light = static_cast<const LightImpl*>(p_camera)->ImplementationData(); IDirect3DRMFrame* light = static_cast<const LightImpl*>(pCamera)->ImplementationData();
IDirect3DRMFrame* lastRendered = appdata->m_pLastRenderedFrame; IDirect3DRMFrame* lastRendered = appdata->m_pLastRenderedFrame;
if (light != lastRendered) { if (light != lastRendered) {
@ -332,23 +332,23 @@ Result ViewImpl::TransformWorldToScreen(const float world[3], float screen[4])
} }
// OFFSET: LEGO1 0x100a3160 // OFFSET: LEGO1 0x100a3160
Result ViewImpl::TransformScreenToWorld(const float p_screen[4], float p_world[3]) Result ViewImpl::TransformScreenToWorld(const float screen[4], float world[3])
{ {
// 100% match minus instruction reordering. // 100% match minus instruction reordering.
D3DVECTOR d3dRMWorld; D3DVECTOR d3dRMWorld;
D3DRMVECTOR4D d3dScreen; D3DRMVECTOR4D d3dScreen;
d3dScreen.x = p_screen[0]; d3dScreen.x = screen[0];
d3dScreen.y = p_screen[1]; d3dScreen.y = screen[1];
d3dScreen.z = p_screen[2]; d3dScreen.z = screen[2];
d3dScreen.w = p_screen[3]; d3dScreen.w = screen[3];
Result result; Result result;
result = ResultVal(m_data->InverseTransform(&d3dRMWorld, &d3dScreen)); result = ResultVal(m_data->InverseTransform(&d3dRMWorld, &d3dScreen));
if (Succeeded(result)) { if (Succeeded(result)) {
p_world[0] = d3dRMWorld.x; world[0] = d3dRMWorld.x;
p_world[1] = d3dRMWorld.y; world[1] = d3dRMWorld.y;
p_world[2] = d3dRMWorld.z; world[2] = d3dRMWorld.z;
} }
return result; return result;

View File

@ -96,7 +96,7 @@ class Camera;
class Group; class Group;
class Mesh; class Mesh;
class Texture; class Texture;
class Something; class Unk;
// VTABLE 0x100db980 // VTABLE 0x100db980
class Object { class Object {
@ -123,20 +123,20 @@ class Renderer : public Object {
unsigned long height unsigned long height
) = 0; ) = 0;
virtual Camera* CreateCamera() = 0; virtual Camera* CreateCamera() = 0;
virtual Light* CreateLight(LightType, float p_r, float p_g, float p_b) = 0; virtual Light* CreateLight(LightType, float r, float g, float b) = 0;
virtual Group* CreateGroup(const Group* p_parent = 0) = 0; virtual Group* CreateGroup(const Group* pParent = 0) = 0;
// vtable+0x20 // vtable+0x20
virtual Something* CreateSomething() = 0; virtual Unk* CreateUnk() = 0;
virtual Texture* CreateTexture() = 0; virtual Texture* CreateTexture() = 0;
virtual Texture* CreateTexture( virtual Texture* CreateTexture(
int p_width, int width,
int p_height, int height,
int p_bitsPerTexel, int bitsPerTexel,
const void* p_pTexels, const void* pTexels,
int p_pTexelsArePersistent, int pTexelsArePersistent,
int p_paletteEntryCount, int paletteEntryCount,
const PaletteEntry* p_pEntries const PaletteEntry* pEntries
) = 0; ) = 0;
virtual Result SetTextureDefaultShadeCount(unsigned long) = 0; virtual Result SetTextureDefaultShadeCount(unsigned long) = 0;
@ -174,11 +174,11 @@ class View : public Object {
// vtable+0x10 // vtable+0x10
virtual Result SetCamera(const Camera*) = 0; virtual Result SetCamera(const Camera*) = 0;
virtual Result SetProjection(ProjectionType) = 0; virtual Result SetProjection(ProjectionType) = 0;
virtual Result SetFrustrum(float p_frontClippingDistance, float p_backClippingDistance, float p_degrees) = 0; virtual Result SetFrustrum(float frontClippingDistance, float backClippingDistance, float degrees) = 0;
virtual Result SetBackgroundColor(float p_r, float p_g, float p_b) = 0; virtual Result SetBackgroundColor(float r, float g, float b) = 0;
// vtable+0x20 // vtable+0x20
virtual Result GetBackgroundColor(float* p_r, float* p_g, float* p_b) = 0; virtual Result GetBackgroundColor(float* r, float* g, float* b) = 0;
virtual Result Clear() = 0; virtual Result Clear() = 0;
virtual Result Render(const Light*) = 0; virtual Result Render(const Light*) = 0;
virtual Result ForceUpdate(unsigned long x, unsigned long y, unsigned long width, unsigned long height) = 0; virtual Result ForceUpdate(unsigned long x, unsigned long y, unsigned long width, unsigned long height) = 0;
@ -229,13 +229,13 @@ class Camera : public Object {
class Light : public Object { class Light : public Object {
public: public:
virtual Result SetTransformation(const FloatMatrix4&) = 0; virtual Result SetTransformation(const FloatMatrix4&) = 0;
virtual Result SetColor(float p_r, float p_g, float p_b) = 0; virtual Result SetColor(float r, float g, float b) = 0;
}; };
// VTABLE 0x100dbbb0 // VTABLE 0x100dbbb0
class Mesh : public Object { class Mesh : public Object {
public: public:
virtual Result SetColor(float p_r, float p_g, float p_b, float p_a) = 0; virtual Result SetColor(float r, float g, float b, float a) = 0;
virtual Result SetTexture(const Texture*) = 0; virtual Result SetTexture(const Texture*) = 0;
virtual Result GetTexture(Texture*&) = 0; virtual Result GetTexture(Texture*&) = 0;
@ -243,17 +243,17 @@ class Mesh : public Object {
virtual Result SetShadingModel(ShadingModel) = 0; virtual Result SetShadingModel(ShadingModel) = 0;
// Clone data in underlying group // Clone data in underlying group
virtual Mesh* DeepClone(Something*) = 0; virtual Mesh* DeepClone(Unk*) = 0;
// Just get another Group pointing to the same underlying data // Just get another Group pointing to the same underlying data
virtual Mesh* ShallowClone(Something*) = 0; virtual Mesh* ShallowClone(Unk*) = 0;
}; };
// VTABLE 0x100dbaa0 // VTABLE 0x100dbaa0
class Group : public Object { class Group : public Object {
public: public:
virtual Result SetTransformation(const FloatMatrix4&) = 0; virtual Result SetTransformation(const FloatMatrix4&) = 0;
virtual Result SetColor(float p_r, float p_g, float p_b, float p_a) = 0; virtual Result SetColor(float r, float g, float b, float a) = 0;
virtual Result SetTexture(const Texture*) = 0; virtual Result SetTexture(const Texture*) = 0;
virtual Result GetTexture(Texture*&) = 0; virtual Result GetTexture(Texture*&) = 0;
virtual Result SetMaterialMode(MaterialMode) = 0; virtual Result SetMaterialMode(MaterialMode) = 0;
@ -272,39 +272,39 @@ class Group : public Object {
// was not in the leaked Tgl code. My suspicion is that it's // was not in the leaked Tgl code. My suspicion is that it's
// some kind of builder class for creating meshes. // some kind of builder class for creating meshes.
// VTABLE 0x100dbb30 // VTABLE 0x100dbb30
class Something : public Object { class Unk : public Object {
public: public:
virtual Result SetMeshData( virtual Result SetMeshData(
unsigned long p_faceCount, unsigned long faceCount,
unsigned long p_vertexCount, unsigned long vertexCount,
const float (*p_positions)[3], const float (*pPositions)[3],
const float (*p_normals)[3], const float (*pNormals)[3],
const float (*p_textureCoordinates)[2], const float (*pTextureCoordinates)[2],
unsigned long p_vertexPerFaceCount, unsigned long vertexPerFaceCount,
unsigned long* p_faceData unsigned long* pFaceData
) = 0; ) = 0;
virtual Result GetBoundingBox(float p_min[3], float p_max[3]) = 0; virtual Result GetBoundingBox(float min[3], float max[3]) = 0;
virtual Something* Clone() = 0; virtual Unk* Clone() = 0;
}; };
// VTABLE 0x100dbb68 // VTABLE 0x100dbb68
class Texture : public Object { class Texture : public Object {
public: public:
// vtable+0x08 // vtable+0x08
virtual Result SetTexels(int p_width, int p_height, int p_bitsPerTexel, void* p_texels) = 0; virtual Result SetTexels(int width, int height, int bitsPerTexel, void* pTexels) = 0;
virtual void FillRowsOfTexture(int p_y, int p_height, void* p_buffer) = 0; virtual void FillRowsOfTexture(int y, int height, void* pBuffer) = 0;
// vtable+0x10 // vtable+0x10
virtual Result Changed(int p_texelsChanged, int p_paletteChanged) = 0; virtual Result Changed(int texelsChanged, int paletteChanged) = 0;
virtual Result GetBufferAndPalette( virtual Result GetBufferAndPalette(
int* p_width, int* pWidth,
int* p_height, int* pHeight,
int* p_depth, int* pDepth,
void** p_buffer, void** ppBuffer,
int* p_paletteSize, int* pPaletteSize,
PaletteEntry** p_palette PaletteEntry** ppPalette
) = 0; ) = 0;
virtual Result SetPalette(int p_entryCount, PaletteEntry* p_entries) = 0; virtual Result SetPalette(int entryCount, PaletteEntry* pEntries) = 0;
}; };
} // namespace Tgl } // namespace Tgl

View File

@ -44,7 +44,7 @@ class ViewLODList : public LODList<ViewLOD> {
// ??? for now, until we have symbol management // ??? for now, until we have symbol management
typedef const char* ROIName; typedef const char* ROIName;
struct ROINameComparator { struct ROINameComparator {
int operator()(const ROIName& rName1, const ROIName& rName2) const bool operator()(const ROIName& rName1, const ROIName& rName2) const
{ {
return strcmp((const char*) rName1, (const char*) rName2) > 0; return strcmp((const char*) rName1, (const char*) rName2) > 0;
} }