Fixed Enhanced Transform node.

This commit is contained in:
Maxim Stewart 2018-08-20 21:29:00 -05:00
parent b88b6bb9f2
commit 0333744308
3 changed files with 36 additions and 20 deletions

View File

@ -7,13 +7,18 @@ These are Armory Nodes I've Made...
</ul>
# To Do
I want to add the following:
I want to add and fix the following:
Add:
<ul>
<li>Near</li>
<li>Track To</li>
</ul>
Fix:
<ul>
<li>Look At</li>
</ul>
# Images
![1 Enhanced Transform](Images/Enhanced_Transform.png)
![2 Look At](Images/Look_At.png)

View File

@ -1,11 +1,15 @@
package armory.logicnode;
import iron.object.Object;
import iron.math.Vec4;
import armory.trait.physics.RigidBody;
import iron.object.Object;
import iron.math.Mat4;
import iron.math.Vec4;
import iron.math.Quat;
class EnhancedTransformNode extends LogicNode {
var value:Mat4 = Mat4.identity();
static var q = new Quat();
public function new(tree:LogicTree) {
super(tree);
@ -19,19 +23,27 @@ class EnhancedTransformNode extends LogicNode {
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;
if(loc.x == 0.0 && loc.y == 0.0 && loc.z == 0.0) {
loc.x = object.transform.loc.x;
loc.y = object.transform.loc.y;
loc.z = object.transform.loc.z;
}
// Rotation transform
object.transform.rot.fromEuler(rot.x, rot.y, rot.z);
object.transform.buildMatrix();
if(rot.x == 0.0 && rot.y == 0.0 && rot.z == 0.0) {
rot.x = object.transform.rot.x;
rot.y = object.transform.rot.y;
rot.z = object.transform.rot.z;
}
// Scale transform
object.transform.scale.x = scale.x;
object.transform.scale.y = scale.y;
object.transform.scale.z = scale.z;
if(scale.x == 0.0 && scale.y == 0.0 && scale.z == 0.0) {
scale.x = object.transform.scale.x;
scale.y = object.transform.scale.y;
scale.z = object.transform.scale.z;
}
q.fromEuler(rot.x, rot.y, rot.z);
value.compose(loc, q, scale);
object.transform.setMatrix(value);
#if arm_physics
var rigidBody = object.getTrait(RigidBody);

View File

@ -14,7 +14,6 @@ class EnhancedTransformNode(Node, ArmLogicTreeNode):
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):