mirror of
https://github.com/isledecomp/isle.git
synced 2025-10-22 16:04:17 +00:00
Implement TglImpl::MeshBuilder::CreateMesh (#635)
* WIP * Change * Fix * Improve match * Rename class * Fix function * Fix annotation * Fix annotations * Fix annotation
This commit is contained in:

committed by
GitHub

parent
53e2353f78
commit
873926afe2
@@ -94,9 +94,9 @@ add_library(tglrl STATIC
|
|||||||
LEGO1/tgl/d3drm/group.cpp
|
LEGO1/tgl/d3drm/group.cpp
|
||||||
LEGO1/tgl/d3drm/light.cpp
|
LEGO1/tgl/d3drm/light.cpp
|
||||||
LEGO1/tgl/d3drm/mesh.cpp
|
LEGO1/tgl/d3drm/mesh.cpp
|
||||||
|
LEGO1/tgl/d3drm/meshbuilder.cpp
|
||||||
LEGO1/tgl/d3drm/renderer.cpp
|
LEGO1/tgl/d3drm/renderer.cpp
|
||||||
LEGO1/tgl/d3drm/texture.cpp
|
LEGO1/tgl/d3drm/texture.cpp
|
||||||
LEGO1/tgl/d3drm/unk.cpp
|
|
||||||
LEGO1/tgl/d3drm/view.cpp
|
LEGO1/tgl/d3drm/view.cpp
|
||||||
)
|
)
|
||||||
register_lego1_target(tglrl)
|
register_lego1_target(tglrl)
|
||||||
|
@@ -72,7 +72,7 @@ LegoResult LegoLOD::Read(Tgl::Renderer* p_renderer, LegoTextureContainer* p_text
|
|||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_unk0x04 = p_renderer->CreateUnk();
|
m_meshBuilder = p_renderer->CreateMeshBuilder();
|
||||||
|
|
||||||
if (p_storage->Read(&m_numMeshes, sizeof(m_numMeshes)) != SUCCESS) {
|
if (p_storage->Read(&m_numMeshes, sizeof(m_numMeshes)) != SUCCESS) {
|
||||||
goto done;
|
goto done;
|
||||||
@@ -188,7 +188,7 @@ LegoResult LegoLOD::Read(Tgl::Renderer* p_renderer, LegoTextureContainer* p_text
|
|||||||
meshUnd2++;
|
meshUnd2++;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_meshes[meshIndex].m_tglMesh = m_unk0x04->CreateMesh(
|
m_meshes[meshIndex].m_tglMesh = m_meshBuilder->CreateMesh(
|
||||||
numPolys & MAXWORD,
|
numPolys & MAXWORD,
|
||||||
numVertices & MAXWORD,
|
numVertices & MAXWORD,
|
||||||
vertices,
|
vertices,
|
||||||
|
@@ -94,11 +94,10 @@ Result GroupImpl::Add(const Mesh* pMesh)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x100a3450
|
// FUNCTION: LEGO1 0x100a3450
|
||||||
Result GroupImpl::Remove(const Unk* pUnk)
|
Result GroupImpl::Remove(const MeshBuilder* pMeshBuilder)
|
||||||
{
|
{
|
||||||
const UnkImpl* pUnkImpl = static_cast<const UnkImpl*>(pUnk);
|
const MeshBuilderImpl* pMeshBuilderImpl = static_cast<const MeshBuilderImpl*>(pMeshBuilder);
|
||||||
// TODO: Incorrect structure
|
return ResultVal(m_data->DeleteVisual(pMeshBuilderImpl->ImplementationData()));
|
||||||
return ResultVal(m_data->DeleteVisual((IDirect3DRMMesh*) pUnkImpl->ImplementationData()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x100a3480
|
// FUNCTION: LEGO1 0x100a3480
|
||||||
|
@@ -34,7 +34,7 @@ class CameraImpl;
|
|||||||
class GroupImpl;
|
class GroupImpl;
|
||||||
class MeshImpl;
|
class MeshImpl;
|
||||||
class TextureImpl;
|
class TextureImpl;
|
||||||
class UnkImpl;
|
class MeshBuilderImpl;
|
||||||
|
|
||||||
// VTABLE: LEGO1 0x100db910
|
// VTABLE: LEGO1 0x100db910
|
||||||
class RendererImpl : public Renderer {
|
class RendererImpl : public Renderer {
|
||||||
@@ -62,7 +62,7 @@ public:
|
|||||||
Group* CreateGroup(const Group* pParent) override;
|
Group* CreateGroup(const Group* pParent) override;
|
||||||
|
|
||||||
// vtable+0x20
|
// vtable+0x20
|
||||||
Unk* CreateUnk() override;
|
MeshBuilder* CreateMeshBuilder() override;
|
||||||
Texture* CreateTexture(
|
Texture* CreateTexture(
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
@@ -273,24 +273,27 @@ public:
|
|||||||
|
|
||||||
// vtable+0x10
|
// vtable+0x10
|
||||||
Result GetTexture(Texture*&) override;
|
Result GetTexture(Texture*&) override;
|
||||||
Result SetTextureMappingMode(ProjectionType) override;
|
Result SetTextureMappingMode(TextureMappingMode) override;
|
||||||
Result SetShadingModel(ShadingModel) override;
|
Result SetShadingModel(ShadingModel) override;
|
||||||
Mesh* DeepClone(Unk*) override;
|
Mesh* DeepClone(MeshBuilder*) override;
|
||||||
|
|
||||||
// vtable+0x20
|
// vtable+0x20
|
||||||
Mesh* ShallowClone(Unk*) override;
|
Mesh* ShallowClone(MeshBuilder*) override;
|
||||||
|
|
||||||
struct MeshData {
|
struct MeshData {
|
||||||
IDirect3DRMMesh* groupMesh;
|
IDirect3DRMMesh* groupMesh;
|
||||||
D3DRMGROUPINDEX groupIndex;
|
D3DRMGROUPINDEX groupIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline MeshData* ImplementationData() const { return m_data; }
|
typedef MeshData* MeshDataType;
|
||||||
|
|
||||||
|
inline const MeshDataType& ImplementationData() const { return m_data; }
|
||||||
|
inline MeshDataType& ImplementationData() { return m_data; }
|
||||||
|
|
||||||
friend class RendererImpl;
|
friend class RendererImpl;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MeshData* m_data;
|
MeshDataType m_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
// VTABLE: LEGO1 0x100dba68
|
// VTABLE: LEGO1 0x100dba68
|
||||||
@@ -320,7 +323,7 @@ public:
|
|||||||
// vtable+0x20
|
// vtable+0x20
|
||||||
Result Add(const Mesh*) override;
|
Result Add(const Mesh*) override;
|
||||||
Result Remove(const Group*) override;
|
Result Remove(const Group*) override;
|
||||||
Result Remove(const Unk*) override;
|
Result Remove(const MeshBuilder*) override;
|
||||||
Result RemoveAll() override;
|
Result RemoveAll() override;
|
||||||
|
|
||||||
// vtable+0x30
|
// vtable+0x30
|
||||||
@@ -335,10 +338,10 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// VTABLE: LEGO1 0x100dbb18
|
// VTABLE: LEGO1 0x100dbb18
|
||||||
class UnkImpl : public Unk {
|
class MeshBuilderImpl : public MeshBuilder {
|
||||||
public:
|
public:
|
||||||
UnkImpl() : m_data(0) {}
|
MeshBuilderImpl() : m_data(0) {}
|
||||||
~UnkImpl() override
|
~MeshBuilderImpl() override
|
||||||
{
|
{
|
||||||
if (m_data) {
|
if (m_data) {
|
||||||
m_data->Release();
|
m_data->Release();
|
||||||
@@ -349,7 +352,7 @@ public:
|
|||||||
void* ImplementationDataPtr() override;
|
void* ImplementationDataPtr() override;
|
||||||
|
|
||||||
// vtable+0x08
|
// vtable+0x08
|
||||||
Tgl::Mesh* CreateMesh(
|
Mesh* CreateMesh(
|
||||||
unsigned long faceCount,
|
unsigned long faceCount,
|
||||||
unsigned long vertexCount,
|
unsigned long vertexCount,
|
||||||
float (*pPositions)[3],
|
float (*pPositions)[3],
|
||||||
@@ -357,18 +360,30 @@ public:
|
|||||||
float (*pTextureCoordinates)[2],
|
float (*pTextureCoordinates)[2],
|
||||||
unsigned long (*pFaceIndices)[3],
|
unsigned long (*pFaceIndices)[3],
|
||||||
unsigned long (*pTextureIndices)[3],
|
unsigned long (*pTextureIndices)[3],
|
||||||
Tgl::ShadingModel shadingModel
|
ShadingModel shadingModel
|
||||||
) override;
|
) override;
|
||||||
Result GetBoundingBox(float min[3], float max[3]) override;
|
Result GetBoundingBox(float min[3], float max[3]) override;
|
||||||
|
|
||||||
// vtable+0x10
|
// vtable+0x10
|
||||||
Unk* Clone() override;
|
MeshBuilder* Clone() override;
|
||||||
|
|
||||||
inline IDirect3DRMMesh* ImplementationData() const { return m_data; }
|
inline IDirect3DRMMesh* ImplementationData() const { return m_data; }
|
||||||
|
|
||||||
friend class RendererImpl;
|
friend class RendererImpl;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
inline Result CreateMeshImpl(
|
||||||
|
MeshImpl* pMeshImpl,
|
||||||
|
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
|
||||||
|
);
|
||||||
|
|
||||||
IDirect3DRMMesh* m_data;
|
IDirect3DRMMesh* m_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -514,7 +529,7 @@ inline D3DRMMATRIX4D* Translate(FloatMatrix4& tglMatrix4x4, D3DRMMATRIX4D& rD3DR
|
|||||||
// TglImpl::LightImpl::`scalar deleting destructor'
|
// TglImpl::LightImpl::`scalar deleting destructor'
|
||||||
|
|
||||||
// SYNTHETIC: LEGO1 0x100a2720
|
// SYNTHETIC: LEGO1 0x100a2720
|
||||||
// TglImpl::UnkImpl::`scalar deleting destructor'
|
// TglImpl::MeshBuilderImpl::`scalar deleting destructor'
|
||||||
|
|
||||||
// SYNTHETIC: LEGO1 0x100a2800
|
// SYNTHETIC: LEGO1 0x100a2800
|
||||||
// TglImpl::TextureImpl::`scalar deleting destructor'
|
// TglImpl::TextureImpl::`scalar deleting destructor'
|
||||||
|
@@ -38,9 +38,9 @@ Result MeshImpl::SetTexture(const Texture* pTexture)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x100a3f80
|
// FUNCTION: LEGO1 0x100a3f80
|
||||||
Result MeshImpl::SetTextureMappingMode(ProjectionType projType)
|
Result MeshImpl::SetTextureMappingMode(TextureMappingMode mode)
|
||||||
{
|
{
|
||||||
if (projType == Perspective) {
|
if (mode == PerspectiveCorrect) {
|
||||||
return ResultVal(m_data->groupMesh->SetGroupMapping(m_data->groupIndex, D3DRMMAP_PERSPCORRECT));
|
return ResultVal(m_data->groupMesh->SetGroupMapping(m_data->groupIndex, D3DRMMAP_PERSPCORRECT));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -73,7 +73,7 @@ Result MeshImpl::SetShadingModel(ShadingModel model)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x100a4030
|
// FUNCTION: LEGO1 0x100a4030
|
||||||
Mesh* MeshImpl::DeepClone(Unk* pUnk)
|
Mesh* MeshImpl::DeepClone(MeshBuilder* pMeshBuilder)
|
||||||
{
|
{
|
||||||
// Create group
|
// Create group
|
||||||
MeshImpl* newMesh = new MeshImpl();
|
MeshImpl* newMesh = new MeshImpl();
|
||||||
@@ -96,7 +96,7 @@ Mesh* MeshImpl::DeepClone(Unk* pUnk)
|
|||||||
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
|
||||||
UnkImpl* target = static_cast<UnkImpl*>(pUnk);
|
MeshBuilderImpl* target = static_cast<MeshBuilderImpl*>(pMeshBuilder);
|
||||||
D3DRMGROUPINDEX index;
|
D3DRMGROUPINDEX index;
|
||||||
target->ImplementationData()->AddGroup(vcount, fcount, vperface, faceBuffer, &index);
|
target->ImplementationData()->AddGroup(vcount, fcount, vperface, faceBuffer, &index);
|
||||||
newMesh->m_data->groupIndex = index;
|
newMesh->m_data->groupIndex = index;
|
||||||
@@ -118,14 +118,14 @@ Mesh* MeshImpl::DeepClone(Unk* pUnk)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x100a4240
|
// FUNCTION: LEGO1 0x100a4240
|
||||||
Mesh* MeshImpl::ShallowClone(Unk* pUnk)
|
Mesh* MeshImpl::ShallowClone(MeshBuilder* pMeshBuilder)
|
||||||
{
|
{
|
||||||
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<UnkImpl*>(pUnk)->ImplementationData();
|
newData->groupMesh = static_cast<MeshBuilderImpl*>(pMeshBuilder)->ImplementationData();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
delete newGroup;
|
delete newGroup;
|
||||||
|
187
LEGO1/tgl/d3drm/meshbuilder.cpp
Normal file
187
LEGO1/tgl/d3drm/meshbuilder.cpp
Normal file
@@ -0,0 +1,187 @@
|
|||||||
|
#include "impl.h"
|
||||||
|
|
||||||
|
using namespace TglImpl;
|
||||||
|
|
||||||
|
DECOMP_SIZE_ASSERT(MeshBuilder, 0x04);
|
||||||
|
DECOMP_SIZE_ASSERT(MeshBuilderImpl, 0x08);
|
||||||
|
|
||||||
|
// FUNCTION: LEGO1 0x100a3830
|
||||||
|
void* MeshBuilderImpl::ImplementationDataPtr()
|
||||||
|
{
|
||||||
|
return reinterpret_cast<void*>(&m_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// FUNCTION: LEGO1 0x100a3840
|
||||||
|
Mesh* MeshBuilderImpl::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
|
||||||
|
)
|
||||||
|
{
|
||||||
|
MeshImpl* pMeshImpl = new MeshImpl;
|
||||||
|
if (CreateMeshImpl(
|
||||||
|
pMeshImpl,
|
||||||
|
faceCount,
|
||||||
|
vertexCount,
|
||||||
|
pPositions,
|
||||||
|
pNormals,
|
||||||
|
pTextureCoordinates,
|
||||||
|
pFaceIndices,
|
||||||
|
pTextureIndices,
|
||||||
|
shadingModel
|
||||||
|
) == Error) {
|
||||||
|
delete pMeshImpl;
|
||||||
|
pMeshImpl = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pMeshImpl;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Result MeshSetTextureMappingMode(MeshImpl::MeshData* pMesh, TextureMappingMode mode)
|
||||||
|
{
|
||||||
|
if (mode == PerspectiveCorrect) {
|
||||||
|
return ResultVal(pMesh->groupMesh->SetGroupMapping(pMesh->groupIndex, D3DRMMAP_PERSPCORRECT));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return ResultVal(pMesh->groupMesh->SetGroupMapping(pMesh->groupIndex, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Result CreateMesh(
|
||||||
|
IDirect3DRMMesh* pD3DRM,
|
||||||
|
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,
|
||||||
|
MeshImpl::MeshDataType& rpMesh
|
||||||
|
)
|
||||||
|
{
|
||||||
|
unsigned long* faceIndices = (unsigned long*) pFaceIndices;
|
||||||
|
D3DRMGROUPINDEX groupIndex = 0;
|
||||||
|
int count = faceCount * 3;
|
||||||
|
int index = 0;
|
||||||
|
|
||||||
|
unsigned int* fData = new unsigned int[count];
|
||||||
|
|
||||||
|
D3DRMVERTEX* vertices = new D3DRMVERTEX[vertexCount];
|
||||||
|
memset(vertices, 0, sizeof(*vertices) * vertexCount);
|
||||||
|
|
||||||
|
rpMesh = new MeshImpl::MeshData;
|
||||||
|
rpMesh->groupMesh = pD3DRM;
|
||||||
|
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
if ((*((unsigned short*) &faceIndices[i] + 1) >> 0x0f) & 0x01) {
|
||||||
|
unsigned long j = *(unsigned short*) &faceIndices[i];
|
||||||
|
vertices[index].position.x = pPositions[j][0];
|
||||||
|
vertices[index].position.y = pPositions[j][1];
|
||||||
|
vertices[index].position.z = pPositions[j][2];
|
||||||
|
j = *((unsigned short*) &faceIndices[i] + 1) & MAXSHORT;
|
||||||
|
vertices[index].normal.x = pNormals[j][0];
|
||||||
|
vertices[index].normal.y = pNormals[j][1];
|
||||||
|
vertices[index].normal.z = pNormals[j][2];
|
||||||
|
|
||||||
|
if (pTextureIndices != NULL && pTextureCoordinates != NULL) {
|
||||||
|
j = ((unsigned long*) pTextureIndices)[i];
|
||||||
|
vertices[index].tu = pTextureCoordinates[j][0];
|
||||||
|
vertices[index].tv = pTextureCoordinates[j][1];
|
||||||
|
}
|
||||||
|
|
||||||
|
fData[i] = index;
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fData[i] = *(unsigned short*) &faceIndices[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Result result;
|
||||||
|
result = ResultVal(pD3DRM->AddGroup(vertexCount, faceCount, 3, fData, &groupIndex));
|
||||||
|
|
||||||
|
if (Succeeded(result)) {
|
||||||
|
rpMesh->groupIndex = groupIndex;
|
||||||
|
result = ResultVal(pD3DRM->SetVertices(groupIndex, 0, vertexCount, vertices));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Succeeded(result)) {
|
||||||
|
if (rpMesh) {
|
||||||
|
delete rpMesh;
|
||||||
|
}
|
||||||
|
rpMesh = NULL;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result = MeshSetTextureMappingMode(rpMesh, PerspectiveCorrect);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fData != NULL) {
|
||||||
|
delete[] fData;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vertices != NULL) {
|
||||||
|
delete[] vertices;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Result MeshBuilderImpl::CreateMeshImpl(
|
||||||
|
MeshImpl* pMeshImpl,
|
||||||
|
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
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return ::CreateMesh(
|
||||||
|
m_data,
|
||||||
|
faceCount,
|
||||||
|
vertexCount,
|
||||||
|
pPositions,
|
||||||
|
pNormals,
|
||||||
|
pTextureCoordinates,
|
||||||
|
pFaceIndices,
|
||||||
|
pTextureIndices,
|
||||||
|
shadingModel,
|
||||||
|
pMeshImpl->ImplementationData()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// FUNCTION: LEGO1 0x100a3ae0
|
||||||
|
Result MeshBuilderImpl::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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FUNCTION: LEGO1 0x100a3b40
|
||||||
|
MeshBuilder* MeshBuilderImpl::Clone()
|
||||||
|
{
|
||||||
|
MeshBuilderImpl* mesh = new MeshBuilderImpl();
|
||||||
|
int ret = m_data->Clone(0, IID_IDirect3DRMMeshBuilder, (void**) &mesh->m_data);
|
||||||
|
if (ret < 0) {
|
||||||
|
delete mesh;
|
||||||
|
mesh = NULL;
|
||||||
|
}
|
||||||
|
return mesh;
|
||||||
|
}
|
@@ -209,20 +209,14 @@ Light* RendererImpl::CreateLight(LightType type, float r, float g, float b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x100a1e90
|
// FUNCTION: LEGO1 0x100a1e90
|
||||||
Unk* RendererImpl::CreateUnk()
|
MeshBuilder* RendererImpl::CreateMeshBuilder()
|
||||||
{
|
{
|
||||||
// Note: I'm fairly certain that Unknown is not what Tgl calls a
|
MeshBuilderImpl* meshBuilder = new MeshBuilderImpl();
|
||||||
// "Mesh", because the methods on Mesh in the Tgl leak line up much
|
if (FAILED(m_data->CreateMesh(&meshBuilder->m_data))) {
|
||||||
// more closely with a different vtable than the one assigned in
|
delete meshBuilder;
|
||||||
// this method (meaning this method is not creating a Mesh).
|
meshBuilder = NULL;
|
||||||
// Maybe this method is something like CreateMeshBuilder where the
|
|
||||||
// Mesh data type in the Tgl leak was split into builder/result?
|
|
||||||
UnkImpl* unknown = new UnkImpl();
|
|
||||||
if (FAILED(m_data->CreateMesh(&unknown->m_data))) {
|
|
||||||
delete unknown;
|
|
||||||
unknown = NULL;
|
|
||||||
}
|
}
|
||||||
return unknown;
|
return meshBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Result RendererCreateTexture(
|
inline Result RendererCreateTexture(
|
||||||
|
@@ -1,55 +0,0 @@
|
|||||||
#include "impl.h"
|
|
||||||
|
|
||||||
using namespace TglImpl;
|
|
||||||
|
|
||||||
DECOMP_SIZE_ASSERT(Unk, 0x04);
|
|
||||||
DECOMP_SIZE_ASSERT(UnkImpl, 0x08);
|
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x100a3830
|
|
||||||
void* UnkImpl::ImplementationDataPtr()
|
|
||||||
{
|
|
||||||
return reinterpret_cast<void*>(&m_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
// STUB: LEGO1 0x100a3840
|
|
||||||
Tgl::Mesh* UnkImpl::CreateMesh(
|
|
||||||
unsigned long faceCount,
|
|
||||||
unsigned long vertexCount,
|
|
||||||
float (*pPositions)[3],
|
|
||||||
float (*pNormals)[3],
|
|
||||||
float (*pTextureCoordinates)[2],
|
|
||||||
unsigned long (*pFaceIndices)[3],
|
|
||||||
unsigned long (*pTextureIndices)[3],
|
|
||||||
Tgl::ShadingModel shadingModel
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FUNCTION: 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FUNCTION: 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;
|
|
||||||
}
|
|
@@ -96,7 +96,7 @@ class Camera;
|
|||||||
class Group;
|
class Group;
|
||||||
class Mesh;
|
class Mesh;
|
||||||
class Texture;
|
class Texture;
|
||||||
class Unk;
|
class MeshBuilder;
|
||||||
|
|
||||||
// VTABLE: LEGO1 0x100db980
|
// VTABLE: LEGO1 0x100db980
|
||||||
class Object {
|
class Object {
|
||||||
@@ -131,7 +131,7 @@ public:
|
|||||||
virtual Group* CreateGroup(const Group* pParent = 0) = 0;
|
virtual Group* CreateGroup(const Group* pParent = 0) = 0;
|
||||||
|
|
||||||
// vtable+0x20
|
// vtable+0x20
|
||||||
virtual Unk* CreateUnk() = 0;
|
virtual MeshBuilder* CreateMeshBuilder() = 0;
|
||||||
virtual Texture* CreateTexture(
|
virtual Texture* CreateTexture(
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
@@ -269,18 +269,21 @@ public:
|
|||||||
// VTABLE: LEGO1 0x100dbbb0
|
// VTABLE: LEGO1 0x100dbbb0
|
||||||
class Mesh : public Object {
|
class Mesh : public Object {
|
||||||
public:
|
public:
|
||||||
|
// SYNTHETIC: LEGO1 0x100a3e10
|
||||||
|
// Tgl::Mesh::~Mesh
|
||||||
|
|
||||||
virtual Result SetColor(float r, float g, float b, float 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 SetTextureMappingMode(ProjectionType) = 0;
|
virtual Result SetTextureMappingMode(TextureMappingMode) = 0;
|
||||||
virtual Result SetShadingModel(ShadingModel) = 0;
|
virtual Result SetShadingModel(ShadingModel) = 0;
|
||||||
|
|
||||||
// Clone data in underlying group
|
// Clone data in underlying group
|
||||||
virtual Mesh* DeepClone(Unk*) = 0;
|
virtual Mesh* DeepClone(MeshBuilder*) = 0;
|
||||||
|
|
||||||
// Just get another Group pointing to the same underlying data
|
// Just get another Group pointing to the same underlying data
|
||||||
virtual Mesh* ShallowClone(Unk*) = 0;
|
virtual Mesh* ShallowClone(MeshBuilder*) = 0;
|
||||||
|
|
||||||
// SYNTHETIC: LEGO1 0x100a3e60
|
// SYNTHETIC: LEGO1 0x100a3e60
|
||||||
// Tgl::Mesh::`scalar deleting destructor'
|
// Tgl::Mesh::`scalar deleting destructor'
|
||||||
@@ -297,7 +300,7 @@ public:
|
|||||||
virtual Result Add(const Group*) = 0;
|
virtual Result Add(const Group*) = 0;
|
||||||
virtual Result Add(const Mesh*) = 0;
|
virtual Result Add(const Mesh*) = 0;
|
||||||
virtual Result Remove(const Group*) = 0;
|
virtual Result Remove(const Group*) = 0;
|
||||||
virtual Result Remove(const Unk*) = 0;
|
virtual Result Remove(const MeshBuilder*) = 0;
|
||||||
virtual Result RemoveAll() = 0;
|
virtual Result RemoveAll() = 0;
|
||||||
|
|
||||||
// This is TransformLocalToWorld in the leak, however it seems
|
// This is TransformLocalToWorld in the leak, however it seems
|
||||||
@@ -315,9 +318,9 @@ public:
|
|||||||
// 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: LEGO1 0x100dbb30
|
// VTABLE: LEGO1 0x100dbb30
|
||||||
class Unk : public Object {
|
class MeshBuilder : public Object {
|
||||||
public:
|
public:
|
||||||
virtual Tgl::Mesh* CreateMesh(
|
virtual Mesh* CreateMesh(
|
||||||
unsigned long faceCount,
|
unsigned long faceCount,
|
||||||
unsigned long vertexCount,
|
unsigned long vertexCount,
|
||||||
float (*pPositions)[3],
|
float (*pPositions)[3],
|
||||||
@@ -325,16 +328,16 @@ public:
|
|||||||
float (*pTextureCoordinates)[2],
|
float (*pTextureCoordinates)[2],
|
||||||
unsigned long (*pFaceIndices)[3],
|
unsigned long (*pFaceIndices)[3],
|
||||||
unsigned long (*pTextureIndices)[3],
|
unsigned long (*pTextureIndices)[3],
|
||||||
Tgl::ShadingModel shadingModel
|
ShadingModel shadingModel
|
||||||
) = 0;
|
) = 0;
|
||||||
virtual Result GetBoundingBox(float min[3], float max[3]) = 0;
|
virtual Result GetBoundingBox(float min[3], float max[3]) = 0;
|
||||||
virtual Unk* Clone() = 0;
|
virtual MeshBuilder* Clone() = 0;
|
||||||
|
|
||||||
// SYNTHETIC: LEGO1 0x100a27b0
|
// SYNTHETIC: LEGO1 0x100a27b0
|
||||||
// Tgl::Unk::~Unk
|
// Tgl::MeshBuilder::~MeshBuilder
|
||||||
|
|
||||||
// SYNTHETIC: LEGO1 0x100a2b10
|
// SYNTHETIC: LEGO1 0x100a2b10
|
||||||
// Tgl::Unk::`scalar deleting destructor'
|
// Tgl::MeshBuilder::`scalar deleting destructor'
|
||||||
};
|
};
|
||||||
|
|
||||||
// VTABLE: LEGO1 0x100dbb68
|
// VTABLE: LEGO1 0x100dbb68
|
||||||
|
@@ -3,5 +3,5 @@
|
|||||||
// FUNCTION: LEGO1 0x100a5e40
|
// FUNCTION: LEGO1 0x100a5e40
|
||||||
ViewLOD::~ViewLOD()
|
ViewLOD::~ViewLOD()
|
||||||
{
|
{
|
||||||
delete m_unk0x04;
|
delete m_meshBuilder;
|
||||||
}
|
}
|
||||||
|
@@ -17,7 +17,7 @@ public:
|
|||||||
c_bit4 = 0x10
|
c_bit4 = 0x10
|
||||||
};
|
};
|
||||||
|
|
||||||
ViewLOD(Tgl::Renderer* pRenderer) : m_unk0x04(NULL), m_unk0x08(3) {}
|
ViewLOD(Tgl::Renderer* pRenderer) : m_meshBuilder(NULL), m_unk0x08(3) {}
|
||||||
~ViewLOD() override;
|
~ViewLOD() override;
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x100a6f30
|
// FUNCTION: LEGO1 0x100a6f30
|
||||||
@@ -26,8 +26,8 @@ public:
|
|||||||
// FUNCTION: LEGO1 0x100a6f50
|
// FUNCTION: LEGO1 0x100a6f50
|
||||||
int NVerts() const override { return NumPolys() * 2; } // vtable+0x08
|
int NVerts() const override { return NumPolys() * 2; } // vtable+0x08
|
||||||
|
|
||||||
Tgl::Unk* GetUnknown0x04() { return m_unk0x04; }
|
Tgl::MeshBuilder* GetMeshBuilder() { return m_meshBuilder; }
|
||||||
const Tgl::Unk* GetUnknown0x04() const { return m_unk0x04; }
|
const Tgl::MeshBuilder* GetMeshBuilder() const { return m_meshBuilder; }
|
||||||
unsigned char GetUnknown0x08Test4() { return m_unk0x08 & 0xffffff04; }
|
unsigned char GetUnknown0x08Test4() { return m_unk0x08 & 0xffffff04; }
|
||||||
unsigned char GetUnknown0x08Test8() { return m_unk0x08 & 0xffffff08; }
|
unsigned char GetUnknown0x08Test8() { return m_unk0x08 & 0xffffff08; }
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ public:
|
|||||||
// ViewLOD::`scalar deleting destructor'
|
// ViewLOD::`scalar deleting destructor'
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Tgl::Unk* m_unk0x04; // 0x04
|
Tgl::MeshBuilder* m_meshBuilder; // 0x04
|
||||||
undefined4 m_unk0x08; // 0x08
|
undefined4 m_unk0x08; // 0x08
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -93,13 +93,13 @@ void ViewManager::FUN_100a66a0(ViewROI* p_roi)
|
|||||||
const ViewLOD* lod = (const ViewLOD*) p_roi->GetLOD(p_roi->GetUnknown0xe0());
|
const ViewLOD* lod = (const ViewLOD*) p_roi->GetLOD(p_roi->GetUnknown0xe0());
|
||||||
|
|
||||||
if (lod != NULL) {
|
if (lod != NULL) {
|
||||||
const Tgl::Unk* unk = NULL;
|
const Tgl::MeshBuilder* meshBuilder = NULL;
|
||||||
Tgl::Group* roiGeometry = p_roi->GetGeometry();
|
Tgl::Group* roiGeometry = p_roi->GetGeometry();
|
||||||
|
|
||||||
unk = lod->GetUnknown0x04();
|
meshBuilder = lod->GetMeshBuilder();
|
||||||
|
|
||||||
if (unk != NULL) {
|
if (meshBuilder != NULL) {
|
||||||
roiGeometry->Remove(unk);
|
roiGeometry->Remove(meshBuilder);
|
||||||
}
|
}
|
||||||
|
|
||||||
scene->Remove(roiGeometry);
|
scene->Remove(roiGeometry);
|
||||||
|
Reference in New Issue
Block a user