191
edits
Paradox-01 (talk | contribs) mNo edit summary |
(Added a script for adjusting forward throw target anims in Blender. Snippet is pretty long; if you have a better idea of formatting it or putting it elsewhere let me know.) |
||
Line 854: | Line 854: | ||
====Forward throws==== | ====Forward throws==== | ||
Scenario: you load two characters into Mod Tool and rotate (+/-180°) the throw target character because you need them to stand face to face as you work on an animation. When you are done animating, the target animation would need to be reversed again. This means multiplying the velocities by -1; the rotation also needs correcting. So it looks like you need *(-1) for the x rotation and -/+180° (depending on your initial change) for the y rotation. | Scenario: you load two characters into Mod Tool and rotate (+/-180°) the throw target character because you need them to stand face to face as you work on an animation. When you are done animating, the target animation would need to be reversed again. This means multiplying the velocities by -1; the rotation also needs correcting. So it looks like you need *(-1) for the x rotation and -/+180° (depending on your initial change) for the y rotation. | ||
====Blender Forward throw adjustment script==== | |||
This is a Blender script for rotating -/+180° and adding PositionOffset to a forward throw Target animation. This will be documented soon. | |||
<pre>import bpy | |||
from math import pi, radians | |||
from mathutils import Matrix, Quaternion, Vector | |||
obj = bpy.context.active_object | |||
scene = bpy.context.scene | |||
def add_object_offset_about_cursor_Z(object,x,y,z): #Translation function | |||
cursor_loc = bpy.context.scene.cursor.location #3D Cursor location | |||
mat = (Matrix.Translation(cursor_loc) @ | |||
Matrix.Translation((x,y,z))) #PositionOffset translation applied | |||
object.matrix_world = mat @ object.matrix_world #Change applied to object | |||
def rotate_object_about_cursor_Z(object, degrees): #Rotation function | |||
cursor_loc = bpy.context.scene.cursor.location #3D Cursor location | |||
mat = (Matrix.Translation(cursor_loc) @ | |||
Matrix.Rotation(radians(degrees), 4, 'Z') @ | |||
Matrix.Translation(-cursor_loc)) #Rotation applied | |||
object.matrix_world = mat @ object.matrix_world #Change applied to object | |||
#BUGGED KEYFRAME-CHECKING FUNCTION, NOT USED BUT MIGHT BE USEFUL IN THE FEATURE | |||
"""def is_keyframe(ob, frame, data_path, array_index=-1): | |||
if ob is not None and ob.animation_data is not None and ob.animation_data.action is not None: | |||
for fcu in ob.animation_data.action.fcurves: | |||
if fcu.data_path == data_path: | |||
if array_index == -1 or fcu.array_index == array_index: | |||
return frame in (p.co.x for p in fcu.keyframe_points) | |||
return False | |||
bpy.types.Object.is_keyframe = is_keyframe """ | |||
obj.keyframe_insert(data_path="location", frame = 0) | |||
obj.matrix_world.translation += Vector((-100, 0, 0)) #no idea what this is doing | |||
obj.keyframe_insert(data_path="location", frame = 100) | |||
scene.frame_set(0) #set start frame | |||
for i in range(0, 100): #loop for every frame | |||
#if obj.is_keyframe(i, obj.path_from_id("location")): Bugged keyframe-check | |||
scene.frame_set(i) | |||
rotate_object_about_cursor_Z(obj, 180) #rotate object | |||
add_object_offset_about_cursor_Z(obj,1,1,1) #translate object | |||
obj.keyframe_insert(data_path="rotation_euler", frame=i) #keyframe rotation | |||
obj.keyframe_insert(data_path="location", frame=i) #keyframe location | |||
</pre> | |||
edits