载入中...
搜索中...
未找到
DecalManager.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
5#include <glm/mat4x4.hpp>
6
7#include <cstdint>
8#include <string>
9#include <vector>
10
11namespace eve::graphics {
12class Graphics;
13class Texture;
14} // namespace eve::graphics
15
16namespace eve::decal {
17
20 int id = 0;
21 float x = 0.f, y = 0.f, z = 0.f;
22 float nx = 0.f, ny = 1.f, nz = 0.f;
23 float yaw = 0.f; // random rotation around the surface normal
24 float size = 0.5f;
25 float depth = 0.15f;
26 float age = 0.f; // seconds since spawn
27 float lifetime = 0.f; // 0 = persistent
28 float fadeIn = 0.f;
29 float fadeOut = 0.f;
33 float uvRect[4] = {0.f, 0.f, 1.f, 1.f};
34 float normalStrength = 0.f;
35 float roughnessStrength = 0.f;
36 float metalStrength = 0.f;
37 float emissiveStrength = 0.f;
38 int blendMode = 0; // 0 = premultiplied over, 1 = additive (emissive)
39 int projectionMode = 0; // 0 = planar, 1 = triplanar, 2 = spherical, 3 = world-aligned
40 float blendSharpness = 4.f;
41 float parallaxScale = 0.f;
42 float parallaxMinLayers = 8.f;
43 float parallaxMaxLayers = 24.f;
44 float edgeFadeWidth = 0.06f;
45 std::string kind; // quota group ("blood", "dirt", ...)
46};
47
54enum class DecalProjectionStatus : std::uint8_t {
55 Applied = 0,
56 UnknownId = 1,
57 InvalidMode = 2,
59};
60
62enum class DecalParallaxStatus : std::uint8_t {
63 Applied = 0,
64 UnknownId = 1,
65 InvalidScale = 2,
66 InvalidLayers = 3,
67};
68
70enum class DecalEdgeFadeStatus : std::uint8_t {
71 Applied = 0,
72 UnknownId = 1,
73 InvalidWidth = 2,
74};
75
86public:
88 static DecalManager &inst();
89
91 int project(float x, float y, float z, float nx, float ny, float nz,
92 graphics::Texture *albedo, const std::string &kind, float size, float depth,
93 bool randomYaw, int seed, float fadeIn, float lifetime, float fadeOut,
94 float normalStrength, float roughnessStrength, float metalStrength,
95 float emissiveStrength);
96
98 bool remove(int id);
100 [[nodiscard]] bool contains(int id) const;
101 void clearAll();
103 int count() const;
105 bool setStrength(int id, float normalStrength, float roughnessStrength, float metalStrength,
106 float emissiveStrength);
108 bool setUvRect(int id, float x, float y, float w, float h);
110 bool setTextures(int id, graphics::Texture *normal, graphics::Texture *params);
112 bool setBlend(int id, const std::string &mode);
118 [[nodiscard]] DecalProjectionStatus setProjection(int id, const std::string &mode,
119 float blendSharpness = 4.f);
121 [[nodiscard]] DecalParallaxStatus setParallax(int id, float scale, float minLayers = 8.f,
122 float maxLayers = 24.f);
124 [[nodiscard]] DecalEdgeFadeStatus setEdgeFade(int id, float width);
125
132 int replace(int previousId, DecalInstance candidate);
133
135 void setLimit(const std::string &kind, int limit);
136
138 void update(float dt);
139
149 void drawAll(graphics::Graphics &gfx, float eyeX, float eyeY, float eyeZ,
150 const glm::mat4 &viewProj, float aspect);
151
153 std::vector<DecalInstance> &instances() { return decals_; }
155 const std::vector<DecalInstance> &instances() const { return decals_; }
156
157private:
158 DecalManager() = default;
159 ~DecalManager() = default;
160 DecalManager(const DecalManager &) = delete;
161 DecalManager &operator=(const DecalManager &) = delete;
162
163 int nextId_ = 1;
164 std::vector<DecalInstance> decals_;
165 struct KindLimit {
166 std::string kind;
167 int limit = 0; // 0 = unlimited
168 };
169 std::vector<KindLimit> limits_;
170 int limitFor(const std::string &kind) const;
171};
172
173} // namespace eve::decal
float w
Definition AnimClip.cpp:738
float y
Definition AnimClip.cpp:738
float x
Definition AnimClip.cpp:738
float z
Definition AnimClip.cpp:738
float normalStrength
float nx
float nz
float ny
graphics::Texture * albedo
#define EVENGINE_API_WORLD
Definition Export.h:109
int h
std::uint32_t width
TokenKind kind
std::array< float, 3 > scale
Texture * normal
std::weak_ptr< const void > lifetime
std::uint32_t seed
Definition PointSet.cpp:807
glm::mat4 viewProj
std::uint32_t count
int limit
Definition TreeMesh.cpp:164
float size
Definition TreeMesh.cpp:156
std::uint32_t depth
CPU-side decal registry: spawn / remove / fade / quotas, and the per-frame drawer that feeds the grap...
const std::vector< DecalInstance > & instances() const
Instances.
std::vector< DecalInstance > & instances()
Instances.
GPU texture created via Graphics::newTexture. Owns GPU resources through an opaque backend handle.
Definition Texture.h:18
std::vector< ParamSpec > params
DecalParallaxStatus
Outcome of applying height-driven parallax settings to a live decal.
DecalProjectionStatus
Outcome of DecalManager::setProjection / Decal::setProjection.
DecalEdgeFadeStatus
Outcome of changing the projection-volume edge mask width.
卡牌游戏 UI 工具模块:工厂 + 脚本绑定入口。 功能参考 ycarowr/UiCard:扇形手牌布局、抽牌/洗牌、悬浮放大、拖拽到落牌区、 敌方手牌(背面/偷看)、费用不足置灰,以及可实时调节的布局...
Definition Animation.h:25
One live decal instance (CPU-side state; GPU draw happens per frame).
graphics::Texture * normal
graphics::Texture * albedo
graphics::Texture * params