1 /** 2 Node used for displaying a $(D Mesh) in 2D. 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.meshinstance2d; 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.node2d; 25 import godot.mesh; 26 import godot.texture; 27 /** 28 Node used for displaying a $(D Mesh) in 2D. 29 30 Can be constructed from an existing $(D Sprite) via a tool in the editor toolbar. Select "Sprite" then "Convert to Mesh2D", select settings in popup and press "Create Mesh2D". 31 */ 32 @GodotBaseClass struct MeshInstance2D 33 { 34 package(godot) enum string _GODOT_internal_name = "MeshInstance2D"; 35 public: 36 @nogc nothrow: 37 union { /** */ godot_object _godot_object; /** */ Node2D _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("get_mesh") GodotMethod!(Mesh) getMesh; 45 @GodotName("get_normal_map") GodotMethod!(Texture) getNormalMap; 46 @GodotName("get_texture") GodotMethod!(Texture) getTexture; 47 @GodotName("set_mesh") GodotMethod!(void, Mesh) setMesh; 48 @GodotName("set_normal_map") GodotMethod!(void, Texture) setNormalMap; 49 @GodotName("set_texture") GodotMethod!(void, Texture) setTexture; 50 } 51 /// 52 pragma(inline, true) bool opEquals(in MeshInstance2D other) const 53 { return _godot_object.ptr is other._godot_object.ptr; } 54 /// 55 pragma(inline, true) typeof(null) opAssign(typeof(null) n) 56 { _godot_object.ptr = n; return null; } 57 /// 58 pragma(inline, true) bool opEquals(typeof(null) n) const 59 { return _godot_object.ptr is n; } 60 /// 61 size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; } 62 mixin baseCasts; 63 /// Construct a new instance of MeshInstance2D. 64 /// Note: use `memnew!MeshInstance2D` instead. 65 static MeshInstance2D _new() 66 { 67 static godot_class_constructor constructor; 68 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("MeshInstance2D"); 69 if(constructor is null) return typeof(this).init; 70 return cast(MeshInstance2D)(constructor()); 71 } 72 @disable new(size_t s); 73 /** 74 75 */ 76 Ref!Mesh getMesh() const 77 { 78 checkClassBinding!(typeof(this))(); 79 return ptrcall!(Mesh)(GDNativeClassBinding.getMesh, _godot_object); 80 } 81 /** 82 83 */ 84 Ref!Texture getNormalMap() const 85 { 86 checkClassBinding!(typeof(this))(); 87 return ptrcall!(Texture)(GDNativeClassBinding.getNormalMap, _godot_object); 88 } 89 /** 90 91 */ 92 Ref!Texture getTexture() const 93 { 94 checkClassBinding!(typeof(this))(); 95 return ptrcall!(Texture)(GDNativeClassBinding.getTexture, _godot_object); 96 } 97 /** 98 99 */ 100 void setMesh(Mesh mesh) 101 { 102 checkClassBinding!(typeof(this))(); 103 ptrcall!(void)(GDNativeClassBinding.setMesh, _godot_object, mesh); 104 } 105 /** 106 107 */ 108 void setNormalMap(Texture normal_map) 109 { 110 checkClassBinding!(typeof(this))(); 111 ptrcall!(void)(GDNativeClassBinding.setNormalMap, _godot_object, normal_map); 112 } 113 /** 114 115 */ 116 void setTexture(Texture texture) 117 { 118 checkClassBinding!(typeof(this))(); 119 ptrcall!(void)(GDNativeClassBinding.setTexture, _godot_object, texture); 120 } 121 /** 122 The $(D Mesh) that will be drawn by the $(D MeshInstance2D). 123 */ 124 @property Mesh mesh() 125 { 126 return getMesh(); 127 } 128 /// ditto 129 @property void mesh(Mesh v) 130 { 131 setMesh(v); 132 } 133 /** 134 The normal map that will be used if using the default $(D CanvasItemMaterial). 135 $(B Note:) Godot expects the normal map to use X+, Y-, and Z+ coordinates. See $(D url=http://wiki.polycount.com/wiki/Normal_Map_Technical_Details#Common_Swizzle_Coordinates)this page$(D /url) for a comparison of normal map coordinates expected by popular engines. 136 */ 137 @property Texture normalMap() 138 { 139 return getNormalMap(); 140 } 141 /// ditto 142 @property void normalMap(Texture v) 143 { 144 setNormalMap(v); 145 } 146 /** 147 The $(D Texture) that will be used if using the default $(D CanvasItemMaterial). Can be accessed as `TEXTURE` in CanvasItem shader. 148 */ 149 @property Texture texture() 150 { 151 return getTexture(); 152 } 153 /// ditto 154 @property void texture(Texture v) 155 { 156 setTexture(v); 157 } 158 }