1 /**
2 Provides a base class for different kinds of light nodes.
3 
4 Copyright:
5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur.  
6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md)  
7 Copyright (c) 2017-2018 Godot-D contributors  
8 
9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License)
10 
11 
12 */
13 module godot.light;
14 import std.meta : AliasSeq, staticIndexOf;
15 import std.traits : Unqual;
16 import godot.d.meta;
17 import godot.core;
18 import godot.c;
19 import godot.d.bind;
20 import godot.d.reference;
21 import godot.object;
22 import godot.visualinstance;
23 import godot.spatial;
24 import godot.node;
25 /**
26 Provides a base class for different kinds of light nodes.
27 
28 Light is the abstract base class for light nodes, so it shouldn't be used directly (It can't be instanced). Other types of light nodes inherit from it. Light contains the common variables and parameters used for lighting.
29 */
30 @GodotBaseClass struct Light
31 {
32 	enum string _GODOT_internal_name = "Light";
33 public:
34 @nogc nothrow:
35 	union { godot_object _godot_object; VisualInstance _GODOT_base; }
36 	alias _GODOT_base this;
37 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
38 	package(godot) __gshared bool _classBindingInitialized = false;
39 	package(godot) static struct _classBinding
40 	{
41 		__gshared:
42 		@GodotName("set_editor_only") GodotMethod!(void, bool) setEditorOnly;
43 		@GodotName("is_editor_only") GodotMethod!(bool) isEditorOnly;
44 		@GodotName("set_param") GodotMethod!(void, long, double) setParam;
45 		@GodotName("get_param") GodotMethod!(double, long) getParam;
46 		@GodotName("set_shadow") GodotMethod!(void, bool) setShadow;
47 		@GodotName("has_shadow") GodotMethod!(bool) hasShadow;
48 		@GodotName("set_negative") GodotMethod!(void, bool) setNegative;
49 		@GodotName("is_negative") GodotMethod!(bool) isNegative;
50 		@GodotName("set_cull_mask") GodotMethod!(void, long) setCullMask;
51 		@GodotName("get_cull_mask") GodotMethod!(long) getCullMask;
52 		@GodotName("set_color") GodotMethod!(void, Color) setColor;
53 		@GodotName("get_color") GodotMethod!(Color) getColor;
54 		@GodotName("set_shadow_reverse_cull_face") GodotMethod!(void, bool) setShadowReverseCullFace;
55 		@GodotName("get_shadow_reverse_cull_face") GodotMethod!(bool) getShadowReverseCullFace;
56 		@GodotName("set_shadow_color") GodotMethod!(void, Color) setShadowColor;
57 		@GodotName("get_shadow_color") GodotMethod!(Color) getShadowColor;
58 		@GodotName("set_bake_mode") GodotMethod!(void, long) setBakeMode;
59 		@GodotName("get_bake_mode") GodotMethod!(Light.BakeMode) getBakeMode;
60 	}
61 	bool opEquals(in Light other) const { return _godot_object.ptr is other._godot_object.ptr; }
62 	Light opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; }
63 	bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; }
64 	mixin baseCasts;
65 	static Light _new()
66 	{
67 		static godot_class_constructor constructor;
68 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("Light");
69 		if(constructor is null) return typeof(this).init;
70 		return cast(Light)(constructor());
71 	}
72 	@disable new(size_t s);
73 	/// 
74 	enum BakeMode : int
75 	{
76 		/**
77 		Light is ignored when baking. Note: hiding a light does $(I not) affect baking.
78 		*/
79 		bakeDisabled = 0,
80 		/**
81 		Only indirect lighting will be baked. Default value.
82 		*/
83 		bakeIndirect = 1,
84 		/**
85 		Both direct and indirect light will be baked. Note: you should hide the light if you don't want it to appear twice (dynamic and baked).
86 		*/
87 		bakeAll = 2,
88 	}
89 	/// 
90 	enum Param : int
91 	{
92 		/**
93 		
94 		*/
95 		paramEnergy = 0,
96 		/**
97 		
98 		*/
99 		paramIndirectEnergy = 1,
100 		/**
101 		
102 		*/
103 		paramSpecular = 2,
104 		/**
105 		
106 		*/
107 		paramRange = 3,
108 		/**
109 		
110 		*/
111 		paramAttenuation = 4,
112 		/**
113 		
114 		*/
115 		paramSpotAngle = 5,
116 		/**
117 		
118 		*/
119 		paramSpotAttenuation = 6,
120 		/**
121 		
122 		*/
123 		paramContactShadowSize = 7,
124 		/**
125 		
126 		*/
127 		paramShadowMaxDistance = 8,
128 		/**
129 		
130 		*/
131 		paramShadowSplit1Offset = 9,
132 		/**
133 		
134 		*/
135 		paramShadowSplit2Offset = 10,
136 		/**
137 		
138 		*/
139 		paramShadowSplit3Offset = 11,
140 		/**
141 		
142 		*/
143 		paramShadowNormalBias = 12,
144 		/**
145 		
146 		*/
147 		paramShadowBias = 13,
148 		/**
149 		
150 		*/
151 		paramShadowBiasSplitScale = 14,
152 		/**
153 		
154 		*/
155 		paramMax = 15,
156 	}
157 	/// 
158 	enum Constants : int
159 	{
160 		paramEnergy = 0,
161 		bakeDisabled = 0,
162 		paramIndirectEnergy = 1,
163 		bakeIndirect = 1,
164 		bakeAll = 2,
165 		paramSpecular = 2,
166 		paramRange = 3,
167 		paramAttenuation = 4,
168 		paramSpotAngle = 5,
169 		paramSpotAttenuation = 6,
170 		paramContactShadowSize = 7,
171 		paramShadowMaxDistance = 8,
172 		paramShadowSplit1Offset = 9,
173 		paramShadowSplit2Offset = 10,
174 		paramShadowSplit3Offset = 11,
175 		paramShadowNormalBias = 12,
176 		paramShadowBias = 13,
177 		paramShadowBiasSplitScale = 14,
178 		paramMax = 15,
179 	}
180 	/**
181 	
182 	*/
183 	void setEditorOnly(in bool editor_only)
184 	{
185 		checkClassBinding!(typeof(this))();
186 		ptrcall!(void)(_classBinding.setEditorOnly, _godot_object, editor_only);
187 	}
188 	/**
189 	
190 	*/
191 	bool isEditorOnly() const
192 	{
193 		checkClassBinding!(typeof(this))();
194 		return ptrcall!(bool)(_classBinding.isEditorOnly, _godot_object);
195 	}
196 	/**
197 	
198 	*/
199 	void setParam(in long param, in double value)
200 	{
201 		checkClassBinding!(typeof(this))();
202 		ptrcall!(void)(_classBinding.setParam, _godot_object, param, value);
203 	}
204 	/**
205 	
206 	*/
207 	double getParam(in long param) const
208 	{
209 		checkClassBinding!(typeof(this))();
210 		return ptrcall!(double)(_classBinding.getParam, _godot_object, param);
211 	}
212 	/**
213 	
214 	*/
215 	void setShadow(in bool enabled)
216 	{
217 		checkClassBinding!(typeof(this))();
218 		ptrcall!(void)(_classBinding.setShadow, _godot_object, enabled);
219 	}
220 	/**
221 	
222 	*/
223 	bool hasShadow() const
224 	{
225 		checkClassBinding!(typeof(this))();
226 		return ptrcall!(bool)(_classBinding.hasShadow, _godot_object);
227 	}
228 	/**
229 	
230 	*/
231 	void setNegative(in bool enabled)
232 	{
233 		checkClassBinding!(typeof(this))();
234 		ptrcall!(void)(_classBinding.setNegative, _godot_object, enabled);
235 	}
236 	/**
237 	
238 	*/
239 	bool isNegative() const
240 	{
241 		checkClassBinding!(typeof(this))();
242 		return ptrcall!(bool)(_classBinding.isNegative, _godot_object);
243 	}
244 	/**
245 	
246 	*/
247 	void setCullMask(in long cull_mask)
248 	{
249 		checkClassBinding!(typeof(this))();
250 		ptrcall!(void)(_classBinding.setCullMask, _godot_object, cull_mask);
251 	}
252 	/**
253 	
254 	*/
255 	long getCullMask() const
256 	{
257 		checkClassBinding!(typeof(this))();
258 		return ptrcall!(long)(_classBinding.getCullMask, _godot_object);
259 	}
260 	/**
261 	
262 	*/
263 	void setColor(in Color color)
264 	{
265 		checkClassBinding!(typeof(this))();
266 		ptrcall!(void)(_classBinding.setColor, _godot_object, color);
267 	}
268 	/**
269 	
270 	*/
271 	Color getColor() const
272 	{
273 		checkClassBinding!(typeof(this))();
274 		return ptrcall!(Color)(_classBinding.getColor, _godot_object);
275 	}
276 	/**
277 	
278 	*/
279 	void setShadowReverseCullFace(in bool enable)
280 	{
281 		checkClassBinding!(typeof(this))();
282 		ptrcall!(void)(_classBinding.setShadowReverseCullFace, _godot_object, enable);
283 	}
284 	/**
285 	
286 	*/
287 	bool getShadowReverseCullFace() const
288 	{
289 		checkClassBinding!(typeof(this))();
290 		return ptrcall!(bool)(_classBinding.getShadowReverseCullFace, _godot_object);
291 	}
292 	/**
293 	
294 	*/
295 	void setShadowColor(in Color shadow_color)
296 	{
297 		checkClassBinding!(typeof(this))();
298 		ptrcall!(void)(_classBinding.setShadowColor, _godot_object, shadow_color);
299 	}
300 	/**
301 	
302 	*/
303 	Color getShadowColor() const
304 	{
305 		checkClassBinding!(typeof(this))();
306 		return ptrcall!(Color)(_classBinding.getShadowColor, _godot_object);
307 	}
308 	/**
309 	
310 	*/
311 	void setBakeMode(in long bake_mode)
312 	{
313 		checkClassBinding!(typeof(this))();
314 		ptrcall!(void)(_classBinding.setBakeMode, _godot_object, bake_mode);
315 	}
316 	/**
317 	
318 	*/
319 	Light.BakeMode getBakeMode() const
320 	{
321 		checkClassBinding!(typeof(this))();
322 		return ptrcall!(Light.BakeMode)(_classBinding.getBakeMode, _godot_object);
323 	}
324 	/**
325 	The light's color.
326 	*/
327 	@property Color lightColor()
328 	{
329 		return getColor();
330 	}
331 	/// ditto
332 	@property void lightColor(Color v)
333 	{
334 		setColor(v);
335 	}
336 	/**
337 	The light's strength multiplier.
338 	*/
339 	@property double lightEnergy()
340 	{
341 		return getParam(0);
342 	}
343 	/// ditto
344 	@property void lightEnergy(double v)
345 	{
346 		setParam(0, v);
347 	}
348 	/**
349 	Secondary multiplier used with indirect light (light bounces). This works in baked light or GIProbe.
350 	*/
351 	@property double lightIndirectEnergy()
352 	{
353 		return getParam(1);
354 	}
355 	/// ditto
356 	@property void lightIndirectEnergy(double v)
357 	{
358 		setParam(1, v);
359 	}
360 	/**
361 	If `true` the light's effect is reversed, darkening areas and casting bright shadows. Default value: `false`.
362 	*/
363 	@property bool lightNegative()
364 	{
365 		return isNegative();
366 	}
367 	/// ditto
368 	@property void lightNegative(bool v)
369 	{
370 		setNegative(v);
371 	}
372 	/**
373 	The intensity of the specular blob in objects affected by the light. At `0` the light becomes a pure diffuse light.
374 	*/
375 	@property double lightSpecular()
376 	{
377 		return getParam(2);
378 	}
379 	/// ditto
380 	@property void lightSpecular(double v)
381 	{
382 		setParam(2, v);
383 	}
384 	/**
385 	The light's bake mode. See $(D bakemode).
386 	*/
387 	@property Light.BakeMode lightBakeMode()
388 	{
389 		return getBakeMode();
390 	}
391 	/// ditto
392 	@property void lightBakeMode(long v)
393 	{
394 		setBakeMode(v);
395 	}
396 	/**
397 	The light will affect objects in the selected layers.
398 	*/
399 	@property long lightCullMask()
400 	{
401 		return getCullMask();
402 	}
403 	/// ditto
404 	@property void lightCullMask(long v)
405 	{
406 		setCullMask(v);
407 	}
408 	/**
409 	If `true` the light will cast shadows. Default value: `false`.
410 	*/
411 	@property bool shadowEnabled()
412 	{
413 		return hasShadow();
414 	}
415 	/// ditto
416 	@property void shadowEnabled(bool v)
417 	{
418 		setShadow(v);
419 	}
420 	/**
421 	The color of shadows cast by this light.
422 	*/
423 	@property Color shadowColor()
424 	{
425 		return getShadowColor();
426 	}
427 	/// ditto
428 	@property void shadowColor(Color v)
429 	{
430 		setShadowColor(v);
431 	}
432 	/**
433 	Used to adjust shadow appearance. Too small a value results in self shadowing, while too large a value causes shadows to separate from casters. Adjust as needed.
434 	*/
435 	@property double shadowBias()
436 	{
437 		return getParam(13);
438 	}
439 	/// ditto
440 	@property void shadowBias(double v)
441 	{
442 		setParam(13, v);
443 	}
444 	/**
445 	Attempts to reduce $(D shadowBias) gap.
446 	*/
447 	@property double shadowContact()
448 	{
449 		return getParam(7);
450 	}
451 	/// ditto
452 	@property void shadowContact(double v)
453 	{
454 		setParam(7, v);
455 	}
456 	/**
457 	
458 	*/
459 	@property bool shadowReverseCullFace()
460 	{
461 		return getShadowReverseCullFace();
462 	}
463 	/// ditto
464 	@property void shadowReverseCullFace(bool v)
465 	{
466 		setShadowReverseCullFace(v);
467 	}
468 	/**
469 	If `true` the light only appears in the editor and will not be visible at runtime. Default value:`false`.
470 	*/
471 	@property bool editorOnly()
472 	{
473 		return isEditorOnly();
474 	}
475 	/// ditto
476 	@property void editorOnly(bool v)
477 	{
478 		setEditorOnly(v);
479 	}
480 }