载入中...
搜索中...
未找到
MeshVfxAsset.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
5#include "common/Result.h"
10
11#include <cstdint>
12#include <map>
13#include <memory>
14#include <optional>
15#include <string>
16#include <string_view>
17#include <vector>
18
19namespace eve::stylize {
20
23 float time = 0.f;
24 float value = 0.f;
25};
26
29 std::vector<MeshVfxFloatKey> keys;
30
32 [[nodiscard]] float evaluate(float normalizedTime) const noexcept;
33};
34
37 float time = 0.f;
38 std::string name;
39};
40
48
51 std::vector<std::string> play;
52 std::vector<std::string> stop;
53 std::vector<std::string> trailBreak;
54};
55
58 std::size_t handled = 0;
59 std::size_t played = 0;
60 std::size_t stopped = 0;
61 std::size_t trailBreaks = 0;
62};
63
66 std::string style;
68 std::map<std::string, float> floatParameters;
69 std::map<std::string, MeshVfxFloatCurve> floatCurves;
70};
71
74 static constexpr std::string_view schemaId = "eve.stylize.mesh-vfx";
75 static constexpr std::uint32_t schemaVersion = 1;
76
77 std::vector<MeshVfxLayerAsset> layers;
78 std::optional<TrailSettings> trail;
79 std::optional<MeshVfxTrailBinding> trailBinding;
80 std::vector<MeshVfxEventAsset> events;
82
88 [[nodiscard]] static eve::Result<MeshVfxAsset> fromJson(std::string_view json);
89
94 [[nodiscard]] eve::Result<std::string> toJson() const;
95
97 [[nodiscard]] eve::Result<void> validate() const;
98};
99
107public:
112 [[nodiscard]] static eve::Result<std::unique_ptr<MeshVfxAssetInstance>> create(const MeshVfxAsset& asset);
115 [[nodiscard]] static eve::Result<std::unique_ptr<MeshVfxAssetInstance>> create(
116 const MeshVfxAsset& asset, const std::map<std::string, std::map<std::string, float>>& externalStyles);
117
119 void bindTarget(MeshEffectTargetHandle target);
121 void play() noexcept;
123 void stop(float fadeOutSeconds = -1.f);
125 void update(float dtSeconds);
130 [[nodiscard]] std::vector<std::string> drainEvents();
132 [[nodiscard]] eve::Result<TrailAppendResult> sampleTrail(const eve::IAttachmentPointSource& source);
134 [[nodiscard]] MeshVfxAnimationDispatch processAnimationEvents(const eve::IAnimationEventSource& source);
135
137 [[nodiscard]] std::size_t layerCount() const noexcept { return layers_.size(); }
139 [[nodiscard]] MeshEffectInstance& layer(std::size_t index) { return *layers_.at(index); }
141 [[nodiscard]] const MeshEffectInstance& layer(std::size_t index) const { return *layers_.at(index); }
143 [[nodiscard]] bool hasTrail() const noexcept { return trail_ != nullptr; }
145 [[nodiscard]] bool isFinished() const noexcept;
147 [[nodiscard]] TrailEmitter& trail();
148
149private:
150 explicit MeshVfxAssetInstance(const MeshVfxAsset& asset,
151 const std::map<std::string, std::map<std::string, float>>& externalStyles);
152
153 std::vector<std::unique_ptr<MeshEffectInstance>> layers_;
154 std::vector<std::map<std::string, MeshVfxFloatCurve>> curves_;
155 std::unique_ptr<TrailEmitter> trail_;
156 std::optional<MeshVfxTrailBinding> trailBinding_;
157 std::vector<MeshVfxEventAsset> events_;
158 MeshVfxAnimationTriggers animationTriggers_;
159 std::vector<std::string> pendingEvents_;
160 float previousNormalizedTime_ = 0.f;
161};
162
169public:
171 explicit MeshVfxAssetSlot(MeshVfxAsset asset);
172
174 [[nodiscard]] eve::Result<std::uint64_t> reload(std::string_view json);
176 [[nodiscard]] const MeshVfxAsset& asset() const noexcept { return asset_; }
178 [[nodiscard]] std::uint64_t revision() const noexcept { return revision_; }
179
180private:
181 MeshVfxAsset asset_;
182 std::uint64_t revision_ = 1;
183};
184
185} // namespace eve::stylize
LogicalId target
#define EVENGINE_API_WORLD
Definition Export.h:109
float f
Move-only, checked operation results for the common layer.
uint32_t index
const UnitySourceAsset & source
Read-only cross-module view of animation events emitted by the latest simulation update....
Read-only cross-module contract for sampling named animated attachment points. @ownership Implementat...
Move-only operation result carrying either a value or Status.
Definition Result.h:155
Runtime state for a shader effect attached to a renderable mesh.
Definition MeshEffect.h:40
Owning runtime instantiated from one immutable MeshVfxAsset snapshot. @ownership Owns all layer runti...
MeshEffectInstance & layer(std::size_t index)
Return one owned layer; throws std::out_of_range for an invalid index.
bool hasTrail() const noexcept
Whether this composition owns a trail emitter.
const MeshEffectInstance & layer(std::size_t index) const
Return one owned layer; throws std::out_of_range for an invalid index.
std::size_t layerCount() const noexcept
Return the number of independently rendered mesh layers.
Transactional hot-reload boundary for one mesh VFX asset. A failed reload preserves both the previous...
std::uint64_t revision() const noexcept
Monotonic successful-reload revision, starting at one.
const MeshVfxAsset & asset() const noexcept
Current immutable asset snapshot.
Deterministic CPU sampler and ribbon mesh generator for weapon trails.
Definition TrailEffect.h:55
Plain world-space point shared by animation consumers without a math-library dependency.
Deterministic timing configuration for one mesh effect playback.
Definition MeshEffect.h:24
Summary of lifecycle actions dispatched from one animation event batch.
Animation notification names mapped to built-in Mesh VFX lifecycle actions.
std::vector< std::string > play
std::vector< std::string > trailBreak
std::vector< std::string > stop
Versioned, backend-neutral description of a real-time mesh effect.
MeshVfxAnimationTriggers animationTriggers
std::optional< MeshVfxTrailBinding > trailBinding
std::vector< MeshVfxEventAsset > events
std::vector< MeshVfxLayerAsset > layers
std::optional< TrailSettings > trail
Named gameplay/render marker on the primary layer's normalized playback timeline.
Piecewise-linear parameter animation evaluated over one playback cycle.
std::vector< MeshVfxFloatKey > keys
One normalized key in a deterministic float parameter curve.
One independently rendered layer in a mesh VFX asset.
std::map< std::string, MeshVfxFloatCurve > floatCurves
std::map< std::string, float > floatParameters
Authored root/tip attachment pair used to sample a weapon ribbon automatically.
eve::AttachmentPoint rootOffset
eve::AttachmentPoint tipOffset