Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
blender_nif_plugin
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
Grant Kim
blender_nif_plugin
Commits
504cc685
Commit
504cc685
authored
3 years ago
by
HENDRIX-ZT2
Committed by
neomonkeus
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix pose import, add debug stuff
parent
c5a1d91b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
io_scene_niftools/modules/nif_import/armature/__init__.py
+21
-10
21 additions, 10 deletions
io_scene_niftools/modules/nif_import/armature/__init__.py
with
21 additions
and
10 deletions
io_scene_niftools/modules/nif_import/armature/__init__.py
+
21
−
10
View file @
504cc685
...
...
@@ -65,16 +65,28 @@ class Armature:
self
.
n_armature
=
None
def
store_pose_matrix
(
self
,
n_node
,
armature_space_pose_store
,
n_root
):
NifLog
.
debug
(
f
"
Storing pose matrix for
{
n_node
.
name
}
"
)
# check that n_block is indeed a bone
if
not
self
.
is_bone
(
n_node
):
return
None
# calculate the transform relative to root, ie. turn nif local into nif armature space
armature_space_pose_store
[
n_node
]
=
n_node
.
get_transform
(
n_root
)
# move down the hierarchy
for
n_child
in
n_node
.
children
:
self
.
store_pose_matrix
(
n_child
,
armature_space_pose_store
,
n_root
)
def
get_skinned_geometries
(
self
,
n_root
):
"""
Yield all children in n_root
'
s tree that have skinning
"""
# search for all NiTriShape or NiTriStrips blocks...
for
n_block
in
n_root
.
tree
(
block_type
=
NifFormat
.
NiTriBasedGeom
):
# yes, we found one, does it have skinning?
if
n_block
.
is_skin
():
yield
n_block
def
import_pose
(
self
,
n_armature
):
"""
Ported and adapted from pyffi send_bones_to_bind_position
"""
NifLog
.
debug
(
f
"
Calculating pose for
{
n_armature
.
name
}
"
)
armature_space_bind_store
=
{}
armature_space_pose_store
=
{}
# check all bones and bone datas to see if a bind position exists
...
...
@@ -84,7 +96,10 @@ class Armature:
self
.
store_pose_matrix
(
n_child
,
armature_space_pose_store
,
n_armature
)
# prioritize geometries that have most nodes in their skin instance
for
geom
in
sorted
(
n_armature
.
get_skinned_geometries
(),
key
=
lambda
g
:
g
.
skin_instance
.
num_bones
,
reverse
=
True
):
geoms
=
sorted
(
self
.
get_skinned_geometries
(
n_armature
),
key
=
lambda
g
:
g
.
skin_instance
.
num_bones
,
reverse
=
True
)
NifLog
.
debug
(
f
"
Found
{
len
(
geoms
)
}
skinned geometries
"
)
for
geom
in
geoms
:
NifLog
.
debug
(
f
"
Checking skin of
{
geom
.
name
}
"
)
skininst
=
geom
.
skin_instance
skindata
=
skininst
.
data
for
bonenode
,
bonedata
in
zip
(
skininst
.
bones
,
skindata
.
bone_list
):
...
...
@@ -284,15 +299,11 @@ class Armature:
# set these here once per run
self
.
n_armature
=
None
self
.
skinned
=
False
# search for all NiTriShape or NiTriStrips blocks...
for
n_block
in
n_root
.
tree
():
if
isinstance
(
n_block
,
NifFormat
.
NiTriBasedGeom
):
# yes, we found one, does it have skinning?
if
n_block
.
is_skin
():
self
.
skinned
=
True
NifLog
.
debug
(
f
"
{
n_block
.
name
}
has skinning.
"
)
# one is enough to require an armature, so stop
return
for
n_block
in
self
.
get_skinned_geometries
(
n_root
):
self
.
skinned
=
True
NifLog
.
debug
(
f
"
{
n_block
.
name
}
has skinning.
"
)
# one is enough to require an armature, so stop
return
NifLog
.
debug
(
f
"
Found no skinned geometries.
"
)
def
is_bone
(
self
,
ni_block
):
...
...
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