expose rotation around axis in nodes

This commit is contained in:
Yannik Böttcher 2019-05-06 19:27:52 +02:00
parent 85a325f082
commit f00fdb4708
2 changed files with 50 additions and 0 deletions

View file

@ -0,0 +1,30 @@
package armory.logicnode;
import iron.object.Object;
import iron.math.Vec4;
import armory.trait.physics.RigidBody;
class RotateObjectAroundAxisNode extends LogicNode {
public function new(tree:LogicTree) {
super(tree);
}
override function run(from:Int) {
var object:Object = inputs[1].get();
var axis:Vec4 = inputs[2].get().normalize();
var angle:Float = inputs[3].get();
if (object == null || axis == null) return;
// the rotate function already calls buildMatrix
object.transform.rotate(axis, angle);
#if arm_physics
var rigidBody = object.getTrait(RigidBody);
if (rigidBody != null) rigidBody.syncTransform();
#end
runOutput(0);
}
}

View file

@ -0,0 +1,20 @@
import bpy
from bpy.props import *
from bpy.types import Node, NodeSocket
from arm.logicnode.arm_nodes import *
class RotateObjectAroundAxisNode(Node, ArmLogicTreeNode):
'''Rotate object around axis node'''
bl_idname = 'LNRotateObjectAroundAxisNode'
bl_label = 'Rotate Object Around Axis'
bl_icon = 'QUESTION'
def init(self, context):
self.inputs.new('ArmNodeSocketAction', 'In')
self.inputs.new('ArmNodeSocketObject', 'Object')
self.inputs.new('NodeSocketVector', 'Axis')
self.inputs[-1].default_value = [0, 0, 1]
self.inputs.new('NodeSocketFloat', 'Angle')
self.outputs.new('ArmNodeSocketAction', 'Out')
add_node(RotateObjectAroundAxisNode, category='Action')