2024-03-09 15:07:52 -05:00
|
|
|
#include "legocharactermanager.h"
|
2023-10-24 19:38:27 -04:00
|
|
|
|
2024-05-03 12:19:12 -04:00
|
|
|
#include "3dmanager/lego3dmanager.h"
|
2024-03-19 14:23:34 -04:00
|
|
|
#include "legoanimactor.h"
|
2024-03-22 13:40:19 -04:00
|
|
|
#include "legocharacters.h"
|
2024-05-03 12:19:12 -04:00
|
|
|
#include "legoextraactor.h"
|
2023-10-12 12:18:24 -04:00
|
|
|
#include "legogamestate.h"
|
2024-05-03 12:19:12 -04:00
|
|
|
#include "legovariables.h"
|
2024-03-19 14:23:34 -04:00
|
|
|
#include "legovideomanager.h"
|
|
|
|
#include "misc.h"
|
2024-03-22 13:40:19 -04:00
|
|
|
#include "misc/legocontainer.h"
|
2024-05-03 12:19:12 -04:00
|
|
|
#include "misc/legostorage.h"
|
2024-03-09 15:07:52 -05:00
|
|
|
#include "mxmisc.h"
|
2024-05-03 12:19:12 -04:00
|
|
|
#include "mxvariabletable.h"
|
2024-03-22 13:40:19 -04:00
|
|
|
#include "realtime/realtime.h"
|
|
|
|
#include "roi/legolod.h"
|
2024-05-03 12:19:12 -04:00
|
|
|
#include "viewmanager/viewmanager.h"
|
2023-10-12 12:18:24 -04:00
|
|
|
|
2024-04-02 08:04:17 -04:00
|
|
|
#include <vec.h>
|
|
|
|
|
2024-03-19 14:23:34 -04:00
|
|
|
DECOMP_SIZE_ASSERT(LegoCharacter, 0x08)
|
2024-03-09 15:07:52 -05:00
|
|
|
DECOMP_SIZE_ASSERT(LegoCharacterManager, 0x08)
|
2024-02-21 15:30:02 -05:00
|
|
|
|
|
|
|
// GLOBAL: LEGO1 0x100fc4e4
|
2024-03-09 15:07:52 -05:00
|
|
|
char* LegoCharacterManager::g_customizeAnimFile = NULL;
|
2024-02-21 15:30:02 -05:00
|
|
|
|
2024-03-29 14:34:50 -04:00
|
|
|
// GLOBAL: LEGO1 0x100fc4d8
|
|
|
|
MxU32 g_unk0x100fc4d8 = 50;
|
|
|
|
|
|
|
|
// GLOBAL: LEGO1 0x100fc4dc
|
|
|
|
MxU32 g_unk0x100fc4dc = 66;
|
|
|
|
|
2024-04-17 07:52:59 -04:00
|
|
|
// GLOBAL: LEGO1 0x100fc4e8
|
|
|
|
MxU32 g_unk0x100fc4e8 = 0;
|
|
|
|
|
2024-04-05 09:57:20 -04:00
|
|
|
// GLOBAL: LEGO1 0x100fc4ec
|
|
|
|
MxU32 g_unk0x100fc4ec = 2;
|
|
|
|
|
2024-03-31 10:05:38 -04:00
|
|
|
// GLOBAL: LEGO1 0x100fc4f0
|
|
|
|
MxU32 g_unk0x100fc4f0 = 0;
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// GLOBAL: LEGO1 0x10104f20
|
2024-05-06 07:15:19 -04:00
|
|
|
LegoCharacterInfo g_characterInfo[66];
|
2023-10-12 12:18:24 -04:00
|
|
|
|
2024-02-21 15:30:02 -05:00
|
|
|
// FUNCTION: LEGO1 0x10082a20
|
2024-03-09 15:07:52 -05:00
|
|
|
LegoCharacterManager::LegoCharacterManager()
|
2024-02-10 20:52:16 -05:00
|
|
|
{
|
2024-03-19 14:23:34 -04:00
|
|
|
m_characters = new LegoCharacterMap();
|
2024-03-22 13:40:19 -04:00
|
|
|
Init();
|
2024-02-21 15:30:02 -05:00
|
|
|
|
|
|
|
m_customizeAnimFile = new CustomizeAnimFileVariable("CUSTOMIZE_ANIM_FILE");
|
|
|
|
VariableTable()->SetVariable(m_customizeAnimFile);
|
|
|
|
}
|
|
|
|
|
2024-05-14 08:13:27 -04:00
|
|
|
// FUNCTION: LEGO1 0x10083180
|
|
|
|
// FUNCTION: BETA10 0x10073dad
|
|
|
|
LegoCharacterManager::~LegoCharacterManager()
|
|
|
|
{
|
|
|
|
LegoCharacter* character = NULL;
|
|
|
|
LegoCharacterMap::iterator it;
|
|
|
|
|
|
|
|
for (it = m_characters->begin(); it != m_characters->end(); it++) {
|
|
|
|
character = (*it).second;
|
|
|
|
|
|
|
|
RemoveROI(character->m_roi);
|
|
|
|
|
|
|
|
delete[] (*it).first;
|
|
|
|
delete (*it).second;
|
|
|
|
}
|
|
|
|
|
|
|
|
delete m_characters;
|
|
|
|
delete[] g_customizeAnimFile;
|
|
|
|
}
|
|
|
|
|
2024-02-21 15:30:02 -05:00
|
|
|
// FUNCTION: LEGO1 0x10083270
|
2024-03-22 13:40:19 -04:00
|
|
|
void LegoCharacterManager::Init()
|
2024-02-21 15:30:02 -05:00
|
|
|
{
|
2024-05-06 07:15:19 -04:00
|
|
|
for (MxS32 i = 0; i < _countof(g_characterInfo); i++) {
|
|
|
|
g_characterInfo[i] = g_characterInfoInit[i];
|
2024-02-21 15:30:02 -05:00
|
|
|
}
|
2024-02-10 20:52:16 -05:00
|
|
|
}
|
|
|
|
|
2024-03-29 10:41:12 -04:00
|
|
|
// FUNCTION: LEGO1 0x100832a0
|
2024-03-09 15:07:52 -05:00
|
|
|
void LegoCharacterManager::FUN_100832a0()
|
2024-02-05 12:35:26 -05:00
|
|
|
{
|
2024-05-06 07:15:19 -04:00
|
|
|
for (MxS32 i = 0; i < _countof(g_characterInfo); i++) {
|
|
|
|
LegoCharacterInfo* info = GetInfo(g_characterInfo[i].m_name);
|
2024-03-29 10:41:12 -04:00
|
|
|
|
2024-04-28 09:04:27 -04:00
|
|
|
if (info != NULL) {
|
|
|
|
LegoExtraActor* actor = info->m_actor;
|
2024-03-29 10:41:12 -04:00
|
|
|
|
|
|
|
if (actor != NULL && actor->IsA("LegoExtraActor")) {
|
2024-05-06 07:15:19 -04:00
|
|
|
LegoROI* roi = g_characterInfo[i].m_roi;
|
2024-03-29 13:30:31 -04:00
|
|
|
MxU32 refCount = GetRefCount(roi);
|
2024-03-29 10:41:12 -04:00
|
|
|
|
2024-03-29 13:30:31 -04:00
|
|
|
while (refCount != 0) {
|
2024-03-29 10:41:12 -04:00
|
|
|
FUN_10083db0(roi);
|
2024-03-29 13:30:31 -04:00
|
|
|
refCount = GetRefCount(roi);
|
2024-03-29 10:41:12 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-02-05 12:35:26 -05:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x10083310
|
2024-03-22 13:40:19 -04:00
|
|
|
MxResult LegoCharacterManager::Write(LegoStorage* p_storage)
|
2023-10-12 12:18:24 -04:00
|
|
|
{
|
2023-10-24 19:38:27 -04:00
|
|
|
MxResult result = FAILURE;
|
2023-10-12 12:18:24 -04:00
|
|
|
|
2024-05-06 07:15:19 -04:00
|
|
|
for (MxS32 i = 0; i < _countof(g_characterInfo); i++) {
|
|
|
|
LegoCharacterInfo* info = &g_characterInfo[i];
|
2023-10-12 12:18:24 -04:00
|
|
|
|
2024-04-28 09:04:27 -04:00
|
|
|
if (p_storage->Write(&info->m_unk0x0c, sizeof(info->m_unk0x0c)) != SUCCESS) {
|
2024-03-22 13:40:19 -04:00
|
|
|
goto done;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-04-28 09:04:27 -04:00
|
|
|
if (p_storage->Write(&info->m_unk0x10, sizeof(info->m_unk0x10)) != SUCCESS) {
|
2024-03-22 13:40:19 -04:00
|
|
|
goto done;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-04-28 09:04:27 -04:00
|
|
|
if (p_storage->Write(&info->m_unk0x14, sizeof(info->m_unk0x14)) != SUCCESS) {
|
2024-03-22 13:40:19 -04:00
|
|
|
goto done;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-04-28 09:04:27 -04:00
|
|
|
if (p_storage->Write(&info->m_parts[c_infohatPart].m_unk0x08, sizeof(info->m_parts[c_infohatPart].m_unk0x08)) !=
|
2024-04-28 08:49:07 -04:00
|
|
|
SUCCESS) {
|
2024-03-22 13:40:19 -04:00
|
|
|
goto done;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-04-28 09:04:27 -04:00
|
|
|
if (p_storage->Write(&info->m_parts[c_infohatPart].m_unk0x14, sizeof(info->m_parts[c_infohatPart].m_unk0x14)) !=
|
2024-04-28 08:49:07 -04:00
|
|
|
SUCCESS) {
|
2024-03-22 13:40:19 -04:00
|
|
|
goto done;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-04-28 08:49:07 -04:00
|
|
|
if (p_storage->Write(
|
2024-04-28 09:04:27 -04:00
|
|
|
&info->m_parts[c_infogronPart].m_unk0x14,
|
|
|
|
sizeof(info->m_parts[c_infogronPart].m_unk0x14)
|
2024-04-28 08:49:07 -04:00
|
|
|
) != SUCCESS) {
|
2024-03-22 13:40:19 -04:00
|
|
|
goto done;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-04-28 09:04:27 -04:00
|
|
|
if (p_storage->Write(&info->m_parts[c_armlftPart].m_unk0x14, sizeof(info->m_parts[c_armlftPart].m_unk0x14)) !=
|
2024-04-28 08:49:07 -04:00
|
|
|
SUCCESS) {
|
2024-03-22 13:40:19 -04:00
|
|
|
goto done;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-04-28 09:04:27 -04:00
|
|
|
if (p_storage->Write(&info->m_parts[c_armrtPart].m_unk0x14, sizeof(info->m_parts[c_armrtPart].m_unk0x14)) !=
|
2024-04-28 08:49:07 -04:00
|
|
|
SUCCESS) {
|
2024-03-22 13:40:19 -04:00
|
|
|
goto done;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-04-28 09:04:27 -04:00
|
|
|
if (p_storage->Write(&info->m_parts[c_leglftPart].m_unk0x14, sizeof(info->m_parts[c_leglftPart].m_unk0x14)) !=
|
2024-04-28 08:49:07 -04:00
|
|
|
SUCCESS) {
|
2024-03-22 13:40:19 -04:00
|
|
|
goto done;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-04-28 09:04:27 -04:00
|
|
|
if (p_storage->Write(&info->m_parts[c_legrtPart].m_unk0x14, sizeof(info->m_parts[c_legrtPart].m_unk0x14)) !=
|
2024-04-28 08:49:07 -04:00
|
|
|
SUCCESS) {
|
2024-03-22 13:40:19 -04:00
|
|
|
goto done;
|
2023-10-24 19:38:27 -04:00
|
|
|
}
|
|
|
|
}
|
2024-02-26 11:19:16 -05:00
|
|
|
|
2024-03-22 13:40:19 -04:00
|
|
|
result = SUCCESS;
|
|
|
|
|
|
|
|
done:
|
2023-10-24 19:38:27 -04:00
|
|
|
return result;
|
2023-10-12 12:18:24 -04:00
|
|
|
}
|
2024-01-16 14:33:03 -05:00
|
|
|
|
2024-03-22 13:40:19 -04:00
|
|
|
// FUNCTION: LEGO1 0x100833f0
|
|
|
|
MxResult LegoCharacterManager::Read(LegoStorage* p_storage)
|
2024-02-27 15:04:17 -05:00
|
|
|
{
|
2024-03-22 13:40:19 -04:00
|
|
|
MxResult result = FAILURE;
|
|
|
|
|
2024-05-06 07:15:19 -04:00
|
|
|
for (MxS32 i = 0; i < _countof(g_characterInfo); i++) {
|
|
|
|
LegoCharacterInfo* info = &g_characterInfo[i];
|
2024-03-22 13:40:19 -04:00
|
|
|
|
2024-04-28 09:04:27 -04:00
|
|
|
if (p_storage->Read(&info->m_unk0x0c, sizeof(info->m_unk0x0c)) != SUCCESS) {
|
2024-03-22 13:40:19 -04:00
|
|
|
goto done;
|
|
|
|
}
|
2024-04-28 09:04:27 -04:00
|
|
|
if (p_storage->Read(&info->m_unk0x10, sizeof(info->m_unk0x10)) != SUCCESS) {
|
2024-03-22 13:40:19 -04:00
|
|
|
goto done;
|
|
|
|
}
|
2024-04-28 09:04:27 -04:00
|
|
|
if (p_storage->Read(&info->m_unk0x14, sizeof(info->m_unk0x14)) != SUCCESS) {
|
2024-03-22 13:40:19 -04:00
|
|
|
goto done;
|
|
|
|
}
|
2024-04-28 09:04:27 -04:00
|
|
|
if (p_storage->Read(&info->m_parts[c_infohatPart].m_unk0x08, sizeof(info->m_parts[c_infohatPart].m_unk0x08)) !=
|
2024-04-28 08:49:07 -04:00
|
|
|
SUCCESS) {
|
2024-03-22 13:40:19 -04:00
|
|
|
goto done;
|
|
|
|
}
|
2024-04-28 09:04:27 -04:00
|
|
|
if (p_storage->Read(&info->m_parts[c_infohatPart].m_unk0x14, sizeof(info->m_parts[c_infohatPart].m_unk0x14)) !=
|
2024-04-28 08:49:07 -04:00
|
|
|
SUCCESS) {
|
2024-03-22 13:40:19 -04:00
|
|
|
goto done;
|
|
|
|
}
|
2024-04-28 08:49:07 -04:00
|
|
|
if (p_storage->Read(
|
2024-04-28 09:04:27 -04:00
|
|
|
&info->m_parts[c_infogronPart].m_unk0x14,
|
|
|
|
sizeof(info->m_parts[c_infogronPart].m_unk0x14)
|
2024-04-28 08:49:07 -04:00
|
|
|
) != SUCCESS) {
|
2024-03-22 13:40:19 -04:00
|
|
|
goto done;
|
|
|
|
}
|
2024-04-28 09:04:27 -04:00
|
|
|
if (p_storage->Read(&info->m_parts[c_armlftPart].m_unk0x14, sizeof(info->m_parts[c_armlftPart].m_unk0x14)) !=
|
2024-04-28 08:49:07 -04:00
|
|
|
SUCCESS) {
|
2024-03-22 13:40:19 -04:00
|
|
|
goto done;
|
|
|
|
}
|
2024-04-28 09:04:27 -04:00
|
|
|
if (p_storage->Read(&info->m_parts[c_armrtPart].m_unk0x14, sizeof(info->m_parts[c_armrtPart].m_unk0x14)) !=
|
2024-04-28 08:49:07 -04:00
|
|
|
SUCCESS) {
|
2024-03-22 13:40:19 -04:00
|
|
|
goto done;
|
|
|
|
}
|
2024-04-28 09:04:27 -04:00
|
|
|
if (p_storage->Read(&info->m_parts[c_leglftPart].m_unk0x14, sizeof(info->m_parts[c_leglftPart].m_unk0x14)) !=
|
2024-04-28 08:49:07 -04:00
|
|
|
SUCCESS) {
|
2024-03-22 13:40:19 -04:00
|
|
|
goto done;
|
|
|
|
}
|
2024-04-28 09:04:27 -04:00
|
|
|
if (p_storage->Read(&info->m_parts[c_legrtPart].m_unk0x14, sizeof(info->m_parts[c_legrtPart].m_unk0x14)) !=
|
2024-04-28 08:49:07 -04:00
|
|
|
SUCCESS) {
|
2024-03-22 13:40:19 -04:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
result = SUCCESS;
|
|
|
|
|
|
|
|
done:
|
|
|
|
return result;
|
2024-02-27 15:04:17 -05:00
|
|
|
}
|
|
|
|
|
2024-03-19 14:23:34 -04:00
|
|
|
// FUNCTION: LEGO1 0x10083500
|
|
|
|
LegoROI* LegoCharacterManager::GetROI(const char* p_key, MxBool p_createEntity)
|
2024-01-22 10:18:46 -05:00
|
|
|
{
|
2024-03-19 14:23:34 -04:00
|
|
|
LegoCharacter* character = NULL;
|
2024-04-19 08:30:36 -04:00
|
|
|
LegoCharacterMap::iterator it = m_characters->find(const_cast<char*>(p_key));
|
2024-03-19 14:23:34 -04:00
|
|
|
|
|
|
|
if (it != m_characters->end()) {
|
|
|
|
character = (*it).second;
|
|
|
|
character->AddRef();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (character == NULL) {
|
|
|
|
LegoROI* roi = CreateROI(p_key);
|
2024-03-23 13:06:31 -04:00
|
|
|
|
|
|
|
if (roi == NULL) {
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2024-03-19 14:44:42 -04:00
|
|
|
roi->SetVisibility(FALSE);
|
2024-03-19 14:23:34 -04:00
|
|
|
|
|
|
|
if (roi != NULL) {
|
|
|
|
character = new LegoCharacter(roi);
|
|
|
|
char* key = new char[strlen(p_key) + 1];
|
|
|
|
|
|
|
|
if (key != NULL) {
|
|
|
|
strcpy(key, p_key);
|
|
|
|
(*m_characters)[key] = character;
|
|
|
|
VideoManager()->Get3DManager()->Add(*roi);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
VideoManager()->Get3DManager()->Remove(*character->m_roi);
|
|
|
|
VideoManager()->Get3DManager()->Add(*character->m_roi);
|
|
|
|
}
|
|
|
|
|
2024-03-23 13:06:31 -04:00
|
|
|
done:
|
2024-03-19 14:23:34 -04:00
|
|
|
if (character != NULL) {
|
|
|
|
if (p_createEntity && character->m_roi->GetEntity() == NULL) {
|
2024-03-23 10:09:20 -04:00
|
|
|
LegoExtraActor* actor = new LegoExtraActor();
|
2024-03-19 14:23:34 -04:00
|
|
|
|
|
|
|
actor->SetROI(character->m_roi, FALSE, FALSE);
|
2024-04-26 10:03:13 -04:00
|
|
|
actor->SetType(LegoEntity::e_character);
|
2024-03-19 14:23:34 -04:00
|
|
|
actor->SetFlag(LegoActor::c_bit2);
|
2024-04-28 09:04:27 -04:00
|
|
|
GetInfo(p_key)->m_actor = actor;
|
2024-03-19 14:23:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return character->m_roi;
|
|
|
|
}
|
|
|
|
|
2024-01-22 10:18:46 -05:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2024-05-11 08:13:27 -04:00
|
|
|
// FUNCTION: LEGO1 0x10083b20
|
2024-05-10 14:07:38 -04:00
|
|
|
// FUNCTION: BETA10 0x10074608
|
2024-05-11 08:13:27 -04:00
|
|
|
MxBool LegoCharacterManager::FUN_10083b20(const char* p_key)
|
2024-05-10 14:07:38 -04:00
|
|
|
{
|
2024-05-11 08:13:27 -04:00
|
|
|
LegoCharacter* character = NULL;
|
|
|
|
LegoCharacterMap::iterator it = m_characters->find(const_cast<char*>(p_key));
|
|
|
|
|
|
|
|
if (it != m_characters->end()) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2024-05-10 14:07:38 -04:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2024-03-29 13:30:31 -04:00
|
|
|
// FUNCTION: LEGO1 0x10083bc0
|
|
|
|
MxU32 LegoCharacterManager::GetRefCount(LegoROI* p_roi)
|
2024-03-29 10:41:12 -04:00
|
|
|
{
|
2024-03-29 13:30:31 -04:00
|
|
|
LegoCharacterMap::iterator it;
|
|
|
|
|
|
|
|
for (it = m_characters->begin(); it != m_characters->end(); it++) {
|
|
|
|
LegoCharacter* character = (*it).second;
|
|
|
|
LegoROI* roi = character->m_roi;
|
|
|
|
|
|
|
|
if (roi == p_roi) {
|
|
|
|
return character->m_refCount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-29 10:41:12 -04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2024-04-19 08:30:36 -04:00
|
|
|
// FUNCTION: LEGO1 0x10083c30
|
2024-04-17 11:03:17 -04:00
|
|
|
// FUNCTION: BETA10 0x10074701
|
|
|
|
void LegoCharacterManager::FUN_10083c30(const char* p_name)
|
|
|
|
{
|
2024-04-19 08:30:36 -04:00
|
|
|
LegoCharacter* character = NULL;
|
|
|
|
LegoCharacterMap::iterator it = m_characters->find(const_cast<char*>(p_name));
|
|
|
|
|
|
|
|
if (it != m_characters->end()) {
|
|
|
|
character = (*it).second;
|
|
|
|
|
|
|
|
if (character->RemoveRef() == 0) {
|
2024-04-28 09:04:27 -04:00
|
|
|
LegoCharacterInfo* info = GetInfo(p_name);
|
2024-04-19 08:30:36 -04:00
|
|
|
LegoEntity* entity = character->m_roi->GetEntity();
|
|
|
|
|
|
|
|
if (entity != NULL) {
|
|
|
|
entity->SetROI(NULL, FALSE, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
RemoveROI(character->m_roi);
|
|
|
|
|
|
|
|
delete[] (*it).first;
|
|
|
|
delete (*it).second;
|
|
|
|
|
|
|
|
m_characters->erase(it);
|
|
|
|
|
2024-04-28 09:04:27 -04:00
|
|
|
if (info != NULL) {
|
|
|
|
if (info->m_actor != NULL) {
|
|
|
|
info->m_actor->ClearFlag(LegoEntity::c_bit2);
|
|
|
|
delete info->m_actor;
|
2024-04-19 08:30:36 -04:00
|
|
|
}
|
|
|
|
else if (entity != NULL && entity->GetFlagsIsSet(LegoEntity::c_bit2)) {
|
|
|
|
entity->ClearFlag(LegoEntity::c_bit2);
|
|
|
|
delete entity;
|
|
|
|
}
|
|
|
|
|
2024-04-28 09:04:27 -04:00
|
|
|
info->m_roi = NULL;
|
|
|
|
info->m_actor = NULL;
|
2024-04-19 08:30:36 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-04-17 11:03:17 -04:00
|
|
|
}
|
|
|
|
|
2024-04-06 12:11:13 -04:00
|
|
|
// FUNCTION: LEGO1 0x10083db0
|
2024-03-09 15:07:52 -05:00
|
|
|
void LegoCharacterManager::FUN_10083db0(LegoROI* p_roi)
|
2024-01-16 14:33:03 -05:00
|
|
|
{
|
2024-04-06 12:11:13 -04:00
|
|
|
LegoCharacter* character = NULL;
|
|
|
|
LegoCharacterMap::iterator it;
|
|
|
|
|
|
|
|
for (it = m_characters->begin(); it != m_characters->end(); it++) {
|
|
|
|
character = (*it).second;
|
|
|
|
|
|
|
|
if (character->m_roi == p_roi) {
|
|
|
|
if (character->RemoveRef() == 0) {
|
2024-04-28 09:04:27 -04:00
|
|
|
LegoCharacterInfo* info = GetInfo(character->m_roi->GetName());
|
2024-04-06 12:11:13 -04:00
|
|
|
LegoEntity* entity = character->m_roi->GetEntity();
|
|
|
|
|
|
|
|
if (entity != NULL) {
|
|
|
|
entity->SetROI(NULL, FALSE, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
RemoveROI(character->m_roi);
|
|
|
|
|
2024-04-19 08:30:36 -04:00
|
|
|
delete[] (*it).first;
|
2024-04-06 12:11:13 -04:00
|
|
|
delete (*it).second;
|
|
|
|
|
|
|
|
m_characters->erase(it);
|
|
|
|
|
2024-04-28 09:04:27 -04:00
|
|
|
if (info != NULL) {
|
|
|
|
if (info->m_actor != NULL) {
|
|
|
|
info->m_actor->ClearFlag(LegoEntity::c_bit2);
|
|
|
|
delete info->m_actor;
|
2024-04-06 12:11:13 -04:00
|
|
|
}
|
|
|
|
else if (entity != NULL && entity->GetFlagsIsSet(LegoEntity::c_bit2)) {
|
|
|
|
entity->ClearFlag(LegoEntity::c_bit2);
|
|
|
|
delete entity;
|
|
|
|
}
|
|
|
|
|
2024-04-28 09:04:27 -04:00
|
|
|
info->m_roi = NULL;
|
|
|
|
info->m_actor = NULL;
|
2024-04-06 12:11:13 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2024-01-16 14:33:03 -05:00
|
|
|
}
|
2024-02-13 18:34:14 -05:00
|
|
|
|
2024-04-06 11:46:40 -04:00
|
|
|
// FUNCTION: LEGO1 0x10083f10
|
2024-03-09 15:07:52 -05:00
|
|
|
void LegoCharacterManager::FUN_10083f10(LegoROI* p_roi)
|
2024-02-13 18:34:14 -05:00
|
|
|
{
|
2024-04-06 11:46:40 -04:00
|
|
|
LegoCharacter* character = NULL;
|
|
|
|
LegoCharacterMap::iterator it;
|
|
|
|
|
|
|
|
for (it = m_characters->begin(); it != m_characters->end(); it++) {
|
|
|
|
character = (*it).second;
|
|
|
|
|
|
|
|
if (character->m_roi == p_roi) {
|
|
|
|
if (character->RemoveRef() == 0) {
|
|
|
|
LegoEntity* entity = character->m_roi->GetEntity();
|
|
|
|
|
|
|
|
if (entity != NULL) {
|
|
|
|
entity->SetROI(NULL, FALSE, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
RemoveROI(character->m_roi);
|
|
|
|
|
2024-04-19 08:30:36 -04:00
|
|
|
delete[] (*it).first;
|
2024-04-06 11:46:40 -04:00
|
|
|
delete (*it).second;
|
|
|
|
|
|
|
|
m_characters->erase(it);
|
|
|
|
|
|
|
|
if (entity != NULL && entity->GetFlagsIsSet(LegoEntity::c_bit2)) {
|
|
|
|
entity->ClearFlag(LegoEntity::c_bit2);
|
|
|
|
delete entity;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x10084010
|
|
|
|
void LegoCharacterManager::RemoveROI(LegoROI* p_roi)
|
|
|
|
{
|
|
|
|
VideoManager()->Get3DManager()->Remove(*p_roi);
|
2024-02-13 18:34:14 -05:00
|
|
|
}
|
2024-02-21 15:30:02 -05:00
|
|
|
|
2024-03-22 13:40:19 -04:00
|
|
|
// FUNCTION: LEGO1 0x10084030
|
2024-03-19 14:23:34 -04:00
|
|
|
LegoROI* LegoCharacterManager::CreateROI(const char* p_key)
|
|
|
|
{
|
2024-03-22 13:40:19 -04:00
|
|
|
MxBool success = FALSE;
|
|
|
|
LegoROI* roi = NULL;
|
|
|
|
BoundingSphere boundingSphere;
|
|
|
|
BoundingBox boundingBox;
|
|
|
|
MxMatrix mat;
|
|
|
|
CompoundObject* comp;
|
2024-04-05 09:57:20 -04:00
|
|
|
MxS32 i;
|
2024-03-22 13:40:19 -04:00
|
|
|
|
|
|
|
Tgl::Renderer* renderer = VideoManager()->GetRenderer();
|
|
|
|
ViewLODListManager* lodManager = GetViewLODListManager();
|
|
|
|
LegoTextureContainer* textureContainer = TextureContainer();
|
2024-04-28 09:04:27 -04:00
|
|
|
LegoCharacterInfo* info = GetInfo(p_key);
|
2024-03-22 13:40:19 -04:00
|
|
|
|
2024-04-28 09:04:27 -04:00
|
|
|
if (info == NULL) {
|
2024-03-22 13:40:19 -04:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!strcmpi(p_key, "pep")) {
|
2024-04-28 09:04:27 -04:00
|
|
|
LegoCharacterInfo* pepper = GetInfo("pepper");
|
2024-03-22 13:40:19 -04:00
|
|
|
|
2024-04-28 09:04:27 -04:00
|
|
|
info->m_unk0x0c = pepper->m_unk0x0c;
|
|
|
|
info->m_unk0x10 = pepper->m_unk0x10;
|
|
|
|
info->m_unk0x14 = pepper->m_unk0x14;
|
2024-03-22 13:40:19 -04:00
|
|
|
|
2024-04-28 09:04:27 -04:00
|
|
|
for (i = 0; i < _countof(info->m_parts); i++) {
|
|
|
|
info->m_parts[i] = pepper->m_parts[i];
|
2024-03-22 13:40:19 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
roi = new LegoROI(renderer);
|
|
|
|
roi->SetName(p_key);
|
|
|
|
|
2024-04-28 08:49:07 -04:00
|
|
|
boundingSphere.Center()[0] = g_characterLODs[c_topLOD].m_boundingSphere[0];
|
|
|
|
boundingSphere.Center()[1] = g_characterLODs[c_topLOD].m_boundingSphere[1];
|
|
|
|
boundingSphere.Center()[2] = g_characterLODs[c_topLOD].m_boundingSphere[2];
|
|
|
|
boundingSphere.Radius() = g_characterLODs[c_topLOD].m_boundingSphere[3];
|
2024-03-22 13:40:19 -04:00
|
|
|
roi->SetBoundingSphere(boundingSphere);
|
|
|
|
|
2024-04-28 08:49:07 -04:00
|
|
|
boundingBox.Min()[0] = g_characterLODs[c_topLOD].m_boundingBox[0];
|
|
|
|
boundingBox.Min()[1] = g_characterLODs[c_topLOD].m_boundingBox[1];
|
|
|
|
boundingBox.Min()[2] = g_characterLODs[c_topLOD].m_boundingBox[2];
|
|
|
|
boundingBox.Max()[0] = g_characterLODs[c_topLOD].m_boundingBox[3];
|
|
|
|
boundingBox.Max()[1] = g_characterLODs[c_topLOD].m_boundingBox[4];
|
|
|
|
boundingBox.Max()[2] = g_characterLODs[c_topLOD].m_boundingBox[5];
|
2024-03-22 13:40:19 -04:00
|
|
|
roi->SetUnknown0x80(boundingBox);
|
|
|
|
|
|
|
|
comp = new CompoundObject();
|
|
|
|
roi->SetComp(comp);
|
|
|
|
|
|
|
|
for (i = 0; i < _countof(g_characterLODs) - 1; i++) {
|
2024-04-05 09:57:20 -04:00
|
|
|
char lodName[256];
|
2024-04-28 09:04:27 -04:00
|
|
|
LegoCharacterInfo::Part& part = info->m_parts[i];
|
2024-03-22 13:40:19 -04:00
|
|
|
|
2024-04-05 09:57:20 -04:00
|
|
|
const char* parentName;
|
2024-03-22 13:40:19 -04:00
|
|
|
if (i == 0 || i == 1) {
|
|
|
|
parentName = part.m_unk0x04[part.m_unk0x00[part.m_unk0x08]];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
parentName = g_characterLODs[i + 1].m_parentName;
|
|
|
|
}
|
|
|
|
|
2024-04-05 09:57:20 -04:00
|
|
|
ViewLODList* lodList = lodManager->Lookup(parentName);
|
|
|
|
MxS32 lodSize = lodList->Size();
|
2024-03-22 13:40:19 -04:00
|
|
|
sprintf(lodName, "%s%d", p_key, i);
|
2024-04-05 09:57:20 -04:00
|
|
|
ViewLODList* dupLodList = lodManager->Create(lodName, lodSize);
|
2024-03-22 13:40:19 -04:00
|
|
|
|
2024-04-05 09:57:20 -04:00
|
|
|
for (MxS32 j = 0; j < lodSize; j++) {
|
|
|
|
LegoLOD* lod = (LegoLOD*) (*lodList)[j];
|
|
|
|
LegoLOD* clone = lod->Clone(renderer);
|
|
|
|
dupLodList->PushBack(clone);
|
2024-03-22 13:40:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
lodList->Release();
|
|
|
|
lodList = dupLodList;
|
|
|
|
|
2024-04-05 09:57:20 -04:00
|
|
|
LegoROI* childROI = new LegoROI(renderer, lodList);
|
2024-03-22 13:40:19 -04:00
|
|
|
lodList->Release();
|
|
|
|
|
|
|
|
childROI->SetName(g_characterLODs[i + 1].m_name);
|
|
|
|
childROI->SetParentROI(roi);
|
|
|
|
|
|
|
|
BoundingSphere childBoundingSphere;
|
|
|
|
childBoundingSphere.Center()[0] = g_characterLODs[i + 1].m_boundingSphere[0];
|
|
|
|
childBoundingSphere.Center()[1] = g_characterLODs[i + 1].m_boundingSphere[1];
|
|
|
|
childBoundingSphere.Center()[2] = g_characterLODs[i + 1].m_boundingSphere[2];
|
|
|
|
childBoundingSphere.Radius() = g_characterLODs[i + 1].m_boundingSphere[3];
|
|
|
|
childROI->SetBoundingSphere(childBoundingSphere);
|
|
|
|
|
|
|
|
BoundingBox childBoundingBox;
|
|
|
|
childBoundingBox.Min()[0] = g_characterLODs[i + 1].m_boundingBox[0];
|
|
|
|
childBoundingBox.Min()[1] = g_characterLODs[i + 1].m_boundingBox[1];
|
|
|
|
childBoundingBox.Min()[2] = g_characterLODs[i + 1].m_boundingBox[2];
|
|
|
|
childBoundingBox.Max()[0] = g_characterLODs[i + 1].m_boundingBox[3];
|
|
|
|
childBoundingBox.Max()[1] = g_characterLODs[i + 1].m_boundingBox[4];
|
|
|
|
childBoundingBox.Max()[2] = g_characterLODs[i + 1].m_boundingBox[5];
|
|
|
|
childROI->SetUnknown0x80(childBoundingBox);
|
|
|
|
|
|
|
|
CalcLocalTransform(
|
|
|
|
Mx3DPointFloat(g_characterLODs[i + 1].m_position),
|
|
|
|
Mx3DPointFloat(g_characterLODs[i + 1].m_direction),
|
|
|
|
Mx3DPointFloat(g_characterLODs[i + 1].m_up),
|
|
|
|
mat
|
|
|
|
);
|
|
|
|
childROI->WrappedSetLocalTransform(mat);
|
|
|
|
|
|
|
|
if (g_characterLODs[i + 1].m_flags & LegoCharacterLOD::c_flag1 &&
|
|
|
|
(i != 0 || part.m_unk0x00[part.m_unk0x08] != 0)) {
|
|
|
|
|
|
|
|
LegoTextureInfo* textureInfo = textureContainer->Get(part.m_unk0x10[part.m_unk0x0c[part.m_unk0x14]]);
|
|
|
|
|
|
|
|
if (textureInfo != NULL) {
|
|
|
|
childROI->FUN_100a9210(textureInfo);
|
|
|
|
childROI->FUN_100a9170(1.0F, 1.0F, 1.0F, 0.0F);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (g_characterLODs[i + 1].m_flags & LegoCharacterLOD::c_flag2 || (i == 0 && part.m_unk0x00[part.m_unk0x08] == 0)) {
|
|
|
|
LegoFloat red, green, blue, alpha;
|
|
|
|
childROI->FUN_100a9bf0(part.m_unk0x10[part.m_unk0x0c[part.m_unk0x14]], red, green, blue, alpha);
|
|
|
|
childROI->FUN_100a9170(red, green, blue, alpha);
|
|
|
|
}
|
|
|
|
|
|
|
|
comp->push_back(childROI);
|
|
|
|
}
|
|
|
|
|
|
|
|
CalcLocalTransform(
|
2024-04-28 08:49:07 -04:00
|
|
|
Mx3DPointFloat(g_characterLODs[c_topLOD].m_position),
|
|
|
|
Mx3DPointFloat(g_characterLODs[c_topLOD].m_direction),
|
|
|
|
Mx3DPointFloat(g_characterLODs[c_topLOD].m_up),
|
2024-03-22 13:40:19 -04:00
|
|
|
mat
|
|
|
|
);
|
|
|
|
roi->WrappedSetLocalTransform(mat);
|
|
|
|
|
2024-04-28 09:04:27 -04:00
|
|
|
info->m_roi = roi;
|
2024-03-22 13:40:19 -04:00
|
|
|
success = TRUE;
|
|
|
|
|
|
|
|
done:
|
|
|
|
if (!success && roi != NULL) {
|
|
|
|
delete roi;
|
|
|
|
roi = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return roi;
|
2024-03-19 14:23:34 -04:00
|
|
|
}
|
|
|
|
|
2024-04-17 07:52:59 -04:00
|
|
|
// FUNCTION: LEGO1 0x100849a0
|
|
|
|
// FUNCTION: BETA10 0x10075b51
|
|
|
|
MxBool LegoCharacterManager::FUN_100849a0(LegoROI* p_roi, LegoTextureInfo* p_textureInfo)
|
2024-04-16 10:07:13 -04:00
|
|
|
{
|
2024-04-17 07:52:59 -04:00
|
|
|
LegoResult result = SUCCESS;
|
2024-04-28 08:49:07 -04:00
|
|
|
LegoROI* head = FindChildROI(p_roi, g_characterLODs[c_headLOD].m_name);
|
2024-04-17 07:52:59 -04:00
|
|
|
|
|
|
|
if (head != NULL) {
|
|
|
|
char lodName[256];
|
|
|
|
|
2024-04-28 08:49:07 -04:00
|
|
|
ViewLODList* lodList = GetViewLODListManager()->Lookup(g_characterLODs[c_headLOD].m_parentName);
|
2024-04-17 07:52:59 -04:00
|
|
|
MxS32 lodSize = lodList->Size();
|
|
|
|
sprintf(lodName, "%s%s%d", p_roi->GetName(), "head", g_unk0x100fc4e8++);
|
|
|
|
ViewLODList* dupLodList = GetViewLODListManager()->Create(lodName, lodSize);
|
|
|
|
|
|
|
|
Tgl::Renderer* renderer = VideoManager()->GetRenderer();
|
|
|
|
|
|
|
|
if (p_textureInfo == NULL) {
|
2024-04-28 09:04:27 -04:00
|
|
|
LegoCharacterInfo* info = GetInfo(p_roi->GetName());
|
|
|
|
LegoCharacterInfo::Part& part = info->m_parts[c_headPart];
|
2024-04-17 07:52:59 -04:00
|
|
|
p_textureInfo = TextureContainer()->Get(part.m_unk0x10[part.m_unk0x0c[part.m_unk0x14]]);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (MxS32 i = 0; i < lodSize; i++) {
|
|
|
|
LegoLOD* lod = (LegoLOD*) (*lodList)[i];
|
|
|
|
LegoLOD* clone = lod->Clone(renderer);
|
|
|
|
|
|
|
|
if (p_textureInfo != NULL) {
|
|
|
|
clone->FUN_100aad70(p_textureInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
dupLodList->PushBack(clone);
|
|
|
|
}
|
|
|
|
|
|
|
|
lodList->Release();
|
|
|
|
lodList = dupLodList;
|
|
|
|
|
|
|
|
if (head->GetUnknown0xe0() >= 0) {
|
|
|
|
VideoManager()->Get3DManager()->GetLego3DView()->GetViewManager()->FUN_100a66a0(head);
|
|
|
|
}
|
|
|
|
|
|
|
|
head->SetLODList(lodList);
|
|
|
|
lodList->Release();
|
|
|
|
}
|
|
|
|
|
|
|
|
return head != NULL;
|
2024-04-16 10:07:13 -04:00
|
|
|
}
|
|
|
|
|
2024-03-29 13:30:46 -04:00
|
|
|
// FUNCTION: LEGO1 0x10084c00
|
|
|
|
MxBool LegoCharacterManager::Exists(const char* p_key)
|
2024-02-27 10:13:00 -05:00
|
|
|
{
|
2024-05-06 07:15:19 -04:00
|
|
|
for (MxU32 i = 0; i < _countof(g_characterInfo); i++) {
|
|
|
|
if (!strcmpi(g_characterInfo[i].m_name, p_key)) {
|
2024-03-29 13:30:46 -04:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-27 10:13:00 -05:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2024-03-29 13:30:46 -04:00
|
|
|
// FUNCTION: LEGO1 0x10084c40
|
|
|
|
LegoExtraActor* LegoCharacterManager::GetActor(const char* p_key)
|
2024-03-23 10:09:20 -04:00
|
|
|
{
|
2024-04-28 09:04:27 -04:00
|
|
|
LegoCharacterInfo* info = GetInfo(p_key);
|
2024-03-29 13:30:46 -04:00
|
|
|
|
2024-04-28 09:04:27 -04:00
|
|
|
if (info != NULL) {
|
|
|
|
return info->m_actor;
|
2024-03-29 13:30:46 -04:00
|
|
|
}
|
|
|
|
|
2024-03-23 10:09:20 -04:00
|
|
|
return NULL;
|
|
|
|
}
|
2024-03-23 13:06:31 -04:00
|
|
|
|
2024-03-22 13:40:19 -04:00
|
|
|
// FUNCTION: LEGO1 0x10084c60
|
2024-04-28 09:04:27 -04:00
|
|
|
LegoCharacterInfo* LegoCharacterManager::GetInfo(const char* p_key)
|
2024-03-19 14:23:34 -04:00
|
|
|
{
|
2024-03-22 13:40:19 -04:00
|
|
|
MxU32 i;
|
|
|
|
|
2024-05-06 07:15:19 -04:00
|
|
|
for (i = 0; i < _countof(g_characterInfo); i++) {
|
|
|
|
if (!strcmpi(g_characterInfo[i].m_name, p_key)) {
|
2024-03-22 13:40:19 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-06 07:15:19 -04:00
|
|
|
if (i < _countof(g_characterInfo)) {
|
|
|
|
return &g_characterInfo[i];
|
2024-03-22 13:40:19 -04:00
|
|
|
}
|
|
|
|
|
2024-03-19 14:23:34 -04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2024-03-29 14:34:50 -04:00
|
|
|
// FUNCTION: LEGO1 0x10084cb0
|
2024-04-28 09:04:27 -04:00
|
|
|
LegoCharacterInfo* LegoCharacterManager::GetInfo(LegoROI* p_roi)
|
2024-03-29 14:34:50 -04:00
|
|
|
{
|
|
|
|
MxU32 i;
|
|
|
|
|
2024-05-06 07:15:19 -04:00
|
|
|
for (i = 0; i < _countof(g_characterInfo); i++) {
|
|
|
|
if (g_characterInfo[i].m_roi == p_roi) {
|
2024-03-29 14:34:50 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-06 07:15:19 -04:00
|
|
|
if (i < _countof(g_characterInfo)) {
|
|
|
|
return &g_characterInfo[i];
|
2024-03-29 14:34:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2024-04-06 08:08:38 -04:00
|
|
|
// FUNCTION: LEGO1 0x10084cf0
|
2024-04-17 07:52:59 -04:00
|
|
|
// FUNCTION: BETA10 0x10075fe2
|
|
|
|
LegoROI* LegoCharacterManager::FindChildROI(LegoROI* p_roi, const char* p_name)
|
2024-03-15 22:20:44 -04:00
|
|
|
{
|
2024-04-06 08:08:38 -04:00
|
|
|
const CompoundObject* comp = p_roi->GetComp();
|
|
|
|
|
|
|
|
#ifdef COMPAT_MODE
|
|
|
|
for (CompoundObject::const_iterator it = comp->begin(); !(it == comp->end()); it++) {
|
|
|
|
#else
|
|
|
|
for (CompoundObject::iterator it = comp->begin(); !(it == comp->end()); it++) {
|
|
|
|
#endif
|
|
|
|
LegoROI* roi = (LegoROI*) *it;
|
|
|
|
|
|
|
|
if (!strcmpi(p_name, roi->GetName())) {
|
|
|
|
return roi;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-05 09:57:20 -04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x10084ec0
|
2024-04-21 10:41:38 -04:00
|
|
|
MxBool LegoCharacterManager::SwitchHat(LegoROI* p_roi)
|
2024-04-05 09:57:20 -04:00
|
|
|
{
|
2024-04-28 09:04:27 -04:00
|
|
|
LegoCharacterInfo* info = GetInfo(p_roi->GetName());
|
2024-04-05 09:57:20 -04:00
|
|
|
|
2024-04-28 09:04:27 -04:00
|
|
|
if (info == NULL) {
|
2024-04-05 09:57:20 -04:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2024-04-28 09:04:27 -04:00
|
|
|
LegoCharacterInfo::Part& part = info->m_parts[c_infohatPart];
|
2024-04-05 09:57:20 -04:00
|
|
|
|
|
|
|
part.m_unk0x08++;
|
|
|
|
MxU8 unk0x00 = part.m_unk0x00[part.m_unk0x08];
|
|
|
|
|
|
|
|
if (unk0x00 == 0xff) {
|
|
|
|
part.m_unk0x08 = 0;
|
|
|
|
unk0x00 = part.m_unk0x00[part.m_unk0x08];
|
|
|
|
}
|
|
|
|
|
2024-04-28 08:49:07 -04:00
|
|
|
LegoROI* childROI = FindChildROI(p_roi, g_characterLODs[c_infohatLOD].m_name);
|
2024-04-05 09:57:20 -04:00
|
|
|
|
|
|
|
if (childROI != NULL) {
|
|
|
|
char lodName[256];
|
|
|
|
|
|
|
|
ViewLODList* lodList = GetViewLODListManager()->Lookup(part.m_unk0x04[unk0x00]);
|
|
|
|
MxS32 lodSize = lodList->Size();
|
|
|
|
sprintf(lodName, "%s%d", p_roi->GetName(), g_unk0x100fc4ec++);
|
|
|
|
ViewLODList* dupLodList = GetViewLODListManager()->Create(lodName, lodSize);
|
|
|
|
|
|
|
|
Tgl::Renderer* renderer = VideoManager()->GetRenderer();
|
|
|
|
LegoFloat red, green, blue, alpha;
|
|
|
|
LegoROI::FUN_100a9bf0(part.m_unk0x10[part.m_unk0x0c[part.m_unk0x14]], red, green, blue, alpha);
|
|
|
|
|
|
|
|
for (MxS32 i = 0; i < lodSize; i++) {
|
|
|
|
LegoLOD* lod = (LegoLOD*) (*lodList)[i];
|
|
|
|
LegoLOD* clone = lod->Clone(renderer);
|
|
|
|
clone->FUN_100aacb0(red, green, blue, alpha);
|
|
|
|
dupLodList->PushBack(clone);
|
|
|
|
}
|
|
|
|
|
|
|
|
lodList->Release();
|
|
|
|
lodList = dupLodList;
|
|
|
|
|
|
|
|
if (childROI->GetUnknown0xe0() >= 0) {
|
|
|
|
VideoManager()->Get3DManager()->GetLego3DView()->GetViewManager()->FUN_100a66a0(childROI);
|
|
|
|
}
|
|
|
|
|
|
|
|
childROI->SetLODList(lodList);
|
|
|
|
lodList->Release();
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
2024-03-15 22:20:44 -04:00
|
|
|
}
|
|
|
|
|
2024-03-29 14:34:50 -04:00
|
|
|
// FUNCTION: LEGO1 0x10085140
|
|
|
|
MxU32 LegoCharacterManager::FUN_10085140(LegoROI* p_roi, MxBool p_und)
|
2024-03-06 14:12:20 -05:00
|
|
|
{
|
2024-04-28 09:04:27 -04:00
|
|
|
LegoCharacterInfo* info = GetInfo(p_roi);
|
2024-03-29 14:34:50 -04:00
|
|
|
|
|
|
|
if (p_und) {
|
2024-04-28 09:04:27 -04:00
|
|
|
return info->m_unk0x14 + g_unk0x100fc4dc;
|
2024-03-29 14:34:50 -04:00
|
|
|
}
|
|
|
|
|
2024-04-28 09:04:27 -04:00
|
|
|
if (info != NULL) {
|
|
|
|
return info->m_unk0x0c + g_unk0x100fc4d8;
|
2024-03-29 14:34:50 -04:00
|
|
|
}
|
|
|
|
|
2024-03-06 14:12:20 -05:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2024-05-11 08:13:27 -04:00
|
|
|
// FUNCTION: LEGO1 0x10085180
|
2024-05-10 14:07:38 -04:00
|
|
|
// FUNCTION: BETA10 0x100768c5
|
|
|
|
MxU8 LegoCharacterManager::FUN_10085180(LegoROI* p_roi)
|
|
|
|
{
|
2024-05-11 08:13:27 -04:00
|
|
|
LegoCharacterInfo* info = GetInfo(p_roi);
|
|
|
|
|
|
|
|
if (info != NULL) {
|
|
|
|
return info->m_unk0x14;
|
|
|
|
}
|
|
|
|
|
2024-05-10 14:07:38 -04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2024-02-21 15:30:02 -05:00
|
|
|
// FUNCTION: LEGO1 0x100851a0
|
2024-03-09 15:07:52 -05:00
|
|
|
void LegoCharacterManager::SetCustomizeAnimFile(const char* p_value)
|
2024-02-21 15:30:02 -05:00
|
|
|
{
|
|
|
|
if (g_customizeAnimFile != NULL) {
|
|
|
|
delete[] g_customizeAnimFile;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_value != NULL) {
|
|
|
|
g_customizeAnimFile = new char[strlen(p_value) + 1];
|
|
|
|
|
|
|
|
if (g_customizeAnimFile != NULL) {
|
|
|
|
strcpy(g_customizeAnimFile, p_value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
g_customizeAnimFile = NULL;
|
|
|
|
}
|
|
|
|
}
|
2024-02-25 12:04:30 -05:00
|
|
|
|
2024-03-31 10:05:38 -04:00
|
|
|
// FUNCTION: LEGO1 0x10085210
|
|
|
|
LegoROI* LegoCharacterManager::FUN_10085210(const char* p_name, const char* p_lodName, MxBool p_createEntity)
|
2024-02-25 12:04:30 -05:00
|
|
|
{
|
2024-03-31 10:05:38 -04:00
|
|
|
LegoROI* roi = NULL;
|
|
|
|
|
|
|
|
MxMatrix mat;
|
|
|
|
Tgl::Renderer* renderer = VideoManager()->GetRenderer();
|
|
|
|
ViewLODListManager* lodManager = GetViewLODListManager();
|
|
|
|
LegoTextureContainer* textureContainer = TextureContainer();
|
|
|
|
ViewLODList* lodList = lodManager->Lookup(p_lodName);
|
|
|
|
|
|
|
|
if (lodList == NULL || lodList->Size() == 0) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
roi = new LegoROI(renderer, lodList);
|
|
|
|
|
|
|
|
const char* name;
|
|
|
|
char buf[20];
|
|
|
|
|
|
|
|
if (p_name != NULL) {
|
|
|
|
name = p_name;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
sprintf(buf, "autoROI_%d", g_unk0x100fc4f0++);
|
|
|
|
name = buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
roi->SetName(name);
|
|
|
|
lodList->Release();
|
|
|
|
|
|
|
|
if (roi != NULL && FUN_10085870(roi) != SUCCESS) {
|
|
|
|
delete roi;
|
|
|
|
roi = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (roi != NULL) {
|
|
|
|
roi->SetVisibility(FALSE);
|
|
|
|
|
|
|
|
LegoCharacter* character = new LegoCharacter(roi);
|
|
|
|
char* key = new char[strlen(name) + 1];
|
|
|
|
|
|
|
|
if (key != NULL) {
|
|
|
|
strcpy(key, name);
|
|
|
|
(*m_characters)[key] = character;
|
|
|
|
VideoManager()->Get3DManager()->Add(*roi);
|
|
|
|
|
|
|
|
if (p_createEntity && roi->GetEntity() == NULL) {
|
|
|
|
LegoEntity* entity = new LegoEntity();
|
|
|
|
|
|
|
|
entity->SetROI(roi, FALSE, FALSE);
|
2024-04-26 10:03:13 -04:00
|
|
|
entity->SetType(LegoEntity::e_unk4);
|
2024-03-31 10:05:38 -04:00
|
|
|
entity->SetFlag(LegoActor::c_bit2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return roi;
|
|
|
|
}
|
|
|
|
|
2024-04-02 08:04:17 -04:00
|
|
|
// FUNCTION: LEGO1 0x10085870
|
2024-03-31 10:05:38 -04:00
|
|
|
MxResult LegoCharacterManager::FUN_10085870(LegoROI* p_roi)
|
|
|
|
{
|
2024-04-02 08:04:17 -04:00
|
|
|
MxResult result = FAILURE;
|
|
|
|
|
|
|
|
BoundingSphere boundingSphere;
|
|
|
|
BoundingBox boundingBox;
|
|
|
|
|
|
|
|
const Tgl::MeshBuilder* meshBuilder = ((ViewLOD*) p_roi->GetLOD(0))->GetMeshBuilder();
|
|
|
|
|
|
|
|
if (meshBuilder != NULL) {
|
|
|
|
float min[3], max[3];
|
|
|
|
|
|
|
|
FILLVEC3(min, 88888.0);
|
|
|
|
FILLVEC3(max, -88888.0);
|
|
|
|
meshBuilder->GetBoundingBox(min, max);
|
|
|
|
|
|
|
|
float center[3];
|
|
|
|
center[0] = (min[0] + max[0]) / 2.0f;
|
|
|
|
center[1] = (min[1] + max[1]) / 2.0f;
|
|
|
|
center[2] = (min[2] + max[2]) / 2.0f;
|
|
|
|
SET3(boundingSphere.Center(), center);
|
|
|
|
|
|
|
|
float radius[3];
|
|
|
|
VMV3(radius, max, min);
|
|
|
|
boundingSphere.Radius() = sqrt(NORMSQRD3(radius)) / 2.0;
|
|
|
|
|
|
|
|
p_roi->SetBoundingSphere(boundingSphere);
|
|
|
|
|
|
|
|
SET3(boundingBox.Min(), min);
|
|
|
|
SET3(boundingBox.Max(), max);
|
|
|
|
|
|
|
|
p_roi->SetUnknown0x80(boundingBox);
|
|
|
|
|
|
|
|
p_roi->VTable0x14();
|
|
|
|
|
|
|
|
result = SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
2024-02-25 12:04:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x10085a80
|
2024-03-31 10:05:38 -04:00
|
|
|
LegoROI* LegoCharacterManager::FUN_10085a80(const char* p_name, const char* p_lodName, MxBool p_createEntity)
|
2024-02-25 12:04:30 -05:00
|
|
|
{
|
2024-03-31 10:05:38 -04:00
|
|
|
return FUN_10085210(p_name, p_lodName, p_createEntity);
|
2024-02-25 12:04:30 -05:00
|
|
|
}
|