mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 16:10:36 +00:00
ModelSceneActor:SetModelByUnit copies the unit's model the way 1.12.1's character panes do in AttachUnitModel (0x005059A0): the unit's own character component is pumped forced (UpdateCharacterComponent 0x00477860), its model (+0xD8) is copied into the scene's M2 scene with CreateModelFromModel (0x00707400, which carries the helm, shoulders and held items), the effect and spell attachments come off (DetachAllItemModels 0x0047A230), and the hand grips close (CloseHand 0x00479660). What DressUpModel's SetModelInstance (0x00504350) adds comes next: a clone of the unit's component (CloneCharacterComponent 0x00476CB0, on a pool component with the model AddRef'd) and the two held-item lanes from unit vtable +0x98. The actor pumps the clone on every update, as the DressUpModel paint (0x00504470) pumps its own, so outfit changes show at once; OnModelLoaded waits for its first composite. On top: retail's Dress, Undress(includeWeapons), UndressSlot, SetSheathed / GetSheathed, SetAutoDress / GetAutoDress, IsGeoReady and GetModelUnitGUID. Undress mirrors ClearModel (0x00504490); sheathing is the unit's AttachHandItem step (AttachItemModel 0x0047A0C0 with the sheathed flag). The lane, weapon and undress steps move out of Model::DressUp into Model::Outfit, which the DressUpModel pane and the actor share. One change on the pane: UndressSlot on a held slot no longer needs the component. PumpDresser takes the engine's force argument, which the old typedef called an unused pointer.
97 lines
3.6 KiB
C++
97 lines
3.6 KiB
C++
// This file is part of ClassicAPI.
|
|
//
|
|
// ClassicAPI is free software: you can redistribute it and/or modify it under the terms
|
|
// of the GNU General Public License as published by the Free Software Foundation, either
|
|
// version 3 of the License, or (at your option) any later version.
|
|
//
|
|
// ClassicAPI is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
// PURPOSE. See the GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License along with
|
|
// ClassicAPI. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
#pragma once
|
|
|
|
#include "animation/Object.h"
|
|
#include "model/Outfit.h"
|
|
|
|
#include <cstdint>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
// The ModelScene frame (model/Scene.cpp) and its actors (model/SceneActor.cpp).
|
|
// docs/notes/model-scene.md has the plan, the retail contract and the probes.
|
|
namespace Model::Scene {
|
|
|
|
// A ModelSceneActor: one model in its scene frame's M2 scene, placed by the
|
|
// scene's paint. A script object (Animation::Object) whose parent is the scene
|
|
// frame, which owns it.
|
|
class Actor : public Animation::Object {
|
|
public:
|
|
static Animation::Class s_class;
|
|
|
|
Actor(void *scene, const char *name);
|
|
~Actor();
|
|
|
|
void *SceneFrame() const { return parent; }
|
|
|
|
// From the scene frame's update walk: load and dress state, scripts.
|
|
void Update(float elapsedSec);
|
|
// From the scene's paint, before the scene animates: the model's
|
|
// placement matrix.
|
|
void Place();
|
|
// The scene frame's alpha changed.
|
|
void ApplyAlpha();
|
|
|
|
// Shows `model` (one reference, which the actor takes over), or nothing.
|
|
void SetModel(void *model, const char *path, const uint8_t *dressRecord);
|
|
// Shows a copy of the unit's model, dressed and armed per autoDress,
|
|
// sheathed and hideWeapons; false (and no model) when it has none.
|
|
bool SetUnitModel(uint64_t guid);
|
|
// Hangs the held items per sheathed and hideWeapons.
|
|
void ApplyWeapons();
|
|
void ClearModel();
|
|
void PlayAnimation();
|
|
// Shows the kit (0 for none) on the model, replacing the one shown.
|
|
void SetSpellVisualKit(uint32_t kitID, bool oneShot);
|
|
// Loads the actor's XML element (an <Actor> template), then runs OnLoad.
|
|
void LoadXml(const void *node, void *status);
|
|
|
|
void *model = nullptr;
|
|
std::string modelPath;
|
|
const uint8_t *dressRecord = nullptr; // CreatureDisplayInfoExtra, until dressed
|
|
// The character component dressing the model: a display's dress, or the
|
|
// clone of a unit's.
|
|
void *dresser = nullptr;
|
|
// A unit's model (SetModelByUnit): the unit and what the copy holds.
|
|
uint64_t unitGuid = 0;
|
|
Outfit::Lanes lanes = {};
|
|
Outfit::Weapons weapons;
|
|
bool autoDress = true;
|
|
bool sheathed = false;
|
|
bool hideWeapons = false;
|
|
bool loaded = false; // OnModelLoaded has run for the model
|
|
bool animFinished = false;
|
|
|
|
float position[3] = {0.0f, 0.0f, 0.0f};
|
|
float yaw = 0.0f, pitch = 0.0f, roll = 0.0f;
|
|
float scale = 1.0f;
|
|
float alpha = 1.0f;
|
|
bool shown = true;
|
|
bool useCenterForOrigin[3] = {false, false, false};
|
|
uint32_t animation = 0;
|
|
int variation = -1;
|
|
float animSpeed = 1.0f;
|
|
float animOffsetSec = 0.0f;
|
|
uint32_t blendOperation = 1; // Enum.ModelBlendOperation: 0 None, 1 Anim
|
|
uint32_t spellVisualKit = 0;
|
|
bool spellVisualKitOneShot = false;
|
|
std::vector<void *> kitEffects; // the kit's effect models, one reference each
|
|
};
|
|
|
|
// Registers the actor class in the current Lua state.
|
|
void RegisterActorClass();
|
|
|
|
} // namespace Model::Scene
|