1 /** 2 2D Sprite node in 3D world. 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.sprite3d; 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.spritebase3d; 24 import godot.texture; 25 import godot.geometryinstance; 26 import godot.visualinstance; 27 import godot.spatial; 28 import godot.node; 29 /** 30 2D Sprite node in 3D world. 31 32 A node that displays a 2D texture in a 3D environment. The texture displayed can be a region from a larger atlas texture, or a frame from a sprite sheet animation. 33 */ 34 @GodotBaseClass struct Sprite3D 35 { 36 enum string _GODOT_internal_name = "Sprite3D"; 37 public: 38 @nogc nothrow: 39 union { godot_object _godot_object; SpriteBase3D _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_texture") GodotMethod!(void, Texture) setTexture; 47 @GodotName("get_texture") GodotMethod!(Texture) getTexture; 48 @GodotName("set_region") GodotMethod!(void, bool) setRegion; 49 @GodotName("is_region") GodotMethod!(bool) isRegion; 50 @GodotName("set_region_rect") GodotMethod!(void, Rect2) setRegionRect; 51 @GodotName("get_region_rect") GodotMethod!(Rect2) getRegionRect; 52 @GodotName("set_frame") GodotMethod!(void, long) setFrame; 53 @GodotName("get_frame") GodotMethod!(long) getFrame; 54 @GodotName("set_vframes") GodotMethod!(void, long) setVframes; 55 @GodotName("get_vframes") GodotMethod!(long) getVframes; 56 @GodotName("set_hframes") GodotMethod!(void, long) setHframes; 57 @GodotName("get_hframes") GodotMethod!(long) getHframes; 58 } 59 bool opEquals(in Sprite3D other) const { return _godot_object.ptr is other._godot_object.ptr; } 60 Sprite3D opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 61 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 62 mixin baseCasts; 63 static Sprite3D _new() 64 { 65 static godot_class_constructor constructor; 66 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("Sprite3D"); 67 if(constructor is null) return typeof(this).init; 68 return cast(Sprite3D)(constructor()); 69 } 70 @disable new(size_t s); 71 /** 72 73 */ 74 void setTexture(Texture texture) 75 { 76 checkClassBinding!(typeof(this))(); 77 ptrcall!(void)(_classBinding.setTexture, _godot_object, texture); 78 } 79 /** 80 81 */ 82 Ref!Texture getTexture() const 83 { 84 checkClassBinding!(typeof(this))(); 85 return ptrcall!(Texture)(_classBinding.getTexture, _godot_object); 86 } 87 /** 88 89 */ 90 void setRegion(in bool enabled) 91 { 92 checkClassBinding!(typeof(this))(); 93 ptrcall!(void)(_classBinding.setRegion, _godot_object, enabled); 94 } 95 /** 96 97 */ 98 bool isRegion() const 99 { 100 checkClassBinding!(typeof(this))(); 101 return ptrcall!(bool)(_classBinding.isRegion, _godot_object); 102 } 103 /** 104 105 */ 106 void setRegionRect(in Rect2 rect) 107 { 108 checkClassBinding!(typeof(this))(); 109 ptrcall!(void)(_classBinding.setRegionRect, _godot_object, rect); 110 } 111 /** 112 113 */ 114 Rect2 getRegionRect() const 115 { 116 checkClassBinding!(typeof(this))(); 117 return ptrcall!(Rect2)(_classBinding.getRegionRect, _godot_object); 118 } 119 /** 120 121 */ 122 void setFrame(in long frame) 123 { 124 checkClassBinding!(typeof(this))(); 125 ptrcall!(void)(_classBinding.setFrame, _godot_object, frame); 126 } 127 /** 128 129 */ 130 long getFrame() const 131 { 132 checkClassBinding!(typeof(this))(); 133 return ptrcall!(long)(_classBinding.getFrame, _godot_object); 134 } 135 /** 136 137 */ 138 void setVframes(in long vframes) 139 { 140 checkClassBinding!(typeof(this))(); 141 ptrcall!(void)(_classBinding.setVframes, _godot_object, vframes); 142 } 143 /** 144 145 */ 146 long getVframes() const 147 { 148 checkClassBinding!(typeof(this))(); 149 return ptrcall!(long)(_classBinding.getVframes, _godot_object); 150 } 151 /** 152 153 */ 154 void setHframes(in long hframes) 155 { 156 checkClassBinding!(typeof(this))(); 157 ptrcall!(void)(_classBinding.setHframes, _godot_object, hframes); 158 } 159 /** 160 161 */ 162 long getHframes() const 163 { 164 checkClassBinding!(typeof(this))(); 165 return ptrcall!(long)(_classBinding.getHframes, _godot_object); 166 } 167 /** 168 $(D Texture) object to draw. 169 */ 170 @property Texture texture() 171 { 172 return getTexture(); 173 } 174 /// ditto 175 @property void texture(Texture v) 176 { 177 setTexture(v); 178 } 179 /** 180 The number of rows in the sprite sheet. 181 */ 182 @property long vframes() 183 { 184 return getVframes(); 185 } 186 /// ditto 187 @property void vframes(long v) 188 { 189 setVframes(v); 190 } 191 /** 192 The number of columns in the sprite sheet. 193 */ 194 @property long hframes() 195 { 196 return getHframes(); 197 } 198 /// ditto 199 @property void hframes(long v) 200 { 201 setHframes(v); 202 } 203 /** 204 Current frame to display from sprite sheet. $(D vframes) or $(D hframes) must be greater than 1. 205 */ 206 @property long frame() 207 { 208 return getFrame(); 209 } 210 /// ditto 211 @property void frame(long v) 212 { 213 setFrame(v); 214 } 215 /** 216 If `true` texture will be cut from a larger atlas texture. See $(D regionRect). Default value: `false`. 217 */ 218 @property bool regionEnabled() 219 { 220 return isRegion(); 221 } 222 /// ditto 223 @property void regionEnabled(bool v) 224 { 225 setRegion(v); 226 } 227 /** 228 The region of the atlas texture to display. $(D regionEnabled) must be `true`. 229 */ 230 @property Rect2 regionRect() 231 { 232 return getRegionRect(); 233 } 234 /// ditto 235 @property void regionRect(Rect2 v) 236 { 237 setRegionRect(v); 238 } 239 }