载入中...
搜索中...
未找到
SkillMeshEffect.cpp
浏览该文件的文档.
2
3#include "common/Exception.h"
4
5namespace eve::stylize {
6namespace {
7const char* styleFor(SkillMeshEffectKind kind) {
8 switch (kind) {
9 case SkillMeshEffectKind::WeaponSlash: return "slash";
10 case SkillMeshEffectKind::ImpactFlash: return "rim";
11 case SkillMeshEffectKind::ChargeAura: return "aura";
12 case SkillMeshEffectKind::BurningBody: return "ember";
13 }
14 throw eve::Exception("SkillMeshEffect: unknown recipe kind");
15}
16
17MeshEffectPlayback playbackFor(SkillMeshEffectKind kind) {
18 switch (kind) {
19 case SkillMeshEffectKind::WeaponSlash: return {0.02f, 0.12f, 0.18f, false};
20 case SkillMeshEffectKind::ImpactFlash: return {0.01f, 0.05f, 0.14f, false};
21 case SkillMeshEffectKind::ChargeAura: return {0.18f, 0.55f, 0.18f, true};
22 case SkillMeshEffectKind::BurningBody: return {0.12f, 0.7f, 0.2f, true};
23 }
24 throw eve::Exception("SkillMeshEffect: unknown recipe kind");
25}
26} // namespace
27
29 : kind_(kind), effect_(std::make_unique<MeshEffectInstance>(styleFor(kind))) {
30 effect_->setPlayback(playbackFor(kind));
32 trail_ = std::make_unique<TrailEmitter>(TrailSettings{64, 0.3f, 0.012f, 2.f});
33}
34
36 if (!trail_) throw eve::Exception("SkillMeshEffect.trail: recipe has no ribbon");
37 return *trail_;
38}
39
41 if (!trail_) throw eve::Exception("SkillMeshEffect.trail: recipe has no ribbon");
42 return *trail_;
43}
44
46
47void SkillMeshEffect::play() noexcept {
48 if (trail_) trail_->clear();
49 effect_->play();
50}
51
52void SkillMeshEffect::stop(float fadeOutSeconds) {
53 effect_->stop(fadeOutSeconds);
54 if (trail_) trail_->breakTrail();
55}
56
57void SkillMeshEffect::update(float dtSeconds) {
58 effect_->update(dtSeconds);
59 if (trail_) trail_->update(dtSeconds);
60}
61
62bool SkillMeshEffect::isFinished() const noexcept {
63 const auto state = effect_->state();
65}
66
68 if (!trail_) throw eve::Exception("SkillMeshEffect.appendBlade: recipe has no ribbon");
69 return trail_->append(root, tip);
70}
71
72} // namespace eve::stylize
LogicalId target
int tip
Definition AnimSmr.cpp:121
int root
Definition AnimSmr.cpp:119
TokenKind kind
EVENGINE_API_FOUNDATION public API.
Definition Exception.h:13
Runtime state for a shader effect attached to a renderable mesh.
Definition MeshEffect.h:40
TrailAppendResult appendBlade(glm::vec3 root, glm::vec3 tip)
Append one blade-edge sample or throw if the recipe has no trail.
TrailEmitter & trail()
Return the owned ribbon or throw when this recipe has no ribbon.
bool isFinished() const noexcept
True when primary effect playback has stopped or finished.
SkillMeshEffect(SkillMeshEffectKind kind)
Construct one built-in composition with validated preset data.
void play() noexcept
Restart playback and clear any retained ribbon samples.
SkillMeshEffectKind kind() const noexcept
Return the immutable built-in recipe identity.
void update(float dtSeconds)
Advance all owned deterministic runtime state.
void stop(float fadeOutSeconds=0.f)
Stop playback, optionally fading from the current envelope.
void bindTarget(MeshEffectTargetHandle target)
Bind the primary effect to a process-local target identity.
Deterministic CPU sampler and ribbon mesh generator for weapon trails.
Definition TrailEffect.h:55
SkillMeshEffectKind
Built-in gameplay-oriented mesh VFX compositions.
TrailAppendResult
Result of attempting to append one weapon-edge sample.
Definition TrailEffect.h:24
Sampling and retention policy for a weapon ribbon trail.
Definition TrailEffect.h:16