载入中...
搜索中...
未找到
Light.cpp
浏览该文件的文档.
1#include "graphics/Light.h"
2
3namespace eve::graphics {
4
5Light2D *Light2D::createLight(const std::string &type) {
6 Light2D *l = Light2D::create();
7 ASSERT(l != nullptr);
8 l->data()->entity = l;
9 l->setType(type);
10 return l;
11}
12
13void Light2D::setType(const std::string &type) {
14 auto d = data();
15 if (type == "dir" || type == "point")
16 d->type = type;
17 else
18 d->type = "point";
19}
20
21std::string Light2D::getType() { return data()->type; }
22
23void Light2D::setPosition(float x, float y) {
24 data()->x = x;
25 data()->y = y;
26}
27
28float Light2D::getX() { return data()->x; }
29float Light2D::getY() { return data()->y; }
30
31void Light2D::setDirection(float dx, float dy) {
32 data()->dx = dx;
33 data()->dy = dy;
34}
35
36float Light2D::getDirX() { return data()->dx; }
37float Light2D::getDirY() { return data()->dy; }
38
39void Light2D::setColor(float r, float g, float b, float intensity) {
40 auto d = data();
41 d->r = r;
42 d->g = g;
43 d->b = b;
44 d->intensity = intensity;
45}
46
47void Light2D::setRadius(float radius) { data()->radius = radius > 0.f ? radius : 0.f; }
48float Light2D::getRadius() { return data()->radius; }
49
50void Light2D::setEnabled(bool enabled) { data()->enabled = enabled; }
51bool Light2D::isEnabled() { return data()->enabled; }
52
53void Light2D::setVolumetric(bool enabled) { data()->volumetric = enabled; }
54bool Light2D::getVolumetric() { return data()->volumetric; }
55
56void Light2D::setVolumetricIntensity(float intensity) {
57 data()->volumetricIntensity = intensity < 0.f ? 0.f : intensity;
58}
59float Light2D::getVolumetricIntensity() { return data()->volumetricIntensity; }
60
61void Light2D::setCanvas(Canvas *canvas) { data()->canvas = canvas; }
62
63Light3D *Light3D::createLight(const std::string &type) {
64 Light3D *l = Light3D::create();
65 ASSERT(l != nullptr);
66 l->data()->entity = l;
67 l->setType(type);
68 return l;
69}
70
71void Light3D::setType(const std::string &type) {
72 auto d = data();
73 if (type == "dir" || type == "point")
74 d->type = type;
75 else
76 d->type = "point";
77}
78
79std::string Light3D::getType() { return data()->type; }
80
81void Light3D::setPosition(float x, float y, float z) {
82 auto d = data();
83 d->x = x;
84 d->y = y;
85 d->z = z;
86}
87
88float Light3D::getX() { return data()->x; }
89float Light3D::getY() { return data()->y; }
90float Light3D::getZ() { return data()->z; }
91
92void Light3D::setDirection(float dx, float dy, float dz) {
93 auto d = data();
94 d->dx = dx;
95 d->dy = dy;
96 d->dz = dz;
97}
98
99float Light3D::getDirX() { return data()->dx; }
100float Light3D::getDirY() { return data()->dy; }
101float Light3D::getDirZ() { return data()->dz; }
102
103void Light3D::setColor(float r, float g, float b, float intensity) {
104 auto d = data();
105 d->r = r;
106 d->g = g;
107 d->b = b;
108 d->intensity = intensity;
109}
110
111void Light3D::setRadius(float radius) { data()->radius = radius > 0.f ? radius : 0.f; }
112float Light3D::getRadius() { return data()->radius; }
113
114void Light3D::setEnabled(bool enabled) { data()->enabled = enabled; }
115bool Light3D::isEnabled() { return data()->enabled; }
116
117void Light3D::setCastShadow(bool cast) { data()->castShadow = cast; }
118bool Light3D::getCastShadow() { return data()->castShadow; }
119
120void Light3D::setShadowBias(float bias) { data()->shadowBias = bias < 0.f ? 0.f : bias; }
121float Light3D::getShadowBias() { return data()->shadowBias; }
122
123void Light3D::setShadowStrength(float strength) {
124 data()->shadowStrength = strength < 0.f ? 0.f : (strength > 1.f ? 1.f : strength);
125}
126float Light3D::getShadowStrength() { return data()->shadowStrength; }
127
128void Light3D::setVolumetric(bool enabled) { data()->volumetric = enabled; }
129bool Light3D::getVolumetric() { return data()->volumetric; }
130
131void Light3D::setVolumetricIntensity(float intensity) {
132 data()->volumetricIntensity = intensity < 0.f ? 0.f : intensity;
133}
134float Light3D::getVolumetricIntensity() { return data()->volumetricIntensity; }
135
136} // namespace eve::graphics
std::string type
int y
Definition Grass.cpp:135
int z
Definition Grass.cpp:135
int x
Definition Grass.cpp:135
uint32_t b
Light2D::Data * data
bool enabled
int d
Declarative 2D light. Collected by RenderSystem (max 8 per canvas/frame). type: "point" | "dir" (≤15 ...
Definition Light.h:31
float getVolumetricIntensity()
Definition Light.cpp:59
void setDirection(float dx, float dy)
Definition Light.cpp:31
void setPosition(float x, float y)
Definition Light.cpp:23
void setColor(float r, float g, float b, float intensity=1.f)
Definition Light.cpp:39
void setVolumetric(bool enabled)
Definition Light.cpp:53
void setCanvas(Canvas *canvas)
Definition Light.cpp:61
void setVolumetricIntensity(float intensity)
Definition Light.cpp:56
void setType(const std::string &type)
Definition Light.cpp:13
void setEnabled(bool enabled)
Definition Light.cpp:50
std::string getType()
Definition Light.cpp:21
static Light2D * createLight(const std::string &type="point")
Definition Light.cpp:5
void setRadius(float radius)
Definition Light.cpp:47
Declarative 3D light. Collected by RenderSystem3D (max 8 per frame). type: "point" | "dir" (≤15 chars...
Definition Light.h:101
void setEnabled(bool enabled)
Definition Light.cpp:114
void setCastShadow(bool cast)
Definition Light.cpp:117
void setDirection(float dx, float dy, float dz)
Definition Light.cpp:92
void setShadowBias(float bias)
Definition Light.cpp:120
float getVolumetricIntensity()
Definition Light.cpp:134
float getShadowStrength()
Definition Light.cpp:126
void setShadowStrength(float strength)
Definition Light.cpp:123
void setPosition(float x, float y, float z)
Definition Light.cpp:81
static Light3D * createLight(const std::string &type="point")
Definition Light.cpp:63
void setType(const std::string &type)
Definition Light.cpp:71
void setVolumetricIntensity(float intensity)
Definition Light.cpp:131
void setRadius(float radius)
Definition Light.cpp:111
void setColor(float r, float g, float b, float intensity=1.f)
Definition Light.cpp:103
void setVolumetric(bool enabled)
Definition Light.cpp:128
std::string getType()
Definition Light.cpp:79
卡牌游戏 UI 工具模块:工厂 + 脚本绑定入口。 功能参考 ycarowr/UiCard:扇形手牌布局、抽牌/洗牌、悬浮放大、拖拽到落牌区、 敌方手牌(背面/偷看)、费用不足置灰,以及可实时调节的布局...
Definition AnimTrail.h:6