From e3096bfc4065a6a48ce248cd5ea0ce667b1ac65d Mon Sep 17 00:00:00 2001 From: Alan O'Cull Date: Wed, 21 Feb 2024 13:18:18 -0500 Subject: [PATCH] Add gun rig --- characters/infantry/p9-lopoly.blend | 4 +-- characters/infantry/post_rig.py | 39 +++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/characters/infantry/p9-lopoly.blend b/characters/infantry/p9-lopoly.blend index 5609b24..54da9c5 100644 --- a/characters/infantry/p9-lopoly.blend +++ b/characters/infantry/p9-lopoly.blend @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f06e11fca284bf93033c3426850ba0b02d1864482863044ace704dc2a4a94e74 -size 5170916 +oid sha256:a36b7d7b69ae9ef5a628fcd86d45b2830690d864ed627f95fe30822b8213f334 +size 5308880 diff --git a/characters/infantry/post_rig.py b/characters/infantry/post_rig.py index ab4586c..1a56385 100644 --- a/characters/infantry/post_rig.py +++ b/characters/infantry/post_rig.py @@ -161,6 +161,27 @@ for b in rig.pose.bones: b.bone_group_index = BGRP_EXTRA elif b.name == "baton_handR_grip": b.custom_shape_scale_xyz = (0.2, 1.0, 0.8) + + ### GUN + elif b.name.startswith("grip_gun"): + b.custom_shape_scale_xyz = (0.1, 1.5, 0.2) + b.custom_shape_translation = (0.0, 0.185, 0.0) + elif b.name == "gun_ammunition": + b.custom_shape_scale_xyz = (0.4, 1.0, 0.4) + b.custom_shape_translation = (0.0, 0.06, 0.0) + elif b.name == "gun_trigger": + b.custom_shape_scale_xyz = (0.3, 1.0, 0.7) + b.custom_shape_translation = (0.0, 0.015, 0.0) + arrcopy(b.lock_rotation, [False, True, True]) + arrcopy(b.lock_location, [True, True, True]) + arrcopy(b.lock_scale, [True, True, True]) + elif b.name == "gun_muzzle": + b.custom_shape_scale_xyz = (0.1, 1.1, 0.2) + b.custom_shape_translation = (0.0, 0.14, 0.0) + arrcopy(b.lock_location, [True, False, True]) + arrcopy(b.lock_rotation, [True, True, True]) + arrcopy(b.lock_scale, [True, False, True]) + b.lock_rotation_w = True ## BODY elif b.name == "neck.001": @@ -170,18 +191,32 @@ for b in rig.pose.bones: # Constrain slider widgets constrain_slider(rig.pose.bones.get('slider1d_baton_constrain'), 0.0, 0.06) constrain_slider(rig.pose.bones.get('slider1d_baton_handIK'), 0.0, 0.06) +constrain_slider(rig.pose.bones.get('slider1d_gun_handRIK'), 0.0, 0.06) +constrain_slider(rig.pose.bones.get('slider1d_gun_handLIK'), 0.0, 0.06) -# Switch Baton Grip's bound parent, default parent to arm, but can switch to separate control +## Switch Baton Grip's bound parent, default parent to arm, but can switch to separate control baton_grip = rig.pose.bones.get("grip_baton") cpy_transforms(baton_grip, 'grip_baton_constrained', 1.0) # Default to hand grip bg_constraint = cpy_transforms(baton_grip, 'grip_baton_free', 0.0) drv_constraint_1D(bg_constraint, 'slider1d_baton_constrain', 0.06) -# Align right hand to baton grip +## Align right hand to baton grip rightHand = rig.pose.bones.get("MCH-upper_arm_ik_target.R") bh_constraint = cpy_transforms(rightHand, 'baton_handR_grip', 0.0) # Default to hand grip drv_constraint_1D(bh_constraint, 'slider1d_baton_handIK', 0.06) +# Gun +gun_grip = rig.pose.bones.get("grip_gun") +cpy_transforms(gun_grip, 'grip_gun_free', 1.0) # Inherit transforms, but be tree-agnostic for IK + +## Align hands to gun grip +ghr_constraint = cpy_transforms(rightHand, 'gun_handR_grip', 0.0) +drv_constraint_1D(ghr_constraint, 'slider1d_gun_handRIK', 0.06) + +leftHand = rig.pose.bones.get("MCH-upper_arm_ik_target.L") +ghl_constraint = cpy_transforms(leftHand, 'gun_handL_grip', 0.0) +drv_constraint_1D(ghl_constraint, 'slider1d_gun_handLIK', 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)