mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 08:00:42 +00:00
feat(model): ModelSceneActor SetShadowShown blob shadows
A ClassicAPI extension, off by default: actor:SetShadowShown(shown) / IsShadowShown() put the world's blob shadow under the actor. The shadow is 1.12's own (DrawBlobShadow 0x006D7920, reached from the entity draw through 0x006D78F0): drawn only while shadowLOD (0x0086F5B4) is 1 and the model is ready; the bounds of sequence (0, 0), skipped when the x or y extent is under the range epsilon, clamped to +-5 and multiplied by the length of the base transform's row 0 (GetBaseTransform 0x00710600); the four corners turned by the base rotation and moved by the base translation. The texture is the one the unit setup loads (Textures\ShadowBlob.blp, handle 0x00CE9DFC, device object through 0x0044ACF0), with the decal's states: blend 4 (DST_COLOR / ZERO), lighting, fog and depth write off, combiner preset 5, and the colour white with the model's alpha (GetAlpha 0x00710CA0; 0x004A2C10 packs that byte on top). The world lays the shadow onto the ground's batches with a decal (0x006D7330). A scene has no ground, so the paint draws the turned box itself as a flat triangle strip on the plane of the base translation, after the animate pass and before the draw passes, so every model draws over the shadows. Culling is off, as for the engine's lightning quad (0x007AFCB0). The decal's height fade and its shadowBias depth test EQUAL are not drawn: both exist to match real ground. A model hung on another casts none.
This commit is contained in:
@@ -90,7 +90,7 @@ In the Frame rows, a name that starts with `:` is a method of the widget that th
|
||||
| [Frame: Slider](docs/API.md#sliderenable--sliderdisable--sliderisenabled) | `:Enable` / `:Disable` / `:IsEnabled` |
|
||||
| [Frame: Cooldown](docs/API.md#createframecooldown--name-parent-template) | `CreateFrame("Cooldown")`, `:SetCooldown`, `:SetCooldownDuration`, `:SetCooldownFromExpirationTime`, `:Clear`, `:GetCooldownTimes`, `:GetCooldownDuration`, `:GetCooldownDisplayDuration`, `:Pause` / `:Resume`, `:SetPaused` / `:IsPaused`, `:SetReverse` / `:GetReverse`, `:SetDrawEdge` / `:GetDrawEdge`, `:SetDrawSwipe` / `:GetDrawSwipe`, `:SetDrawBling` / `:GetDrawBling`, `:SetSwipeColor`, `:SetEdgeColor`, `:SetSwipeTexture`, `:SetEdgeTexture`, `:SetBlingTexture`, `:SetRotation` / `:GetRotation`, `:SetHideCountdownNumbers` / `:GetHideCountdownNumbers`, `:GetCountdownFontString`, `:SetCountdownAbbrevThreshold` / `:GetCountdownAbbrevThreshold`, `:SetCountdownMillisecondsThreshold` / `:GetCountdownMillisecondsThreshold`, `:SetMinimumCountdownDuration` / `:GetMinimumCountdownDuration`, `OnCooldownDone`, `CooldownFrame_Set`, `CooldownFrame_Clear`, `CooldownFrame_SetDisplayAsPercentage` |
|
||||
| [Frame: ModelScene](docs/API.md#modelscene) | `CreateFrame("ModelScene")`, `<ModelScene>` (`drawLayer`, `fogNear`, `fogFar`, `<FogColor>`, `<ViewInsets>`), `:CreateActor`, `:GetNumActors`, `:GetActorAtIndex`, `:SetCameraPosition` / `:GetCameraPosition`, `:SetCameraOrientationByYawPitchRoll`, `:SetCameraOrientationByAxisVectors`, `:GetCameraForward`, `:GetCameraRight`, `:GetCameraUp`, `:SetCameraFieldOfView` / `:GetCameraFieldOfView`, `:SetCameraNearClip` / `:GetCameraNearClip`, `:SetCameraFarClip` / `:GetCameraFarClip`, `:SetViewInsets` / `:GetViewInsets`, `:SetViewTranslation` / `:GetViewTranslation`, `:Project3DPointTo2D`, `:SetLightType` / `:GetLightType`, `:SetLightVisible` / `:IsLightVisible`, `:SetLightDirection` / `:GetLightDirection`, `:SetLightPosition` / `:GetLightPosition`, `:SetLightAmbientColor` / `:GetLightAmbientColor`, `:SetLightDiffuseColor` / `:GetLightDiffuseColor`, `:SetFogColor` / `:GetFogColor`, `:SetFogNear` / `:GetFogNear`, `:SetFogFar` / `:GetFogFar`, `:ClearFog`, `:SetDrawLayer` / `:GetDrawLayer`, `:SetPaused`, `:SetAllowOverlappedModels` / `:GetAllowOverlappedModels`, `:SetGroundTerrain` / `:GetGroundTerrain`, `:GetActorAtCursor`, `OnActorEnter` / `OnActorLeave` |
|
||||
| [Frame: ModelSceneActor](docs/API.md#actorsetmodelbycreaturedisplayiddisplayid--useactiveplayercustomizations) | `:SetModelByCreatureDisplayID`, `:SetModelByPath`, `:SetModelByUnit`, `:SetModelByUnitCreatureDisplayID`, `:GetModelUnitGUID`, `:Dress`, `:Undress`, `:UndressSlot`, `:TryOn`, `:DressPlayerSlot`, `:IsSlotAllowed` / `:IsSlotVisible`, `:GetItemTransmogInfo`, `:GetItemTransmogInfoList`, `:SetItemTransmogInfo`, `:SetSheathed` / `:GetSheathed`, `:SetSheathedCategory`, `:UseUnitSheatheCategory`, `:SetAutoDress` / `:GetAutoDress`, `:IsGeoReady`, `:ClearModel`, `:IsLoaded`, `:GetModelPath`, `:SetPosition` / `:GetPosition`, `:SetYaw` / `:GetYaw`, `:SetPitch` / `:GetPitch`, `:SetRoll` / `:GetRoll`, `:SetScale` / `:GetScale`, `:SetUseCenterForOrigin` / `:IsUsingCenterForOrigin`, `:GetActiveBoundingBox`, `:GetMaxBoundingBox`, `:Show` / `:Hide` / `:SetShown` / `:IsShown` / `:IsVisible`, `:SetAlpha` / `:GetAlpha`, `:SetAnimation` / `:GetAnimation`, `:GetAnimationVariation`, `:SetAnimationBlendOperation` / `:GetAnimationBlendOperation`, `:SetPaused` / `:GetPaused`, `:SetSpellVisualKit` / `:GetSpellVisualKit`, `:ApplySpellVisualKit`, `:PlayAnimationKit` / `:StopAnimationKit`, `:AttachToMount`, `:DetachFromMount`, `:CalculateMountScale`, `:GetAttachmentPosition`, `:AttachToActor`, `:DetachFromActor`, `:PlaySpellVisual`, `:SetPlayAnimationSounds` / `:GetPlayAnimationSounds`, `OnLoad`, `OnUpdate`, `OnModelLoading`, `OnModelLoaded`, `OnModelCleared`, `OnAnimFinished`, `<Actor>` templates |
|
||||
| [Frame: ModelSceneActor](docs/API.md#actorsetmodelbycreaturedisplayiddisplayid--useactiveplayercustomizations) | `:SetModelByCreatureDisplayID`, `:SetModelByPath`, `:SetModelByUnit`, `:SetModelByUnitCreatureDisplayID`, `:GetModelUnitGUID`, `:Dress`, `:Undress`, `:UndressSlot`, `:TryOn`, `:DressPlayerSlot`, `:IsSlotAllowed` / `:IsSlotVisible`, `:GetItemTransmogInfo`, `:GetItemTransmogInfoList`, `:SetItemTransmogInfo`, `:SetSheathed` / `:GetSheathed`, `:SetSheathedCategory`, `:UseUnitSheatheCategory`, `:SetAutoDress` / `:GetAutoDress`, `:IsGeoReady`, `:ClearModel`, `:IsLoaded`, `:GetModelPath`, `:SetPosition` / `:GetPosition`, `:SetYaw` / `:GetYaw`, `:SetPitch` / `:GetPitch`, `:SetRoll` / `:GetRoll`, `:SetScale` / `:GetScale`, `:SetUseCenterForOrigin` / `:IsUsingCenterForOrigin`, `:GetActiveBoundingBox`, `:GetMaxBoundingBox`, `:Show` / `:Hide` / `:SetShown` / `:IsShown` / `:IsVisible`, `:SetAlpha` / `:GetAlpha`, `:SetAnimation` / `:GetAnimation`, `:GetAnimationVariation`, `:SetAnimationBlendOperation` / `:GetAnimationBlendOperation`, `:SetPaused` / `:GetPaused`, `:SetSpellVisualKit` / `:GetSpellVisualKit`, `:ApplySpellVisualKit`, `:PlayAnimationKit` / `:StopAnimationKit`, `:AttachToMount`, `:DetachFromMount`, `:CalculateMountScale`, `:GetAttachmentPosition`, `:AttachToActor`, `:DetachFromActor`, `:PlaySpellVisual`, `:SetPlayAnimationSounds` / `:GetPlayAnimationSounds`, `:SetShadowShown` / `:IsShadowShown`, `OnLoad`, `OnUpdate`, `OnModelLoading`, `OnModelLoaded`, `OnModelCleared`, `OnAnimFinished`, `<Actor>` templates |
|
||||
| [Frame: ScrollingMessageFrame](docs/API.md#smfsethyperlinksenabledenabled--smfgethyperlinksenabled) | `:SetHyperlinksEnabled` / `:GetHyperlinksEnabled`, `:GetMessageInfo` (with the extra `:AddMessage` values), `:BackFillMessage` (adds a message as the oldest), `:RemoveMessagesByPredicate`, `:SetScrollOffset` / `:GetScrollOffset`, `:GetMaxScrollRange`, `:ScrollByAmount`, `:SetInsertMode` / `:GetInsertMode`, `:AddOnDisplayRefreshedCallback` |
|
||||
| [Frame: scripts](docs/API.md#onenable-and-ondisable-scripts) | `OnEnable`, `OnDisable`, `OnMinMaxChanged`, `OnAttributeChanged`, `OnCharComposition`, `OnTextChanged` (`userInput`), `PreClick`, `PostClick`, `SetModernScriptArgs` / `GetModernScriptArgs` |
|
||||
| [FriendList](docs/API.md#friendlist) | `AddOrRemoveFriend`, `C_FriendList.GetFriendInfo`, `C_FriendList.GetFriendInfoByIndex`, `C_FriendList.GetNumFriends`, `C_FriendList.GetNumOnlineFriends`, `C_FriendList.GetNumWhoResults`, `C_FriendList.GetWhoInfo`, `C_FriendList.IsFriend`, `C_FriendList.IsIgnored`, `C_FriendList.IsIgnoredByGuid`, `C_FriendList.IsWhoQueryPending`, `C_FriendList.SendWhoQueryByName`, `C_FriendList.SetFriendNotes`, `C_FriendList.SetFriendNotesByIndex` |
|
||||
|
||||
+25
@@ -880,6 +880,7 @@ build instructions.
|
||||
- [`actor:AttachToActor(parent, attachmentID)`](#actorattachtoactorparent-attachmentid)
|
||||
- [`actor:DetachFromActor()`](#actordetachfromactor)
|
||||
- [`actor:SetPlayAnimationSounds(enabled)` / `actor:GetPlayAnimationSounds()`](#actorsetplayanimationsoundsenabled--actorgetplayanimationsounds)
|
||||
- [`actor:SetShadowShown(shown)` / `actor:IsShadowShown()`](#actorsetshadowshownshown--actorisshadowshown)
|
||||
- [`actor:PlaySpellVisual(spellID [, target [, castTimeMs]])`](#actorplayspellvisualspellid--target--casttimems)
|
||||
- [Actor scripts](#actor-scripts)
|
||||
- [`<Actor>` templates](#actor-templates)
|
||||
@@ -19755,6 +19756,30 @@ wolf:SetPlayAnimationSounds(true)
|
||||
wolf:SetAnimation(5) -- run
|
||||
```
|
||||
|
||||
### `actor:SetShadowShown(shown)` / `actor:IsShadowShown()`
|
||||
|
||||
Shows or hides a blob shadow under the model. It is the same dark blob that
|
||||
units have on the ground in the world. The default is off.
|
||||
|
||||
- The shadow lies flat on the plane of the actor's position, below its
|
||||
feet. The scene has no ground, so the shadow does not follow a slope.
|
||||
- The size of the shadow comes from the bounds of the model and from the
|
||||
scale of the actor. The shadow turns with the yaw of the actor.
|
||||
- The shadow darkens what is behind it. It fades with the alpha of the
|
||||
actor.
|
||||
- The model draws over its shadow, and over the shadows of the other
|
||||
actors.
|
||||
- The shadow shows only while the `shadowLOD` cvar is `1`, as in the world.
|
||||
This is the default value.
|
||||
- A hidden actor shows no shadow. An actor that hangs on another actor (a
|
||||
seated rider, or an actor of `AttachToActor`) shows no shadow of its own.
|
||||
|
||||
This is a ClassicAPI extension.
|
||||
|
||||
```lua
|
||||
mount:SetShadowShown(true)
|
||||
```
|
||||
|
||||
### `actor:PlaySpellVisual(spellID [, target [, castTimeMs]])`
|
||||
|
||||
Plays the visual of a spell that this actor casts at `target`, and returns
|
||||
|
||||
@@ -13345,6 +13345,38 @@ enum Offsets {
|
||||
// +0x410, priority +0x420, value +0x41C. Mode 1 is the world pick's.
|
||||
FUN_M2MODEL_SET_HIT_TEST_MODE = 0x00713CB0,
|
||||
M2_HIT_TEST_SKINNED = 1,
|
||||
// CM2Model::GetBaseTransform — `__thiscall(model, float out[16])`, ret 4:
|
||||
// copies the base matrix +0xBC. GetAlpha — `float __thiscall(model)`:
|
||||
// +0x180 (Ghidra 0x00710600, 0x00710CA0).
|
||||
FUN_M2MODEL_GET_BASE_TRANSFORM = 0x00710600,
|
||||
FUN_M2MODEL_GET_ALPHA = 0x00710CA0,
|
||||
|
||||
// ---- The blob shadow (DrawBlobShadow 0x006D7920; benilla
|
||||
// lighting/shadows). A world entity with flag 0x400 draws it when its
|
||||
// model is ready and shadowLOD is 1 (0x006D78F0). The box is the bounds
|
||||
// of sequence (0, 0), skipped when the x or y extent is under
|
||||
// VAR_HAS_RANGE_EPSILON, clamped to +-5 and multiplied by the length of
|
||||
// the base transform's row 0 (times 1.0, 0x00811698); its four corners
|
||||
// turn by the base rotation (rows over that length) and move by the base
|
||||
// translation. The decal states (0x006D7F27..0x006D7FCF): push, blend 4,
|
||||
// lighting / fog / depth write off, the blob on stage 0, fog colour
|
||||
// white, combiner preset 5, depth function EQUAL when shadowBias is not
|
||||
// 0; colour white with the model's alpha (0x004A2C10 packs its first
|
||||
// argument as the top byte), then the decal draw 0x006D7330 and pop.
|
||||
VAR_SHADOW_LOD = 0x0086F5B4, // int, the shadowLOD cvar (default 1)
|
||||
VAR_SHADOW_BLOB_TEXTURE = 0x00CE9DFC, // HTEXTURE Textures\ShadowBlob.blp; the unit setup loads it (0x006D8070)
|
||||
SHADOW_BOUNDS_CLAMP = 5,
|
||||
// Render-state ids (benilla gx/renderstate: the id table).
|
||||
GXRS_BLEND = 0x07, // blend mode 0..10
|
||||
GXRS_LIGHTING = 0x0E,
|
||||
GXRS_FOG = 0x0F,
|
||||
GXRS_DEPTH_WRITE = 0x12,
|
||||
GXRS_CULL = 0x14,
|
||||
GXRS_BLEND_MODULATE = 4, // DST_COLOR / ZERO
|
||||
GXRS_COMBINE_BLEND_DIFFUSE_ALPHA = 5, // stage: texture to the vertex colour by its alpha
|
||||
// Topology for FUN_GX_PRIM_INDEXED: 4 is a triangle strip (the lightning
|
||||
// bolt's quad, 0x007AFCB0).
|
||||
GX_PRIM_TRIANGLE_STRIP = 4,
|
||||
// `__fastcall(model)`: drops one instance reference (HandleClose2).
|
||||
FUN_MODEL_INSTANCE_RELEASE = 0x007103A0,
|
||||
// CM2Model::IsReady — `__thiscall(model, wait, recurseChildren)`:
|
||||
|
||||
@@ -229,6 +229,18 @@ inline uintptr_t RayHit(void *scene, const float (&p0)[3], const float (&p1)[3])
|
||||
return reinterpret_cast<Fn>(Offsets::FUN_M2SCENE_RAY_HIT)(scene, p0, p1, &fraction, 1);
|
||||
}
|
||||
|
||||
// The base matrix (row vectors: rows 0..2 the scaled axes, row 3 the
|
||||
// translation).
|
||||
inline void GetBaseTransform(void *model, float (&m)[16]) {
|
||||
using Fn = void(__thiscall *)(void *, float *);
|
||||
reinterpret_cast<Fn>(Offsets::FUN_M2MODEL_GET_BASE_TRANSFORM)(model, m);
|
||||
}
|
||||
|
||||
inline float GetAlpha(void *model) {
|
||||
using Fn = float(__thiscall *)(void *);
|
||||
return reinterpret_cast<Fn>(Offsets::FUN_M2MODEL_GET_ALPHA)(model);
|
||||
}
|
||||
|
||||
inline void *FirstChild(const void *model) {
|
||||
return Game::Read<void *>(model, Offsets::OFF_MODEL_INSTANCE_CHILD_HEAD);
|
||||
}
|
||||
|
||||
@@ -346,6 +346,108 @@ void CameraTransforms(void *frame, void *camera, const float (&rect)[4]) {
|
||||
}
|
||||
}
|
||||
|
||||
// ---- ground shadows (actor:SetShadowShown) -------------------------------------
|
||||
|
||||
// The world's blob shadow (DrawBlobShadow 0x006D7920, Offsets::VAR_SHADOW_LOD):
|
||||
// Textures\ShadowBlob.blp over the box of the model's sequence (0, 0)
|
||||
// bounds, clamped to +-5, multiplied by the base scale and turned with the
|
||||
// base rotation, in white with the model's alpha, multiplied onto what is
|
||||
// behind it; only while shadowLOD is 1 and the model is ready. The world lays
|
||||
// it onto the ground's batches with a decal (0x006D7330). A scene has no
|
||||
// ground, so the turned box itself is drawn, flat on the plane of the base
|
||||
// translation (the model's origin, its feet), with the decal's states. Not
|
||||
// drawn: the decal's fade with height (the quad is at the feet) and the
|
||||
// shadowBias depth test EQUAL (it matches the ground's own depth, and the
|
||||
// quad is its own geometry). Culling is off, as for the engine's other
|
||||
// single quads (the lightning bolt, 0x007AFCB0), so the quad shows from
|
||||
// either side. A model hung on another (a seated rider) casts none: its
|
||||
// base transform is relative to its parent, and the world's entity list
|
||||
// holds the mount alone.
|
||||
//
|
||||
// The shadows draw after the animate pass and before the models, without
|
||||
// depth writes: each model then draws over the shadows, its own included.
|
||||
|
||||
using GxRsSet_t = void(__fastcall *)(int selector, int value);
|
||||
using GxRsSetPtr_t = void(__fastcall *)(int selector, const void *value);
|
||||
using GxState_t = void(__fastcall *)();
|
||||
using GetRenderable_t = void *(__fastcall *)(void *texture, int force, void *);
|
||||
using PrimStreams_t = void(__fastcall *)(int count, const void *pos, int posStride, const void *normal,
|
||||
int normalStride, const void *colors, int colorStride,
|
||||
int unused8, int unused9, const void *uv0, int uv0Stride,
|
||||
const void *uv1, int uv1Stride);
|
||||
using PrimIndexed_t = void(__fastcall *)(int primType, int indexCount, const uint16_t *indices);
|
||||
|
||||
// Draws one actor's shadow; the decal states are set.
|
||||
void DrawShadow(Actor &actor, const float (&eye)[3]) {
|
||||
void *model = actor.model;
|
||||
if (!actor.shadowShown || !actor.shown || model == nullptr || M2::Parent(model) != nullptr ||
|
||||
!M2::IsReady(model, 0, 0))
|
||||
return;
|
||||
float box[6]; // min xyz, max xyz
|
||||
M2::GetSequenceBounds(model, 0, 0, box);
|
||||
const float epsilon = Game::Read<float>(Offsets::VAR_HAS_RANGE_EPSILON);
|
||||
if (std::fabs(box[4] - box[1]) < epsilon || std::fabs(box[3] - box[0]) < epsilon)
|
||||
return;
|
||||
constexpr float kClamp = static_cast<float>(Offsets::SHADOW_BOUNDS_CLAMP);
|
||||
for (float &v : box)
|
||||
v = v < -kClamp ? -kClamp : (v > kClamp ? kClamp : v);
|
||||
float m[16];
|
||||
M2::GetBaseTransform(model, m);
|
||||
const float scale = std::sqrt(m[0] * m[0] + m[1] * m[1] + m[2] * m[2]);
|
||||
for (float &v : box)
|
||||
v *= scale;
|
||||
// The rotation rows: the scaled axes over the scale, unless it is 1.
|
||||
const float inv = std::fabs(scale - 1.0f) < epsilon ? 1.0f : 1.0f / scale;
|
||||
const float x0 = box[0], y0 = box[1], x1 = box[3], y1 = box[4];
|
||||
// Strip order; u runs along the model's y, v along its x.
|
||||
const float local[4][2] = {{x0, y0}, {x1, y0}, {x0, y1}, {x1, y1}};
|
||||
float pos[4][3];
|
||||
float uv[4][2];
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
const float x = local[i][0], y = local[i][1];
|
||||
pos[i][0] = (x * m[0] + y * m[4]) * inv + m[12] - eye[0];
|
||||
pos[i][1] = (x * m[1] + y * m[5]) * inv + m[13] - eye[1];
|
||||
pos[i][2] = m[14] - eye[2];
|
||||
uv[i][0] = (y - y0) / (y1 - y0);
|
||||
uv[i][1] = (x - x0) / (x1 - x0);
|
||||
}
|
||||
float alpha = M2::GetAlpha(model);
|
||||
alpha = alpha < 0.0f ? 0.0f : (alpha > 1.0f ? 1.0f : alpha);
|
||||
const uint32_t color = (static_cast<uint32_t>(alpha * 255.0f + 0.5f) << 24) | 0x00FFFFFFu;
|
||||
const uint32_t colors[4] = {color, color, color, color};
|
||||
static const uint16_t kStrip[4] = {0, 1, 2, 3};
|
||||
reinterpret_cast<PrimStreams_t>(Offsets::FUN_GX_PRIM_STREAMS)(4, pos, 12, nullptr, 0, colors, 4, 0, 0,
|
||||
uv, 8, nullptr, 0);
|
||||
reinterpret_cast<PrimIndexed_t>(Offsets::FUN_GX_PRIM_INDEXED)(Offsets::GX_PRIM_TRIANGLE_STRIP, 4,
|
||||
kStrip);
|
||||
}
|
||||
|
||||
void DrawShadows(void *frame, const float (&eye)[3]) {
|
||||
void *texture = Game::Read<void *>(Offsets::VAR_SHADOW_BLOB_TEXTURE);
|
||||
if (Game::Read<int>(Offsets::VAR_SHADOW_LOD) != 1 || texture == nullptr)
|
||||
return;
|
||||
const std::vector<Actor *> &actors = *F(frame).actors;
|
||||
bool any = false;
|
||||
for (const Actor *actor : actors)
|
||||
any = any || actor->shadowShown;
|
||||
if (!any)
|
||||
return;
|
||||
auto rs = reinterpret_cast<GxRsSet_t>(Offsets::FUN_GX_RS_SET);
|
||||
reinterpret_cast<GxState_t>(Offsets::FUN_GX_STATE_PUSH)();
|
||||
rs(Offsets::GXRS_BLEND, Offsets::GXRS_BLEND_MODULATE);
|
||||
rs(Offsets::GXRS_LIGHTING, 0);
|
||||
rs(Offsets::GXRS_FOG, 0);
|
||||
rs(Offsets::GXRS_DEPTH_WRITE, 0);
|
||||
rs(Offsets::GXRS_CULL, 0);
|
||||
reinterpret_cast<GxRsSetPtr_t>(Offsets::FUN_GX_RS_SET_PTR)(
|
||||
Offsets::GXRS_TEXTURE0,
|
||||
reinterpret_cast<GetRenderable_t>(Offsets::FUN_TEXTURE_GET_RENDERABLE)(texture, 1, nullptr));
|
||||
rs(Offsets::GXRS_COMBINER0, Offsets::GXRS_COMBINE_BLEND_DIFFUSE_ALPHA);
|
||||
for (Actor *actor : actors)
|
||||
DrawShadow(*actor, eye);
|
||||
reinterpret_cast<GxState_t>(Offsets::FUN_GX_STATE_POP)();
|
||||
}
|
||||
|
||||
void __fastcall Paint(void *frame) {
|
||||
using SetupOrtho_t = void(__fastcall *)(const float *rect, const float *point, int unused);
|
||||
using DdcToNdc_t = void(__fastcall *)(float *x, float *y, float inX, float inY);
|
||||
@@ -382,6 +484,7 @@ void __fastcall Paint(void *frame) {
|
||||
PlaceActors(frame);
|
||||
void *scene = Model::Pane::Scene(frame);
|
||||
M2::AnimateScene(scene, eye);
|
||||
DrawShadows(frame, eye);
|
||||
auto draw = reinterpret_cast<Draw_t>(Offsets::FUN_M2SCENE_DRAW);
|
||||
draw(scene, 0);
|
||||
draw(scene, 1);
|
||||
|
||||
@@ -101,6 +101,7 @@ class Actor : public Animation::Object {
|
||||
// unit's UNIT_FIELD_DISPLAYID), for its sound data; 0 for a model file.
|
||||
uint32_t displayID = 0;
|
||||
bool playAnimationSounds = false; // SetPlayAnimationSounds
|
||||
bool shadowShown = false; // SetShadowShown: a blob shadow under the model
|
||||
// The character component dressing the model: a display's dress, or the
|
||||
// clone of a unit's.
|
||||
void *dresser = nullptr;
|
||||
|
||||
@@ -147,6 +147,8 @@
|
||||
// animation), DetachFromActor takes it off, and GetAttachmentPosition is the
|
||||
// engine's own CM2Model::GetAttachmentPosition. Both attach methods refuse a
|
||||
// cycle (M2::CanAttach): EnsureAnimated recurses through the parent chain.
|
||||
// SetShadowShown only sets the flag the scene's paint reads (model/Scene.cpp,
|
||||
// "ground shadows": the world's blob shadow on the actor's plane).
|
||||
//
|
||||
// XML: an <Actor> element is a template CreateActor names (1.12's file loader
|
||||
// registers every virtual top-level node whatever its tag), loaded the way an
|
||||
@@ -1104,6 +1106,20 @@ int __fastcall Script_GetPlayAnimationSounds(void *L) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int __fastcall Script_SetShadowShown(void *L) {
|
||||
if (Actor *actor = Self(L))
|
||||
actor->shadowShown = Game::Lua::ToBoolean(L, 2) != 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __fastcall Script_IsShadowShown(void *L) {
|
||||
Actor *actor = Self(L);
|
||||
if (actor == nullptr)
|
||||
return 0;
|
||||
Game::Lua::PushBool(L, actor->shadowShown);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int __fastcall Script_DetachFromActor(void *L) {
|
||||
Actor *child = Self(L);
|
||||
if (child == nullptr)
|
||||
@@ -1405,6 +1421,8 @@ const Game::Lua::FrameMethodEntry kMethods[] = {
|
||||
{"ApplySpellVisualKit", &Script_ApplySpellVisualKit},
|
||||
{"SetPlayAnimationSounds", &Script_SetPlayAnimationSounds},
|
||||
{"GetPlayAnimationSounds", &Script_GetPlayAnimationSounds},
|
||||
{"SetShadowShown", &Script_SetShadowShown},
|
||||
{"IsShadowShown", &Script_IsShadowShown},
|
||||
{"ClearModel", &Script_ClearModel},
|
||||
{"IsLoaded", &Script_IsLoaded},
|
||||
{"GetModelPath", &Script_GetModelPath},
|
||||
@@ -1703,6 +1721,13 @@ const Game::Doc::Function kSetPlayAnimationSounds{
|
||||
const Game::Doc::Function kGetPlayAnimationSounds{
|
||||
"Returns whether the model's animations play their sounds.", {}, kAnimationSoundsArg, nullptr,
|
||||
true};
|
||||
const Game::Doc::Field kShadowShownArg[] = {Req("shown", "bool")};
|
||||
const Game::Doc::Function kSetShadowShown{
|
||||
"Sets whether a blob shadow shows under the model, as under a unit in the world, while the "
|
||||
"shadowLOD cvar is 1. Off by default.",
|
||||
kShadowShownArg, {}, nullptr, true};
|
||||
const Game::Doc::Function kIsShadowShown{"Returns whether the actor shows a blob shadow.", {},
|
||||
kShadowShownArg, nullptr, true};
|
||||
const Game::Doc::Function kDetachFromActor{
|
||||
"Takes this actor off the actor it hangs on. False when it hangs on none.", {},
|
||||
kMountSuccessRet, nullptr, true};
|
||||
@@ -1783,6 +1808,8 @@ const Game::Doc::Method kMethodDocs[] = {
|
||||
{"ApplySpellVisualKit", &kApplySpellVisualKit},
|
||||
{"SetPlayAnimationSounds", &kSetPlayAnimationSounds},
|
||||
{"GetPlayAnimationSounds", &kGetPlayAnimationSounds},
|
||||
{"SetShadowShown", &kSetShadowShown},
|
||||
{"IsShadowShown", &kIsShadowShown},
|
||||
{"ClearModel", &kClearModel},
|
||||
{"IsLoaded", &kIsLoaded},
|
||||
{"GetModelPath", &kGetModelPath},
|
||||
|
||||
Reference in New Issue
Block a user