1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
#include "baked_light_instance.h"
#include "scene/scene_string_names.h"
RID BakedLightInstance::get_baked_light_instance() const {
if (baked_light.is_null())
return RID();
else
return get_instance();
}
void BakedLightInstance::set_baked_light(const Ref<BakedLight>& p_baked_light) {
baked_light=p_baked_light;
RID base_rid;
if (baked_light.is_valid())
base_rid=baked_light->get_rid();
else
base_rid=RID();
set_base(base_rid);
if (is_inside_world()) {
emit_signal(SceneStringNames::get_singleton()->baked_light_changed);
// for (List<Node*>::Element *E=baked_geometry.front();E;E=E->next()) {
// VS::get_singleton()->instance_geometry_set_baked_light(E->get()->get_instance(),baked_light.is_valid()?get_instance():RID());
// }
}
}
Ref<BakedLight> BakedLightInstance::get_baked_light() const{
return baked_light;
}
AABB BakedLightInstance::get_aabb() const {
return AABB(Vector3(0,0,0),Vector3(1,1,1));
}
DVector<Face3> BakedLightInstance::get_faces(uint32_t p_usage_flags) const {
return DVector<Face3>();
}
void BakedLightInstance::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_baked_light","baked_light"),&BakedLightInstance::set_baked_light);
ObjectTypeDB::bind_method(_MD("get_baked_light"),&BakedLightInstance::get_baked_light);
ObjectTypeDB::bind_method(_MD("get_baked_light_instance"),&BakedLightInstance::get_baked_light_instance);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"baked_light",PROPERTY_HINT_RESOURCE_TYPE,"BakedLight"),_SCS("set_baked_light"),_SCS("get_baked_light"));
ADD_SIGNAL( MethodInfo("baked_light_changed"));
}
BakedLightInstance::BakedLightInstance() {
}
/////////////////////////
void BakedLightSampler::set_param(Param p_param,float p_value) {
ERR_FAIL_INDEX(p_param,PARAM_MAX);
params[p_param]=p_value;
VS::get_singleton()->baked_light_sampler_set_param(base,VS::BakedLightSamplerParam(p_param),p_value);
}
float BakedLightSampler::get_param(Param p_param) const{
ERR_FAIL_INDEX_V(p_param,PARAM_MAX,0);
return params[p_param];
}
void BakedLightSampler::set_resolution(int p_resolution){
ERR_FAIL_COND(p_resolution<4 || p_resolution>32);
resolution=p_resolution;
VS::get_singleton()->baked_light_sampler_set_resolution(base,resolution);
}
int BakedLightSampler::get_resolution() const {
return resolution;
}
AABB BakedLightSampler::get_aabb() const {
float r = get_param(PARAM_RADIUS);
return AABB( Vector3(-r,-r,-r),Vector3(r*2,r*2,r*2));
}
DVector<Face3> BakedLightSampler::get_faces(uint32_t p_usage_flags) const {
return DVector<Face3>();
}
void BakedLightSampler::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_param","param","value"),&BakedLightSampler::set_param);
ObjectTypeDB::bind_method(_MD("get_param","param"),&BakedLightSampler::get_param);
ObjectTypeDB::bind_method(_MD("set_resolution","resolution"),&BakedLightSampler::set_resolution);
ObjectTypeDB::bind_method(_MD("get_resolution"),&BakedLightSampler::get_resolution);
BIND_CONSTANT( PARAM_RADIUS );
BIND_CONSTANT( PARAM_STRENGTH );
BIND_CONSTANT( PARAM_ATTENUATION );
BIND_CONSTANT( PARAM_DETAIL_RATIO );
BIND_CONSTANT( PARAM_MAX );
ADD_PROPERTYI( PropertyInfo(Variant::REAL,"params/radius",PROPERTY_HINT_RANGE,"0.01,1024,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_RADIUS);
ADD_PROPERTYI( PropertyInfo(Variant::REAL,"params/strength",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_STRENGTH);
ADD_PROPERTYI( PropertyInfo(Variant::REAL,"params/attenuation",PROPERTY_HINT_EXP_EASING),_SCS("set_param"),_SCS("get_param"),PARAM_ATTENUATION);
ADD_PROPERTYI( PropertyInfo(Variant::REAL,"params/detail_ratio",PROPERTY_HINT_RANGE,"0.01,1.0,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_DETAIL_RATIO);
// ADD_PROPERTYI( PropertyInfo(Variant::REAL,"params/detail_ratio",PROPERTY_HINT_RANGE,"0,20,1"),_SCS("set_param"),_SCS("get_param"),PARAM_DETAIL_RATIO);
ADD_PROPERTY( PropertyInfo(Variant::REAL,"params/resolution",PROPERTY_HINT_RANGE,"4,32,1"),_SCS("set_resolution"),_SCS("get_resolution"));
}
BakedLightSampler::BakedLightSampler() {
base = VS::get_singleton()->baked_light_sampler_create();
set_base(base);
params[PARAM_RADIUS]=1.0;
params[PARAM_STRENGTH]=1.0;
params[PARAM_ATTENUATION]=1.0;
params[PARAM_DETAIL_RATIO]=0.1;
resolution=16;
}
BakedLightSampler::~BakedLightSampler(){
VS::get_singleton()->free(base);
}
|