1 /** 2 $(D OpenSimplexNoise) filled texture. 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.noisetexture; 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.texture; 24 import godot.opensimplexnoise; 25 import godot.image; 26 import godot.resource; 27 import godot.reference; 28 /** 29 $(D OpenSimplexNoise) filled texture. 30 31 Uses an $(D OpenSimplexNoise) to fill the texture data. You can specify the texture size but keep in mind that larger textures will take longer to generate and seamless noise only works with square sized textures. 32 NoiseTexture can also generate normalmap textures. 33 */ 34 @GodotBaseClass struct NoiseTexture 35 { 36 enum string _GODOT_internal_name = "NoiseTexture"; 37 public: 38 @nogc nothrow: 39 union { godot_object _godot_object; Texture _GODOT_base; } 40 alias _GODOT_base this; 41 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 42 package(godot) __gshared bool _classBindingInitialized = false; 43 package(godot) static struct _classBinding 44 { 45 __gshared: 46 @GodotName("set_width") GodotMethod!(void, long) setWidth; 47 @GodotName("set_height") GodotMethod!(void, long) setHeight; 48 @GodotName("set_noise") GodotMethod!(void, OpenSimplexNoise) setNoise; 49 @GodotName("get_noise") GodotMethod!(OpenSimplexNoise) getNoise; 50 @GodotName("set_seamless") GodotMethod!(void, bool) setSeamless; 51 @GodotName("get_seamless") GodotMethod!(bool) getSeamless; 52 @GodotName("set_as_normalmap") GodotMethod!(void, bool) setAsNormalmap; 53 @GodotName("is_normalmap") GodotMethod!(bool) isNormalmap; 54 @GodotName("_update_texture") GodotMethod!(void) _updateTexture; 55 @GodotName("_generate_texture") GodotMethod!(Image) _generateTexture; 56 @GodotName("_thread_done") GodotMethod!(void, Image) _threadDone; 57 } 58 bool opEquals(in NoiseTexture other) const { return _godot_object.ptr is other._godot_object.ptr; } 59 NoiseTexture opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 60 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 61 mixin baseCasts; 62 static NoiseTexture _new() 63 { 64 static godot_class_constructor constructor; 65 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("NoiseTexture"); 66 if(constructor is null) return typeof(this).init; 67 return cast(NoiseTexture)(constructor()); 68 } 69 @disable new(size_t s); 70 /** 71 72 */ 73 void setWidth(in long width) 74 { 75 checkClassBinding!(typeof(this))(); 76 ptrcall!(void)(_classBinding.setWidth, _godot_object, width); 77 } 78 /** 79 80 */ 81 void setHeight(in long height) 82 { 83 checkClassBinding!(typeof(this))(); 84 ptrcall!(void)(_classBinding.setHeight, _godot_object, height); 85 } 86 /** 87 88 */ 89 void setNoise(OpenSimplexNoise noise) 90 { 91 checkClassBinding!(typeof(this))(); 92 ptrcall!(void)(_classBinding.setNoise, _godot_object, noise); 93 } 94 /** 95 96 */ 97 Ref!OpenSimplexNoise getNoise() 98 { 99 checkClassBinding!(typeof(this))(); 100 return ptrcall!(OpenSimplexNoise)(_classBinding.getNoise, _godot_object); 101 } 102 /** 103 104 */ 105 void setSeamless(in bool seamless) 106 { 107 checkClassBinding!(typeof(this))(); 108 ptrcall!(void)(_classBinding.setSeamless, _godot_object, seamless); 109 } 110 /** 111 112 */ 113 bool getSeamless() 114 { 115 checkClassBinding!(typeof(this))(); 116 return ptrcall!(bool)(_classBinding.getSeamless, _godot_object); 117 } 118 /** 119 120 */ 121 void setAsNormalmap(in bool as_normalmap) 122 { 123 checkClassBinding!(typeof(this))(); 124 ptrcall!(void)(_classBinding.setAsNormalmap, _godot_object, as_normalmap); 125 } 126 /** 127 128 */ 129 bool isNormalmap() 130 { 131 checkClassBinding!(typeof(this))(); 132 return ptrcall!(bool)(_classBinding.isNormalmap, _godot_object); 133 } 134 /** 135 136 */ 137 void _updateTexture() 138 { 139 Array _GODOT_args = Array.empty_array; 140 String _GODOT_method_name = String("_update_texture"); 141 this.callv(_GODOT_method_name, _GODOT_args); 142 } 143 /** 144 145 */ 146 Ref!Image _generateTexture() 147 { 148 Array _GODOT_args = Array.empty_array; 149 String _GODOT_method_name = String("_generate_texture"); 150 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!Image); 151 } 152 /** 153 154 */ 155 void _threadDone(Image image) 156 { 157 Array _GODOT_args = Array.empty_array; 158 _GODOT_args.append(image); 159 String _GODOT_method_name = String("_thread_done"); 160 this.callv(_GODOT_method_name, _GODOT_args); 161 } 162 /** 163 Width of the generated texture. 164 */ 165 @property long width() 166 { 167 return getWidth(); 168 } 169 /// ditto 170 @property void width(long v) 171 { 172 setWidth(v); 173 } 174 /** 175 Height of the generated texture. 176 */ 177 @property long height() 178 { 179 return getHeight(); 180 } 181 /// ditto 182 @property void height(long v) 183 { 184 setHeight(v); 185 } 186 /** 187 Whether the texture can be tiled without visible seams or not. Seamless textures take longer to generate. 188 */ 189 @property bool seamless() 190 { 191 return getSeamless(); 192 } 193 /// ditto 194 @property void seamless(bool v) 195 { 196 setSeamless(v); 197 } 198 /** 199 If true, the resulting texture contains a normal map created from the original noise interpreted as a bump map. 200 */ 201 @property bool asNormalmap() 202 { 203 return isNormalmap(); 204 } 205 /// ditto 206 @property void asNormalmap(bool v) 207 { 208 setAsNormalmap(v); 209 } 210 /** 211 The $(D OpenSimplexNoise) instance used to generate the noise. 212 */ 213 @property OpenSimplexNoise noise() 214 { 215 return getNoise(); 216 } 217 /// ditto 218 @property void noise(OpenSimplexNoise v) 219 { 220 setNoise(v); 221 } 222 }