1 /** 2 Abstract base $(D Resource) for coloring and shading geometry. 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.material; 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.resource; 24 /** 25 Abstract base $(D Resource) for coloring and shading geometry. 26 27 Material is a base $(D Resource) used for coloring and shading geometry. All materials inherit from it and almost all $(D VisualInstance) derived nodes carry a Material. A few flags and parameters are shared between all material types and are configured here. 28 */ 29 @GodotBaseClass struct Material 30 { 31 package(godot) enum string _GODOT_internal_name = "Material"; 32 public: 33 @nogc nothrow: 34 union { /** */ godot_object _godot_object; /** */ Resource _GODOT_base; } 35 alias _GODOT_base this; 36 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 37 package(godot) __gshared bool _classBindingInitialized = false; 38 package(godot) static struct GDNativeClassBinding 39 { 40 __gshared: 41 @GodotName("get_next_pass") GodotMethod!(Material) getNextPass; 42 @GodotName("get_render_priority") GodotMethod!(long) getRenderPriority; 43 @GodotName("set_next_pass") GodotMethod!(void, Material) setNextPass; 44 @GodotName("set_render_priority") GodotMethod!(void, long) setRenderPriority; 45 } 46 /// 47 pragma(inline, true) bool opEquals(in Material other) const 48 { return _godot_object.ptr is other._godot_object.ptr; } 49 /// 50 pragma(inline, true) typeof(null) opAssign(typeof(null) n) 51 { _godot_object.ptr = n; return null; } 52 /// 53 pragma(inline, true) bool opEquals(typeof(null) n) const 54 { return _godot_object.ptr is n; } 55 /// 56 size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; } 57 mixin baseCasts; 58 /// Construct a new instance of Material. 59 /// Note: use `memnew!Material` instead. 60 static Material _new() 61 { 62 static godot_class_constructor constructor; 63 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("Material"); 64 if(constructor is null) return typeof(this).init; 65 return cast(Material)(constructor()); 66 } 67 @disable new(size_t s); 68 /// 69 enum Constants : int 70 { 71 /** 72 Minimum value for the $(D renderPriority) parameter. 73 */ 74 renderPriorityMin = -128, 75 /** 76 Maximum value for the $(D renderPriority) parameter. 77 */ 78 renderPriorityMax = 127, 79 } 80 /** 81 82 */ 83 Ref!Material getNextPass() const 84 { 85 checkClassBinding!(typeof(this))(); 86 return ptrcall!(Material)(GDNativeClassBinding.getNextPass, _godot_object); 87 } 88 /** 89 90 */ 91 long getRenderPriority() const 92 { 93 checkClassBinding!(typeof(this))(); 94 return ptrcall!(long)(GDNativeClassBinding.getRenderPriority, _godot_object); 95 } 96 /** 97 98 */ 99 void setNextPass(Material next_pass) 100 { 101 checkClassBinding!(typeof(this))(); 102 ptrcall!(void)(GDNativeClassBinding.setNextPass, _godot_object, next_pass); 103 } 104 /** 105 106 */ 107 void setRenderPriority(in long priority) 108 { 109 checkClassBinding!(typeof(this))(); 110 ptrcall!(void)(GDNativeClassBinding.setRenderPriority, _godot_object, priority); 111 } 112 /** 113 Sets the $(D Material) to be used for the next pass. This renders the object again using a different material. 114 $(B Note:) only applies to $(D SpatialMaterial)s and $(D ShaderMaterial)s with type "Spatial". 115 */ 116 @property Material nextPass() 117 { 118 return getNextPass(); 119 } 120 /// ditto 121 @property void nextPass(Material v) 122 { 123 setNextPass(v); 124 } 125 /** 126 Sets the render priority for transparent objects in 3D scenes. Higher priority objects will be sorted in front of lower priority objects. 127 $(B Note:) this only applies to sorting of transparent objects. This will not impact how transparent objects are sorted relative to opaque objects. This is because opaque objects are not sorted, while transparent objects are sorted from back to front (subject to priority). 128 */ 129 @property long renderPriority() 130 { 131 return getRenderPriority(); 132 } 133 /// ditto 134 @property void renderPriority(long v) 135 { 136 setRenderPriority(v); 137 } 138 }