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> </ul>
# To Do # To Do
I want to add the following: I want to add and fix the following:
Add:
<ul> <ul>
<li>Near</li> <li>Near</li>
<li>Track To</li> <li>Track To</li>
</ul> </ul>
Fix:
<ul>
<li>Look At</li>
</ul>
# Images # Images
![1 Enhanced Transform](Images/Enhanced_Transform.png) ![1 Enhanced Transform](Images/Enhanced_Transform.png)
![2 Look At](Images/Look_At.png) ![2 Look At](Images/Look_At.png)

View File

@ -1,37 +1,49 @@
package armory.logicnode; package armory.logicnode;
import iron.object.Object;
import iron.math.Vec4;
import armory.trait.physics.RigidBody; 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 { class EnhancedTransformNode extends LogicNode {
var value:Mat4 = Mat4.identity();
static var q = new Quat();
public function new(tree:LogicTree) { public function new(tree:LogicTree) {
super(tree); super(tree);
} }
override function run() { override function run() {
var object:Object = inputs[1].get(); var object:Object = inputs[1].get();
var loc:Vec4 = inputs[2].get(); var loc:Vec4 = inputs[2].get();
var rot:Vec4 = inputs[3].get(); var rot:Vec4 = inputs[3].get();
var scale:Vec4 = inputs[4].get(); var scale:Vec4 = inputs[4].get();
if (loc == null || rot == null || scale == null) return; if (loc == null || rot == null || scale == null) return;
// Location transform if(loc.x == 0.0 && loc.y == 0.0 && loc.z == 0.0) {
object.transform.loc.x = loc.x; loc.x = object.transform.loc.x;
object.transform.loc.y = loc.y; loc.y = object.transform.loc.y;
object.transform.loc.z = loc.z; loc.z = object.transform.loc.z;
}
// Rotation transform if(rot.x == 0.0 && rot.y == 0.0 && rot.z == 0.0) {
object.transform.rot.fromEuler(rot.x, rot.y, rot.z); rot.x = object.transform.rot.x;
object.transform.buildMatrix(); rot.y = object.transform.rot.y;
rot.z = object.transform.rot.z;
}
// Scale transform if(scale.x == 0.0 && scale.y == 0.0 && scale.z == 0.0) {
object.transform.scale.x = scale.x; scale.x = object.transform.scale.x;
object.transform.scale.y = scale.y; scale.y = object.transform.scale.y;
object.transform.scale.z = scale.z; 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 #if arm_physics
var rigidBody = object.getTrait(RigidBody); var rigidBody = object.getTrait(RigidBody);

View File

@ -14,7 +14,6 @@ class EnhancedTransformNode(Node, ArmLogicTreeNode):
self.inputs.new('NodeSocketVector', 'Location') self.inputs.new('NodeSocketVector', 'Location')
self.inputs.new('NodeSocketVector', 'Rotation') self.inputs.new('NodeSocketVector', 'Rotation')
self.inputs.new('NodeSocketVector', 'Scale') self.inputs.new('NodeSocketVector', 'Scale')
self.inputs[-1].default_value = [1.0, 1.0, 1.0]
self.outputs.new('ArmNodeSocketAction', 'Out') self.outputs.new('ArmNodeSocketAction', 'Out')
class LookAtNode(Node, ArmLogicTreeNode): class LookAtNode(Node, ArmLogicTreeNode):