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.meta;
17 import godot.core;
18 import godot.c;
19 import godot.d.bind;
20 import godot.d.reference;
21 import godot.object;
22 import godot.visualinstance;
23 import godot.material;
24 import godot.spatial;
25 import godot.node;
26 /**
27 Base node for geometry based visual instances.
28 
29 Shares some common functionality like visibility and custom materials.
30 */
31 @GodotBaseClass struct GeometryInstance
32 {
33 	enum string _GODOT_internal_name = "GeometryInstance";
34 public:
35 @nogc nothrow:
36 	union { godot_object _godot_object; VisualInstance _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 _classBinding
41 	{
42 		__gshared:
43 		@GodotName("set_material_override") GodotMethod!(void, Material) setMaterialOverride;
44 		@GodotName("get_material_override") GodotMethod!(Material) getMaterialOverride;
45 		@GodotName("set_flag") GodotMethod!(void, long, bool) setFlag;
46 		@GodotName("get_flag") GodotMethod!(bool, long) getFlag;
47 		@GodotName("set_cast_shadows_setting") GodotMethod!(void, long) setCastShadowsSetting;
48 		@GodotName("get_cast_shadows_setting") GodotMethod!(GeometryInstance.ShadowCastingSetting) getCastShadowsSetting;
49 		@GodotName("set_lod_max_hysteresis") GodotMethod!(void, double) setLodMaxHysteresis;
50 		@GodotName("get_lod_max_hysteresis") GodotMethod!(double) getLodMaxHysteresis;
51 		@GodotName("set_lod_max_distance") GodotMethod!(void, double) setLodMaxDistance;
52 		@GodotName("get_lod_max_distance") GodotMethod!(double) getLodMaxDistance;
53 		@GodotName("set_lod_min_hysteresis") GodotMethod!(void, double) setLodMinHysteresis;
54 		@GodotName("get_lod_min_hysteresis") GodotMethod!(double) getLodMinHysteresis;
55 		@GodotName("set_lod_min_distance") GodotMethod!(void, double) setLodMinDistance;
56 		@GodotName("get_lod_min_distance") GodotMethod!(double) getLodMinDistance;
57 		@GodotName("set_extra_cull_margin") GodotMethod!(void, double) setExtraCullMargin;
58 		@GodotName("get_extra_cull_margin") GodotMethod!(double) getExtraCullMargin;
59 	}
60 	bool opEquals(in GeometryInstance other) const { return _godot_object.ptr is other._godot_object.ptr; }
61 	GeometryInstance opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; }
62 	bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; }
63 	mixin baseCasts;
64 	static GeometryInstance _new()
65 	{
66 		static godot_class_constructor constructor;
67 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("GeometryInstance");
68 		if(constructor is null) return typeof(this).init;
69 		return cast(GeometryInstance)(constructor());
70 	}
71 	@disable new(size_t s);
72 	/// 
73 	enum Flags : int
74 	{
75 		/**
76 		Will allow the GeometryInstance to be used when baking lights using a $(D GIProbe) and/or any other form of baked lighting.
77 		Added documentation for GeometryInstance and VisualInstance
78 		*/
79 		flagUseBakedLight = 0,
80 		/**
81 		
82 		*/
83 		flagMax = 2,
84 	}
85 	/// 
86 	enum ShadowCastingSetting : int
87 	{
88 		/**
89 		Will not cast any shadows.
90 		*/
91 		shadowCastingSettingOff = 0,
92 		/**
93 		Will cast shadows from all visible faces in the GeometryInstance.
94 		Will take culling into account, so faces not being rendered will not be taken into account when shadow casting.
95 		*/
96 		shadowCastingSettingOn = 1,
97 		/**
98 		Will cast shadows from all visible faces in the GeometryInstance.
99 		Will not take culling into account, so all faces will be taken into account when shadow casting.
100 		*/
101 		shadowCastingSettingDoubleSided = 2,
102 		/**
103 		Will only show the shadows casted from this object.
104 		In other words: The actual mesh will not be visible, only the shadows casted from the mesh.
105 		*/
106 		shadowCastingSettingShadowsOnly = 3,
107 	}
108 	/// 
109 	enum Constants : int
110 	{
111 		shadowCastingSettingOff = 0,
112 		flagUseBakedLight = 0,
113 		shadowCastingSettingOn = 1,
114 		flagMax = 2,
115 		shadowCastingSettingDoubleSided = 2,
116 		shadowCastingSettingShadowsOnly = 3,
117 	}
118 	/**
119 	
120 	*/
121 	void setMaterialOverride(Material material)
122 	{
123 		checkClassBinding!(typeof(this))();
124 		ptrcall!(void)(_classBinding.setMaterialOverride, _godot_object, material);
125 	}
126 	/**
127 	
128 	*/
129 	Ref!Material getMaterialOverride() const
130 	{
131 		checkClassBinding!(typeof(this))();
132 		return ptrcall!(Material)(_classBinding.getMaterialOverride, _godot_object);
133 	}
134 	/**
135 	
136 	*/
137 	void setFlag(in long flag, in bool value)
138 	{
139 		checkClassBinding!(typeof(this))();
140 		ptrcall!(void)(_classBinding.setFlag, _godot_object, flag, value);
141 	}
142 	/**
143 	
144 	*/
145 	bool getFlag(in long flag) const
146 	{
147 		checkClassBinding!(typeof(this))();
148 		return ptrcall!(bool)(_classBinding.getFlag, _godot_object, flag);
149 	}
150 	/**
151 	
152 	*/
153 	void setCastShadowsSetting(in long shadow_casting_setting)
154 	{
155 		checkClassBinding!(typeof(this))();
156 		ptrcall!(void)(_classBinding.setCastShadowsSetting, _godot_object, shadow_casting_setting);
157 	}
158 	/**
159 	
160 	*/
161 	GeometryInstance.ShadowCastingSetting getCastShadowsSetting() const
162 	{
163 		checkClassBinding!(typeof(this))();
164 		return ptrcall!(GeometryInstance.ShadowCastingSetting)(_classBinding.getCastShadowsSetting, _godot_object);
165 	}
166 	/**
167 	
168 	*/
169 	void setLodMaxHysteresis(in double mode)
170 	{
171 		checkClassBinding!(typeof(this))();
172 		ptrcall!(void)(_classBinding.setLodMaxHysteresis, _godot_object, mode);
173 	}
174 	/**
175 	
176 	*/
177 	double getLodMaxHysteresis() const
178 	{
179 		checkClassBinding!(typeof(this))();
180 		return ptrcall!(double)(_classBinding.getLodMaxHysteresis, _godot_object);
181 	}
182 	/**
183 	
184 	*/
185 	void setLodMaxDistance(in double mode)
186 	{
187 		checkClassBinding!(typeof(this))();
188 		ptrcall!(void)(_classBinding.setLodMaxDistance, _godot_object, mode);
189 	}
190 	/**
191 	
192 	*/
193 	double getLodMaxDistance() const
194 	{
195 		checkClassBinding!(typeof(this))();
196 		return ptrcall!(double)(_classBinding.getLodMaxDistance, _godot_object);
197 	}
198 	/**
199 	
200 	*/
201 	void setLodMinHysteresis(in double mode)
202 	{
203 		checkClassBinding!(typeof(this))();
204 		ptrcall!(void)(_classBinding.setLodMinHysteresis, _godot_object, mode);
205 	}
206 	/**
207 	
208 	*/
209 	double getLodMinHysteresis() const
210 	{
211 		checkClassBinding!(typeof(this))();
212 		return ptrcall!(double)(_classBinding.getLodMinHysteresis, _godot_object);
213 	}
214 	/**
215 	
216 	*/
217 	void setLodMinDistance(in double mode)
218 	{
219 		checkClassBinding!(typeof(this))();
220 		ptrcall!(void)(_classBinding.setLodMinDistance, _godot_object, mode);
221 	}
222 	/**
223 	
224 	*/
225 	double getLodMinDistance() const
226 	{
227 		checkClassBinding!(typeof(this))();
228 		return ptrcall!(double)(_classBinding.getLodMinDistance, _godot_object);
229 	}
230 	/**
231 	
232 	*/
233 	void setExtraCullMargin(in double margin)
234 	{
235 		checkClassBinding!(typeof(this))();
236 		ptrcall!(void)(_classBinding.setExtraCullMargin, _godot_object, margin);
237 	}
238 	/**
239 	
240 	*/
241 	double getExtraCullMargin() const
242 	{
243 		checkClassBinding!(typeof(this))();
244 		return ptrcall!(double)(_classBinding.getExtraCullMargin, _godot_object);
245 	}
246 	/**
247 	The selected shadow casting flag. See SHADOW_CASTING_SETTING_* constants for values.
248 	*/
249 	@property GeometryInstance.ShadowCastingSetting castShadow()
250 	{
251 		return getCastShadowsSetting();
252 	}
253 	/// ditto
254 	@property void castShadow(long v)
255 	{
256 		setCastShadowsSetting(v);
257 	}
258 	/**
259 	The extra distance added to the GeometryInstance's bounding box ($(D AABB)) to increase its cull box.
260 	*/
261 	@property double extraCullMargin()
262 	{
263 		return getExtraCullMargin();
264 	}
265 	/// ditto
266 	@property void extraCullMargin(double v)
267 	{
268 		setExtraCullMargin(v);
269 	}
270 	/**
271 	If `true` this GeometryInstance will be used when baking lights using a $(D GIProbe) and/or any other form of baked lighting.
272 	*/
273 	@property bool useInBakedLight()
274 	{
275 		return getFlag(0);
276 	}
277 	/// ditto
278 	@property void useInBakedLight(bool v)
279 	{
280 		setFlag(0, v);
281 	}
282 	/**
283 	The GeometryInstance's min LOD distance.
284 	*/
285 	@property double lodMinDistance()
286 	{
287 		return getLodMinDistance();
288 	}
289 	/// ditto
290 	@property void lodMinDistance(double v)
291 	{
292 		setLodMinDistance(v);
293 	}
294 	/**
295 	The GeometryInstance's min LOD margin.
296 	*/
297 	@property double lodMinHysteresis()
298 	{
299 		return getLodMinHysteresis();
300 	}
301 	/// ditto
302 	@property void lodMinHysteresis(double v)
303 	{
304 		setLodMinHysteresis(v);
305 	}
306 	/**
307 	The GeometryInstance's max LOD distance.
308 	*/
309 	@property double lodMaxDistance()
310 	{
311 		return getLodMaxDistance();
312 	}
313 	/// ditto
314 	@property void lodMaxDistance(double v)
315 	{
316 		setLodMaxDistance(v);
317 	}
318 	/**
319 	The GeometryInstance's max LOD margin.
320 	*/
321 	@property double lodMaxHysteresis()
322 	{
323 		return getLodMaxHysteresis();
324 	}
325 	/// ditto
326 	@property void lodMaxHysteresis(double v)
327 	{
328 		setLodMaxHysteresis(v);
329 	}
330 }