1 /** 2 Omnidirectional light, such as a light bulb or a candle. 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.omnilight; 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.light; 25 import godot.visualinstance; 26 /** 27 Omnidirectional light, such as a light bulb or a candle. 28 29 An Omnidirectional light is a type of $(D Light) that emits light in all directions. The light is attenuated by distance and this attenuation can be configured by changing its energy, radius, and attenuation parameters. 30 $(B Note:) By default, only 32 OmniLights may affect a single mesh $(I resource) at once. Consider splitting your level into several meshes to decrease the likelihood that more than 32 lights will affect the same mesh resource. Splitting the level mesh will also improve frustum culling effectiveness, leading to greater performance. If you need to use more lights per mesh, you can increase $(D ProjectSettings.rendering/limits/rendering/maxLightsPerObject) at the cost of shader compilation times. 31 */ 32 @GodotBaseClass struct OmniLight 33 { 34 package(godot) enum string _GODOT_internal_name = "OmniLight"; 35 public: 36 @nogc nothrow: 37 union { /** */ godot_object _godot_object; /** */ Light _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("get_shadow_detail") GodotMethod!(OmniLight.ShadowDetail) getShadowDetail; 45 @GodotName("get_shadow_mode") GodotMethod!(OmniLight.ShadowMode) getShadowMode; 46 @GodotName("set_shadow_detail") GodotMethod!(void, long) setShadowDetail; 47 @GodotName("set_shadow_mode") GodotMethod!(void, long) setShadowMode; 48 } 49 /// 50 pragma(inline, true) bool opEquals(in OmniLight other) const 51 { return _godot_object.ptr is other._godot_object.ptr; } 52 /// 53 pragma(inline, true) typeof(null) opAssign(typeof(null) n) 54 { _godot_object.ptr = n; return null; } 55 /// 56 pragma(inline, true) bool opEquals(typeof(null) n) const 57 { return _godot_object.ptr is n; } 58 /// 59 size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; } 60 mixin baseCasts; 61 /// Construct a new instance of OmniLight. 62 /// Note: use `memnew!OmniLight` instead. 63 static OmniLight _new() 64 { 65 static godot_class_constructor constructor; 66 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("OmniLight"); 67 if(constructor is null) return typeof(this).init; 68 return cast(OmniLight)(constructor()); 69 } 70 @disable new(size_t s); 71 /// 72 enum ShadowMode : int 73 { 74 /** 75 Shadows are rendered to a dual-paraboloid texture. Faster than $(D constant SHADOW_CUBE), but lower-quality. 76 */ 77 shadowDualParaboloid = 0, 78 /** 79 Shadows are rendered to a cubemap. Slower than $(D constant SHADOW_DUAL_PARABOLOID), but higher-quality. 80 */ 81 shadowCube = 1, 82 } 83 /// 84 enum ShadowDetail : int 85 { 86 /** 87 Use more detail vertically when computing the shadow. 88 */ 89 shadowDetailVertical = 0, 90 /** 91 Use more detail horizontally when computing the shadow. 92 */ 93 shadowDetailHorizontal = 1, 94 } 95 /// 96 enum Constants : int 97 { 98 shadowDualParaboloid = 0, 99 shadowDetailVertical = 0, 100 shadowDetailHorizontal = 1, 101 shadowCube = 1, 102 } 103 /** 104 105 */ 106 OmniLight.ShadowDetail getShadowDetail() const 107 { 108 checkClassBinding!(typeof(this))(); 109 return ptrcall!(OmniLight.ShadowDetail)(GDNativeClassBinding.getShadowDetail, _godot_object); 110 } 111 /** 112 113 */ 114 OmniLight.ShadowMode getShadowMode() const 115 { 116 checkClassBinding!(typeof(this))(); 117 return ptrcall!(OmniLight.ShadowMode)(GDNativeClassBinding.getShadowMode, _godot_object); 118 } 119 /** 120 121 */ 122 void setShadowDetail(in long detail) 123 { 124 checkClassBinding!(typeof(this))(); 125 ptrcall!(void)(GDNativeClassBinding.setShadowDetail, _godot_object, detail); 126 } 127 /** 128 129 */ 130 void setShadowMode(in long mode) 131 { 132 checkClassBinding!(typeof(this))(); 133 ptrcall!(void)(GDNativeClassBinding.setShadowMode, _godot_object, mode); 134 } 135 /** 136 The light's attenuation (drop-off) curve. A number of presets are available in the $(B Inspector) by right-clicking the curve. 137 */ 138 @property double omniAttenuation() 139 { 140 return getParam(4); 141 } 142 /// ditto 143 @property void omniAttenuation(double v) 144 { 145 setParam(4, v); 146 } 147 /** 148 The light's radius. Note that the effectively lit area may appear to be smaller depending on the $(D omniAttenuation) in use. No matter the $(D omniAttenuation) in use, the light will never reach anything outside this radius. 149 */ 150 @property double omniRange() 151 { 152 return getParam(3); 153 } 154 /// ditto 155 @property void omniRange(double v) 156 { 157 setParam(3, v); 158 } 159 /** 160 See $(D shadowdetail). 161 */ 162 @property OmniLight.ShadowDetail omniShadowDetail() 163 { 164 return getShadowDetail(); 165 } 166 /// ditto 167 @property void omniShadowDetail(long v) 168 { 169 setShadowDetail(v); 170 } 171 /** 172 See $(D shadowmode). 173 */ 174 @property OmniLight.ShadowMode omniShadowMode() 175 { 176 return getShadowMode(); 177 } 178 /// ditto 179 @property void omniShadowMode(long v) 180 { 181 setShadowMode(v); 182 } 183 }