Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

Commit

Permalink
quat nodes
Browse files Browse the repository at this point in the history
2 new quat nodes
  • Loading branch information
Simonrazer committed Feb 15, 2018
1 parent 6d0b760 commit 7e842a0
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 0 deletions.
34 changes: 34 additions & 0 deletions Sources/armory/logicnode/QuatToEulerNode.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package armory.logicnode;

import iron.math.Mat4;
import iron.math.Vec4;
import iron.math.Quat;

class QuatToEulerNode extends LogicNode {


public function new(tree:LogicTree) {
super(tree);

}


override function get(from:Int):Dynamic {
var x:Float = inputs[0].get();
var y:Float = inputs[1].get();
var z:Float = inputs[2].get();
var w:Float = inputs[3].get();
var q = new Quat();

q.x=x;
q.y=y;
q.z=z;
q.w=w;

var v = new Vec4();
v.setFrom(q.getEuler());
return v;
}
}


28 changes: 28 additions & 0 deletions Sources/armory/logicnode/SeparateQuatNode.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package armory.logicnode;

import iron.math.Mat4;
import iron.math.Vec4;
import iron.math.Quat;

class SeparateQuatNode extends LogicNode {


public function new(tree:LogicTree) {
super(tree);

}


override function get(from:Int):Dynamic {
var m:Mat4 = inputs[0].get();

if (from == 0) return m.getQuat().x;
else if (from == 1) return m.getQuat().y;
else if (from == 2) return m.getQuat().z;
else if (from == 3) return m.getQuat().w;
else return m.getQuat().getEuler();

}
}


29 changes: 29 additions & 0 deletions blender.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,33 @@
from arm.logicnode.arm_nodes import *
import arm.nodes_logic

class QuatToEulerNode(Node, ArmLogicTreeNode):
'''QuatToEulerNode'''
bl_idname = 'LNQuatToEulerNode'
bl_label = 'Quat To Euler'
bl_icon = 'GAME'

def init(self, context):
self.inputs.new('NodeSocketFloat', 'X')
self.inputs.new('NodeSocketFloat', 'Y')
self.inputs.new('NodeSocketFloat', 'Z')
self.inputs.new('NodeSocketFloat', 'W')
self.outputs.new('NodeSocketVector', 'Euler')

class SeparateQuatNode(Node, ArmLogicTreeNode):
'''SeparateQuatNode'''
bl_idname = 'LNSeparateQuatNode'
bl_label = 'Separate Quat'
bl_icon = 'GAME'

def init(self, context):
self.inputs.new('NodeSocketShader', 'Transform')
self.outputs.new('NodeSocketFloat', 'X')
self.outputs.new('NodeSocketFloat', 'Y')
self.outputs.new('NodeSocketFloat', 'Z')
self.outputs.new('NodeSocketFloat', 'W')
self.outputs.new('NodeSocketVector', 'Euler')

class TranslateOnLocalAxisNode(Node, ArmLogicTreeNode):
'''TranslateOnLocalAxisNode'''
bl_idname = 'LNTranslateOnLocalAxisNode'
Expand Down Expand Up @@ -85,6 +112,8 @@ def init(self, context):

def register():
# Add custom nodes
add_node(QuatToEulerNode, category= 'Value')
add_node(SeparateQuatNode, category='Value')
add_node(TranslateOnLocalAxisNode, category='Action')
add_node(ArrayLoopIndiceNode, category='Logic')
add_node(ToBoolNode, category='Logic')
Expand Down

0 comments on commit 7e842a0

Please sign in to comment.