Initial commit...
This commit is contained in:
parent
58cbccea2a
commit
bd3159b023
Binary file not shown.
After Width: | Height: | Size: 37 KiB |
Binary file not shown.
After Width: | Height: | Size: 23 KiB |
|
@ -13,3 +13,7 @@ I want to add the following:
|
|||
<li>Near</li>
|
||||
<li>Track To</li>
|
||||
</ul>
|
||||
|
||||
# Images
|
||||
![1 Enhanced Transform](Images/Enhanced Transform.png)
|
||||
![2 Pane View](Images/Look At.png)
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
package armory.logicnode;
|
||||
|
||||
import iron.object.Object;
|
||||
import iron.math.Vec4;
|
||||
import armory.trait.physics.RigidBody;
|
||||
|
||||
|
||||
class EnhancedTransformNode extends LogicNode {
|
||||
|
||||
public function new(tree:LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run() {
|
||||
var object:Object = inputs[1].get();
|
||||
var loc:Vec4 = inputs[2].get();
|
||||
var rot:Vec4 = inputs[3].get();
|
||||
var scale:Vec4 = inputs[4].get();
|
||||
|
||||
if (loc == null || rot == null || scale == null) return;
|
||||
|
||||
// Location transform
|
||||
object.transform.loc.x = loc.x;
|
||||
object.transform.loc.y = loc.y;
|
||||
object.transform.loc.z = loc.z;
|
||||
|
||||
// Rotation transform
|
||||
object.transform.rot.fromEuler(rot.x, rot.y, rot.z);
|
||||
object.transform.buildMatrix();
|
||||
|
||||
// Scale transform
|
||||
object.transform.scale.x = scale.x;
|
||||
object.transform.scale.y = scale.y;
|
||||
object.transform.scale.z = scale.z;
|
||||
|
||||
#if arm_physics
|
||||
var rigidBody = object.getTrait(RigidBody);
|
||||
if (rigidBody != null) rigidBody.syncTransform();
|
||||
#end
|
||||
|
||||
super.run();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package armory.logicnode;
|
||||
|
||||
import iron.object.Object;
|
||||
import iron.math.Vec3;
|
||||
import armory.trait.physics.RigidBody;
|
||||
|
||||
|
||||
class LookAtNode extends LogicNode {
|
||||
|
||||
public function new(tree:LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run() {
|
||||
var targeter:Object = inputs[1].get();
|
||||
var target:Object = inputs[2].get();
|
||||
var threeDeeTrack:Bool = inputs[3].get();
|
||||
|
||||
var targeterRot:Vec3;
|
||||
var targetLoc:Vec3;
|
||||
|
||||
if (targeter == null || target == null) return;
|
||||
|
||||
targeterRot = new Vec3(targeter.transform.rot.x,
|
||||
targeter.transform.rot.y,
|
||||
targeter.transform.rot.z);
|
||||
|
||||
targetLoc = new Vec3(target.transform.loc.x,
|
||||
target.transform.loc.y,
|
||||
target.transform.loc.z);
|
||||
|
||||
var newZLook = targeterRot.z + (targeterRot.z - (targetLoc.y / targetLoc.x));
|
||||
|
||||
if ( threeDeeTrack == true ) {
|
||||
targeter.transform
|
||||
.setRotation(targeterRot.x, targetLoc.y, newZLook);
|
||||
} else {
|
||||
targeter.transform
|
||||
.setRotation(targeterRot.x, targeterRot.y, newZLook);
|
||||
}
|
||||
|
||||
#if arm_physics
|
||||
var rigidBody = targeter.getTrait(RigidBody);
|
||||
if (rigidBody != null) rigidBody.syncTransform();
|
||||
#end
|
||||
|
||||
super.run();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
from bpy.types import Node
|
||||
from arm.logicnode.arm_nodes import *
|
||||
import arm.nodes_logic
|
||||
|
||||
class EnhancedTransformNode(Node, ArmLogicTreeNode):
|
||||
'''EnhancedTransformNode'''
|
||||
bl_idname = 'LNEnhancedTransformNode'
|
||||
bl_label = 'Enhanced Transform'
|
||||
bl_icon = 'GAME'
|
||||
|
||||
def init(self, context):
|
||||
self.inputs.new('ArmNodeSocketAction', 'In')
|
||||
self.inputs.new('ArmNodeSocketObject', 'Object')
|
||||
self.inputs.new('NodeSocketVector', 'Location')
|
||||
self.inputs.new('NodeSocketVector', 'Rotation')
|
||||
self.inputs.new('NodeSocketVector', 'Scale')
|
||||
self.inputs[-1].default_value = [1.0, 1.0, 1.0]
|
||||
self.outputs.new('ArmNodeSocketAction', 'Out')
|
||||
|
||||
class LookAtNode(Node, ArmLogicTreeNode):
|
||||
'''LookAtNode'''
|
||||
bl_idname = 'LNLookAtNode'
|
||||
bl_label = 'Look At'
|
||||
bl_icon = 'GAME'
|
||||
|
||||
def init(self, context):
|
||||
self.inputs.new('ArmNodeSocketAction', 'In')
|
||||
self.inputs.new('ArmNodeSocketObject', 'Object')
|
||||
self.inputs.new('ArmNodeSocketObject', 'Object')
|
||||
self.inputs.new('NodeSocketBool', '3D Track')
|
||||
self.outputs.new('ArmNodeSocketAction', 'Out')
|
||||
|
||||
|
||||
def register():
|
||||
# Add custom nodes
|
||||
add_node(EnhancedTransformNode, category='Action')
|
||||
add_node(LookAtNode, category='Action')
|
||||
|
||||
# Register newly added nodes
|
||||
arm.nodes_logic.register_nodes()
|
Loading…
Reference in New Issue