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