From 70144ec7c16f1207423f862bac09d8332fa83022 Mon Sep 17 00:00:00 2001 From: Alan O'Cull Date: Mon, 19 Feb 2024 13:20:17 -0500 Subject: [PATCH] Work on Infantry rigging --- characters/infantry/p8-lopoly.blend | 3 - characters/infantry/p9-lopoly.blend | 3 + characters/infantry/post_rig.py | 89 +++++++++++++++++------------ 3 files changed, 55 insertions(+), 40 deletions(-) delete mode 100644 characters/infantry/p8-lopoly.blend create mode 100644 characters/infantry/p9-lopoly.blend diff --git a/characters/infantry/p8-lopoly.blend b/characters/infantry/p8-lopoly.blend deleted file mode 100644 index 70d0a54..0000000 --- a/characters/infantry/p8-lopoly.blend +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:9283ff96d5d5913ced20f688a9d00993157a913b0fd38bcdb93cf0a6f4b7ffa8 -size 2455075 diff --git a/characters/infantry/p9-lopoly.blend b/characters/infantry/p9-lopoly.blend new file mode 100644 index 0000000..1023540 --- /dev/null +++ b/characters/infantry/p9-lopoly.blend @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8ab57c5c47611049cec8c22ac0c72e91d654d97eb4e876cfd22d4e618d3d0709 +size 4875672 diff --git a/characters/infantry/post_rig.py b/characters/infantry/post_rig.py index 6b54fdb..b556973 100644 --- a/characters/infantry/post_rig.py +++ b/characters/infantry/post_rig.py @@ -1,7 +1,7 @@ import bpy from bpy.types import Constraint, PoseBone -rig = bpy.data.objects["skeleton_insurrectionist"] +rig = bpy.data.objects["infantry"] ## FIX PARENTS def reparent(b: str, newParent: str = 'DEF-spine'): @@ -48,13 +48,13 @@ reparent('DEF-palm.02.R', 'DEF-hand.R') reparent('DEF-palm.03.R', 'DEF-hand.R') reparent('DEF-palm.04.R', 'DEF-hand.R') -# Force axe to be exported by setting it as a deform bone -rig.data.edit_bones['axe'].use_deform = True +## Force axe to be exported by setting it as a deform bone +#rig.data.edit_bones['axe'].use_deform = True -# Switch into POSE mode to set up animation constraints +## Switch into POSE mode to set up animation constraints bpy.ops.object.mode_set(mode='POSE') -## Declare Functions for animation constraints +### Declare Functions for animation constraints def arrcopy(copyTo, copyFrom): for i in range(min(len(copyTo), len(copyFrom))): copyTo[i] = copyFrom[i] @@ -111,8 +111,15 @@ def constrain_slider(b: PoseBone, minimum: float = 0, maximum: float = 0.06): c.max_y = maximum c.use_transform_limit = True c.owner_space = 'LOCAL' +def cpy_transforms(b: PoseBone, subtarget, influence = 1.0): + constraint = b.constraints.new('COPY_TRANSFORMS') + constraint.target = rig + constraint.subtarget = subtarget # note subtarget uses name not object + constraint.target_space = 'POSE' + constraint.owner_space = 'POSE' + constraint.influence = influence -# Fix widget scalings +## Fix widget scalings, and constrain them for b in rig.pose.bones: if b.name.startswith("menu_"): b.use_custom_shape_bone_size = False @@ -129,39 +136,47 @@ for b in rig.pose.bones: b.lock_rotation_w = True elif b.name == "axe_gripadjust": b.custom_shape_scale_xyz = (1.0, 0.8, 0.1) + elif b.name == "baton_obj": + b.custom_shape_scale_xyz = (0.2, 2.6, 0.2) + b.custom_shape_translation = (0.0, 0.25, 0.0) + elif b.name == "neck.001": + arrcopy(b.lock_location, [True, True, True]) -# Constrain menu sliders so they are limited to proper bounds -constrain_slider(rig.pose.bones.get('slider1d_axe_gripadjust')) -constrain_slider(rig.pose.bones.get('slider1d_axe_lefthand_grip')) -constrain_slider(rig.pose.bones.get('slider1d_axe_smear'), -0.03, 0.03) +## Constrain menu sliders so they are limited to proper bounds +#constrain_slider(rig.pose.bones.get('slider1d_axe_gripadjust')) +#constrain_slider(rig.pose.bones.get('slider1d_axe_lefthand_grip')) +#constrain_slider(rig.pose.bones.get('slider1d_axe_smear'), -0.03, 0.03) -# Arm and Hand switch for Axe Base -# https://blender.stackexchange.com/questions/46928/set-bone-constraints-via-python-api#46986 -axe_base = rig.pose.bones.get("axe_base") -axe_constraint: Constraint = None -if axe_base is not None: - axe_constraint = axe_base.constraints.new('COPY_TRANSFORMS') - axe_constraint.target = rig - axe_constraint.subtarget = 'DEF-hand.R' # note subtarget uses name not object - axe_constraint.target_space = 'POSE' - axe_constraint.owner_space = 'POSE' - axe_constraint.influence = 0.0 +## Arm and Hand switch for Axe Base +## https://blender.stackexchange.com/questions/46928/set-bone-constraints-via-python-api#46986 +#axe_base = rig.pose.bones.get("axe_base") +#axe_constraint: Constraint = None +#if axe_base is not None: +# axe_constraint = axe_base.constraints.new('COPY_TRANSFORMS') +# axe_constraint.target = rig +# axe_constraint.subtarget = 'DEF-hand.R' # note subtarget uses name not object +# axe_constraint.target_space = 'POSE' +# axe_constraint.owner_space = 'POSE' +# axe_constraint.influence = 0.0 -# Left-Hand grip switch for Axe -left_hand = rig.pose.bones.get("hand_ik.L") -lh_constraint: Constraint = None -if axe_base is not None: - lh_constraint = left_hand.constraints.new('COPY_TRANSFORMS') - lh_constraint.target = rig - lh_constraint.subtarget = 'axe_grip_lefthand' # note subtarget uses name not object - lh_constraint.target_space = 'POSE' - lh_constraint.owner_space = 'POSE' - lh_constraint.influence = 0.0 +## Left-Hand grip switch for Axe +#left_hand = rig.pose.bones.get("hand_ik.L") +#lh_constraint: Constraint = None +#if axe_base is not None: +# lh_constraint = left_hand.constraints.new('COPY_TRANSFORMS') +# lh_constraint.target = rig +# lh_constraint.subtarget = 'axe_grip_lefthand' # note subtarget uses name not object +# lh_constraint.target_space = 'POSE' +# lh_constraint.owner_space = 'POSE' +# lh_constraint.influence = 0.0 -## Set up driver constraint for the switches -drv_constraint_1D(axe_constraint, 'slider1d_axe_gripadjust', 0.06) -drv_constraint_1D(lh_constraint, 'slider1d_axe_lefthand_grip', 0.06) +baton_grip = rig.pose.bones.get("grip_baton") +cpy_transforms(baton_grip, 'baton_obj', 1.0) -## Set up smear effect drivers for axe -drv_blend_1D('Key', 'smear_down', 'slider1d_axe_smear', 0.03) -drv_blend_1D('Key', 'smear_up', 'slider1d_axe_smear', -0.03) +### Set up driver constraint for the switches +#drv_constraint_1D(axe_constraint, 'slider1d_axe_gripadjust', 0.06) +#drv_constraint_1D(lh_constraint, 'slider1d_axe_lefthand_grip', 0.06) + +### Set up smear effect drivers for axe +#drv_blend_1D('Key', 'smear_down', 'slider1d_axe_smear', 0.03) +#drv_blend_1D('Key', 'smear_up', 'slider1d_axe_smear', -0.03)