mirror of
https://github.com/isledecomp/isle.git
synced 2025-10-23 00:14:22 +00:00
Refactor geom
library into geom
and shape
(#1263)
* Refactor `geom` library into `geom` and `util` * Rename to `shape`
This commit is contained in:

committed by
GitHub

parent
5b19d7953a
commit
1b99d75543
@@ -1,19 +0,0 @@
|
||||
#include "legobox.h"
|
||||
|
||||
#include "decomp.h"
|
||||
#include "misc/legoutil.h"
|
||||
|
||||
DECOMP_SIZE_ASSERT(LegoBox, 0x18)
|
||||
|
||||
// FUNCTION: LEGO1 0x100d3740
|
||||
LegoResult LegoBox::Read(LegoStorage* p_storage)
|
||||
{
|
||||
LegoResult result;
|
||||
if ((result = m_min.Read(p_storage)) != SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
if ((result = m_max.Read(p_storage)) != SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
@@ -1,32 +0,0 @@
|
||||
#ifndef __LEGOBOX_H
|
||||
#define __LEGOBOX_H
|
||||
|
||||
#include "legovertex.h"
|
||||
|
||||
// SIZE 0x18
|
||||
class LegoBox {
|
||||
public:
|
||||
LegoVertex& GetMin() { return m_min; }
|
||||
void SetMin(LegoVertex& p_min) { m_min = p_min; }
|
||||
LegoVertex& GetMax() { return m_max; }
|
||||
void SetMax(LegoVertex& p_max) { m_max = p_max; }
|
||||
// LegoVertex GetCenter()
|
||||
// {
|
||||
// return LegoVertex(
|
||||
// (m_min.GetX() + m_max.GetX()) / 2,
|
||||
// (m_min.GetY() + m_max.GetY()) / 2,
|
||||
// (m_min.GetZ() + m_max.GetZ()) / 2
|
||||
// );
|
||||
// }
|
||||
LegoFloat GetDX() { return m_max.GetX() - m_min.GetX(); }
|
||||
LegoFloat GetDY() { return m_max.GetY() - m_min.GetY(); }
|
||||
LegoFloat GetDZ() { return m_max.GetZ() - m_min.GetZ(); }
|
||||
LegoBool IsEmpty() { return m_min.IsOrigin() && m_max.IsOrigin(); }
|
||||
LegoResult Read(LegoStorage* p_storage);
|
||||
|
||||
protected:
|
||||
LegoVertex m_min; // 0x00
|
||||
LegoVertex m_max; // 0x0c
|
||||
};
|
||||
|
||||
#endif // __LEGOBOX_H
|
@@ -1,91 +0,0 @@
|
||||
#include "legomesh.h"
|
||||
|
||||
#include "misc/legostorage.h"
|
||||
|
||||
DECOMP_SIZE_ASSERT(LegoMeshUnkComponent, 0x1c)
|
||||
DECOMP_SIZE_ASSERT(LegoMesh, 0x24)
|
||||
|
||||
// FUNCTION: LEGO1 0x100d3810
|
||||
LegoMesh::LegoMesh()
|
||||
{
|
||||
m_alpha = 0.0F;
|
||||
m_shading = e_flat;
|
||||
m_unk0x14 = 0;
|
||||
m_textureName = NULL;
|
||||
m_unk0x0d = 0;
|
||||
m_unk0x10 = NULL;
|
||||
m_unk0x20 = 0;
|
||||
m_unk0x21 = FALSE;
|
||||
m_materialName = NULL;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100d3860
|
||||
LegoMesh::~LegoMesh()
|
||||
{
|
||||
if (m_textureName != NULL) {
|
||||
delete[] m_textureName;
|
||||
}
|
||||
|
||||
if (m_materialName != NULL) {
|
||||
delete[] m_materialName;
|
||||
}
|
||||
|
||||
if (m_unk0x10 != NULL) {
|
||||
delete m_unk0x10;
|
||||
}
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100d38f0
|
||||
LegoResult LegoMesh::Read(LegoStorage* p_storage)
|
||||
{
|
||||
LegoResult result;
|
||||
LegoU32 textureLength, materialLength;
|
||||
if ((result = m_color.Read(p_storage)) != SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
if ((result = p_storage->Read(&m_alpha, sizeof(m_alpha))) != SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
if ((result = p_storage->Read(&m_shading, sizeof(m_shading))) != SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
if ((result = p_storage->Read(&m_unk0x0d, sizeof(m_unk0x0d))) != SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
if ((result = p_storage->Read(&m_unk0x20, sizeof(m_unk0x20))) != SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
if ((result = p_storage->Read(&m_unk0x21, sizeof(m_unk0x21))) != SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if ((result = p_storage->Read(&textureLength, sizeof(textureLength))) != SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
if (textureLength) {
|
||||
m_textureName = new LegoChar[textureLength + 1];
|
||||
|
||||
if ((result = p_storage->Read(m_textureName, textureLength)) != SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
m_textureName[textureLength] = '\0';
|
||||
strlwr(m_textureName);
|
||||
}
|
||||
|
||||
if ((result = p_storage->Read(&materialLength, sizeof(materialLength))) != SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
if (materialLength) {
|
||||
m_materialName = new LegoChar[materialLength + 1];
|
||||
|
||||
if ((result = p_storage->Read(m_materialName, materialLength)) != SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
m_materialName[materialLength] = '\0';
|
||||
strlwr(m_materialName);
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
@@ -1,78 +0,0 @@
|
||||
#ifndef __LEGOMESH_H
|
||||
#define __LEGOMESH_H
|
||||
|
||||
#include "decomp.h"
|
||||
#include "misc/legocolor.h"
|
||||
#include "misc/legotypes.h"
|
||||
|
||||
class LegoStorage;
|
||||
|
||||
// SIZE 0x1c
|
||||
struct LegoMeshUnkComponent {
|
||||
~LegoMeshUnkComponent()
|
||||
{
|
||||
if (m_unk0x08) {
|
||||
delete m_unk0x08;
|
||||
}
|
||||
if (m_unk0x0c) {
|
||||
delete m_unk0x0c;
|
||||
}
|
||||
if (m_unk0x10) {
|
||||
delete m_unk0x10;
|
||||
}
|
||||
if (m_unk0x14) {
|
||||
delete m_unk0x14;
|
||||
}
|
||||
if (m_unk0x18) {
|
||||
delete m_unk0x18;
|
||||
}
|
||||
}
|
||||
|
||||
undefined m_unk0x00[8]; // 0x00
|
||||
undefined* m_unk0x08; // 0x08
|
||||
undefined* m_unk0x0c; // 0x0c
|
||||
undefined* m_unk0x10; // 0x10
|
||||
undefined* m_unk0x14; // 0x14
|
||||
undefined* m_unk0x18; // 0x18
|
||||
};
|
||||
|
||||
// VTABLE: LEGO1 0x100dd228
|
||||
// SIZE 0x24
|
||||
class LegoMesh {
|
||||
public:
|
||||
enum {
|
||||
e_flat,
|
||||
e_gouraud,
|
||||
e_wireframe
|
||||
};
|
||||
|
||||
LegoMesh();
|
||||
virtual ~LegoMesh();
|
||||
LegoColor GetColor() { return m_color; }
|
||||
void SetColor(LegoColor p_color) { m_color = p_color; }
|
||||
LegoFloat GetAlpha() { return m_alpha; }
|
||||
LegoU8 GetShading() { return m_shading; }
|
||||
void SetShading(LegoU8 p_shading) { m_shading = p_shading; }
|
||||
LegoU8 GetUnknown0x0d() { return m_unk0x0d; }
|
||||
const LegoChar* GetTextureName() { return m_textureName; }
|
||||
const LegoChar* GetMaterialName() { return m_materialName; }
|
||||
LegoBool GetUnknown0x21() { return m_unk0x21; }
|
||||
LegoResult Read(LegoStorage* p_storage);
|
||||
|
||||
// SYNTHETIC: LEGO1 0x100d3840
|
||||
// LegoMesh::`scalar deleting destructor'
|
||||
|
||||
protected:
|
||||
LegoColor m_color; // 0x04
|
||||
LegoFloat m_alpha; // 0x08
|
||||
LegoU8 m_shading; // 0x0c
|
||||
LegoU8 m_unk0x0d; // 0x0d
|
||||
LegoMeshUnkComponent* m_unk0x10; // 0x10 - unused, except in destructor
|
||||
undefined4 m_unk0x14; // 0x14 - unused
|
||||
LegoChar* m_textureName; // 0x18
|
||||
LegoChar* m_materialName; // 0x1c
|
||||
undefined m_unk0x20; // 0x20 - unused
|
||||
LegoBool m_unk0x21; // 0x21
|
||||
};
|
||||
|
||||
#endif // __LEGOMESH_H
|
@@ -1,19 +0,0 @@
|
||||
#include "legosphere.h"
|
||||
|
||||
#include "decomp.h"
|
||||
#include "misc/legostorage.h"
|
||||
|
||||
DECOMP_SIZE_ASSERT(LegoSphere, 0x10)
|
||||
|
||||
// FUNCTION: LEGO1 0x100d3770
|
||||
LegoResult LegoSphere::Read(LegoStorage* p_storage)
|
||||
{
|
||||
LegoResult result;
|
||||
if ((result = m_center.Read(p_storage)) != SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
if ((result = p_storage->Read(&m_radius, sizeof(m_radius))) != SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
#ifndef __LEGOSPHERE_H
|
||||
#define __LEGOSPHERE_H
|
||||
|
||||
#include "legovertex.h"
|
||||
|
||||
// SIZE 0x10
|
||||
class LegoSphere {
|
||||
public:
|
||||
LegoSphere() { m_radius = 0.0F; }
|
||||
LegoVertex& GetCenter() { return m_center; }
|
||||
void SetCenter(LegoVertex& p_center) { m_center = p_center; }
|
||||
LegoFloat GetRadius() { return m_radius; }
|
||||
void SetRadius(LegoFloat p_radius) { m_radius = p_radius; }
|
||||
LegoResult Read(LegoStorage* p_storage);
|
||||
|
||||
protected:
|
||||
LegoVertex m_center; // 0x00
|
||||
LegoFloat m_radius; // 0x0c
|
||||
};
|
||||
|
||||
#endif // __LEGOSPHERE_H
|
@@ -1,30 +0,0 @@
|
||||
#include "legovertex.h"
|
||||
|
||||
#include "decomp.h"
|
||||
#include "misc/legostorage.h"
|
||||
|
||||
DECOMP_SIZE_ASSERT(LegoVertex, 0x0c)
|
||||
|
||||
// FUNCTION: LEGO1 0x100d37b0
|
||||
LegoVertex::LegoVertex()
|
||||
{
|
||||
m_coordinates[0] = 0.0F;
|
||||
m_coordinates[1] = 0.0F;
|
||||
m_coordinates[2] = 0.0F;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100d37c0
|
||||
LegoResult LegoVertex::Read(LegoStorage* p_storage)
|
||||
{
|
||||
LegoResult result;
|
||||
if ((result = p_storage->Read(&m_coordinates[0], sizeof(m_coordinates[0]))) != SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
if ((result = p_storage->Read(&m_coordinates[1], sizeof(m_coordinates[1]))) != SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
if ((result = p_storage->Read(&m_coordinates[2], sizeof(m_coordinates[2]))) != SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
@@ -1,30 +0,0 @@
|
||||
#ifndef __LEGOVERTEX_H
|
||||
#define __LEGOVERTEX_H
|
||||
|
||||
#include "misc/legotypes.h"
|
||||
|
||||
class LegoStorage;
|
||||
|
||||
// SIZE 0x0c
|
||||
class LegoVertex {
|
||||
public:
|
||||
LegoVertex();
|
||||
LegoFloat GetCoordinate(LegoU32 p_i) { return m_coordinates[p_i]; }
|
||||
void SetCoordinate(LegoU32 p_i, LegoFloat p_coordinate) { m_coordinates[p_i] = p_coordinate; }
|
||||
LegoFloat GetX() { return m_coordinates[0]; }
|
||||
void SetX(LegoFloat p_x) { m_coordinates[0] = p_x; }
|
||||
LegoFloat GetY() { return m_coordinates[1]; }
|
||||
void SetY(LegoFloat p_y) { m_coordinates[1] = p_y; }
|
||||
LegoFloat GetZ() { return m_coordinates[2]; }
|
||||
void SetZ(LegoFloat p_z) { m_coordinates[2] = p_z; }
|
||||
LegoBool IsOrigin() { return m_coordinates[0] == 0.0 && m_coordinates[1] == 0.0 && m_coordinates[2] == 0.0; }
|
||||
LegoResult Read(LegoStorage* p_storage);
|
||||
|
||||
LegoFloat& operator[](int i) { return m_coordinates[i]; }
|
||||
LegoFloat operator[](int i) const { return m_coordinates[i]; }
|
||||
|
||||
protected:
|
||||
LegoFloat m_coordinates[3]; // 0x00
|
||||
};
|
||||
|
||||
#endif // __LEGOVERTEX_H
|
Reference in New Issue
Block a user