1 /**
2 Library of meshes.
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.meshlibrary;
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.resource;
25 import godot.mesh;
26 import godot.navigationmesh;
27 import godot.texture;
28 /**
29 Library of meshes.
30 
31 A library of meshes. Contains a list of $(D Mesh) resources, each with a name and ID. Each item can also include collision and navigation shapes. This resource is used in $(D GridMap).
32 */
33 @GodotBaseClass struct MeshLibrary
34 {
35 	package(godot) enum string _GODOT_internal_name = "MeshLibrary";
36 public:
37 @nogc nothrow:
38 	union { /** */ godot_object _godot_object; /** */ Resource _GODOT_base; }
39 	alias _GODOT_base this;
40 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
41 	package(godot) __gshared bool _classBindingInitialized = false;
42 	package(godot) static struct GDNativeClassBinding
43 	{
44 		__gshared:
45 		@GodotName("clear") GodotMethod!(void) clear;
46 		@GodotName("create_item") GodotMethod!(void, long) createItem;
47 		@GodotName("find_item_by_name") GodotMethod!(long, String) findItemByName;
48 		@GodotName("get_item_list") GodotMethod!(PoolIntArray) getItemList;
49 		@GodotName("get_item_mesh") GodotMethod!(Mesh, long) getItemMesh;
50 		@GodotName("get_item_name") GodotMethod!(String, long) getItemName;
51 		@GodotName("get_item_navmesh") GodotMethod!(NavigationMesh, long) getItemNavmesh;
52 		@GodotName("get_item_navmesh_transform") GodotMethod!(Transform, long) getItemNavmeshTransform;
53 		@GodotName("get_item_preview") GodotMethod!(Texture, long) getItemPreview;
54 		@GodotName("get_item_shapes") GodotMethod!(Array, long) getItemShapes;
55 		@GodotName("get_last_unused_item_id") GodotMethod!(long) getLastUnusedItemId;
56 		@GodotName("remove_item") GodotMethod!(void, long) removeItem;
57 		@GodotName("set_item_mesh") GodotMethod!(void, long, Mesh) setItemMesh;
58 		@GodotName("set_item_name") GodotMethod!(void, long, String) setItemName;
59 		@GodotName("set_item_navmesh") GodotMethod!(void, long, NavigationMesh) setItemNavmesh;
60 		@GodotName("set_item_navmesh_transform") GodotMethod!(void, long, Transform) setItemNavmeshTransform;
61 		@GodotName("set_item_preview") GodotMethod!(void, long, Texture) setItemPreview;
62 		@GodotName("set_item_shapes") GodotMethod!(void, long, Array) setItemShapes;
63 	}
64 	/// 
65 	pragma(inline, true) bool opEquals(in MeshLibrary other) const
66 	{ return _godot_object.ptr is other._godot_object.ptr; }
67 	/// 
68 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
69 	{ _godot_object.ptr = n; return null; }
70 	/// 
71 	pragma(inline, true) bool opEquals(typeof(null) n) const
72 	{ return _godot_object.ptr is n; }
73 	/// 
74 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
75 	mixin baseCasts;
76 	/// Construct a new instance of MeshLibrary.
77 	/// Note: use `memnew!MeshLibrary` instead.
78 	static MeshLibrary _new()
79 	{
80 		static godot_class_constructor constructor;
81 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("MeshLibrary");
82 		if(constructor is null) return typeof(this).init;
83 		return cast(MeshLibrary)(constructor());
84 	}
85 	@disable new(size_t s);
86 	/**
87 	Clears the library.
88 	*/
89 	void clear()
90 	{
91 		checkClassBinding!(typeof(this))();
92 		ptrcall!(void)(GDNativeClassBinding.clear, _godot_object);
93 	}
94 	/**
95 	Creates a new item in the library with the given ID.
96 	You can get an unused ID from $(D getLastUnusedItemId).
97 	*/
98 	void createItem(in long id)
99 	{
100 		checkClassBinding!(typeof(this))();
101 		ptrcall!(void)(GDNativeClassBinding.createItem, _godot_object, id);
102 	}
103 	/**
104 	Returns the first item with the given name.
105 	*/
106 	long findItemByName(in String name) const
107 	{
108 		checkClassBinding!(typeof(this))();
109 		return ptrcall!(long)(GDNativeClassBinding.findItemByName, _godot_object, name);
110 	}
111 	/**
112 	Returns the list of item IDs in use.
113 	*/
114 	PoolIntArray getItemList() const
115 	{
116 		checkClassBinding!(typeof(this))();
117 		return ptrcall!(PoolIntArray)(GDNativeClassBinding.getItemList, _godot_object);
118 	}
119 	/**
120 	Returns the item's mesh.
121 	*/
122 	Ref!Mesh getItemMesh(in long id) const
123 	{
124 		checkClassBinding!(typeof(this))();
125 		return ptrcall!(Mesh)(GDNativeClassBinding.getItemMesh, _godot_object, id);
126 	}
127 	/**
128 	Returns the item's name.
129 	*/
130 	String getItemName(in long id) const
131 	{
132 		checkClassBinding!(typeof(this))();
133 		return ptrcall!(String)(GDNativeClassBinding.getItemName, _godot_object, id);
134 	}
135 	/**
136 	Returns the item's navigation mesh.
137 	*/
138 	Ref!NavigationMesh getItemNavmesh(in long id) const
139 	{
140 		checkClassBinding!(typeof(this))();
141 		return ptrcall!(NavigationMesh)(GDNativeClassBinding.getItemNavmesh, _godot_object, id);
142 	}
143 	/**
144 	Returns the transform applied to the item's navigation mesh.
145 	*/
146 	Transform getItemNavmeshTransform(in long id) const
147 	{
148 		checkClassBinding!(typeof(this))();
149 		return ptrcall!(Transform)(GDNativeClassBinding.getItemNavmeshTransform, _godot_object, id);
150 	}
151 	/**
152 	When running in the editor, returns a generated item preview (a 3D rendering in isometric perspective). When used in a running project, returns the manually-defined item preview which can be set using $(D setItemPreview). Returns an empty $(D Texture) if no preview was manually set in a running project.
153 	*/
154 	Ref!Texture getItemPreview(in long id) const
155 	{
156 		checkClassBinding!(typeof(this))();
157 		return ptrcall!(Texture)(GDNativeClassBinding.getItemPreview, _godot_object, id);
158 	}
159 	/**
160 	Returns an item's collision shapes.
161 	The array consists of each $(D Shape) followed by its $(D Transform).
162 	*/
163 	Array getItemShapes(in long id) const
164 	{
165 		checkClassBinding!(typeof(this))();
166 		return ptrcall!(Array)(GDNativeClassBinding.getItemShapes, _godot_object, id);
167 	}
168 	/**
169 	Gets an unused ID for a new item.
170 	*/
171 	long getLastUnusedItemId() const
172 	{
173 		checkClassBinding!(typeof(this))();
174 		return ptrcall!(long)(GDNativeClassBinding.getLastUnusedItemId, _godot_object);
175 	}
176 	/**
177 	Removes the item.
178 	*/
179 	void removeItem(in long id)
180 	{
181 		checkClassBinding!(typeof(this))();
182 		ptrcall!(void)(GDNativeClassBinding.removeItem, _godot_object, id);
183 	}
184 	/**
185 	Sets the item's mesh.
186 	*/
187 	void setItemMesh(in long id, Mesh mesh)
188 	{
189 		checkClassBinding!(typeof(this))();
190 		ptrcall!(void)(GDNativeClassBinding.setItemMesh, _godot_object, id, mesh);
191 	}
192 	/**
193 	Sets the item's name.
194 	This name is shown in the editor. It can also be used to look up the item later using $(D findItemByName).
195 	*/
196 	void setItemName(in long id, in String name)
197 	{
198 		checkClassBinding!(typeof(this))();
199 		ptrcall!(void)(GDNativeClassBinding.setItemName, _godot_object, id, name);
200 	}
201 	/**
202 	Sets the item's navigation mesh.
203 	*/
204 	void setItemNavmesh(in long id, NavigationMesh navmesh)
205 	{
206 		checkClassBinding!(typeof(this))();
207 		ptrcall!(void)(GDNativeClassBinding.setItemNavmesh, _godot_object, id, navmesh);
208 	}
209 	/**
210 	Sets the transform to apply to the item's navigation mesh.
211 	*/
212 	void setItemNavmeshTransform(in long id, in Transform navmesh)
213 	{
214 		checkClassBinding!(typeof(this))();
215 		ptrcall!(void)(GDNativeClassBinding.setItemNavmeshTransform, _godot_object, id, navmesh);
216 	}
217 	/**
218 	Sets a texture to use as the item's preview icon in the editor.
219 	*/
220 	void setItemPreview(in long id, Texture texture)
221 	{
222 		checkClassBinding!(typeof(this))();
223 		ptrcall!(void)(GDNativeClassBinding.setItemPreview, _godot_object, id, texture);
224 	}
225 	/**
226 	Sets an item's collision shapes.
227 	The array should consist of $(D Shape) objects, each followed by a $(D Transform) that will be applied to it. For shapes that should not have a transform, use $(D constant Transform.IDENTITY).
228 	*/
229 	void setItemShapes(in long id, in Array shapes)
230 	{
231 		checkClassBinding!(typeof(this))();
232 		ptrcall!(void)(GDNativeClassBinding.setItemShapes, _godot_object, id, shapes);
233 	}
234 }