2023-06-30 14:34:39 -04:00
|
|
|
#include "legoroi.h"
|
|
|
|
|
2023-11-01 11:12:03 -04:00
|
|
|
#include <string.h>
|
|
|
|
|
2024-02-17 10:07:34 -05:00
|
|
|
DECOMP_SIZE_ASSERT(LegoROI, 0x108)
|
|
|
|
DECOMP_SIZE_ASSERT(TimeROI, 0x10c)
|
2024-01-01 19:17:38 -05:00
|
|
|
|
2023-11-01 11:12:03 -04:00
|
|
|
// SIZE 0x14
|
|
|
|
typedef struct {
|
|
|
|
const char* m_name;
|
2024-01-24 21:16:29 -05:00
|
|
|
int m_red;
|
|
|
|
int m_green;
|
|
|
|
int m_blue;
|
|
|
|
int m_unk0x10;
|
2023-11-01 11:12:03 -04:00
|
|
|
} ROIColorAlias;
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// GLOBAL: LEGO1 0x100dbe28
|
2023-11-01 11:12:03 -04:00
|
|
|
const double g_normalizeByteToFloat = 1.0 / 255;
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// GLOBAL: LEGO1 0x101011b0
|
2023-11-01 11:12:03 -04:00
|
|
|
ROIColorAlias g_roiColorAliases[22] = {
|
|
|
|
{"lego black", 0x21, 0x21, 0x21, 0}, {"lego black f", 0x21, 0x21, 0x21, 0},
|
|
|
|
{"lego black flat", 0x21, 0x21, 0x21, 0}, {"lego blue", 0x00, 0x54, 0x8c, 0},
|
|
|
|
{"lego blue flat", 0x00, 0x54, 0x8c, 0}, {"lego brown", 0x4a, 0x23, 0x1a, 0},
|
|
|
|
{"lego brown flt", 0x4a, 0x23, 0x1a, 0}, {"lego brown flat", 0x4a, 0x23, 0x1a, 0},
|
|
|
|
{"lego drk grey", 0x40, 0x40, 0x40, 0}, {"lego drk grey flt", 0x40, 0x40, 0x40, 0},
|
|
|
|
{"lego dk grey flt", 0x40, 0x40, 0x40, 0}, {"lego green", 0x00, 0x78, 0x2d, 0},
|
|
|
|
{"lego green flat", 0x00, 0x78, 0x2d, 0}, {"lego lt grey", 0x82, 0x82, 0x82, 0},
|
|
|
|
{"lego lt grey flt", 0x82, 0x82, 0x82, 0}, {"lego lt grey fla", 0x82, 0x82, 0x82, 0},
|
|
|
|
{"lego red", 0xcb, 0x12, 0x20, 0}, {"lego red flat", 0xcb, 0x12, 0x20, 0},
|
|
|
|
{"lego white", 0xfa, 0xfa, 0xfa, 0}, {"lego white flat", 0xfa, 0xfa, 0xfa, 0},
|
|
|
|
{"lego yellow", 0xff, 0xb9, 0x00, 0}, {"lego yellow flat", 0xff, 0xb9, 0x00, 0},
|
|
|
|
};
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// GLOBAL: LEGO1 0x10101368
|
2024-01-24 21:16:29 -05:00
|
|
|
int g_roiConfig = 100;
|
2023-06-30 14:34:39 -04:00
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// GLOBAL: LEGO1 0x101013ac
|
2023-11-01 11:12:03 -04:00
|
|
|
ROIHandler g_someHandlerFunction = NULL;
|
2023-06-30 14:34:39 -04:00
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100a81c0
|
2024-01-24 21:16:29 -05:00
|
|
|
void LegoROI::configureLegoROI(int p_roiConfig)
|
2023-06-30 14:34:39 -04:00
|
|
|
{
|
2023-12-13 05:48:14 -05:00
|
|
|
g_roiConfig = p_roiConfig;
|
2023-06-30 14:34:39 -04:00
|
|
|
}
|
2023-11-01 11:12:03 -04:00
|
|
|
|
2024-02-17 10:07:34 -05:00
|
|
|
// FUNCTION: LEGO1 0x100a81d0
|
2024-03-01 12:19:41 -05:00
|
|
|
LegoROI::LegoROI(Tgl::Renderer* p_renderer) : ViewROI(p_renderer, NULL)
|
2024-02-17 10:07:34 -05:00
|
|
|
{
|
|
|
|
m_unk0xd4 = NULL;
|
|
|
|
m_name = NULL;
|
|
|
|
m_unk0x104 = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x100a82d0
|
2024-03-01 12:19:41 -05:00
|
|
|
LegoROI::LegoROI(Tgl::Renderer* p_renderer, ViewLODList* p_lodList) : ViewROI(p_renderer, p_lodList)
|
2024-02-17 10:07:34 -05:00
|
|
|
{
|
|
|
|
m_unk0xd4 = NULL;
|
|
|
|
m_name = NULL;
|
|
|
|
m_unk0x104 = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x100a83c0
|
|
|
|
LegoROI::~LegoROI()
|
|
|
|
{
|
|
|
|
if (comp) {
|
|
|
|
CompoundObject::iterator iterator;
|
|
|
|
|
|
|
|
for (iterator = comp->begin(); !(iterator == comp->end()); ++iterator) {
|
|
|
|
ROI* child = *iterator;
|
|
|
|
|
|
|
|
delete child;
|
|
|
|
}
|
|
|
|
|
|
|
|
delete comp;
|
|
|
|
comp = 0;
|
|
|
|
}
|
|
|
|
if (m_name) {
|
|
|
|
delete[] m_name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-24 11:48:16 -05:00
|
|
|
// STUB: LEGO1 0x100a84a0
|
|
|
|
LegoResult LegoROI::Read(
|
|
|
|
OrientableROI* p_unk0xd4,
|
|
|
|
Tgl::Renderer* p_renderer,
|
|
|
|
ViewLODListManager* p_viewLODListManager,
|
|
|
|
LegoTextureContainer* p_textureContainer,
|
|
|
|
LegoStorage* p_storage
|
|
|
|
)
|
|
|
|
{
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
// STUB: LEGO1 0x100a90f0
|
|
|
|
LegoResult LegoROI::SetFrame(LegoAnim* p_anim, LegoTime p_time)
|
|
|
|
{
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
2024-02-17 10:07:34 -05:00
|
|
|
// FUNCTION: LEGO1 0x100a9a50
|
|
|
|
TimeROI::TimeROI(Tgl::Renderer* p_renderer, ViewLODList* p_lodList, int p_time) : LegoROI(p_renderer, p_lodList)
|
2024-01-01 19:17:38 -05:00
|
|
|
{
|
|
|
|
m_time = p_time;
|
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100a9bf0
|
2024-01-24 21:16:29 -05:00
|
|
|
unsigned char LegoROI::CallTheHandlerFunction(
|
2023-11-01 11:12:03 -04:00
|
|
|
char* p_param,
|
2024-01-24 21:16:29 -05:00
|
|
|
float& p_red,
|
|
|
|
float& p_green,
|
|
|
|
float& p_blue,
|
|
|
|
float& p_other
|
2023-11-01 11:12:03 -04:00
|
|
|
)
|
|
|
|
{
|
|
|
|
// TODO
|
2024-02-01 15:42:10 -05:00
|
|
|
if (p_param == NULL) {
|
2023-11-01 11:12:03 -04:00
|
|
|
return FALSE;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-11-01 11:12:03 -04:00
|
|
|
|
|
|
|
if (g_someHandlerFunction) {
|
|
|
|
char buf[32];
|
2024-02-01 15:42:10 -05:00
|
|
|
if (g_someHandlerFunction(p_param, buf, 32)) {
|
2023-11-01 11:12:03 -04:00
|
|
|
p_param = buf;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-11-01 11:12:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return ColorAliasLookup(p_param, p_red, p_green, p_blue, p_other);
|
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100a9c50
|
2024-01-24 21:16:29 -05:00
|
|
|
unsigned char LegoROI::ColorAliasLookup(char* p_param, float& p_red, float& p_green, float& p_blue, float& p_other)
|
2023-11-01 11:12:03 -04:00
|
|
|
{
|
|
|
|
// TODO: this seems awfully hacky for these devs. is there a dynamic way
|
|
|
|
// to represent `the end of this array` that would improve this?
|
2024-01-24 21:16:29 -05:00
|
|
|
unsigned int i = 0;
|
2023-11-01 11:12:03 -04:00
|
|
|
do {
|
|
|
|
if (strcmpi(g_roiColorAliases[i].m_name, p_param) == 0) {
|
|
|
|
p_red = g_roiColorAliases[i].m_red * g_normalizeByteToFloat;
|
|
|
|
p_green = g_roiColorAliases[i].m_green * g_normalizeByteToFloat;
|
|
|
|
p_blue = g_roiColorAliases[i].m_blue * g_normalizeByteToFloat;
|
2023-12-13 05:48:14 -05:00
|
|
|
p_other = g_roiColorAliases[i].m_unk0x10 * g_normalizeByteToFloat;
|
2023-11-01 11:12:03 -04:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
i++;
|
2024-01-24 21:16:29 -05:00
|
|
|
} while ((int*) &g_roiColorAliases[i] < &g_roiConfig);
|
2023-11-01 11:12:03 -04:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100a9d30
|
2023-11-01 11:12:03 -04:00
|
|
|
void LegoROI::SetSomeHandlerFunction(ROIHandler p_func)
|
|
|
|
{
|
|
|
|
g_someHandlerFunction = p_func;
|
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100a9e10
|
2024-01-24 21:16:29 -05:00
|
|
|
void LegoROI::SetDisplayBB(int p_displayBB)
|
2023-11-01 11:12:03 -04:00
|
|
|
{
|
|
|
|
// Intentionally empty function
|
|
|
|
}
|
2024-01-01 19:17:38 -05:00
|
|
|
|
2024-01-20 18:04:46 -05:00
|
|
|
// FUNCTION: LEGO1 0x100aa340
|
|
|
|
float LegoROI::IntrinsicImportance() const
|
|
|
|
{
|
|
|
|
return .5;
|
|
|
|
}
|
|
|
|
|
2024-01-01 19:17:38 -05:00
|
|
|
// STUB: LEGO1 0x100aa350
|
|
|
|
void LegoROI::UpdateWorldBoundingVolumes()
|
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
}
|