Merge pull request #1864 from MoritzBrueckner/new-nodes
Some new nodes and improvements (by @knowledgenude )
This commit is contained in:
commit
0b01c4648d
24
Sources/armory/logicnode/GetObjectOffscreenNode.hx
Normal file
24
Sources/armory/logicnode/GetObjectOffscreenNode.hx
Normal file
|
@ -0,0 +1,24 @@
|
|||
package armory.logicnode;
|
||||
|
||||
import iron.object.Object;
|
||||
|
||||
class GetObjectOffscreenNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
var object: Object = inputs[0].get();
|
||||
|
||||
if (object == null) return null;
|
||||
|
||||
return switch (from) {
|
||||
case 0: object.culled;
|
||||
case 1: object.culledMesh;
|
||||
case 2: object.culledShadow;
|
||||
default: null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
38
Sources/armory/logicnode/GetRigidBodyDataNode.hx
Normal file
38
Sources/armory/logicnode/GetRigidBodyDataNode.hx
Normal file
|
@ -0,0 +1,38 @@
|
|||
package armory.logicnode;
|
||||
|
||||
import iron.object.Object;
|
||||
import armory.trait.physics.RigidBody;
|
||||
|
||||
class GetRigidBodyDataNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
var object: Object = inputs[0].get();
|
||||
|
||||
if (object == null) return null;
|
||||
|
||||
#if arm_physics
|
||||
var rigidBody = object.getTrait(RigidBody);
|
||||
|
||||
return switch (from) {
|
||||
case 0:
|
||||
if (rigidBody == null) return false;
|
||||
return true;
|
||||
|
||||
//case 1: rigidBody.btshape;
|
||||
case 1: rigidBody.group;
|
||||
case 2: rigidBody.mask;
|
||||
case 3: rigidBody.animated;
|
||||
case 4: rigidBody.staticObj;
|
||||
case 5: rigidBody.angularDamping;
|
||||
case 6: rigidBody.linearDamping;
|
||||
case 7: rigidBody.friction;
|
||||
case 8: rigidBody.mass;
|
||||
default: null;
|
||||
}
|
||||
#end
|
||||
}
|
||||
}
|
|
@ -11,8 +11,14 @@ class GetVisibleNode extends LogicNode {
|
|||
override function get(from: Int): Dynamic {
|
||||
var object: Object = inputs[0].get();
|
||||
|
||||
if (object == null) false;
|
||||
if (object == null) return null;
|
||||
|
||||
return switch (from) {
|
||||
case 0: object.visible;
|
||||
case 1: object.visibleMesh;
|
||||
case 2: object.visibleShadow;
|
||||
default: null;
|
||||
}
|
||||
|
||||
return object.visible;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@ import iron.object.Object;
|
|||
|
||||
class SetVisibleNode extends LogicNode {
|
||||
|
||||
public var property0: String;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
@ -11,10 +13,31 @@ class SetVisibleNode extends LogicNode {
|
|||
override function run(from: Int) {
|
||||
var object: Object = inputs[1].get();
|
||||
var visible: Bool = inputs[2].get();
|
||||
var children: Bool = inputs[3].get();
|
||||
|
||||
if (object == null) return;
|
||||
|
||||
object.visible = visible;
|
||||
var objectChildren: Array<Object> = object.children;
|
||||
|
||||
switch (property0) {
|
||||
case "Object":
|
||||
object.visible = visible;
|
||||
if (children == true) for (child in objectChildren) {
|
||||
child.visible = visible;
|
||||
}
|
||||
|
||||
case "Mesh":
|
||||
object.visibleMesh = visible;
|
||||
if (children == true) for (child in objectChildren) {
|
||||
child.visibleMesh = visible;
|
||||
}
|
||||
|
||||
case "Shadow":
|
||||
object.visibleShadow = visible;
|
||||
if (children == true) for (child in objectChildren) {
|
||||
child.visibleShadow = visible;
|
||||
}
|
||||
}
|
||||
|
||||
runOutput(0);
|
||||
}
|
||||
|
|
16
blender/arm/logicnode/object/LN_get_object_offscreen.py
Normal file
16
blender/arm/logicnode/object/LN_get_object_offscreen.py
Normal file
|
@ -0,0 +1,16 @@
|
|||
from arm.logicnode.arm_nodes import *
|
||||
|
||||
class GetObjectOffscreenNode(ArmLogicTreeNode):
|
||||
"""Get Object Offscreen node"""
|
||||
bl_idname = 'LNGetObjectOffscreenNode'
|
||||
bl_label = 'Get Object Offscreen'
|
||||
arm_version = 1
|
||||
|
||||
def init(self, context):
|
||||
super(GetObjectOffscreenNode, self).init(context)
|
||||
self.inputs.new('ArmNodeSocketObject', 'Object')
|
||||
self.outputs.new('NodeSocketBool', 'Object')
|
||||
self.outputs.new('NodeSocketBool', 'Mesh')
|
||||
self.outputs.new('NodeSocketBool', 'Shadow')
|
||||
|
||||
add_node(GetObjectOffscreenNode, category=PKG_AS_CATEGORY, section='props')
|
|
@ -1,7 +1,7 @@
|
|||
from arm.logicnode.arm_nodes import *
|
||||
|
||||
class GetVisibleNode(ArmLogicTreeNode):
|
||||
"""Get visible node"""
|
||||
"""Get Visible node"""
|
||||
bl_idname = 'LNGetVisibleNode'
|
||||
bl_label = 'Get Visible'
|
||||
arm_version = 1
|
||||
|
@ -9,6 +9,8 @@ class GetVisibleNode(ArmLogicTreeNode):
|
|||
def init(self, context):
|
||||
super(GetVisibleNode, self).init(context)
|
||||
self.add_input('ArmNodeSocketObject', 'Object')
|
||||
self.add_output('NodeSocketBool', 'Visible')
|
||||
self.add_output('NodeSocketBool', 'Object')
|
||||
self.add_output('NodeSocketBool', 'Mesh')
|
||||
self.add_output('NodeSocketBool', 'Shadow')
|
||||
|
||||
add_node(GetVisibleNode, category=PKG_AS_CATEGORY, section='props')
|
||||
|
|
|
@ -1,16 +1,27 @@
|
|||
from arm.logicnode.arm_nodes import *
|
||||
|
||||
class SetVisibleNode(ArmLogicTreeNode):
|
||||
"""Set visible node"""
|
||||
"""Set Visible node"""
|
||||
bl_idname = 'LNSetVisibleNode'
|
||||
bl_label = 'Set Visible'
|
||||
arm_version = 1
|
||||
|
||||
property0: EnumProperty(
|
||||
items = [('Object', 'Object', 'Object'),
|
||||
('Mesh', 'Mesh', 'Mesh'),
|
||||
('Shadow', 'Shadow', 'Shadow'),
|
||||
],
|
||||
name='', default='Object')
|
||||
|
||||
def init(self, context):
|
||||
super(SetVisibleNode, self).init(context)
|
||||
self.add_input('ArmNodeSocketAction', 'In')
|
||||
self.add_input('ArmNodeSocketObject', 'Object')
|
||||
self.add_input('NodeSocketBool', 'Visible')
|
||||
self.add_input('NodeSocketBool', 'Children')
|
||||
self.add_output('ArmNodeSocketAction', 'Out')
|
||||
|
||||
def draw_buttons(self, context, layout):
|
||||
layout.prop(self, 'property0')
|
||||
|
||||
add_node(SetVisibleNode, category=PKG_AS_CATEGORY, section='props')
|
||||
|
|
22
blender/arm/logicnode/physics/LN_get_rigid_body_data.py
Normal file
22
blender/arm/logicnode/physics/LN_get_rigid_body_data.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
from arm.logicnode.arm_nodes import *
|
||||
|
||||
class GetRigidBodyDataNode(ArmLogicTreeNode):
|
||||
"""Get Rigid Body Data node"""
|
||||
bl_idname = 'LNGetRigidBodyDataNode'
|
||||
bl_label = 'Get Rigid Body Data'
|
||||
bl_icon = 'NONE'
|
||||
|
||||
def init(self, context):
|
||||
self.inputs.new('ArmNodeSocketObject', 'Object')
|
||||
self.outputs.new('NodeSocketBool', 'Rigid Body')
|
||||
#self.outputs.new('NodeSocketString', 'Collision Shape')
|
||||
self.outputs.new('NodeSocketInt', 'Collision Group')
|
||||
self.outputs.new('NodeSocketInt', 'Collision Mask')
|
||||
self.outputs.new('NodeSocketBool', 'Animated')
|
||||
self.outputs.new('NodeSocketBool', 'Static')
|
||||
self.outputs.new('NodeSocketFloat', 'Angular Damping')
|
||||
self.outputs.new('NodeSocketFloat', 'Linear Damping')
|
||||
self.outputs.new('NodeSocketFloat', 'Friction')
|
||||
self.outputs.new('NodeSocketFloat', 'Mass')
|
||||
|
||||
add_node(GetRigidBodyDataNode, category=PKG_AS_CATEGORY, section='props')
|
Loading…
Reference in a new issue