1 /**
2 Type of $(D Sky) that is generated procedurally based on user input parameters.
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.proceduralsky;
14 import std.meta : AliasSeq, staticIndexOf;
15 import std.traits : Unqual;
16 import godot.d.traits;
17 import godot.core;
18 import godot.c;
19 import godot.d.bind;
20 import godot.d.reference;
21 import godot.globalenums;
22 import godot.object;
23 import godot.classdb;
24 import godot.sky;
25 import godot.image;
26 /**
27 Type of $(D Sky) that is generated procedurally based on user input parameters.
28 
29 ProceduralSky provides a way to create an effective background quickly by defining procedural parameters for the sun, the sky and the ground. The sky and ground are very similar, they are defined by a color at the horizon, another color, and finally an easing curve to interpolate between these two colors. Similarly, the sun is described by a position in the sky, a color, and an easing curve. However, the sun also defines a minimum and maximum angle, these two values define at what distance the easing curve begins and ends from the sun, and thus end up defining the size of the sun in the sky.
30 The ProceduralSky is updated on the CPU after the parameters change. It is stored in a texture and then displayed as a background in the scene. This makes it relatively unsuitable for real-time updates during gameplay. However, with a small enough texture size, it can still be updated relatively frequently, as it is updated on a background thread when multi-threading is available.
31 */
32 @GodotBaseClass struct ProceduralSky
33 {
34 	package(godot) enum string _GODOT_internal_name = "ProceduralSky";
35 public:
36 @nogc nothrow:
37 	union { /** */ godot_object _godot_object; /** */ Sky _GODOT_base; }
38 	alias _GODOT_base this;
39 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
40 	package(godot) __gshared bool _classBindingInitialized = false;
41 	package(godot) static struct GDNativeClassBinding
42 	{
43 		__gshared:
44 		@GodotName("_thread_done") GodotMethod!(void, Image) _threadDone;
45 		@GodotName("_update_sky") GodotMethod!(void) _updateSky;
46 		@GodotName("get_ground_bottom_color") GodotMethod!(Color) getGroundBottomColor;
47 		@GodotName("get_ground_curve") GodotMethod!(double) getGroundCurve;
48 		@GodotName("get_ground_energy") GodotMethod!(double) getGroundEnergy;
49 		@GodotName("get_ground_horizon_color") GodotMethod!(Color) getGroundHorizonColor;
50 		@GodotName("get_sky_curve") GodotMethod!(double) getSkyCurve;
51 		@GodotName("get_sky_energy") GodotMethod!(double) getSkyEnergy;
52 		@GodotName("get_sky_horizon_color") GodotMethod!(Color) getSkyHorizonColor;
53 		@GodotName("get_sky_top_color") GodotMethod!(Color) getSkyTopColor;
54 		@GodotName("get_sun_angle_max") GodotMethod!(double) getSunAngleMax;
55 		@GodotName("get_sun_angle_min") GodotMethod!(double) getSunAngleMin;
56 		@GodotName("get_sun_color") GodotMethod!(Color) getSunColor;
57 		@GodotName("get_sun_curve") GodotMethod!(double) getSunCurve;
58 		@GodotName("get_sun_energy") GodotMethod!(double) getSunEnergy;
59 		@GodotName("get_sun_latitude") GodotMethod!(double) getSunLatitude;
60 		@GodotName("get_sun_longitude") GodotMethod!(double) getSunLongitude;
61 		@GodotName("get_texture_size") GodotMethod!(ProceduralSky.TextureSize) getTextureSize;
62 		@GodotName("set_ground_bottom_color") GodotMethod!(void, Color) setGroundBottomColor;
63 		@GodotName("set_ground_curve") GodotMethod!(void, double) setGroundCurve;
64 		@GodotName("set_ground_energy") GodotMethod!(void, double) setGroundEnergy;
65 		@GodotName("set_ground_horizon_color") GodotMethod!(void, Color) setGroundHorizonColor;
66 		@GodotName("set_sky_curve") GodotMethod!(void, double) setSkyCurve;
67 		@GodotName("set_sky_energy") GodotMethod!(void, double) setSkyEnergy;
68 		@GodotName("set_sky_horizon_color") GodotMethod!(void, Color) setSkyHorizonColor;
69 		@GodotName("set_sky_top_color") GodotMethod!(void, Color) setSkyTopColor;
70 		@GodotName("set_sun_angle_max") GodotMethod!(void, double) setSunAngleMax;
71 		@GodotName("set_sun_angle_min") GodotMethod!(void, double) setSunAngleMin;
72 		@GodotName("set_sun_color") GodotMethod!(void, Color) setSunColor;
73 		@GodotName("set_sun_curve") GodotMethod!(void, double) setSunCurve;
74 		@GodotName("set_sun_energy") GodotMethod!(void, double) setSunEnergy;
75 		@GodotName("set_sun_latitude") GodotMethod!(void, double) setSunLatitude;
76 		@GodotName("set_sun_longitude") GodotMethod!(void, double) setSunLongitude;
77 		@GodotName("set_texture_size") GodotMethod!(void, long) setTextureSize;
78 	}
79 	/// 
80 	pragma(inline, true) bool opEquals(in ProceduralSky other) const
81 	{ return _godot_object.ptr is other._godot_object.ptr; }
82 	/// 
83 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
84 	{ _godot_object.ptr = n; return null; }
85 	/// 
86 	pragma(inline, true) bool opEquals(typeof(null) n) const
87 	{ return _godot_object.ptr is n; }
88 	/// 
89 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
90 	mixin baseCasts;
91 	/// Construct a new instance of ProceduralSky.
92 	/// Note: use `memnew!ProceduralSky` instead.
93 	static ProceduralSky _new()
94 	{
95 		static godot_class_constructor constructor;
96 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("ProceduralSky");
97 		if(constructor is null) return typeof(this).init;
98 		return cast(ProceduralSky)(constructor());
99 	}
100 	@disable new(size_t s);
101 	/// 
102 	enum TextureSize : int
103 	{
104 		/**
105 		Sky texture will be 256x128.
106 		*/
107 		textureSize256 = 0,
108 		/**
109 		Sky texture will be 512x256.
110 		*/
111 		textureSize512 = 1,
112 		/**
113 		Sky texture will be 1024x512. This is the default size.
114 		*/
115 		textureSize1024 = 2,
116 		/**
117 		Sky texture will be 2048x1024.
118 		*/
119 		textureSize2048 = 3,
120 		/**
121 		Sky texture will be 4096x2048.
122 		*/
123 		textureSize4096 = 4,
124 		/**
125 		Represents the size of the $(D texturesize) enum.
126 		*/
127 		textureSizeMax = 5,
128 	}
129 	/// 
130 	enum Constants : int
131 	{
132 		textureSize256 = 0,
133 		textureSize512 = 1,
134 		textureSize1024 = 2,
135 		textureSize2048 = 3,
136 		textureSize4096 = 4,
137 		textureSizeMax = 5,
138 	}
139 	/**
140 	
141 	*/
142 	void _threadDone(Image image)
143 	{
144 		Array _GODOT_args = Array.make();
145 		_GODOT_args.append(image);
146 		String _GODOT_method_name = String("_thread_done");
147 		this.callv(_GODOT_method_name, _GODOT_args);
148 	}
149 	/**
150 	
151 	*/
152 	void _updateSky()
153 	{
154 		Array _GODOT_args = Array.make();
155 		String _GODOT_method_name = String("_update_sky");
156 		this.callv(_GODOT_method_name, _GODOT_args);
157 	}
158 	/**
159 	
160 	*/
161 	Color getGroundBottomColor() const
162 	{
163 		checkClassBinding!(typeof(this))();
164 		return ptrcall!(Color)(GDNativeClassBinding.getGroundBottomColor, _godot_object);
165 	}
166 	/**
167 	
168 	*/
169 	double getGroundCurve() const
170 	{
171 		checkClassBinding!(typeof(this))();
172 		return ptrcall!(double)(GDNativeClassBinding.getGroundCurve, _godot_object);
173 	}
174 	/**
175 	
176 	*/
177 	double getGroundEnergy() const
178 	{
179 		checkClassBinding!(typeof(this))();
180 		return ptrcall!(double)(GDNativeClassBinding.getGroundEnergy, _godot_object);
181 	}
182 	/**
183 	
184 	*/
185 	Color getGroundHorizonColor() const
186 	{
187 		checkClassBinding!(typeof(this))();
188 		return ptrcall!(Color)(GDNativeClassBinding.getGroundHorizonColor, _godot_object);
189 	}
190 	/**
191 	
192 	*/
193 	double getSkyCurve() const
194 	{
195 		checkClassBinding!(typeof(this))();
196 		return ptrcall!(double)(GDNativeClassBinding.getSkyCurve, _godot_object);
197 	}
198 	/**
199 	
200 	*/
201 	double getSkyEnergy() const
202 	{
203 		checkClassBinding!(typeof(this))();
204 		return ptrcall!(double)(GDNativeClassBinding.getSkyEnergy, _godot_object);
205 	}
206 	/**
207 	
208 	*/
209 	Color getSkyHorizonColor() const
210 	{
211 		checkClassBinding!(typeof(this))();
212 		return ptrcall!(Color)(GDNativeClassBinding.getSkyHorizonColor, _godot_object);
213 	}
214 	/**
215 	
216 	*/
217 	Color getSkyTopColor() const
218 	{
219 		checkClassBinding!(typeof(this))();
220 		return ptrcall!(Color)(GDNativeClassBinding.getSkyTopColor, _godot_object);
221 	}
222 	/**
223 	
224 	*/
225 	double getSunAngleMax() const
226 	{
227 		checkClassBinding!(typeof(this))();
228 		return ptrcall!(double)(GDNativeClassBinding.getSunAngleMax, _godot_object);
229 	}
230 	/**
231 	
232 	*/
233 	double getSunAngleMin() const
234 	{
235 		checkClassBinding!(typeof(this))();
236 		return ptrcall!(double)(GDNativeClassBinding.getSunAngleMin, _godot_object);
237 	}
238 	/**
239 	
240 	*/
241 	Color getSunColor() const
242 	{
243 		checkClassBinding!(typeof(this))();
244 		return ptrcall!(Color)(GDNativeClassBinding.getSunColor, _godot_object);
245 	}
246 	/**
247 	
248 	*/
249 	double getSunCurve() const
250 	{
251 		checkClassBinding!(typeof(this))();
252 		return ptrcall!(double)(GDNativeClassBinding.getSunCurve, _godot_object);
253 	}
254 	/**
255 	
256 	*/
257 	double getSunEnergy() const
258 	{
259 		checkClassBinding!(typeof(this))();
260 		return ptrcall!(double)(GDNativeClassBinding.getSunEnergy, _godot_object);
261 	}
262 	/**
263 	
264 	*/
265 	double getSunLatitude() const
266 	{
267 		checkClassBinding!(typeof(this))();
268 		return ptrcall!(double)(GDNativeClassBinding.getSunLatitude, _godot_object);
269 	}
270 	/**
271 	
272 	*/
273 	double getSunLongitude() const
274 	{
275 		checkClassBinding!(typeof(this))();
276 		return ptrcall!(double)(GDNativeClassBinding.getSunLongitude, _godot_object);
277 	}
278 	/**
279 	
280 	*/
281 	ProceduralSky.TextureSize getTextureSize() const
282 	{
283 		checkClassBinding!(typeof(this))();
284 		return ptrcall!(ProceduralSky.TextureSize)(GDNativeClassBinding.getTextureSize, _godot_object);
285 	}
286 	/**
287 	
288 	*/
289 	void setGroundBottomColor(in Color color)
290 	{
291 		checkClassBinding!(typeof(this))();
292 		ptrcall!(void)(GDNativeClassBinding.setGroundBottomColor, _godot_object, color);
293 	}
294 	/**
295 	
296 	*/
297 	void setGroundCurve(in double curve)
298 	{
299 		checkClassBinding!(typeof(this))();
300 		ptrcall!(void)(GDNativeClassBinding.setGroundCurve, _godot_object, curve);
301 	}
302 	/**
303 	
304 	*/
305 	void setGroundEnergy(in double energy)
306 	{
307 		checkClassBinding!(typeof(this))();
308 		ptrcall!(void)(GDNativeClassBinding.setGroundEnergy, _godot_object, energy);
309 	}
310 	/**
311 	
312 	*/
313 	void setGroundHorizonColor(in Color color)
314 	{
315 		checkClassBinding!(typeof(this))();
316 		ptrcall!(void)(GDNativeClassBinding.setGroundHorizonColor, _godot_object, color);
317 	}
318 	/**
319 	
320 	*/
321 	void setSkyCurve(in double curve)
322 	{
323 		checkClassBinding!(typeof(this))();
324 		ptrcall!(void)(GDNativeClassBinding.setSkyCurve, _godot_object, curve);
325 	}
326 	/**
327 	
328 	*/
329 	void setSkyEnergy(in double energy)
330 	{
331 		checkClassBinding!(typeof(this))();
332 		ptrcall!(void)(GDNativeClassBinding.setSkyEnergy, _godot_object, energy);
333 	}
334 	/**
335 	
336 	*/
337 	void setSkyHorizonColor(in Color color)
338 	{
339 		checkClassBinding!(typeof(this))();
340 		ptrcall!(void)(GDNativeClassBinding.setSkyHorizonColor, _godot_object, color);
341 	}
342 	/**
343 	
344 	*/
345 	void setSkyTopColor(in Color color)
346 	{
347 		checkClassBinding!(typeof(this))();
348 		ptrcall!(void)(GDNativeClassBinding.setSkyTopColor, _godot_object, color);
349 	}
350 	/**
351 	
352 	*/
353 	void setSunAngleMax(in double degrees)
354 	{
355 		checkClassBinding!(typeof(this))();
356 		ptrcall!(void)(GDNativeClassBinding.setSunAngleMax, _godot_object, degrees);
357 	}
358 	/**
359 	
360 	*/
361 	void setSunAngleMin(in double degrees)
362 	{
363 		checkClassBinding!(typeof(this))();
364 		ptrcall!(void)(GDNativeClassBinding.setSunAngleMin, _godot_object, degrees);
365 	}
366 	/**
367 	
368 	*/
369 	void setSunColor(in Color color)
370 	{
371 		checkClassBinding!(typeof(this))();
372 		ptrcall!(void)(GDNativeClassBinding.setSunColor, _godot_object, color);
373 	}
374 	/**
375 	
376 	*/
377 	void setSunCurve(in double curve)
378 	{
379 		checkClassBinding!(typeof(this))();
380 		ptrcall!(void)(GDNativeClassBinding.setSunCurve, _godot_object, curve);
381 	}
382 	/**
383 	
384 	*/
385 	void setSunEnergy(in double energy)
386 	{
387 		checkClassBinding!(typeof(this))();
388 		ptrcall!(void)(GDNativeClassBinding.setSunEnergy, _godot_object, energy);
389 	}
390 	/**
391 	
392 	*/
393 	void setSunLatitude(in double degrees)
394 	{
395 		checkClassBinding!(typeof(this))();
396 		ptrcall!(void)(GDNativeClassBinding.setSunLatitude, _godot_object, degrees);
397 	}
398 	/**
399 	
400 	*/
401 	void setSunLongitude(in double degrees)
402 	{
403 		checkClassBinding!(typeof(this))();
404 		ptrcall!(void)(GDNativeClassBinding.setSunLongitude, _godot_object, degrees);
405 	}
406 	/**
407 	
408 	*/
409 	void setTextureSize(in long size)
410 	{
411 		checkClassBinding!(typeof(this))();
412 		ptrcall!(void)(GDNativeClassBinding.setTextureSize, _godot_object, size);
413 	}
414 	/**
415 	Color of the ground at the bottom.
416 	*/
417 	@property Color groundBottomColor()
418 	{
419 		return getGroundBottomColor();
420 	}
421 	/// ditto
422 	@property void groundBottomColor(Color v)
423 	{
424 		setGroundBottomColor(v);
425 	}
426 	/**
427 	How quickly the $(D groundHorizonColor) fades into the $(D groundBottomColor).
428 	*/
429 	@property double groundCurve()
430 	{
431 		return getGroundCurve();
432 	}
433 	/// ditto
434 	@property void groundCurve(double v)
435 	{
436 		setGroundCurve(v);
437 	}
438 	/**
439 	Amount of energy contribution from the ground.
440 	*/
441 	@property double groundEnergy()
442 	{
443 		return getGroundEnergy();
444 	}
445 	/// ditto
446 	@property void groundEnergy(double v)
447 	{
448 		setGroundEnergy(v);
449 	}
450 	/**
451 	Color of the ground at the horizon.
452 	*/
453 	@property Color groundHorizonColor()
454 	{
455 		return getGroundHorizonColor();
456 	}
457 	/// ditto
458 	@property void groundHorizonColor(Color v)
459 	{
460 		setGroundHorizonColor(v);
461 	}
462 	/**
463 	How quickly the $(D skyHorizonColor) fades into the $(D skyTopColor).
464 	*/
465 	@property double skyCurve()
466 	{
467 		return getSkyCurve();
468 	}
469 	/// ditto
470 	@property void skyCurve(double v)
471 	{
472 		setSkyCurve(v);
473 	}
474 	/**
475 	Amount of energy contribution from the sky.
476 	*/
477 	@property double skyEnergy()
478 	{
479 		return getSkyEnergy();
480 	}
481 	/// ditto
482 	@property void skyEnergy(double v)
483 	{
484 		setSkyEnergy(v);
485 	}
486 	/**
487 	Color of the sky at the horizon.
488 	*/
489 	@property Color skyHorizonColor()
490 	{
491 		return getSkyHorizonColor();
492 	}
493 	/// ditto
494 	@property void skyHorizonColor(Color v)
495 	{
496 		setSkyHorizonColor(v);
497 	}
498 	/**
499 	Color of the sky at the top.
500 	*/
501 	@property Color skyTopColor()
502 	{
503 		return getSkyTopColor();
504 	}
505 	/// ditto
506 	@property void skyTopColor(Color v)
507 	{
508 		setSkyTopColor(v);
509 	}
510 	/**
511 	Distance from center of sun where it fades out completely.
512 	*/
513 	@property double sunAngleMax()
514 	{
515 		return getSunAngleMax();
516 	}
517 	/// ditto
518 	@property void sunAngleMax(double v)
519 	{
520 		setSunAngleMax(v);
521 	}
522 	/**
523 	Distance from sun where it goes from solid to starting to fade.
524 	*/
525 	@property double sunAngleMin()
526 	{
527 		return getSunAngleMin();
528 	}
529 	/// ditto
530 	@property void sunAngleMin(double v)
531 	{
532 		setSunAngleMin(v);
533 	}
534 	/**
535 	The sun's color.
536 	*/
537 	@property Color sunColor()
538 	{
539 		return getSunColor();
540 	}
541 	/// ditto
542 	@property void sunColor(Color v)
543 	{
544 		setSunColor(v);
545 	}
546 	/**
547 	How quickly the sun fades away between $(D sunAngleMin) and $(D sunAngleMax).
548 	*/
549 	@property double sunCurve()
550 	{
551 		return getSunCurve();
552 	}
553 	/// ditto
554 	@property void sunCurve(double v)
555 	{
556 		setSunCurve(v);
557 	}
558 	/**
559 	Amount of energy contribution from the sun.
560 	*/
561 	@property double sunEnergy()
562 	{
563 		return getSunEnergy();
564 	}
565 	/// ditto
566 	@property void sunEnergy(double v)
567 	{
568 		setSunEnergy(v);
569 	}
570 	/**
571 	The sun's height using polar coordinates.
572 	*/
573 	@property double sunLatitude()
574 	{
575 		return getSunLatitude();
576 	}
577 	/// ditto
578 	@property void sunLatitude(double v)
579 	{
580 		setSunLatitude(v);
581 	}
582 	/**
583 	The direction of the sun using polar coordinates.
584 	*/
585 	@property double sunLongitude()
586 	{
587 		return getSunLongitude();
588 	}
589 	/// ditto
590 	@property void sunLongitude(double v)
591 	{
592 		setSunLongitude(v);
593 	}
594 	/**
595 	Size of $(D Texture) that the ProceduralSky will generate. The size is set using $(D texturesize).
596 	*/
597 	@property ProceduralSky.TextureSize textureSize()
598 	{
599 		return getTextureSize();
600 	}
601 	/// ditto
602 	@property void textureSize(long v)
603 	{
604 		setTextureSize(v);
605 	}
606 }