Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2982 from t3du/world
World Logic Nodes
- Loading branch information
Showing
14 changed files
with
304 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
blender/arm/logicnode/world/LN_get_hosekwilkie_properties.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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') |
38 changes: 38 additions & 0 deletions
38
blender/arm/logicnode/world/LN_set_hosekwilkie_properties.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from arm.logicnode.arm_nodes import add_node_section | ||
|
||
add_node_section(name='default', category='world') |