-
Notifications
You must be signed in to change notification settings - Fork 342
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #441 from og76/patch-2
change dir/rot and rot/dir to use algo
- Loading branch information
Showing
3 changed files
with
28 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,28 @@ | ||
import bpy | ||
from bpy.props import * | ||
from ... events import executionCodeChanged | ||
from ... algorithms.rotation import generateRotationToDirectionCode | ||
from ... base_types.node import AnimationNode | ||
|
||
directionAxisItems = [(axis, axis, "") for axis in ("X", "Y", "Z", "-X", "-Y", "-Z")] | ||
|
||
class RotationToDirectionNode(bpy.types.Node, AnimationNode): | ||
bl_idname = "an_RotationToDirectionNode" | ||
bl_label = "Rotation to Direction" | ||
|
||
directionAxis = EnumProperty(items = directionAxisItems, update = executionCodeChanged, default = "Z") | ||
|
||
def create(self): | ||
self.inputs.new("an_EulerSocket", "Rotation", "rotation") | ||
self.inputs.new("an_FloatSocket", "Length", "length").value = 1 | ||
self.outputs.new("an_VectorSocket", "Direction", "direction") | ||
self.width += 20 | ||
|
||
def draw(self, layout): | ||
layout.prop(self, "directionAxis", expand = True) | ||
|
||
def getExecutionCode(self): | ||
yield "matrix = rotation.to_matrix(); matrix.resize_4x4()" | ||
yield "direction = matrix * mathutils.Vector((0, 0, length))" | ||
return generateRotationToDirectionCode("rotation", "length", "direction", self.directionAxis) | ||
|
||
def getUsedModules(self): | ||
return ["mathutils"] |