1 /** 2 2D Sprite node in 3D environment. 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.spritebase3d; 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.geometryinstance; 23 import godot.trianglemesh; 24 import godot.visualinstance; 25 import godot.spatial; 26 import godot.node; 27 /** 28 2D Sprite node in 3D environment. 29 30 A node that displays 2D texture information in a 3D environment. 31 */ 32 @GodotBaseClass struct SpriteBase3D 33 { 34 enum string _GODOT_internal_name = "SpriteBase3D"; 35 public: 36 @nogc nothrow: 37 union { godot_object _godot_object; GeometryInstance _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 _classBinding 42 { 43 __gshared: 44 @GodotName("set_centered") GodotMethod!(void, bool) setCentered; 45 @GodotName("is_centered") GodotMethod!(bool) isCentered; 46 @GodotName("set_offset") GodotMethod!(void, Vector2) setOffset; 47 @GodotName("get_offset") GodotMethod!(Vector2) getOffset; 48 @GodotName("set_flip_h") GodotMethod!(void, bool) setFlipH; 49 @GodotName("is_flipped_h") GodotMethod!(bool) isFlippedH; 50 @GodotName("set_flip_v") GodotMethod!(void, bool) setFlipV; 51 @GodotName("is_flipped_v") GodotMethod!(bool) isFlippedV; 52 @GodotName("set_modulate") GodotMethod!(void, Color) setModulate; 53 @GodotName("get_modulate") GodotMethod!(Color) getModulate; 54 @GodotName("set_opacity") GodotMethod!(void, double) setOpacity; 55 @GodotName("get_opacity") GodotMethod!(double) getOpacity; 56 @GodotName("set_pixel_size") GodotMethod!(void, double) setPixelSize; 57 @GodotName("get_pixel_size") GodotMethod!(double) getPixelSize; 58 @GodotName("set_axis") GodotMethod!(void, long) setAxis; 59 @GodotName("get_axis") GodotMethod!(Vector3.Axis) getAxis; 60 @GodotName("set_draw_flag") GodotMethod!(void, long, bool) setDrawFlag; 61 @GodotName("get_draw_flag") GodotMethod!(bool, long) getDrawFlag; 62 @GodotName("set_alpha_cut_mode") GodotMethod!(void, long) setAlphaCutMode; 63 @GodotName("get_alpha_cut_mode") GodotMethod!(SpriteBase3D.AlphaCutMode) getAlphaCutMode; 64 @GodotName("get_item_rect") GodotMethod!(Rect2) getItemRect; 65 @GodotName("generate_triangle_mesh") GodotMethod!(TriangleMesh) generateTriangleMesh; 66 @GodotName("_queue_update") GodotMethod!(void) _queueUpdate; 67 @GodotName("_im_update") GodotMethod!(void) _imUpdate; 68 } 69 bool opEquals(in SpriteBase3D other) const { return _godot_object.ptr is other._godot_object.ptr; } 70 SpriteBase3D opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 71 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 72 mixin baseCasts; 73 static SpriteBase3D _new() 74 { 75 static godot_class_constructor constructor; 76 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("SpriteBase3D"); 77 if(constructor is null) return typeof(this).init; 78 return cast(SpriteBase3D)(constructor()); 79 } 80 @disable new(size_t s); 81 /// 82 enum DrawFlags : int 83 { 84 /** 85 If set, the texture's transparency and the opacity are used to make those parts of the Sprite invisible. 86 */ 87 flagTransparent = 0, 88 /** 89 If set, the Light in the Environment has effects on the Sprite. 90 */ 91 flagShaded = 1, 92 /** 93 If set, texture can be seen from the back as well, if not, it is invisible when looking at it from behind. 94 */ 95 flagDoubleSided = 2, 96 /** 97 Used internally to mark the end of the Flags section. 98 */ 99 flagMax = 3, 100 } 101 /// 102 enum AlphaCutMode : int 103 { 104 /** 105 106 */ 107 alphaCutDisabled = 0, 108 /** 109 110 */ 111 alphaCutDiscard = 1, 112 /** 113 114 */ 115 alphaCutOpaquePrepass = 2, 116 } 117 /// 118 enum Constants : int 119 { 120 flagTransparent = 0, 121 alphaCutDisabled = 0, 122 alphaCutDiscard = 1, 123 flagShaded = 1, 124 alphaCutOpaquePrepass = 2, 125 flagDoubleSided = 2, 126 flagMax = 3, 127 } 128 /** 129 130 */ 131 void setCentered(in bool centered) 132 { 133 checkClassBinding!(typeof(this))(); 134 ptrcall!(void)(_classBinding.setCentered, _godot_object, centered); 135 } 136 /** 137 138 */ 139 bool isCentered() const 140 { 141 checkClassBinding!(typeof(this))(); 142 return ptrcall!(bool)(_classBinding.isCentered, _godot_object); 143 } 144 /** 145 146 */ 147 void setOffset(in Vector2 offset) 148 { 149 checkClassBinding!(typeof(this))(); 150 ptrcall!(void)(_classBinding.setOffset, _godot_object, offset); 151 } 152 /** 153 154 */ 155 Vector2 getOffset() const 156 { 157 checkClassBinding!(typeof(this))(); 158 return ptrcall!(Vector2)(_classBinding.getOffset, _godot_object); 159 } 160 /** 161 162 */ 163 void setFlipH(in bool flip_h) 164 { 165 checkClassBinding!(typeof(this))(); 166 ptrcall!(void)(_classBinding.setFlipH, _godot_object, flip_h); 167 } 168 /** 169 170 */ 171 bool isFlippedH() const 172 { 173 checkClassBinding!(typeof(this))(); 174 return ptrcall!(bool)(_classBinding.isFlippedH, _godot_object); 175 } 176 /** 177 178 */ 179 void setFlipV(in bool flip_v) 180 { 181 checkClassBinding!(typeof(this))(); 182 ptrcall!(void)(_classBinding.setFlipV, _godot_object, flip_v); 183 } 184 /** 185 186 */ 187 bool isFlippedV() const 188 { 189 checkClassBinding!(typeof(this))(); 190 return ptrcall!(bool)(_classBinding.isFlippedV, _godot_object); 191 } 192 /** 193 194 */ 195 void setModulate(in Color modulate) 196 { 197 checkClassBinding!(typeof(this))(); 198 ptrcall!(void)(_classBinding.setModulate, _godot_object, modulate); 199 } 200 /** 201 202 */ 203 Color getModulate() const 204 { 205 checkClassBinding!(typeof(this))(); 206 return ptrcall!(Color)(_classBinding.getModulate, _godot_object); 207 } 208 /** 209 210 */ 211 void setOpacity(in double opacity) 212 { 213 checkClassBinding!(typeof(this))(); 214 ptrcall!(void)(_classBinding.setOpacity, _godot_object, opacity); 215 } 216 /** 217 218 */ 219 double getOpacity() const 220 { 221 checkClassBinding!(typeof(this))(); 222 return ptrcall!(double)(_classBinding.getOpacity, _godot_object); 223 } 224 /** 225 226 */ 227 void setPixelSize(in double pixel_size) 228 { 229 checkClassBinding!(typeof(this))(); 230 ptrcall!(void)(_classBinding.setPixelSize, _godot_object, pixel_size); 231 } 232 /** 233 234 */ 235 double getPixelSize() const 236 { 237 checkClassBinding!(typeof(this))(); 238 return ptrcall!(double)(_classBinding.getPixelSize, _godot_object); 239 } 240 /** 241 242 */ 243 void setAxis(in long axis) 244 { 245 checkClassBinding!(typeof(this))(); 246 ptrcall!(void)(_classBinding.setAxis, _godot_object, axis); 247 } 248 /** 249 250 */ 251 Vector3.Axis getAxis() const 252 { 253 checkClassBinding!(typeof(this))(); 254 return ptrcall!(Vector3.Axis)(_classBinding.getAxis, _godot_object); 255 } 256 /** 257 258 */ 259 void setDrawFlag(in long flag, in bool enabled) 260 { 261 checkClassBinding!(typeof(this))(); 262 ptrcall!(void)(_classBinding.setDrawFlag, _godot_object, flag, enabled); 263 } 264 /** 265 266 */ 267 bool getDrawFlag(in long flag) const 268 { 269 checkClassBinding!(typeof(this))(); 270 return ptrcall!(bool)(_classBinding.getDrawFlag, _godot_object, flag); 271 } 272 /** 273 274 */ 275 void setAlphaCutMode(in long mode) 276 { 277 checkClassBinding!(typeof(this))(); 278 ptrcall!(void)(_classBinding.setAlphaCutMode, _godot_object, mode); 279 } 280 /** 281 282 */ 283 SpriteBase3D.AlphaCutMode getAlphaCutMode() const 284 { 285 checkClassBinding!(typeof(this))(); 286 return ptrcall!(SpriteBase3D.AlphaCutMode)(_classBinding.getAlphaCutMode, _godot_object); 287 } 288 /** 289 290 */ 291 Rect2 getItemRect() const 292 { 293 checkClassBinding!(typeof(this))(); 294 return ptrcall!(Rect2)(_classBinding.getItemRect, _godot_object); 295 } 296 /** 297 298 */ 299 Ref!TriangleMesh generateTriangleMesh() const 300 { 301 checkClassBinding!(typeof(this))(); 302 return ptrcall!(TriangleMesh)(_classBinding.generateTriangleMesh, _godot_object); 303 } 304 /** 305 306 */ 307 void _queueUpdate() 308 { 309 Array _GODOT_args = Array.empty_array; 310 String _GODOT_method_name = String("_queue_update"); 311 this.callv(_GODOT_method_name, _GODOT_args); 312 } 313 /** 314 315 */ 316 void _imUpdate() 317 { 318 Array _GODOT_args = Array.empty_array; 319 String _GODOT_method_name = String("_im_update"); 320 this.callv(_GODOT_method_name, _GODOT_args); 321 } 322 /** 323 If `true` texture will be centered. Default value: `true`. 324 */ 325 @property bool centered() 326 { 327 return isCentered(); 328 } 329 /// ditto 330 @property void centered(bool v) 331 { 332 setCentered(v); 333 } 334 /** 335 The texture's drawing offset. 336 */ 337 @property Vector2 offset() 338 { 339 return getOffset(); 340 } 341 /// ditto 342 @property void offset(Vector2 v) 343 { 344 setOffset(v); 345 } 346 /** 347 If `true` texture is flipped horizontally. Default value: `false`. 348 */ 349 @property bool flipH() 350 { 351 return isFlippedH(); 352 } 353 /// ditto 354 @property void flipH(bool v) 355 { 356 setFlipH(v); 357 } 358 /** 359 If `true` texture is flipped vertically. Default value: `false`. 360 */ 361 @property bool flipV() 362 { 363 return isFlippedV(); 364 } 365 /// ditto 366 @property void flipV(bool v) 367 { 368 setFlipV(v); 369 } 370 /** 371 A color value that gets multiplied on, could be used for mood-coloring or to simulate the color of light. 372 */ 373 @property Color modulate() 374 { 375 return getModulate(); 376 } 377 /// ditto 378 @property void modulate(Color v) 379 { 380 setModulate(v); 381 } 382 /** 383 The objects visibility on a scale from `0` fully invisible to `1` fully visible. 384 */ 385 @property double opacity() 386 { 387 return getOpacity(); 388 } 389 /// ditto 390 @property void opacity(double v) 391 { 392 setOpacity(v); 393 } 394 /** 395 The size of one pixel's width on the Sprite to scale it in 3D. 396 */ 397 @property double pixelSize() 398 { 399 return getPixelSize(); 400 } 401 /// ditto 402 @property void pixelSize(double v) 403 { 404 setPixelSize(v); 405 } 406 /** 407 The direction in which the front of the texture faces. 408 */ 409 @property Vector3.Axis axis() 410 { 411 return getAxis(); 412 } 413 /// ditto 414 @property void axis(long v) 415 { 416 setAxis(v); 417 } 418 /** 419 If `true` the texture's transparency and the opacity are used to make those parts of the Sprite invisible. Default value: `true`. 420 */ 421 @property bool transparent() 422 { 423 return getDrawFlag(0); 424 } 425 /// ditto 426 @property void transparent(bool v) 427 { 428 setDrawFlag(0, v); 429 } 430 /** 431 If `true` the $(D Light) in the $(D Environment) has effects on the Sprite. Default value: `false`. 432 */ 433 @property bool shaded() 434 { 435 return getDrawFlag(1); 436 } 437 /// ditto 438 @property void shaded(bool v) 439 { 440 setDrawFlag(1, v); 441 } 442 /** 443 If `true` texture can be seen from the back as well, if `false`, it is invisible when looking at it from behind. Default value: `true`. 444 */ 445 @property bool doubleSided() 446 { 447 return getDrawFlag(2); 448 } 449 /// ditto 450 @property void doubleSided(bool v) 451 { 452 setDrawFlag(2, v); 453 } 454 /** 455 456 */ 457 @property SpriteBase3D.AlphaCutMode alphaCut() 458 { 459 return getAlphaCutMode(); 460 } 461 /// ditto 462 @property void alphaCut(long v) 463 { 464 setAlphaCutMode(v); 465 } 466 }