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