1 /** 2 Base class for nodes in a visual shader graph. 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.visualshadernode; 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 import godot.reference; 25 /** 26 Base class for nodes in a visual shader graph. 27 */ 28 @GodotBaseClass struct VisualShaderNode 29 { 30 package(godot) enum string _GODOT_internal_name = "VisualShaderNode"; 31 public: 32 @nogc nothrow: 33 union { /** */ godot_object _godot_object; /** */ Resource _GODOT_base; } 34 alias _GODOT_base this; 35 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 36 package(godot) __gshared bool _classBindingInitialized = false; 37 package(godot) static struct GDNativeClassBinding 38 { 39 __gshared: 40 @GodotName("get_default_input_values") GodotMethod!(Array) getDefaultInputValues; 41 @GodotName("get_input_port_default_value") GodotMethod!(Variant, long) getInputPortDefaultValue; 42 @GodotName("get_output_port_for_preview") GodotMethod!(long) getOutputPortForPreview; 43 @GodotName("set_default_input_values") GodotMethod!(void, Array) setDefaultInputValues; 44 @GodotName("set_input_port_default_value") GodotMethod!(void, long, Variant) setInputPortDefaultValue; 45 @GodotName("set_output_port_for_preview") GodotMethod!(void, long) setOutputPortForPreview; 46 } 47 /// 48 pragma(inline, true) bool opEquals(in VisualShaderNode other) const 49 { return _godot_object.ptr is other._godot_object.ptr; } 50 /// 51 pragma(inline, true) typeof(null) opAssign(typeof(null) n) 52 { _godot_object.ptr = n; return null; } 53 /// 54 pragma(inline, true) bool opEquals(typeof(null) n) const 55 { return _godot_object.ptr is n; } 56 /// 57 size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; } 58 mixin baseCasts; 59 /// Construct a new instance of VisualShaderNode. 60 /// Note: use `memnew!VisualShaderNode` instead. 61 static VisualShaderNode _new() 62 { 63 static godot_class_constructor constructor; 64 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("VisualShaderNode"); 65 if(constructor is null) return typeof(this).init; 66 return cast(VisualShaderNode)(constructor()); 67 } 68 @disable new(size_t s); 69 /// 70 enum PortType : int 71 { 72 /** 73 Floating-point scalar. Translated to `float` type in shader code. 74 */ 75 portTypeScalar = 0, 76 /** 77 3D vector of floating-point values. Translated to `vec3` type in shader code. 78 */ 79 portTypeVector = 1, 80 /** 81 Boolean type. Translated to `bool` type in shader code. 82 */ 83 portTypeBoolean = 2, 84 /** 85 Transform type. Translated to `mat4` type in shader code. 86 */ 87 portTypeTransform = 3, 88 /** 89 Sampler type. Translated to reference of sampler uniform in shader code. Can only be used for input ports in non-uniform nodes. 90 */ 91 portTypeSampler = 4, 92 /** 93 Represents the size of the $(D porttype) enum. 94 */ 95 portTypeMax = 5, 96 } 97 /// 98 enum Constants : int 99 { 100 portTypeScalar = 0, 101 portTypeVector = 1, 102 portTypeBoolean = 2, 103 portTypeTransform = 3, 104 portTypeSampler = 4, 105 portTypeMax = 5, 106 } 107 /** 108 Returns an $(D Array) containing default values for all of the input ports of the node in the form `$(D index0, value0, index1, value1, ...)`. 109 */ 110 Array getDefaultInputValues() const 111 { 112 checkClassBinding!(typeof(this))(); 113 return ptrcall!(Array)(GDNativeClassBinding.getDefaultInputValues, _godot_object); 114 } 115 /** 116 Returns the default value of the input `port`. 117 */ 118 Variant getInputPortDefaultValue(in long port) const 119 { 120 checkClassBinding!(typeof(this))(); 121 return ptrcall!(Variant)(GDNativeClassBinding.getInputPortDefaultValue, _godot_object, port); 122 } 123 /** 124 125 */ 126 long getOutputPortForPreview() const 127 { 128 checkClassBinding!(typeof(this))(); 129 return ptrcall!(long)(GDNativeClassBinding.getOutputPortForPreview, _godot_object); 130 } 131 /** 132 Sets the default input ports values using an $(D Array) of the form `$(D index0, value0, index1, value1, ...)`. For example: `$(D 0, Vector3(0, 0, 0), 1, Vector3(0, 0, 0))`. 133 */ 134 void setDefaultInputValues(in Array values) 135 { 136 checkClassBinding!(typeof(this))(); 137 ptrcall!(void)(GDNativeClassBinding.setDefaultInputValues, _godot_object, values); 138 } 139 /** 140 Sets the default value for the selected input `port`. 141 */ 142 void setInputPortDefaultValue(VariantArg1)(in long port, in VariantArg1 value) 143 { 144 checkClassBinding!(typeof(this))(); 145 ptrcall!(void)(GDNativeClassBinding.setInputPortDefaultValue, _godot_object, port, value); 146 } 147 /** 148 149 */ 150 void setOutputPortForPreview(in long port) 151 { 152 checkClassBinding!(typeof(this))(); 153 ptrcall!(void)(GDNativeClassBinding.setOutputPortForPreview, _godot_object, port); 154 } 155 /** 156 157 */ 158 @property Array defaultInputValues() 159 { 160 return getDefaultInputValues(); 161 } 162 /// ditto 163 @property void defaultInputValues(Array v) 164 { 165 setDefaultInputValues(v); 166 } 167 /** 168 Sets the output port index which will be showed for preview. If set to `-1` no port will be open for preview. 169 */ 170 @property long outputPortForPreview() 171 { 172 return getOutputPortForPreview(); 173 } 174 /// ditto 175 @property void outputPortForPreview(long v) 176 { 177 setOutputPortForPreview(v); 178 } 179 }