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
77d52086
Commit
77d52086
authored
13 years ago
by
Benjy Cook
Browse files
Options
Downloads
Patches
Plain Diff
Updated Mocap addon with fixes for latest api changes and some reported bugs
parent
3c0c5199
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mocap/__init__.py
+8
-0
8 additions, 0 deletions
mocap/__init__.py
mocap/retarget.py
+12
-11
12 additions, 11 deletions
mocap/retarget.py
with
20 additions
and
11 deletions
mocap/__init__.py
+
8
−
0
View file @
77d52086
...
...
@@ -53,11 +53,19 @@ else:
from
.
import
mocap_constraints
from
.
import
retarget
from
.
import
mocap_tools
# MocapConstraint class
# Defines MocapConstraint datatype, used to add and configute mocap constraints
# Attached to Armature data
def
hasIKConstraint
(
pose_bone
):
#utility function / predicate, returns True if given bone has IK constraint
ik
=
[
constraint
for
constraint
in
pose_bone
.
constraints
if
constraint
.
type
==
"
IK
"
]
if
ik
:
return
ik
[
0
]
else
:
return
False
class
MocapConstraint
(
bpy
.
types
.
PropertyGroup
):
name
=
StringProperty
(
name
=
"
Name
"
,
...
...
This diff is collapsed.
Click to expand it.
mocap/retarget.py
+
12
−
11
View file @
77d52086
...
...
@@ -21,7 +21,7 @@
import
bpy
from
mathutils
import
Vector
,
Matrix
from
math
import
radians
from
b
l_operators
import
nla
from
b
py_extras.anim_utils
import
bake_action
def
hasIKConstraint
(
pose_bone
):
...
...
@@ -292,15 +292,15 @@ def copyTranslation(performer_obj, enduser_obj, perfFeet, root, s_frame, e_frame
if
linearAvg
:
#determine the average change in scale needed
avg
=
sum
(
linearAvg
)
/
len
(
linearAvg
)
scene
.
frame_set
(
s_frame
)
initialPos
=
(
tailLoc
(
perf_bones
[
perfRoot
])
/
avg
)
for
t
in
range
(
s_frame
,
e_frame
):
scene
.
frame_set
(
t
)
#calculate the new position, by dividing by the found ratio between performer and enduser
newTranslation
=
(
tailLoc
(
perf_bones
[
perfRoot
])
/
avg
)
stride_bone
.
location
=
enduser_obj_mat
*
(
newTranslation
-
initialPos
)
stride_bone
.
keyframe_insert
(
"
location
"
)
else
:
avg
=
1
scene
.
frame_set
(
s_frame
)
initialPos
=
(
tailLoc
(
perf_bones
[
perfRoot
])
/
avg
)
for
t
in
range
(
s_frame
,
e_frame
):
scene
.
frame_set
(
t
)
#calculate the new position, by dividing by the found ratio between performer and enduser
newTranslation
=
(
tailLoc
(
perf_bones
[
perfRoot
])
/
avg
)
stride_bone
.
location
=
enduser_obj_mat
*
(
newTranslation
-
initialPos
)
stride_bone
.
keyframe_insert
(
"
location
"
)
stride_bone
.
animation_data
.
action
.
name
=
(
"
Stride Bone
"
+
action_name
)
...
...
@@ -520,8 +520,9 @@ def totalRetarget(performer_obj, enduser_obj, scene, s_frame, e_frame):
else
:
prepareForBake
(
enduser_obj
)
print
(
"
Retargeting pose (Advanced Retarget)
"
)
nla
.
bake
(
s_frame
,
e_frame
,
action
=
enduser_obj
.
animation_data
.
action
,
only_selected
=
True
,
do_pose
=
True
,
do_object
=
False
,
step
=
step
)
name
=
performer_obj
.
animation_data
.
action
.
name
bake_action
(
s_frame
,
e_frame
,
action
=
enduser_obj
.
animation_data
.
action
,
only_selected
=
True
,
do_pose
=
True
,
do_object
=
False
,
step
=
step
)
name
=
performer_obj
.
animation_data
.
action
.
name
[:
10
]
#We trim the name down to 10 chars because of Action Name length maximum
enduser_obj
.
animation_data
.
action
.
name
=
"
Base
"
+
name
print
(
"
Second pass: retargeting root translation and clean up
"
)
stride_bone
=
copyTranslation
(
performer_obj
,
enduser_obj
,
feetBones
,
root
,
s_frame
,
e_frame
,
scene
,
enduser_obj_mat
)
...
...
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