Work on Infantry rigging
This commit is contained in:
parent
cf23d0c88c
commit
70144ec7c1
BIN
characters/infantry/p8-lopoly.blend
(Stored with Git LFS)
BIN
characters/infantry/p8-lopoly.blend
(Stored with Git LFS)
Binary file not shown.
BIN
characters/infantry/p9-lopoly.blend
(Stored with Git LFS)
Normal file
BIN
characters/infantry/p9-lopoly.blend
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user