1 /**
2 Extrudes a 2D polygon shape to create a 3D mesh.
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.csgpolygon;
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.csgprimitive;
25 import godot.material;
26 /**
27 Extrudes a 2D polygon shape to create a 3D mesh.
28 
29 This node takes a 2D polygon shape and extrudes it to create a 3D mesh.
30 */
31 @GodotBaseClass struct CSGPolygon
32 {
33 	package(godot) enum string _GODOT_internal_name = "CSGPolygon";
34 public:
35 @nogc nothrow:
36 	union { /** */ godot_object _godot_object; /** */ CSGPrimitive _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("_has_editable_3d_polygon_no_depth") GodotMethod!(bool) _hasEditable3dPolygonNoDepth;
44 		@GodotName("_is_editable_3d_polygon") GodotMethod!(bool) _isEditable3dPolygon;
45 		@GodotName("_path_changed") GodotMethod!(void) _pathChanged;
46 		@GodotName("_path_exited") GodotMethod!(void) _pathExited;
47 		@GodotName("get_depth") GodotMethod!(double) getDepth;
48 		@GodotName("get_material") GodotMethod!(Material) getMaterial;
49 		@GodotName("get_mode") GodotMethod!(CSGPolygon.Mode) getMode;
50 		@GodotName("get_path_interval") GodotMethod!(double) getPathInterval;
51 		@GodotName("get_path_node") GodotMethod!(NodePath) getPathNode;
52 		@GodotName("get_path_rotation") GodotMethod!(CSGPolygon.PathRotation) getPathRotation;
53 		@GodotName("get_polygon") GodotMethod!(PoolVector2Array) getPolygon;
54 		@GodotName("get_smooth_faces") GodotMethod!(bool) getSmoothFaces;
55 		@GodotName("get_spin_degrees") GodotMethod!(double) getSpinDegrees;
56 		@GodotName("get_spin_sides") GodotMethod!(long) getSpinSides;
57 		@GodotName("is_path_continuous_u") GodotMethod!(bool) isPathContinuousU;
58 		@GodotName("is_path_joined") GodotMethod!(bool) isPathJoined;
59 		@GodotName("is_path_local") GodotMethod!(bool) isPathLocal;
60 		@GodotName("set_depth") GodotMethod!(void, double) setDepth;
61 		@GodotName("set_material") GodotMethod!(void, Material) setMaterial;
62 		@GodotName("set_mode") GodotMethod!(void, long) setMode;
63 		@GodotName("set_path_continuous_u") GodotMethod!(void, bool) setPathContinuousU;
64 		@GodotName("set_path_interval") GodotMethod!(void, double) setPathInterval;
65 		@GodotName("set_path_joined") GodotMethod!(void, bool) setPathJoined;
66 		@GodotName("set_path_local") GodotMethod!(void, bool) setPathLocal;
67 		@GodotName("set_path_node") GodotMethod!(void, NodePath) setPathNode;
68 		@GodotName("set_path_rotation") GodotMethod!(void, long) setPathRotation;
69 		@GodotName("set_polygon") GodotMethod!(void, PoolVector2Array) setPolygon;
70 		@GodotName("set_smooth_faces") GodotMethod!(void, bool) setSmoothFaces;
71 		@GodotName("set_spin_degrees") GodotMethod!(void, double) setSpinDegrees;
72 		@GodotName("set_spin_sides") GodotMethod!(void, long) setSpinSides;
73 	}
74 	/// 
75 	pragma(inline, true) bool opEquals(in CSGPolygon other) const
76 	{ return _godot_object.ptr is other._godot_object.ptr; }
77 	/// 
78 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
79 	{ _godot_object.ptr = n; return null; }
80 	/// 
81 	pragma(inline, true) bool opEquals(typeof(null) n) const
82 	{ return _godot_object.ptr is n; }
83 	/// 
84 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
85 	mixin baseCasts;
86 	/// Construct a new instance of CSGPolygon.
87 	/// Note: use `memnew!CSGPolygon` instead.
88 	static CSGPolygon _new()
89 	{
90 		static godot_class_constructor constructor;
91 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("CSGPolygon");
92 		if(constructor is null) return typeof(this).init;
93 		return cast(CSGPolygon)(constructor());
94 	}
95 	@disable new(size_t s);
96 	/// 
97 	enum PathRotation : int
98 	{
99 		/**
100 		Slice is not rotated.
101 		*/
102 		pathRotationPolygon = 0,
103 		/**
104 		Slice is rotated around the up vector of the path.
105 		*/
106 		pathRotationPath = 1,
107 		/**
108 		Slice is rotate to match the path exactly.
109 		*/
110 		pathRotationPathFollow = 2,
111 	}
112 	/// 
113 	enum Mode : int
114 	{
115 		/**
116 		Shape is extruded to $(D depth).
117 		*/
118 		modeDepth = 0,
119 		/**
120 		Shape is extruded by rotating it around an axis.
121 		*/
122 		modeSpin = 1,
123 		/**
124 		Shape is extruded along a path set by a $(D Shape) set in $(D pathNode).
125 		*/
126 		modePath = 2,
127 	}
128 	/// 
129 	enum Constants : int
130 	{
131 		modeDepth = 0,
132 		pathRotationPolygon = 0,
133 		pathRotationPath = 1,
134 		modeSpin = 1,
135 		pathRotationPathFollow = 2,
136 		modePath = 2,
137 	}
138 	/**
139 	
140 	*/
141 	bool _hasEditable3dPolygonNoDepth() const
142 	{
143 		Array _GODOT_args = Array.make();
144 		String _GODOT_method_name = String("_has_editable_3d_polygon_no_depth");
145 		return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!bool);
146 	}
147 	/**
148 	
149 	*/
150 	bool _isEditable3dPolygon() const
151 	{
152 		Array _GODOT_args = Array.make();
153 		String _GODOT_method_name = String("_is_editable_3d_polygon");
154 		return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!bool);
155 	}
156 	/**
157 	
158 	*/
159 	void _pathChanged()
160 	{
161 		Array _GODOT_args = Array.make();
162 		String _GODOT_method_name = String("_path_changed");
163 		this.callv(_GODOT_method_name, _GODOT_args);
164 	}
165 	/**
166 	
167 	*/
168 	void _pathExited()
169 	{
170 		Array _GODOT_args = Array.make();
171 		String _GODOT_method_name = String("_path_exited");
172 		this.callv(_GODOT_method_name, _GODOT_args);
173 	}
174 	/**
175 	
176 	*/
177 	double getDepth() const
178 	{
179 		checkClassBinding!(typeof(this))();
180 		return ptrcall!(double)(GDNativeClassBinding.getDepth, _godot_object);
181 	}
182 	/**
183 	
184 	*/
185 	Ref!Material getMaterial() const
186 	{
187 		checkClassBinding!(typeof(this))();
188 		return ptrcall!(Material)(GDNativeClassBinding.getMaterial, _godot_object);
189 	}
190 	/**
191 	
192 	*/
193 	CSGPolygon.Mode getMode() const
194 	{
195 		checkClassBinding!(typeof(this))();
196 		return ptrcall!(CSGPolygon.Mode)(GDNativeClassBinding.getMode, _godot_object);
197 	}
198 	/**
199 	
200 	*/
201 	double getPathInterval() const
202 	{
203 		checkClassBinding!(typeof(this))();
204 		return ptrcall!(double)(GDNativeClassBinding.getPathInterval, _godot_object);
205 	}
206 	/**
207 	
208 	*/
209 	NodePath getPathNode() const
210 	{
211 		checkClassBinding!(typeof(this))();
212 		return ptrcall!(NodePath)(GDNativeClassBinding.getPathNode, _godot_object);
213 	}
214 	/**
215 	
216 	*/
217 	CSGPolygon.PathRotation getPathRotation() const
218 	{
219 		checkClassBinding!(typeof(this))();
220 		return ptrcall!(CSGPolygon.PathRotation)(GDNativeClassBinding.getPathRotation, _godot_object);
221 	}
222 	/**
223 	
224 	*/
225 	PoolVector2Array getPolygon() const
226 	{
227 		checkClassBinding!(typeof(this))();
228 		return ptrcall!(PoolVector2Array)(GDNativeClassBinding.getPolygon, _godot_object);
229 	}
230 	/**
231 	
232 	*/
233 	bool getSmoothFaces() const
234 	{
235 		checkClassBinding!(typeof(this))();
236 		return ptrcall!(bool)(GDNativeClassBinding.getSmoothFaces, _godot_object);
237 	}
238 	/**
239 	
240 	*/
241 	double getSpinDegrees() const
242 	{
243 		checkClassBinding!(typeof(this))();
244 		return ptrcall!(double)(GDNativeClassBinding.getSpinDegrees, _godot_object);
245 	}
246 	/**
247 	
248 	*/
249 	long getSpinSides() const
250 	{
251 		checkClassBinding!(typeof(this))();
252 		return ptrcall!(long)(GDNativeClassBinding.getSpinSides, _godot_object);
253 	}
254 	/**
255 	
256 	*/
257 	bool isPathContinuousU() const
258 	{
259 		checkClassBinding!(typeof(this))();
260 		return ptrcall!(bool)(GDNativeClassBinding.isPathContinuousU, _godot_object);
261 	}
262 	/**
263 	
264 	*/
265 	bool isPathJoined() const
266 	{
267 		checkClassBinding!(typeof(this))();
268 		return ptrcall!(bool)(GDNativeClassBinding.isPathJoined, _godot_object);
269 	}
270 	/**
271 	
272 	*/
273 	bool isPathLocal() const
274 	{
275 		checkClassBinding!(typeof(this))();
276 		return ptrcall!(bool)(GDNativeClassBinding.isPathLocal, _godot_object);
277 	}
278 	/**
279 	
280 	*/
281 	void setDepth(in double depth)
282 	{
283 		checkClassBinding!(typeof(this))();
284 		ptrcall!(void)(GDNativeClassBinding.setDepth, _godot_object, depth);
285 	}
286 	/**
287 	
288 	*/
289 	void setMaterial(Material material)
290 	{
291 		checkClassBinding!(typeof(this))();
292 		ptrcall!(void)(GDNativeClassBinding.setMaterial, _godot_object, material);
293 	}
294 	/**
295 	
296 	*/
297 	void setMode(in long mode)
298 	{
299 		checkClassBinding!(typeof(this))();
300 		ptrcall!(void)(GDNativeClassBinding.setMode, _godot_object, mode);
301 	}
302 	/**
303 	
304 	*/
305 	void setPathContinuousU(in bool enable)
306 	{
307 		checkClassBinding!(typeof(this))();
308 		ptrcall!(void)(GDNativeClassBinding.setPathContinuousU, _godot_object, enable);
309 	}
310 	/**
311 	
312 	*/
313 	void setPathInterval(in double distance)
314 	{
315 		checkClassBinding!(typeof(this))();
316 		ptrcall!(void)(GDNativeClassBinding.setPathInterval, _godot_object, distance);
317 	}
318 	/**
319 	
320 	*/
321 	void setPathJoined(in bool enable)
322 	{
323 		checkClassBinding!(typeof(this))();
324 		ptrcall!(void)(GDNativeClassBinding.setPathJoined, _godot_object, enable);
325 	}
326 	/**
327 	
328 	*/
329 	void setPathLocal(in bool enable)
330 	{
331 		checkClassBinding!(typeof(this))();
332 		ptrcall!(void)(GDNativeClassBinding.setPathLocal, _godot_object, enable);
333 	}
334 	/**
335 	
336 	*/
337 	void setPathNode(NodePathArg0)(in NodePathArg0 path)
338 	{
339 		checkClassBinding!(typeof(this))();
340 		ptrcall!(void)(GDNativeClassBinding.setPathNode, _godot_object, path);
341 	}
342 	/**
343 	
344 	*/
345 	void setPathRotation(in long mode)
346 	{
347 		checkClassBinding!(typeof(this))();
348 		ptrcall!(void)(GDNativeClassBinding.setPathRotation, _godot_object, mode);
349 	}
350 	/**
351 	
352 	*/
353 	void setPolygon(in PoolVector2Array polygon)
354 	{
355 		checkClassBinding!(typeof(this))();
356 		ptrcall!(void)(GDNativeClassBinding.setPolygon, _godot_object, polygon);
357 	}
358 	/**
359 	
360 	*/
361 	void setSmoothFaces(in bool smooth_faces)
362 	{
363 		checkClassBinding!(typeof(this))();
364 		ptrcall!(void)(GDNativeClassBinding.setSmoothFaces, _godot_object, smooth_faces);
365 	}
366 	/**
367 	
368 	*/
369 	void setSpinDegrees(in double degrees)
370 	{
371 		checkClassBinding!(typeof(this))();
372 		ptrcall!(void)(GDNativeClassBinding.setSpinDegrees, _godot_object, degrees);
373 	}
374 	/**
375 	
376 	*/
377 	void setSpinSides(in long spin_sides)
378 	{
379 		checkClassBinding!(typeof(this))();
380 		ptrcall!(void)(GDNativeClassBinding.setSpinSides, _godot_object, spin_sides);
381 	}
382 	/**
383 	Extrusion depth when $(D mode) is $(D constant MODE_DEPTH).
384 	*/
385 	@property double depth()
386 	{
387 		return getDepth();
388 	}
389 	/// ditto
390 	@property void depth(double v)
391 	{
392 		setDepth(v);
393 	}
394 	/**
395 	Extrusion mode.
396 	*/
397 	@property CSGPolygon.Mode mode()
398 	{
399 		return getMode();
400 	}
401 	/// ditto
402 	@property void mode(long v)
403 	{
404 		setMode(v);
405 	}
406 	/**
407 	If `true` the u component of our uv will continuously increase in unison with the distance traveled along our path when $(D mode) is $(D constant MODE_PATH).
408 	*/
409 	@property bool pathContinuousU()
410 	{
411 		return isPathContinuousU();
412 	}
413 	/// ditto
414 	@property void pathContinuousU(bool v)
415 	{
416 		setPathContinuousU(v);
417 	}
418 	/**
419 	Interval at which a new extrusion slice is added along the path when $(D mode) is $(D constant MODE_PATH).
420 	*/
421 	@property double pathInterval()
422 	{
423 		return getPathInterval();
424 	}
425 	/// ditto
426 	@property void pathInterval(double v)
427 	{
428 		setPathInterval(v);
429 	}
430 	/**
431 	If `true` the start and end of our path are joined together ensuring there is no seam when $(D mode) is $(D constant MODE_PATH).
432 	*/
433 	@property bool pathJoined()
434 	{
435 		return isPathJoined();
436 	}
437 	/// ditto
438 	@property void pathJoined(bool v)
439 	{
440 		setPathJoined(v);
441 	}
442 	/**
443 	If `false` we extrude centered on our path, if `true` we extrude in relation to the position of our CSGPolygon when $(D mode) is $(D constant MODE_PATH).
444 	*/
445 	@property bool pathLocal()
446 	{
447 		return isPathLocal();
448 	}
449 	/// ditto
450 	@property void pathLocal(bool v)
451 	{
452 		setPathLocal(v);
453 	}
454 	/**
455 	The $(D Shape) object containing the path along which we extrude when $(D mode) is $(D constant MODE_PATH).
456 	*/
457 	@property NodePath pathNode()
458 	{
459 		return getPathNode();
460 	}
461 	/// ditto
462 	@property void pathNode(NodePath v)
463 	{
464 		setPathNode(v);
465 	}
466 	/**
467 	The method by which each slice is rotated along the path when $(D mode) is $(D constant MODE_PATH).
468 	*/
469 	@property CSGPolygon.PathRotation pathRotation()
470 	{
471 		return getPathRotation();
472 	}
473 	/// ditto
474 	@property void pathRotation(long v)
475 	{
476 		setPathRotation(v);
477 	}
478 	/**
479 	Point array that defines the shape that we'll extrude.
480 	*/
481 	@property PoolVector2Array polygon()
482 	{
483 		return getPolygon();
484 	}
485 	/// ditto
486 	@property void polygon(PoolVector2Array v)
487 	{
488 		setPolygon(v);
489 	}
490 	/**
491 	Generates smooth normals so smooth shading is applied to our mesh.
492 	*/
493 	@property bool smoothFaces()
494 	{
495 		return getSmoothFaces();
496 	}
497 	/// ditto
498 	@property void smoothFaces(bool v)
499 	{
500 		setSmoothFaces(v);
501 	}
502 	/**
503 	Degrees to rotate our extrusion for each slice when $(D mode) is $(D constant MODE_SPIN).
504 	*/
505 	@property double spinDegrees()
506 	{
507 		return getSpinDegrees();
508 	}
509 	/// ditto
510 	@property void spinDegrees(double v)
511 	{
512 		setSpinDegrees(v);
513 	}
514 	/**
515 	Number of extrusion when $(D mode) is $(D constant MODE_SPIN).
516 	*/
517 	@property long spinSides()
518 	{
519 		return getSpinSides();
520 	}
521 	/// ditto
522 	@property void spinSides(long v)
523 	{
524 		setSpinSides(v);
525 	}
526 }