diff --git a/Sources/armory/logicnode/GetHosekWilkiePropertiesNode.hx b/Sources/armory/logicnode/GetHosekWilkiePropertiesNode.hx new file mode 100644 index 0000000000..2f9a1d6cac --- /dev/null +++ b/Sources/armory/logicnode/GetHosekWilkiePropertiesNode.hx @@ -0,0 +1,27 @@ +package armory.logicnode; + +import iron.math.Vec4; + +class GetHosekWilkiePropertiesNode extends LogicNode { + + public function new(tree: LogicTree) { + super(tree); + } + + override function get(from: Int): Dynamic { + + var world = iron.Scene.active.world.raw; + + return switch (from) { + case 0: + world.turbidity; + case 1: + world.ground_albedo; + case 2: + new Vec4(world.sun_direction[0], world.sun_direction[1], world.sun_direction[2]); + default: + null; + } + return null; + } +} \ No newline at end of file diff --git a/Sources/armory/logicnode/GetNishitaPropertiesNode.hx b/Sources/armory/logicnode/GetNishitaPropertiesNode.hx new file mode 100644 index 0000000000..41c784143c --- /dev/null +++ b/Sources/armory/logicnode/GetNishitaPropertiesNode.hx @@ -0,0 +1,29 @@ +package armory.logicnode; + +import iron.math.Vec4; + +class GetNishitaPropertiesNode extends LogicNode { + + public function new(tree: LogicTree) { + super(tree); + } + + override function get(from: Int): Dynamic { + + var world = iron.Scene.active.world.raw; + + return switch (from) { + case 0: + world.nishita_density[0]; + case 1: + world.nishita_density[1]; + case 2: + world.nishita_density[2]; + case 3: + new Vec4(world.sun_direction[0], world.sun_direction[1], world.sun_direction[2]); + default: + null; + } + return null; + } +} \ No newline at end of file diff --git a/Sources/armory/logicnode/GetWorldStrengthNode.hx b/Sources/armory/logicnode/GetWorldStrengthNode.hx new file mode 100644 index 0000000000..c97c7bf966 --- /dev/null +++ b/Sources/armory/logicnode/GetWorldStrengthNode.hx @@ -0,0 +1,12 @@ +package armory.logicnode; + +class GetWorldStrengthNode extends LogicNode { + + public function new(tree: LogicTree) { + super(tree); + } + + override function get(from: Int): Dynamic { + return iron.Scene.active.world.raw.probe.strength; + } +} \ No newline at end of file diff --git a/Sources/armory/logicnode/SetHosekWilkiePropertiesNode.hx b/Sources/armory/logicnode/SetHosekWilkiePropertiesNode.hx new file mode 100644 index 0000000000..905f1f9a8f --- /dev/null +++ b/Sources/armory/logicnode/SetHosekWilkiePropertiesNode.hx @@ -0,0 +1,41 @@ +package armory.logicnode; + +import armory.renderpath.HosekWilkie; +import iron.math.Vec4; + +class SetHosekWilkiePropertiesNode extends LogicNode { + + public var property0:String; + + public function new(tree: LogicTree) { + super(tree); + } + + override function run(from: Int) { + + var world = iron.Scene.active.world; + + if(property0 == 'Turbidity/Ground Albedo'){ + world.raw.turbidity = inputs[1].get(); + world.raw.ground_albedo = inputs[2].get(); + } + + if(property0 == 'Turbidity') + world.raw.turbidity = inputs[1].get(); + + if(property0 == 'Ground Albedo') + world.raw.ground_albedo = inputs[1].get(); + + if(property0 == 'Sun Direction'){ + var vec:Vec4 = inputs[1].get(); + world.raw.sun_direction[0] = vec.x; + world.raw.sun_direction[1] = vec.y; + world.raw.sun_direction[2] = vec.z; + } + + HosekWilkie.recompute(world); + + runOutput(0); + + } +} diff --git a/Sources/armory/logicnode/SetNishitaPropertiesNode.hx b/Sources/armory/logicnode/SetNishitaPropertiesNode.hx new file mode 100644 index 0000000000..c7b44a8c9d --- /dev/null +++ b/Sources/armory/logicnode/SetNishitaPropertiesNode.hx @@ -0,0 +1,45 @@ +package armory.logicnode; + +import armory.renderpath.Nishita; +import iron.math.Vec4; + +class SetNishitaPropertiesNode extends LogicNode { + + public var property0:String; + + public function new(tree: LogicTree) { + super(tree); + } + + override function run(from: Int) { + + var world = iron.Scene.active.world; + + if(property0 == 'Density'){ + world.raw.nishita_density[0] = inputs[1].get(); + world.raw.nishita_density[1] = inputs[2].get(); + world.raw.nishita_density[2] = inputs[3].get(); + } + + if(property0 == 'Air') + world.raw.nishita_density[0] = inputs[1].get(); + + if(property0 == 'Dust') + world.raw.nishita_density[1] = inputs[1].get(); + + if(property0 == 'Ozone') + world.raw.nishita_density[2] = inputs[1].get(); + + if(property0 == 'Sun Direction'){ + var vec:Vec4 = inputs[1].get(); + world.raw.sun_direction[0] = vec.x; + world.raw.sun_direction[1] = vec.y; + world.raw.sun_direction[2] = vec.z; + } + + Nishita.recompute(world); + + runOutput(0); + + } +} diff --git a/Sources/armory/logicnode/SetWorldStrengthNode.hx b/Sources/armory/logicnode/SetWorldStrengthNode.hx new file mode 100644 index 0000000000..f4adad6f6b --- /dev/null +++ b/Sources/armory/logicnode/SetWorldStrengthNode.hx @@ -0,0 +1,16 @@ +package armory.logicnode; + +class SetWorldStrengthNode extends LogicNode { + + public function new(tree: LogicTree) { + super(tree); + } + + override function run(from: Int) { + + iron.Scene.active.world.raw.probe.strength = inputs[1].get(); + + runOutput(0); + + } +} diff --git a/blender/arm/logicnode/__init__.py b/blender/arm/logicnode/__init__.py index 9ba4250f9b..0dae5e7d0f 100644 --- a/blender/arm/logicnode/__init__.py +++ b/blender/arm/logicnode/__init__.py @@ -34,6 +34,7 @@ def init_categories(): arm_nodes.add_category('Camera', icon='OUTLINER_OB_CAMERA', section="data") arm_nodes.add_category('Material', icon='MATERIAL', section="data") arm_nodes.add_category('Light', icon='LIGHT', section="data") + arm_nodes.add_category('World', icon='WORLD', section="data") arm_nodes.add_category('Object', icon='OBJECT_DATA', section="data") arm_nodes.add_category('Scene', icon='SCENE_DATA', section="data") arm_nodes.add_category('Trait', icon='NODETREE', section="data") diff --git a/blender/arm/logicnode/world/LN_get_hosekwilkie_properties.py b/blender/arm/logicnode/world/LN_get_hosekwilkie_properties.py new file mode 100644 index 0000000000..353f43938e --- /dev/null +++ b/blender/arm/logicnode/world/LN_get_hosekwilkie_properties.py @@ -0,0 +1,12 @@ +from arm.logicnode.arm_nodes import * + +class GetHosekWilkiePropertiesNode(ArmLogicTreeNode): + """Gets the HosekWilkie properties.""" + bl_idname = 'LNGetHosekWilkiePropertiesNode' + bl_label = 'Get HosekWilkie Properties' + arm_version = 1 + + def arm_init(self, context): + self.add_output('ArmFloatSocket', 'Turbidity') + self.add_output('ArmFloatSocket', 'Ground Albedo') + self.add_output('ArmVectorSocket', 'Sun Direction') diff --git a/blender/arm/logicnode/world/LN_get_nishita_properties.py b/blender/arm/logicnode/world/LN_get_nishita_properties.py new file mode 100644 index 0000000000..458777fada --- /dev/null +++ b/blender/arm/logicnode/world/LN_get_nishita_properties.py @@ -0,0 +1,14 @@ +from arm.logicnode.arm_nodes import * + +class GetNishitaPropertiesNode(ArmLogicTreeNode): + """Gets the Nishita properties.""" + bl_idname = 'LNGetNishitaPropertiesNode' + bl_label = 'Get Nishita Properties' + arm_version = 1 + + def arm_init(self, context): + self.add_output('ArmFloatSocket', 'Air') + self.add_output('ArmFloatSocket', 'Dust') + self.add_output('ArmFloatSocket', 'Ozone') + self.add_output('ArmVectorSocket', 'Sun Direction') + diff --git a/blender/arm/logicnode/world/LN_get_world_strength.py b/blender/arm/logicnode/world/LN_get_world_strength.py new file mode 100644 index 0000000000..bcc37811b1 --- /dev/null +++ b/blender/arm/logicnode/world/LN_get_world_strength.py @@ -0,0 +1,10 @@ +from arm.logicnode.arm_nodes import * + +class GetWorldStrengthNode(ArmLogicTreeNode): + """Gets the strength of the given World.""" + bl_idname = 'LNGetWorldStrengthNode' + bl_label = 'Get World Strength' + arm_version = 1 + + def arm_init(self, context): + self.add_output('ArmFloatSocket', 'Strength') diff --git a/blender/arm/logicnode/world/LN_set_hosekwilkie_properties.py b/blender/arm/logicnode/world/LN_set_hosekwilkie_properties.py new file mode 100644 index 0000000000..1e3e3d0768 --- /dev/null +++ b/blender/arm/logicnode/world/LN_set_hosekwilkie_properties.py @@ -0,0 +1,38 @@ +from arm.logicnode.arm_nodes import * + +class SetHosekWilkiePropertiesNode(ArmLogicTreeNode): + """Sets the HosekWilkie properties.""" + bl_idname = 'LNSetHosekWilkiePropertiesNode' + bl_label = 'Set HosekWilkie Properties' + arm_version = 1 + + def remove_extra_inputs(self, context): + while len(self.inputs) > 1: + self.inputs.remove(self.inputs[-1]) + if self.property0 == 'Turbidity/Ground Albedo': + self.add_input('ArmFloatSocket', 'Turbidity') + self.add_input('ArmFloatSocket', 'Ground Albedo') + if self.property0 == 'Turbidity': + self.add_input('ArmFloatSocket', 'Turbidity') + if self.property0 == 'Ground Albedo': + self.add_input('ArmFloatSocket', 'Ground Albedo') + if self.property0 == 'Sun Direction': + self.add_input('ArmVectorSocket', 'Sun Direction') + + property0: HaxeEnumProperty( + 'property0', + items = [('Turbidity/Ground Albedo', 'Turbidity/Ground Albedo', 'Turbidity, Ground Albedo'), + ('Turbidity', 'Turbidity', 'Turbidity'), + ('Ground Albedo', 'Ground Albedo', 'Ground Albedo'), + ('Sun Direction', 'Sun Direction', 'Sun Direction')], + name='', default='Turbidity/Ground Albedo', update=remove_extra_inputs) + + def arm_init(self, context): + self.add_input('ArmNodeSocketAction', 'In') + self.add_input('ArmFloatSocket', 'Turbidity') + self.add_input('ArmFloatSocket', 'Ground_Albedo') + + self.add_output('ArmNodeSocketAction', 'Out') + + def draw_buttons(self, context, layout): + layout.prop(self, 'property0') \ No newline at end of file diff --git a/blender/arm/logicnode/world/LN_set_nishita_properties.py b/blender/arm/logicnode/world/LN_set_nishita_properties.py new file mode 100644 index 0000000000..9e693bc3f0 --- /dev/null +++ b/blender/arm/logicnode/world/LN_set_nishita_properties.py @@ -0,0 +1,43 @@ +from arm.logicnode.arm_nodes import * + +class SetNishitaPropertiesNode(ArmLogicTreeNode): + """Sets the Nishita properties""" + bl_idname = 'LNSetNishitaPropertiesNode' + bl_label = 'Set Nishita Properties' + arm_version = 1 + + def remove_extra_inputs(self, context): + while len(self.inputs) > 1: + self.inputs.remove(self.inputs[-1]) + if self.property0 == 'Density': + self.add_input('ArmFloatSocket', 'Air') + self.add_input('ArmFloatSocket', 'Dust') + self.add_input('ArmFloatSocket', 'Ozone') + if self.property0 == 'Air': + self.add_input('ArmFloatSocket', 'Air') + if self.property0 == 'Dust': + self.add_input('ArmFloatSocket', 'Dust') + if self.property0 == 'Ozone': + self.add_input('ArmFloatSocket', 'Ozone') + if self.property0 == 'Sun Direction': + self.add_input('ArmVectorSocket', 'Sun Direction') + + property0: HaxeEnumProperty( + 'property0', + items = [('Density', 'Density', 'Air, Dust, Ozone'), + ('Air', 'Air', 'Air'), + ('Dust', 'Dust', 'Dust'), + ('Ozone', 'Ozone', 'Ozone'), + ('Sun Direction', 'Sun Direction', 'Sun Direction')], + name='', default='Density', update=remove_extra_inputs) + + def arm_init(self, context): + self.add_input('ArmNodeSocketAction', 'In') + self.add_input('ArmFloatSocket', 'Air') + self.add_input('ArmFloatSocket', 'Dust') + self.add_input('ArmFloatSocket', 'Ozone') + + self.add_output('ArmNodeSocketAction', 'Out') + + def draw_buttons(self, context, layout): + layout.prop(self, 'property0') \ No newline at end of file diff --git a/blender/arm/logicnode/world/LN_set_world_strength.py b/blender/arm/logicnode/world/LN_set_world_strength.py new file mode 100644 index 0000000000..3e7fedf6ff --- /dev/null +++ b/blender/arm/logicnode/world/LN_set_world_strength.py @@ -0,0 +1,13 @@ +from arm.logicnode.arm_nodes import * + +class SetWorldStrengthNode(ArmLogicTreeNode): + """Sets the strength of the given World.""" + bl_idname = 'LNSetWorldStrengthNode' + bl_label = 'Set World Strength' + arm_version = 1 + + def arm_init(self, context): + self.add_input('ArmNodeSocketAction', 'In') + self.add_input('ArmFloatSocket', 'Strength') + + self.add_output('ArmNodeSocketAction', 'Out') diff --git a/blender/arm/logicnode/world/__init__.py b/blender/arm/logicnode/world/__init__.py new file mode 100644 index 0000000000..f7b34e3c10 --- /dev/null +++ b/blender/arm/logicnode/world/__init__.py @@ -0,0 +1,3 @@ +from arm.logicnode.arm_nodes import add_node_section + +add_node_section(name='default', category='world') \ No newline at end of file