1 /** 2 Simple texture that uses a mesh to draw itself. 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.meshtexture; 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.texture; 25 import godot.mesh; 26 /** 27 Simple texture that uses a mesh to draw itself. 28 29 It's limited because flags can't be changed and region drawing is not supported. 30 */ 31 @GodotBaseClass struct MeshTexture 32 { 33 package(godot) enum string _GODOT_internal_name = "MeshTexture"; 34 public: 35 @nogc nothrow: 36 union { /** */ godot_object _godot_object; /** */ Texture _GODOT_base; } 37 alias _GODOT_base this; 38 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 39 package(godot) __gshared bool _classBindingInitialized = false; 40 package(godot) static struct GDNativeClassBinding 41 { 42 __gshared: 43 @GodotName("get_base_texture") GodotMethod!(Texture) getBaseTexture; 44 @GodotName("get_image_size") GodotMethod!(Vector2) getImageSize; 45 @GodotName("get_mesh") GodotMethod!(Mesh) getMesh; 46 @GodotName("set_base_texture") GodotMethod!(void, Texture) setBaseTexture; 47 @GodotName("set_image_size") GodotMethod!(void, Vector2) setImageSize; 48 @GodotName("set_mesh") GodotMethod!(void, Mesh) setMesh; 49 } 50 /// 51 pragma(inline, true) bool opEquals(in MeshTexture other) const 52 { return _godot_object.ptr is other._godot_object.ptr; } 53 /// 54 pragma(inline, true) typeof(null) opAssign(typeof(null) n) 55 { _godot_object.ptr = n; return null; } 56 /// 57 pragma(inline, true) bool opEquals(typeof(null) n) const 58 { return _godot_object.ptr is n; } 59 /// 60 size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; } 61 mixin baseCasts; 62 /// Construct a new instance of MeshTexture. 63 /// Note: use `memnew!MeshTexture` instead. 64 static MeshTexture _new() 65 { 66 static godot_class_constructor constructor; 67 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("MeshTexture"); 68 if(constructor is null) return typeof(this).init; 69 return cast(MeshTexture)(constructor()); 70 } 71 @disable new(size_t s); 72 /** 73 74 */ 75 Ref!Texture getBaseTexture() const 76 { 77 checkClassBinding!(typeof(this))(); 78 return ptrcall!(Texture)(GDNativeClassBinding.getBaseTexture, _godot_object); 79 } 80 /** 81 82 */ 83 Vector2 getImageSize() const 84 { 85 checkClassBinding!(typeof(this))(); 86 return ptrcall!(Vector2)(GDNativeClassBinding.getImageSize, _godot_object); 87 } 88 /** 89 90 */ 91 Ref!Mesh getMesh() const 92 { 93 checkClassBinding!(typeof(this))(); 94 return ptrcall!(Mesh)(GDNativeClassBinding.getMesh, _godot_object); 95 } 96 /** 97 98 */ 99 void setBaseTexture(Texture texture) 100 { 101 checkClassBinding!(typeof(this))(); 102 ptrcall!(void)(GDNativeClassBinding.setBaseTexture, _godot_object, texture); 103 } 104 /** 105 106 */ 107 void setImageSize(in Vector2 size) 108 { 109 checkClassBinding!(typeof(this))(); 110 ptrcall!(void)(GDNativeClassBinding.setImageSize, _godot_object, size); 111 } 112 /** 113 114 */ 115 void setMesh(Mesh mesh) 116 { 117 checkClassBinding!(typeof(this))(); 118 ptrcall!(void)(GDNativeClassBinding.setMesh, _godot_object, mesh); 119 } 120 /** 121 Sets the base texture that the Mesh will use to draw. 122 */ 123 @property Texture baseTexture() 124 { 125 return getBaseTexture(); 126 } 127 /// ditto 128 @property void baseTexture(Texture v) 129 { 130 setBaseTexture(v); 131 } 132 /** 133 Sets the size of the image, needed for reference. 134 */ 135 @property Vector2 imageSize() 136 { 137 return getImageSize(); 138 } 139 /// ditto 140 @property void imageSize(Vector2 v) 141 { 142 setImageSize(v); 143 } 144 /** 145 Sets the mesh used to draw. It must be a mesh using 2D vertices. 146 */ 147 @property Mesh mesh() 148 { 149 return getMesh(); 150 } 151 /// ditto 152 @property void mesh(Mesh v) 153 { 154 setMesh(v); 155 } 156 }