expose rotation around axis in nodes
This commit is contained in:
parent
85a325f082
commit
f00fdb4708
30
Sources/armory/logicnode/RotateObjectAroundAxisNode.hx
Normal file
30
Sources/armory/logicnode/RotateObjectAroundAxisNode.hx
Normal 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);
|
||||
}
|
||||
}
|
20
blender/arm/logicnode/action_rotate_object_around_axis.py
Normal file
20
blender/arm/logicnode/action_rotate_object_around_axis.py
Normal 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')
|
Loading…
Reference in a new issue