73 LegoCharacterMap::iterator it;
75 for (it = m_characters->begin(); it != m_characters->end(); it++) {
76 character = (*it).second;
78 RemoveROI(character->
m_roi);
85 delete[] g_customizeAnimFile;
105 if (actor !=
NULL && actor->
IsA(
"LegoExtraActor")) {
109 while (refCount != 0) {
143 if (p_storage->
Write(
252 LegoCharacterMap::const_iterator it = m_characters->find(
const_cast<char*
>(p_name));
254 if (!(it == m_characters->end())) {
255 character = (*it).second;
259 if (character ==
NULL) {
260 LegoROI* roi = CreateActorROI(p_name);
266 char* name =
new char[strlen(p_name) + 1];
269 strcpy(name, p_name);
270 (*m_characters)[name] = character;
280 if (character !=
NULL) {
290 return character->
m_roi;
301 LegoCharacterMap::iterator it = m_characters->find(
const_cast<char*
>(p_name));
303 if (it != m_characters->end()) {
313 LegoCharacterMap::iterator it;
315 for (it = m_characters->begin(); it != m_characters->end(); it++) {
332 LegoCharacterMap::iterator it = m_characters->find(
const_cast<char*
>(p_name));
334 if (it != m_characters->end()) {
335 character = (*it).second;
341 if (entity !=
NULL) {
345 RemoveROI(character->
m_roi);
347 delete[] (*it).first;
350 m_characters->erase(it);
373 LegoCharacterMap::iterator it;
375 for (it = m_characters->begin(); it != m_characters->end(); it++) {
376 character = (*it).second;
378 if (character->
m_roi == p_roi) {
383 if (entity !=
NULL) {
387 RemoveROI(character->
m_roi);
389 delete[] (*it).first;
392 m_characters->erase(it);
418 LegoCharacterMap::iterator it;
420 for (it = m_characters->begin(); it != m_characters->end(); it++) {
421 character = (*it).second;
423 if (character->
m_roi == p_roi) {
427 if (entity !=
NULL) {
431 RemoveROI(character->
m_roi);
433 delete[] (*it).first;
436 m_characters->erase(it);
451void LegoCharacterManager::RemoveROI(
LegoROI* p_roi)
458LegoROI* LegoCharacterManager::CreateActorROI(
const char* p_key)
477 if (!strcmpi(p_key,
"pep")) {
513 const char* parentName;
514 if (i == 0 || i == 1) {
523 sprintf(lodName,
"%s%d", p_key, i);
526 for (
MxS32 j = 0; j < lodSize; j++) {
533 lodList = dupLodList;
569 if (textureInfo !=
NULL) {
580 comp->push_back(childROI);
595 if (!success && roi !=
NULL) {
623 if (p_texture ==
NULL) {
632 for (
MxS32 i = 0; i < lodSize; i++) {
636 if (p_texture !=
NULL) {
644 lodList = dupLodList;
723LegoROI* LegoCharacterManager::FindChildROI(
LegoROI* p_roi,
const char* p_name)
726 CompoundObject::const_iterator it;
728 CompoundObject::iterator it;
733 for (it = comp->begin(); it != comp->end(); it++) {
736 if (!strcmpi(p_name, roi->
GetName())) {
749 const char* targetName = p_targetROI->
GetName();
752 for (partIndex = 0; partIndex < numParts; partIndex++) {
753 if (!strcmp(targetName,
g_actorLODs[partIndex + 1].m_name)) {
758 assert(partIndex < numParts);
761 if (partIndex == 6) {
764 else if (partIndex == 7) {
767 else if (partIndex == 3) {
770 else if (partIndex == 0) {
788 p_targetROI = FindChildROI(p_roi,
g_actorLODs[partIndex + 1].m_name);
818 if (unk0x00 == 0xff) {
825 if (childROI !=
NULL) {
837 for (
MxS32 i = 0; i < lodSize; i++) {
840 clone->
SetColor(red, green, blue, alpha);
845 lodList = dupLodList;
868 if (info->
m_sound >= g_maxSound) {
888 if (info->
m_move >= g_maxMove) {
967 if (g_customizeAnimFile !=
NULL) {
968 delete[] g_customizeAnimFile;
971 if (p_value !=
NULL) {
972 g_customizeAnimFile =
new char[strlen(p_value) + 1];
974 if (g_customizeAnimFile !=
NULL) {
975 strcpy(g_customizeAnimFile, p_value);
979 g_customizeAnimFile =
NULL;
995 if (lodList ==
NULL || lodList->
Size() == 0) {
999 roi =
new LegoROI(renderer, lodList);
1004 if (p_name !=
NULL) {
1024 char* key =
new char[strlen(name) + 1];
1028 (*m_characters)[key] = character;
1054 if (meshBuilder !=
NULL) {
1055 float min[3], max[3];
1062 center[0] = (min[0] + max[0]) / 2.0f;
1063 center[1] = (min[1] + max[1]) / 2.0f;
1064 center[2] = (min[2] + max[2]) / 2.0f;
1068 VMV3(radius, max, min);
1103 if (strcmp(
m_key.
GetData(),
"CUSTOMIZE_ANIM_FILE") == 0) {
[AI] Represents an axis-aligned bounding box in 3D space, using minimum and maximum points.
const Vector3 & Min() const
[AI] Const accessor for the minimum corner of the bounding box.
const Vector3 & Max() const
[AI] Const accessor for the maximum corner of the bounding box.
[AI] Represents a bounding sphere in 3D space with center and radius.
const float & Radius() const
[AI] Const accessor for the sphere radius.
const Vector3 & Center() const
[AI] Const accessor for the center of the sphere.
[AI] MxVariable subclass used to represent and propagate changes to the character customization anima...
CustomizeAnimFileVariable(const char *p_key)
[AI] Constructs the variable and sets its key (converted to uppercase).
void SetValue(const char *p_value) override
[AI] Sets the variable value and propagates customization file changes to relevant managers.
size_t Size() const
[AI] Returns the current number of LODObject pointers contained.
const T * PushBack(const T *)
[AI] Typed append.
BOOL Add(ViewROI &rROI)
[AI] Adds a ViewROI (rendered object) to the scene.
Lego3DView * GetLego3DView()
[AI] Returns the encapsulated Lego3DView instance.
BOOL Remove(ViewROI &rROI)
[AI] Removes a ViewROI from the scene.
ViewManager * GetViewManager()
[AI] Returns the ViewManager responsible for managing scene objects and transformations.
void SetROI(LegoROI *p_roi, MxBool p_bool1, MxBool p_bool2) override
[AI] Sets the Region of Interest (ROI, i.e.
static void SetCustomizeAnimFile(const char *p_value)
[AI] Sets the global filename for a custom "customize animation" SMK/FLC file.
[AI] Manages reference-counted characters and provides character creation, switching,...
MxBool SwitchMood(LegoROI *p_roi)
[AI] Cycles the mood type for the actor, updating the per-actor info.
LegoActorInfo * GetActorInfo(const char *p_name)
[AI] Returns the actor info struct for the character of the given name, or NULL if not found.
MxResult Write(LegoStorage *p_storage)
[AI] Writes the persistent character info data to a storage object.
void ReleaseAllActors()
[AI] Releases all actors associated with this manager, unregistering/releasing references until destr...
MxU32 GetNumActors()
[AI] Returns the number of actors registered in global g_actorInfo.
void Init()
[AI] Initializes all actor info structures based on their templates/defaults.
LegoExtraActor * GetExtraActor(const char *p_name)
[AI] Returns an extra actor associated with a given character name, or NULL if not found.
MxU32 GetSoundId(LegoROI *p_roi, MxBool p_und)
[AI] Returns the sound ID for the ROI's current sound/mood selection.
MxResult Read(LegoStorage *p_storage)
[AI] Reads character info data from a storage object.
LegoROI * CreateAutoROI(const char *p_name, const char *p_lodName, MxBool p_createEntity)
[AI] Creates an "auto" ROI object with the given name, LOD name, and optional entity creation.
static void SetCustomizeAnimFile(const char *p_value)
[AI] Sets the value of the customization animation file variable, propagating to all relevant subsyst...
MxU8 GetMood(LegoROI *p_roi)
[AI] Returns the current mood value (0-3) for the actor associated with the ROI.
MxResult FUN_10085870(LegoROI *p_roi)
[AI] Initializes auto-ROI with bounding volume and transformation.
MxU32 GetRefCount(LegoROI *p_roi)
[AI] Returns the reference count for a given LegoROI* tracked by the manager.
static MxBool IsActor(const char *p_name)
[AI] Checks if the given name matches an actor in the global actor table (case-insensitive).
~LegoCharacterManager()
[AI] Destroys the manager, cleaning up all managed characters and animation customization state.
void ReleaseActor(const char *p_name)
[AI] Releases a character/ROI by name, decrementing its reference count and deleting if zero.
LegoROI * GetActorROI(const char *p_name, MxBool p_createEntity)
[AI] Returns a LegoROI for the given character name, creating and registering the actor if necessary.
MxBool SwitchColor(LegoROI *p_roi, LegoROI *p_targetROI)
[AI] Changes the color of a part of a character's ROI, updating its part info index and updating ROI ...
MxBool SwitchSound(LegoROI *p_roi)
[AI] Cycles the sound type for the actor, updating the per-actor info.
MxBool FUN_100849a0(LegoROI *p_roi, LegoTextureInfo *p_texture)
[AI] Replaces the head LOD of a character ROI with a new LOD list built using the provided texture.
MxBool SwitchVariant(LegoROI *p_roi)
[AI] Cycles through part variants (e.g.
void ReleaseAutoROI(LegoROI *p_roi)
[AI] Releases an "auto" ROI, used for dynamically created ROI objects by this manager.
MxBool Exists(const char *p_name)
[AI] Returns whether a character with the given name exists in the manager.
LegoROI * FUN_10085a80(const char *p_name, const char *p_lodName, MxBool p_createEntity)
[AI] Helper function that delegates to CreateAutoROI.
MxBool SwitchMove(LegoROI *p_roi)
[AI] Cycles the move type for the actor, updating the per-actor info.
const char * GetActorName(MxS32 p_index)
[AI] Returns the actor name for the given actor index (lookup in global g_actorInfo table).
MxU32 GetAnimationId(LegoROI *p_roi)
[AI] Returns an animation ID corresponding to the ROI's move index.
T * Get(const char *p_name)
Retrieve the element mapped to the given name, or nullptr if missing.
[AI] Represents an entity that can be placed and managed in the LEGO Island world.
void SetFlag(MxU8 p_flag)
[AI] Sets the given flag in the flags byte.
virtual void SetROI(LegoROI *p_roi, MxBool p_bool1, MxBool p_bool2)
[AI] Assigns a 3D ROI (3D object instance) to this entity, controlling how it appears/acts in the wor...
MxBool GetFlagsIsSet(MxU8 p_flag)
[AI] Checks if a flag is set in the primary flags byte (m_flags).
void ClearFlag(MxU8 p_flag)
[AI] Clears the given flag in the flags byte.
void SetType(MxU8 p_type)
[AI] Sets the entity's type (actor/plant/building/etc.) [AI]
@ e_autoROI
[AI] Catchall for ROI-adapted/unknown entities [AI]
@ e_actor
[AI] Standard character entity controlled by scripts or user [AI]
@ c_managerOwned
[AI] Indicates this entity is managed/owned by an entity manager [AI]
[AI] Level-Of-Detail (LOD) object used for rendering and managing polygonal mesh data with LOD switch...
LegoResult FUN_100aad70(LegoTextureInfo *p_textureInfo)
[AI] Assigns the group texture to all textured meshes, but does NOT override mesh color.
LegoLOD * Clone(Tgl::Renderer *p_renderer)
[AI] Create an exact copy of this LOD, including cloned meshes, for another (or the same) renderer.
LegoResult SetColor(LegoFloat p_red, LegoFloat p_green, LegoFloat p_blue, LegoFloat p_alpha)
[AI] Overrides the color of all non-textured mesh parts for this LOD.
static void SetCustomizeAnimFile(const char *p_value)
[AI] Sets the global file path or name to use for plant customization animations.
[AI] Represents a Real-time Object Instance enriched with LEGO-specific functionality.
void SetUnknown0x80(const BoundingBox &p_unk0x80)
[AI] Sets the local bounding box from read data.
void SetBoundingSphere(const BoundingSphere &p_sphere)
[AI] Sets the local and world bounding spheres.
LegoResult SetTextureInfo(LegoTextureInfo *p_textureInfo)
[AI] Associates every LOD in this ROI (and sub-ROIs) with a given texture (palette/material informati...
LegoResult SetLodColor(LegoFloat p_red, LegoFloat p_green, LegoFloat p_blue, LegoFloat p_alpha)
[AI] Sets the RGBA color for all LODs and recursively for all children.
void SetComp(CompoundObject *p_comp)
[AI] Attaches a new CompoundObject pointer (container for child ROIs).
const LegoChar * GetName() const
[AI] Gets this ROI's name.
LegoEntity * GetEntity()
[AI] Gets the entity associated with this ROI (or NULL).
void SetName(const LegoChar *p_name)
[AI] Sets this ROI's name, replacing the previous (converted to lower-case).
static LegoBool GetRGBAColor(const LegoChar *p_name, float &p_red, float &p_green, float &p_blue, float &p_alpha)
[AI] [Static] Resolves a logical color alias into RGBA floats.
Abstract base class providing an interface for file-like storage with binary and text read/write oper...
virtual LegoResult Write(const void *p_buffer, LegoU32 p_size)=0
Write bytes from buffer into storage.
virtual LegoResult Read(void *p_buffer, LegoU32 p_size)=0
Read bytes from storage into buffer.
Specialized LegoContainer handling LegoTextureInfo objects and their DirectDraw/Direct3D caching.
[AI] Contains DirectDraw and Direct3DRM handles and metadata for a texture used in the LEGO Island re...
Lego3DManager * Get3DManager()
[AI] Returns the Lego3DManager for this manager, which owns all 3D scene representations and view con...
Tgl::Renderer * GetRenderer()
[AI] Returns the underlying renderer for this manager; normally a Direct3D Retained Mode wrapper.
[AI] Represents a 3D point with floating-point precision, inheriting from Vector3.
[AI] Represents a 4x4 transformation matrix, specialized for the LEGO Island engine and derived from ...
char * GetData() const
Returns a pointer to the internal character buffer.
void ToUpperCase()
Converts the string contents to uppercase in-place.
void SetVariable(const char *p_key, const char *p_value)
Sets a variable by key and value, replacing or updating if it exists.
MxString m_key
[AI] The variable's key (name), always stored in uppercase.
void WrappedSetLocalTransform(const Matrix4 &p_transform)
Wraps SetLocalTransform, for possible override or interface uniformity.
virtual void VTable0x14()
[AI] Calls VTable0x1c().
void SetParentROI(OrientableROI *p_parentROI)
Sets the parent ROI used for transformation hierarchy.
void SetVisibility(unsigned char p_visible)
[AI] Sets the visibility flag to the provided value.
const CompoundObject * GetComp() const
[AI] Returns the pointer to the compound object structure, or NULL if not present.
const LODObject * GetLOD(int i) const
[AI] Returns the LODObject at the specified index.
[AI] Builder class for assembling mesh data and extracting mesh objects.
virtual Result GetBoundingBox(float min[3], float max[3]) const =0
[AI] Gets the bounding box for the constructed mesh geometry.
[AI] Main interface/factory for rendering resources and scene graphs.
[AI] Manages the lifecycle, lookup, and sharing of ViewLODList instances for different ROI names.
ViewLODList * Create(const ROIName &rROIName, int lodCount)
[AI] Creates and registers a new ViewLODList for a named ROI, with space for the specified number of ...
ViewLODList * Lookup(const ROIName &) const
[AI] Looks up an existing ViewLODList by ROI name, incrementing its reference count.
[AI] Reference-counted list of Level-of-Detail (LOD) objects associated with a single ROI (Realtime O...
int Release()
[AI] Decrements the reference count.
[AI] Represents a Level of Detail (LOD) object for rendering, implemented with a mesh builder and sup...
void RemoveROIDetailFromScene(ViewROI *p_roi)
[AI] Removes the currently active LOD detail from the rendering scene for the given ROI and detaches ...
int GetUnknown0xe0()
[AI] Gets the value of an internal state field at offset 0xe0.
void SetLODList(ViewLODList *lodList)
[AI] Sets the ViewLODList for this ROI, managing reference counting.
#define DECOMP_SIZE_ASSERT(T, S)
@ c_armrtPart
[AI] Right arm. [AI]
@ c_leglftPart
[AI] Left leg. [AI]
@ c_infohatPart
[AI] Info hat or top accessory slot. [AI]
@ c_legrtPart
[AI] Right leg. [AI]
@ c_infogronPart
[AI] Info/torso accent part. [AI]
@ c_armlftPart
[AI] Left arm. [AI]
@ c_headPart
[AI] Head slot. [AI]
LegoActorInfo g_actorInfoInit[66]
[AI] Global initialization table for the 66 actor types in the game, each entry describing all key as...
@ c_infohatLOD
[AI] Information hat or top-accessory. [AI]
@ c_topLOD
[AI] Top/root of the actor LOD hierarchy (usually main body root). [AI]
LegoActorLOD g_actorLODs[11]
[AI] Array of 11 LOD definitions which describe the conventions for actor part hierarchy and bounding...
MxU32 g_characterAnimationId
LegoActorInfo g_actorInfo[66]
map< char *, LegoCharacter *, LegoCharacterComparator > LegoCharacterMap
[AI] Map from character name strings to LegoCharacter pointers.
#define NULL
[AI] Null pointer value (C/C++ semantics).
#define FAILURE
[AI] Used to indicate a failed operation in result codes.
LegoS32 LegoResult
[AI] Function result type (return code): typically SUCCESS (0) or FAILURE (-1).
#define SUCCESS
[AI] Used to indicate a successful operation in result codes.
float LegoFloat
[AI] Floating point type used throughout LEGO Island.
LegoVideoManager * VideoManager()
[AI] Accessor for the game's LegoVideoManager subsystem. Used for managing 3D/video hardware....
LegoCharacterManager * CharacterManager()
[AI] Accessor for the character manager, which manages in-game characters/NPCs. [AI]
LegoBuildingManager * BuildingManager()
[AI] Accessor for the building manager, handles constructible buildings and structures....
ViewLODListManager * GetViewLODListManager()
[AI] Returns the global ViewLODListManager for view LOD (Level of Detail) resources....
LegoPlantManager * PlantManager()
[AI] Accessor for the plant manager, handling in-game foliage and plants. [AI]
LegoTextureContainer * TextureContainer()
[AI] Accessor for the texture container used for global texture management. [AI]
MxVariableTable * VariableTable()
[AI] Returns the variable table used for script variables and global key/value state.
void CalcLocalTransform(const Vector3 &p_posVec, const Vector3 &p_dirVec, const Vector3 &p_upVec, Matrix4 &p_outMatrix)
[AI] Computes a transformation matrix based on a position, direction, and up vector.
list< ROI * > CompoundObject
[AI] Describes a part/slot of a LEGO actor (e.g.
MxU8 m_unk0x08
[AI] Default part variant index (or count/selection index). [AI_SUGGESTED_NAME: m_defaultVariant]
const char ** m_unk0x04
[AI] Pointer to array of strings representing the names/resources corresponding to the part's variant...
MxU8 * m_unk0x00
[AI] Pointer to list of variant indices for this part (options for which sub-parts may be picked by t...
MxU8 m_unk0x14
[AI] Default color/texture or palette index for the part. [AI_SUGGESTED_NAME: m_defaultPalette]
MxU8 * m_unk0x0c
[AI] Pointer to a list of values (indices/colors), purpose is to map this part to a color/texture set...
const char ** m_unk0x10
[AI] Pointer to palette or color array, typically strings with color names or filenames for textures....
[AI] Contains information about a single LEGO actor/character, including its name,...
MxS32 m_move
[AI] Movement profile, move type, or current move id. [AI]
LegoExtraActor * m_actor
[AI] Pointer to the runtime logic/controller object for the actor (LegoExtraActor),...
LegoROI * m_roi
[AI] Pointer to the runtime ROI (graphical representation/model) of the actor, assigned at runtime....
MxS32 m_sound
[AI] Sound profile or current sound effect associated (index/id). [AI]
MxU8 m_mood
[AI] Mood parameter for the actor (expressions/mouth shape/animation set). [AI]
Part m_parts[10]
[AI] Table of body parts, each with their own variant/color selection and mappings (see Part struct)....
const char * m_name
[AI] Unique name string for this actor type (used for lookup in runtime logic, e.g....
const char * m_parentName
[AI] Name of parent part/Lod, forming hierarchy for placing in the model. [AI]
float m_boundingSphere[4]
[AI] Defines center (x, y, z) and radius for the part's bounding sphere (collision and culling)....
float m_boundingBox[6]
[AI] Defines axis-aligned bounding box: minX, minY, minZ, maxX, maxY, maxZ. Used for spatial culling....
@ c_flag2
[AI] Used to denote a secondary special flag (usage determined by implementation)....
@ c_flag1
[AI] Used to denote special processing/class of LOD part (see usage in creation routines)....
[AI] Holds a LegoROI pointer and reference count for a character instance managed by LegoCharacterMan...
LegoROI * m_roi
[AI] Pointer to the character's ROI object.
MxU32 m_refCount
[AI] Reference count tracking how many owners the character ROI has.
void AddRef()
[AI] Increments the internal reference count for this character.
MxU32 RemoveRef()
[AI] Decrements the internal reference count.