Add gun rig

This commit is contained in:
Alan O'Cull 2024-02-21 13:18:18 -05:00
parent 5e084cc96e
commit e3096bfc40
2 changed files with 39 additions and 4 deletions

BIN
characters/infantry/p9-lopoly.blend (Stored with Git LFS)

Binary file not shown.

View File

@ -161,6 +161,27 @@ for b in rig.pose.bones:
b.bone_group_index = BGRP_EXTRA b.bone_group_index = BGRP_EXTRA
elif b.name == "baton_handR_grip": elif b.name == "baton_handR_grip":
b.custom_shape_scale_xyz = (0.2, 1.0, 0.8) 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 ## BODY
elif b.name == "neck.001": elif b.name == "neck.001":
@ -170,18 +191,32 @@ for b in rig.pose.bones:
# Constrain slider widgets # Constrain slider widgets
constrain_slider(rig.pose.bones.get('slider1d_baton_constrain'), 0.0, 0.06) 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_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") baton_grip = rig.pose.bones.get("grip_baton")
cpy_transforms(baton_grip, 'grip_baton_constrained', 1.0) # Default to hand grip cpy_transforms(baton_grip, 'grip_baton_constrained', 1.0) # Default to hand grip
bg_constraint = cpy_transforms(baton_grip, 'grip_baton_free', 0.0) bg_constraint = cpy_transforms(baton_grip, 'grip_baton_free', 0.0)
drv_constraint_1D(bg_constraint, 'slider1d_baton_constrain', 0.06) 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") 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 bh_constraint = cpy_transforms(rightHand, 'baton_handR_grip', 0.0) # Default to hand grip
drv_constraint_1D(bh_constraint, 'slider1d_baton_handIK', 0.06) 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 ### Set up smear effect drivers for axe
#drv_blend_1D('Key', 'smear_down', 'slider1d_axe_smear', 0.03) #drv_blend_1D('Key', 'smear_down', 'slider1d_axe_smear', 0.03)
#drv_blend_1D('Key', 'smear_up', 'slider1d_axe_smear', -0.03) #drv_blend_1D('Key', 'smear_up', 'slider1d_axe_smear', -0.03)