Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
blender-addons
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
blender
blender-addons
Commits
4339115f
Commit
4339115f
authored
13 years ago
by
Nathan Vegdahl
Browse files
Options
Downloads
Patches
Plain Diff
Rigify: user can disable control and deform rig generation on copy and copy_chain.
parent
8b339cda
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
rigify/rigs/basic/copy.py
+41
-13
41 additions, 13 deletions
rigify/rigs/basic/copy.py
rigify/rigs/basic/copy_chain.py
+75
-37
75 additions, 37 deletions
rigify/rigs/basic/copy_chain.py
with
116 additions
and
50 deletions
rigify/rigs/basic/copy.py
+
41
−
13
View file @
4339115f
...
@@ -36,6 +36,8 @@ class Rig:
...
@@ -36,6 +36,8 @@ class Rig:
self
.
org_bone
=
bone
self
.
org_bone
=
bone
self
.
org_name
=
strip_org
(
bone
)
self
.
org_name
=
strip_org
(
bone
)
self
.
params
=
params
self
.
params
=
params
self
.
make_control
=
params
.
make_control
self
.
make_deform
=
params
.
make_deform
def
generate
(
self
):
def
generate
(
self
):
"""
Generate the rig.
"""
Generate the rig.
...
@@ -46,31 +48,57 @@ class Rig:
...
@@ -46,31 +48,57 @@ class Rig:
bpy
.
ops
.
object
.
mode_set
(
mode
=
'
EDIT
'
)
bpy
.
ops
.
object
.
mode_set
(
mode
=
'
EDIT
'
)
# Make a control bone (copy of original).
# Make a control bone (copy of original).
bone
=
copy_bone
(
self
.
obj
,
self
.
org_bone
,
self
.
org_name
)
if
self
.
make_control
:
bone
=
copy_bone
(
self
.
obj
,
self
.
org_bone
,
self
.
org_name
)
# Make a deformation bone (copy of original, child of original).
# Make a deformation bone (copy of original, child of original).
def_bone
=
copy_bone
(
self
.
obj
,
self
.
org_bone
,
make_deformer_name
(
self
.
org_name
))
if
self
.
make_deform
:
def_bone
=
copy_bone
(
self
.
obj
,
self
.
org_bone
,
make_deformer_name
(
self
.
org_name
))
# Get edit bones
# Get edit bones
eb
=
self
.
obj
.
data
.
edit_bones
eb
=
self
.
obj
.
data
.
edit_bones
bone_e
=
eb
[
bone
]
if
self
.
make_control
:
def_bone_e
=
eb
[
def_bone
]
bone_e
=
eb
[
bone
]
if
self
.
make_deform
:
def_bone_e
=
eb
[
def_bone
]
# Parent
# Parent
def_bone_e
.
use_connect
=
False
if
self
.
make_deform
:
def_bone_e
.
parent
=
eb
[
self
.
org_bone
]
def_bone_e
.
use_connect
=
False
def_bone_e
.
parent
=
eb
[
self
.
org_bone
]
bpy
.
ops
.
object
.
mode_set
(
mode
=
'
OBJECT
'
)
bpy
.
ops
.
object
.
mode_set
(
mode
=
'
OBJECT
'
)
pb
=
self
.
obj
.
pose
.
bones
pb
=
self
.
obj
.
pose
.
bones
# Constrain the original bone.
if
self
.
make_control
:
con
=
pb
[
self
.
org_bone
].
constraints
.
new
(
'
COPY_TRANSFORMS
'
)
# Constrain the original bone.
con
.
name
=
"
copy_transforms
"
con
=
pb
[
self
.
org_bone
].
constraints
.
new
(
'
COPY_TRANSFORMS
'
)
con
.
target
=
self
.
obj
con
.
name
=
"
copy_transforms
"
con
.
subtarget
=
bone
con
.
target
=
self
.
obj
con
.
subtarget
=
bone
# Create control widget
# Create control widget
create_bone_widget
(
self
.
obj
,
bone
)
create_bone_widget
(
self
.
obj
,
bone
)
@classmethod
def
add_parameters
(
self
,
group
):
"""
Add the parameters of this rig type to the
RigifyParameters PropertyGroup
"""
group
.
make_control
=
bpy
.
props
.
BoolProperty
(
name
=
"
Control
"
,
default
=
True
,
description
=
"
Create a control bone for the copy.
"
)
group
.
make_deform
=
bpy
.
props
.
BoolProperty
(
name
=
"
Deform
"
,
default
=
True
,
description
=
"
Create a deform bone for the copy.
"
)
@classmethod
def
parameters_ui
(
self
,
layout
,
obj
,
bone
):
"""
Create the ui for the rig parameters.
"""
params
=
obj
.
pose
.
bones
[
bone
].
rigify_parameters
[
0
]
r
=
layout
.
row
()
r
.
prop
(
params
,
"
make_control
"
)
r
=
layout
.
row
()
r
.
prop
(
params
,
"
make_deform
"
)
@classmethod
@classmethod
def
create_sample
(
self
,
obj
):
def
create_sample
(
self
,
obj
):
...
...
This diff is collapsed.
Click to expand it.
rigify/rigs/basic/copy_chain.py
+
75
−
37
View file @
4339115f
...
@@ -36,6 +36,8 @@ class Rig:
...
@@ -36,6 +36,8 @@ class Rig:
self
.
obj
=
obj
self
.
obj
=
obj
self
.
org_bones
=
[
bone_name
]
+
connected_children_names
(
obj
,
bone_name
)
self
.
org_bones
=
[
bone_name
]
+
connected_children_names
(
obj
,
bone_name
)
self
.
params
=
params
self
.
params
=
params
self
.
make_controls
=
params
.
make_controls
self
.
make_deforms
=
params
.
make_deforms
if
len
(
self
.
org_bones
)
<=
1
:
if
len
(
self
.
org_bones
)
<=
1
:
raise
MetarigError
(
"
RIGIFY ERROR: Bone
'
%s
'
: input to rig type must be a chain of 2 or more bones.
"
%
(
strip_org
(
bone
)))
raise
MetarigError
(
"
RIGIFY ERROR: Bone
'
%s
'
: input to rig type must be a chain of 2 or more bones.
"
%
(
strip_org
(
bone
)))
...
@@ -55,51 +57,87 @@ class Rig:
...
@@ -55,51 +57,87 @@ class Rig:
for
i
in
range
(
len
(
self
.
org_bones
)):
for
i
in
range
(
len
(
self
.
org_bones
)):
name
=
self
.
org_bones
[
i
]
name
=
self
.
org_bones
[
i
]
# Create bones
# Control bone
def_bone
=
copy_bone
(
self
.
obj
,
name
)
if
self
.
make_controls
:
ctrl_bone
=
copy_bone
(
self
.
obj
,
name
)
# Copy
ctrl_bone
=
copy_bone
(
self
.
obj
,
name
)
# Get edit bones
eb
=
self
.
obj
.
data
.
edit_bones
eb
=
self
.
obj
.
data
.
edit_bones
ctrl_bone_e
=
eb
[
ctrl_bone
]
def_bone_e
=
eb
[
def_bone
]
# Name
ctrl_bone_e
=
eb
[
ctrl_bone
]
ctrl_bone_e
.
name
=
strip_org
(
name
)
# Parenting
# Set their names
if
i
==
0
:
def_bone_e
.
name
=
make_deformer_name
(
strip_org
(
name
))
# First bone
ctrl_bone_e
.
name
=
strip_org
(
name
)
ctrl_bone_e
.
parent
=
eb
[
self
.
org_bones
[
0
]].
parent
else
:
# Add them to their respective lists
# The rest
def_chain
+=
[
def_bone_e
.
name
]
ctrl_bone_e
.
parent
=
eb
[
ctrl_chain
[
-
1
]]
ctrl_chain
+=
[
ctrl_bone_e
.
name
]
# Add to list
ctrl_chain
+=
[
ctrl_bone_e
.
name
]
# Parenting
if
i
==
0
:
# First bone
def_bone_e
.
parent
=
eb
[
self
.
org_bones
[
i
]].
parent
ctrl_bone_e
.
parent
=
eb
[
self
.
org_bones
[
i
]].
parent
else
:
else
:
# The rest
ctrl_chain
+=
[
None
]
def_bone_e
.
parent
=
eb
[
def_chain
[
i
-
1
]]
ctrl_bone_e
.
parent
=
eb
[
ctrl_chain
[
i
-
1
]]
# Deformation bone
if
self
.
make_deforms
:
# Copy
def_bone
=
copy_bone
(
self
.
obj
,
name
)
eb
=
self
.
obj
.
data
.
edit_bones
def_bone_e
=
eb
[
def_bone
]
# Name
def_bone_e
.
name
=
make_deformer_name
(
strip_org
(
name
))
# Parenting
if
i
==
0
:
# First bone
def_bone_e
.
parent
=
eb
[
self
.
org_bones
[
0
]].
parent
else
:
# The rest
def_bone_e
.
parent
=
eb
[
def_chain
[
-
1
]]
# Add to list
def_chain
+=
[
def_bone_e
.
name
]
else
:
def_chain
+=
[
None
]
bpy
.
ops
.
object
.
mode_set
(
mode
=
'
OBJECT
'
)
bpy
.
ops
.
object
.
mode_set
(
mode
=
'
OBJECT
'
)
pb
=
self
.
obj
.
pose
.
bones
pb
=
self
.
obj
.
pose
.
bones
# Constraint org and def
to the control bones
# Constraint
s for
org and def
for
org
,
ctrl
,
defrm
in
zip
(
self
.
org_bones
,
ctrl_chain
,
def_chain
):
for
org
,
ctrl
,
defrm
in
zip
(
self
.
org_bones
,
ctrl_chain
,
def_chain
):
con
=
pb
[
org
].
constraints
.
new
(
'
COPY_TRANSFORMS
'
)
if
self
.
make_controls
:
con
.
name
=
"
copy_transforms
"
con
=
pb
[
org
].
constraints
.
new
(
'
COPY_TRANSFORMS
'
)
con
.
target
=
self
.
obj
con
.
name
=
"
copy_transforms
"
con
.
subtarget
=
ctrl
con
.
target
=
self
.
obj
con
.
subtarget
=
ctrl
con
=
pb
[
defrm
].
constraints
.
new
(
'
COPY_TRANSFORMS
'
)
con
.
name
=
"
copy_transforms
"
if
self
.
make_deforms
:
con
.
target
=
self
.
obj
con
=
pb
[
defrm
].
constraints
.
new
(
'
COPY_TRANSFORMS
'
)
con
.
subtarget
=
ctrl
con
.
name
=
"
copy_transforms
"
con
.
target
=
self
.
obj
con
.
subtarget
=
org
# Create control widgets
# Create control widgets
for
bone
in
ctrl_chain
:
if
self
.
make_controls
:
create_bone_widget
(
self
.
obj
,
bone
)
for
bone
in
ctrl_chain
:
create_bone_widget
(
self
.
obj
,
bone
)
@classmethod
def
add_parameters
(
self
,
group
):
"""
Add the parameters of this rig type to the
RigifyParameters PropertyGroup
"""
group
.
make_controls
=
bpy
.
props
.
BoolProperty
(
name
=
"
Controls
"
,
default
=
True
,
description
=
"
Create control bones for the copy.
"
)
group
.
make_deforms
=
bpy
.
props
.
BoolProperty
(
name
=
"
Deform
"
,
default
=
True
,
description
=
"
Create deform bones for the copy.
"
)
@classmethod
def
parameters_ui
(
self
,
layout
,
obj
,
bone
):
"""
Create the ui for the rig parameters.
"""
params
=
obj
.
pose
.
bones
[
bone
].
rigify_parameters
[
0
]
r
=
layout
.
row
()
r
.
prop
(
params
,
"
make_controls
"
)
r
=
layout
.
row
()
r
.
prop
(
params
,
"
make_deforms
"
)
@classmethod
@classmethod
def
create_sample
(
self
,
obj
):
def
create_sample
(
self
,
obj
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment