Fixed Enhanced Transform node.
This commit is contained in:
parent
b88b6bb9f2
commit
0333744308
|
@ -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)
|
||||
|
|
|
@ -1,37 +1,49 @@
|
|||
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);
|
||||
}
|
||||
|
||||
override function run() {
|
||||
var object:Object = inputs[1].get();
|
||||
var object:Object = inputs[1].get();
|
||||
var loc:Vec4 = inputs[2].get();
|
||||
var rot:Vec4 = inputs[3].get();
|
||||
var scale:Vec4 = inputs[4].get();
|
||||
var rot:Vec4 = inputs[3].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
|
||||
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);
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue