1 /**
2 Base node for geometry-based visual instances.
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.geometryinstance;
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.visualinstance;
24 import godot.material;
25 /**
26 Base node for geometry-based visual instances.
27 
28 Shares some common functionality like visibility and custom materials.
29 */
30 @GodotBaseClass struct GeometryInstance
31 {
32 	package(godot) enum string _GODOT_internal_name = "GeometryInstance";
33 public:
34 @nogc nothrow:
35 	union { /** */ godot_object _godot_object; /** */ VisualInstance _GODOT_base; }
36 	alias _GODOT_base this;
37 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
38 	package(godot) __gshared bool _classBindingInitialized = false;
39 	package(godot) static struct GDNativeClassBinding
40 	{
41 		__gshared:
42 		@GodotName("get_cast_shadows_setting") GodotMethod!(GeometryInstance.ShadowCastingSetting) getCastShadowsSetting;
43 		@GodotName("get_extra_cull_margin") GodotMethod!(double) getExtraCullMargin;
44 		@GodotName("get_flag") GodotMethod!(bool, long) getFlag;
45 		@GodotName("get_generate_lightmap") GodotMethod!(bool) getGenerateLightmap;
46 		@GodotName("get_lightmap_scale") GodotMethod!(GeometryInstance.LightmapScale) getLightmapScale;
47 		@GodotName("get_lod_max_distance") GodotMethod!(double) getLodMaxDistance;
48 		@GodotName("get_lod_max_hysteresis") GodotMethod!(double) getLodMaxHysteresis;
49 		@GodotName("get_lod_min_distance") GodotMethod!(double) getLodMinDistance;
50 		@GodotName("get_lod_min_hysteresis") GodotMethod!(double) getLodMinHysteresis;
51 		@GodotName("get_material_override") GodotMethod!(Material) getMaterialOverride;
52 		@GodotName("set_cast_shadows_setting") GodotMethod!(void, long) setCastShadowsSetting;
53 		@GodotName("set_custom_aabb") GodotMethod!(void, AABB) setCustomAabb;
54 		@GodotName("set_extra_cull_margin") GodotMethod!(void, double) setExtraCullMargin;
55 		@GodotName("set_flag") GodotMethod!(void, long, bool) setFlag;
56 		@GodotName("set_generate_lightmap") GodotMethod!(void, bool) setGenerateLightmap;
57 		@GodotName("set_lightmap_scale") GodotMethod!(void, long) setLightmapScale;
58 		@GodotName("set_lod_max_distance") GodotMethod!(void, double) setLodMaxDistance;
59 		@GodotName("set_lod_max_hysteresis") GodotMethod!(void, double) setLodMaxHysteresis;
60 		@GodotName("set_lod_min_distance") GodotMethod!(void, double) setLodMinDistance;
61 		@GodotName("set_lod_min_hysteresis") GodotMethod!(void, double) setLodMinHysteresis;
62 		@GodotName("set_material_override") GodotMethod!(void, Material) setMaterialOverride;
63 	}
64 	/// 
65 	pragma(inline, true) bool opEquals(in GeometryInstance 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 GeometryInstance.
77 	/// Note: use `memnew!GeometryInstance` instead.
78 	static GeometryInstance _new()
79 	{
80 		static godot_class_constructor constructor;
81 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("GeometryInstance");
82 		if(constructor is null) return typeof(this).init;
83 		return cast(GeometryInstance)(constructor());
84 	}
85 	@disable new(size_t s);
86 	/// 
87 	enum Flags : int
88 	{
89 		/**
90 		Will allow the GeometryInstance to be used when baking lights using a $(D GIProbe) or $(D BakedLightmap).
91 		*/
92 		flagUseBakedLight = 0,
93 		/**
94 		Unused in this class, exposed for consistency with $(D VisualServer.instanceflags).
95 		*/
96 		flagDrawNextFrameIfVisible = 1,
97 		/**
98 		Represents the size of the $(D flags) enum.
99 		*/
100 		flagMax = 2,
101 	}
102 	/// 
103 	enum ShadowCastingSetting : int
104 	{
105 		/**
106 		Will not cast any shadows.
107 		*/
108 		shadowCastingSettingOff = 0,
109 		/**
110 		Will cast shadows from all visible faces in the GeometryInstance.
111 		Will take culling into account, so faces not being rendered will not be taken into account when shadow casting.
112 		*/
113 		shadowCastingSettingOn = 1,
114 		/**
115 		Will cast shadows from all visible faces in the GeometryInstance.
116 		Will not take culling into account, so all faces will be taken into account when shadow casting.
117 		*/
118 		shadowCastingSettingDoubleSided = 2,
119 		/**
120 		Will only show the shadows casted from this object.
121 		In other words, the actual mesh will not be visible, only the shadows casted from the mesh will be.
122 		*/
123 		shadowCastingSettingShadowsOnly = 3,
124 	}
125 	/// 
126 	enum LightmapScale : int
127 	{
128 		/**
129 		The generated lightmap texture will have the original size.
130 		*/
131 		lightmapScale1x = 0,
132 		/**
133 		The generated lightmap texture will be twice as large, on each axis.
134 		*/
135 		lightmapScale2x = 1,
136 		/**
137 		The generated lightmap texture will be 4 times as large, on each axis.
138 		*/
139 		lightmapScale4x = 2,
140 		/**
141 		The generated lightmap texture will be 8 times as large, on each axis.
142 		*/
143 		lightmapScale8x = 3,
144 		/**
145 		
146 		*/
147 		lightmapScaleMax = 4,
148 	}
149 	/// 
150 	enum Constants : int
151 	{
152 		flagUseBakedLight = 0,
153 		lightmapScale1x = 0,
154 		shadowCastingSettingOff = 0,
155 		flagDrawNextFrameIfVisible = 1,
156 		lightmapScale2x = 1,
157 		shadowCastingSettingOn = 1,
158 		flagMax = 2,
159 		shadowCastingSettingDoubleSided = 2,
160 		lightmapScale4x = 2,
161 		shadowCastingSettingShadowsOnly = 3,
162 		lightmapScale8x = 3,
163 		lightmapScaleMax = 4,
164 	}
165 	/**
166 	
167 	*/
168 	GeometryInstance.ShadowCastingSetting getCastShadowsSetting() const
169 	{
170 		checkClassBinding!(typeof(this))();
171 		return ptrcall!(GeometryInstance.ShadowCastingSetting)(GDNativeClassBinding.getCastShadowsSetting, _godot_object);
172 	}
173 	/**
174 	
175 	*/
176 	double getExtraCullMargin() const
177 	{
178 		checkClassBinding!(typeof(this))();
179 		return ptrcall!(double)(GDNativeClassBinding.getExtraCullMargin, _godot_object);
180 	}
181 	/**
182 	Returns the $(D GeometryInstance.flags) that have been set for this object.
183 	*/
184 	bool getFlag(in long flag) const
185 	{
186 		checkClassBinding!(typeof(this))();
187 		return ptrcall!(bool)(GDNativeClassBinding.getFlag, _godot_object, flag);
188 	}
189 	/**
190 	
191 	*/
192 	bool getGenerateLightmap()
193 	{
194 		checkClassBinding!(typeof(this))();
195 		return ptrcall!(bool)(GDNativeClassBinding.getGenerateLightmap, _godot_object);
196 	}
197 	/**
198 	
199 	*/
200 	GeometryInstance.LightmapScale getLightmapScale() const
201 	{
202 		checkClassBinding!(typeof(this))();
203 		return ptrcall!(GeometryInstance.LightmapScale)(GDNativeClassBinding.getLightmapScale, _godot_object);
204 	}
205 	/**
206 	
207 	*/
208 	double getLodMaxDistance() const
209 	{
210 		checkClassBinding!(typeof(this))();
211 		return ptrcall!(double)(GDNativeClassBinding.getLodMaxDistance, _godot_object);
212 	}
213 	/**
214 	
215 	*/
216 	double getLodMaxHysteresis() const
217 	{
218 		checkClassBinding!(typeof(this))();
219 		return ptrcall!(double)(GDNativeClassBinding.getLodMaxHysteresis, _godot_object);
220 	}
221 	/**
222 	
223 	*/
224 	double getLodMinDistance() const
225 	{
226 		checkClassBinding!(typeof(this))();
227 		return ptrcall!(double)(GDNativeClassBinding.getLodMinDistance, _godot_object);
228 	}
229 	/**
230 	
231 	*/
232 	double getLodMinHysteresis() const
233 	{
234 		checkClassBinding!(typeof(this))();
235 		return ptrcall!(double)(GDNativeClassBinding.getLodMinHysteresis, _godot_object);
236 	}
237 	/**
238 	
239 	*/
240 	Ref!Material getMaterialOverride() const
241 	{
242 		checkClassBinding!(typeof(this))();
243 		return ptrcall!(Material)(GDNativeClassBinding.getMaterialOverride, _godot_object);
244 	}
245 	/**
246 	
247 	*/
248 	void setCastShadowsSetting(in long shadow_casting_setting)
249 	{
250 		checkClassBinding!(typeof(this))();
251 		ptrcall!(void)(GDNativeClassBinding.setCastShadowsSetting, _godot_object, shadow_casting_setting);
252 	}
253 	/**
254 	Overrides the bounding box of this node with a custom one. To remove it, set an $(D AABB) with all fields set to zero.
255 	*/
256 	void setCustomAabb(in AABB aabb)
257 	{
258 		checkClassBinding!(typeof(this))();
259 		ptrcall!(void)(GDNativeClassBinding.setCustomAabb, _godot_object, aabb);
260 	}
261 	/**
262 	
263 	*/
264 	void setExtraCullMargin(in double margin)
265 	{
266 		checkClassBinding!(typeof(this))();
267 		ptrcall!(void)(GDNativeClassBinding.setExtraCullMargin, _godot_object, margin);
268 	}
269 	/**
270 	Sets the $(D GeometryInstance.flags) specified. See $(D GeometryInstance.flags) for options.
271 	*/
272 	void setFlag(in long flag, in bool value)
273 	{
274 		checkClassBinding!(typeof(this))();
275 		ptrcall!(void)(GDNativeClassBinding.setFlag, _godot_object, flag, value);
276 	}
277 	/**
278 	
279 	*/
280 	void setGenerateLightmap(in bool enabled)
281 	{
282 		checkClassBinding!(typeof(this))();
283 		ptrcall!(void)(GDNativeClassBinding.setGenerateLightmap, _godot_object, enabled);
284 	}
285 	/**
286 	
287 	*/
288 	void setLightmapScale(in long scale)
289 	{
290 		checkClassBinding!(typeof(this))();
291 		ptrcall!(void)(GDNativeClassBinding.setLightmapScale, _godot_object, scale);
292 	}
293 	/**
294 	
295 	*/
296 	void setLodMaxDistance(in double mode)
297 	{
298 		checkClassBinding!(typeof(this))();
299 		ptrcall!(void)(GDNativeClassBinding.setLodMaxDistance, _godot_object, mode);
300 	}
301 	/**
302 	
303 	*/
304 	void setLodMaxHysteresis(in double mode)
305 	{
306 		checkClassBinding!(typeof(this))();
307 		ptrcall!(void)(GDNativeClassBinding.setLodMaxHysteresis, _godot_object, mode);
308 	}
309 	/**
310 	
311 	*/
312 	void setLodMinDistance(in double mode)
313 	{
314 		checkClassBinding!(typeof(this))();
315 		ptrcall!(void)(GDNativeClassBinding.setLodMinDistance, _godot_object, mode);
316 	}
317 	/**
318 	
319 	*/
320 	void setLodMinHysteresis(in double mode)
321 	{
322 		checkClassBinding!(typeof(this))();
323 		ptrcall!(void)(GDNativeClassBinding.setLodMinHysteresis, _godot_object, mode);
324 	}
325 	/**
326 	
327 	*/
328 	void setMaterialOverride(Material material)
329 	{
330 		checkClassBinding!(typeof(this))();
331 		ptrcall!(void)(GDNativeClassBinding.setMaterialOverride, _godot_object, material);
332 	}
333 	/**
334 	The selected shadow casting flag. See $(D shadowcastingsetting) for possible values.
335 	*/
336 	@property GeometryInstance.ShadowCastingSetting castShadow()
337 	{
338 		return getCastShadowsSetting();
339 	}
340 	/// ditto
341 	@property void castShadow(long v)
342 	{
343 		setCastShadowsSetting(v);
344 	}
345 	/**
346 	The extra distance added to the GeometryInstance's bounding box ($(D AABB)) to increase its cull box.
347 	*/
348 	@property double extraCullMargin()
349 	{
350 		return getExtraCullMargin();
351 	}
352 	/// ditto
353 	@property void extraCullMargin(double v)
354 	{
355 		setExtraCullMargin(v);
356 	}
357 	/**
358 	When disabled, the mesh will be taken into account when computing indirect lighting, but the resulting lightmap will not be saved. Useful for emissive only materials or shadow casters.
359 	*/
360 	@property bool generateLightmap()
361 	{
362 		return getGenerateLightmap();
363 	}
364 	/// ditto
365 	@property void generateLightmap(bool v)
366 	{
367 		setGenerateLightmap(v);
368 	}
369 	/**
370 	Scale factor for the generated baked lightmap. Useful for adding detail to certain mesh instances.
371 	*/
372 	@property GeometryInstance.LightmapScale lightmapScale()
373 	{
374 		return getLightmapScale();
375 	}
376 	/// ditto
377 	@property void lightmapScale(long v)
378 	{
379 		setLightmapScale(v);
380 	}
381 	/**
382 	The GeometryInstance's max LOD distance.
383 	$(B Note:) This property currently has no effect.
384 	*/
385 	@property double lodMaxDistance()
386 	{
387 		return getLodMaxDistance();
388 	}
389 	/// ditto
390 	@property void lodMaxDistance(double v)
391 	{
392 		setLodMaxDistance(v);
393 	}
394 	/**
395 	The GeometryInstance's max LOD margin.
396 	$(B Note:) This property currently has no effect.
397 	*/
398 	@property double lodMaxHysteresis()
399 	{
400 		return getLodMaxHysteresis();
401 	}
402 	/// ditto
403 	@property void lodMaxHysteresis(double v)
404 	{
405 		setLodMaxHysteresis(v);
406 	}
407 	/**
408 	The GeometryInstance's min LOD distance.
409 	$(B Note:) This property currently has no effect.
410 	*/
411 	@property double lodMinDistance()
412 	{
413 		return getLodMinDistance();
414 	}
415 	/// ditto
416 	@property void lodMinDistance(double v)
417 	{
418 		setLodMinDistance(v);
419 	}
420 	/**
421 	The GeometryInstance's min LOD margin.
422 	$(B Note:) This property currently has no effect.
423 	*/
424 	@property double lodMinHysteresis()
425 	{
426 		return getLodMinHysteresis();
427 	}
428 	/// ditto
429 	@property void lodMinHysteresis(double v)
430 	{
431 		setLodMinHysteresis(v);
432 	}
433 	/**
434 	If `true`, this GeometryInstance will be used when baking lights using a $(D GIProbe) or $(D BakedLightmap).
435 	*/
436 	@property bool useInBakedLight()
437 	{
438 		return getFlag(0);
439 	}
440 	/// ditto
441 	@property void useInBakedLight(bool v)
442 	{
443 		setFlag(0, v);
444 	}
445 }