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
f453fc9b
Commit
f453fc9b
authored
13 years ago
by
Campbell Barton
Browse files
Options
Downloads
Patches
Plain Diff
added X rotate 90d on import by default, still need to to the reverse on export.
parent
5f26ea87
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
io_anim_bvh/__init__.py
+38
-2
38 additions, 2 deletions
io_anim_bvh/__init__.py
io_anim_bvh/import_bvh.py
+40
-15
40 additions, 15 deletions
io_anim_bvh/import_bvh.py
with
78 additions
and
17 deletions
io_anim_bvh/__init__.py
+
38
−
2
View file @
f453fc9b
...
@@ -46,7 +46,10 @@ from bpy.props import (StringProperty,
...
@@ -46,7 +46,10 @@ from bpy.props import (StringProperty,
BoolProperty
,
BoolProperty
,
EnumProperty
,
EnumProperty
,
)
)
from
bpy_extras.io_utils
import
ImportHelper
,
ExportHelper
from
bpy_extras.io_utils
import
(
ImportHelper
,
ExportHelper
,
axis_conversion
,
)
class
ImportBVH
(
bpy
.
types
.
Operator
,
ImportHelper
):
class
ImportBVH
(
bpy
.
types
.
Operator
,
ImportHelper
):
...
@@ -100,8 +103,41 @@ class ImportBVH(bpy.types.Operator, ImportHelper):
...
@@ -100,8 +103,41 @@ class ImportBVH(bpy.types.Operator, ImportHelper):
default
=
'
NATIVE
'
,
default
=
'
NATIVE
'
,
)
)
axis_forward
=
EnumProperty
(
name
=
"
Forward
"
,
items
=
((
'
X
'
,
"
X Forward
"
,
""
),
(
'
Y
'
,
"
Y Forward
"
,
""
),
(
'
Z
'
,
"
Z Forward
"
,
""
),
(
'
-X
'
,
"
-X Forward
"
,
""
),
(
'
-Y
'
,
"
-Y Forward
"
,
""
),
(
'
-Z
'
,
"
-Z Forward
"
,
""
),
),
default
=
'
-Z
'
,
)
axis_up
=
EnumProperty
(
name
=
"
Up
"
,
items
=
((
'
X
'
,
"
X Up
"
,
""
),
(
'
Y
'
,
"
Y Up
"
,
""
),
(
'
Z
'
,
"
Z Up
"
,
""
),
(
'
-X
'
,
"
-X Up
"
,
""
),
(
'
-Y
'
,
"
-Y Up
"
,
""
),
(
'
-Z
'
,
"
-Z Up
"
,
""
),
),
default
=
'
Y
'
,
)
def
execute
(
self
,
context
):
def
execute
(
self
,
context
):
keywords
=
self
.
as_keywords
(
ignore
=
(
"
filter_glob
"
,))
keywords
=
self
.
as_keywords
(
ignore
=
(
"
axis_forward
"
,
"
axis_up
"
,
"
filter_glob
"
,
))
global_matrix
=
axis_conversion
(
from_forward
=
self
.
axis_forward
,
from_up
=
self
.
axis_up
,
).
to_4x4
()
keywords
[
"
global_matrix
"
]
=
global_matrix
from
.
import
import_bvh
from
.
import
import_bvh
return
import_bvh
.
load
(
self
,
context
,
**
keywords
)
return
import_bvh
.
load
(
self
,
context
,
**
keywords
)
...
...
This diff is collapsed.
Click to expand it.
io_anim_bvh/import_bvh.py
+
40
−
15
View file @
f453fc9b
...
@@ -43,13 +43,13 @@ class BVH_Node(object):
...
@@ -43,13 +43,13 @@ class BVH_Node(object):
'
has_rot
'
,
# Conveinience function, bool, same as (channels[3]!=-1 or channels[4]!=-1 channels[5]!=-1)
'
has_rot
'
,
# Conveinience function, bool, same as (channels[3]!=-1 or channels[4]!=-1 channels[5]!=-1)
'
temp
'
)
# use this for whatever you want
'
temp
'
)
# use this for whatever you want
_eul_order_lookup
=
{
_eul_order_lookup
=
{
(
0
,
1
,
2
):
'
XYZ
'
,
(
0
,
1
,
2
):
'
X
Y
Z
'
,
(
0
,
2
,
1
):
'
XZ
Y
'
,
(
0
,
2
,
1
):
'
XZ
Y
'
,
(
1
,
0
,
2
):
'
Y
XZ
'
,
(
1
,
0
,
2
):
'
Y
X
Z
'
,
(
1
,
2
,
0
):
'
YZ
X
'
,
(
1
,
2
,
0
):
'
Y
ZX
'
,
(
2
,
0
,
1
):
'
ZX
Y
'
,
(
2
,
0
,
1
):
'
Z
X
Y
'
,
(
2
,
1
,
0
):
'
ZY
X
'
,
(
2
,
1
,
0
):
'
ZYX
'
}
}
def
__init__
(
self
,
name
,
rest_head_world
,
rest_head_local
,
parent
,
channels
,
rot_order
):
def
__init__
(
self
,
name
,
rest_head_world
,
rest_head_local
,
parent
,
channels
,
rot_order
):
self
.
name
=
name
self
.
name
=
name
...
@@ -331,7 +331,14 @@ def bvh_node_dict2objects(context, bvh_name, bvh_nodes, rotate_mode='NATIVE', fr
...
@@ -331,7 +331,14 @@ def bvh_node_dict2objects(context, bvh_name, bvh_nodes, rotate_mode='NATIVE', fr
return
objects
return
objects
def
bvh_node_dict2armature
(
context
,
bvh_name
,
bvh_nodes
,
rotate_mode
=
'
XYZ
'
,
frame_start
=
1
,
IMPORT_LOOP
=
False
):
def
bvh_node_dict2armature
(
context
,
bvh_name
,
bvh_nodes
,
rotate_mode
=
'
XYZ
'
,
frame_start
=
1
,
IMPORT_LOOP
=
False
,
global_matrix
=
None
,
):
if
frame_start
<
1
:
if
frame_start
<
1
:
frame_start
=
1
frame_start
=
1
...
@@ -507,10 +514,24 @@ def bvh_node_dict2armature(context, bvh_name, bvh_nodes, rotate_mode='XYZ', fram
...
@@ -507,10 +514,24 @@ def bvh_node_dict2armature(context, bvh_name, bvh_nodes, rotate_mode='XYZ', fram
for
bez
in
cu
.
keyframe_points
:
for
bez
in
cu
.
keyframe_points
:
bez
.
interpolation
=
'
LINEAR
'
bez
.
interpolation
=
'
LINEAR
'
# finally apply matrix
arm_ob
.
matrix_world
=
global_matrix
bpy
.
ops
.
object
.
transform_apply
(
rotation
=
True
)
return
arm_ob
return
arm_ob
def
load
(
operator
,
context
,
filepath
=
""
,
target
=
'
ARMATURE
'
,
rotate_mode
=
'
NATIVE
'
,
global_scale
=
1.0
,
use_cyclic
=
False
,
frame_start
=
1
):
def
load
(
operator
,
context
,
filepath
=
""
,
target
=
'
ARMATURE
'
,
rotate_mode
=
'
NATIVE
'
,
global_scale
=
1.0
,
use_cyclic
=
False
,
frame_start
=
1
,
global_matrix
=
None
,
):
import
time
import
time
t1
=
time
.
time
()
t1
=
time
.
time
()
print
(
'
\t
parsing bvh %r...
'
%
filepath
,
end
=
""
)
print
(
'
\t
parsing bvh %r...
'
%
filepath
,
end
=
""
)
...
@@ -530,15 +551,19 @@ def load(operator, context, filepath="", target='ARMATURE', rotate_mode='NATIVE'
...
@@ -530,15 +551,19 @@ def load(operator, context, filepath="", target='ARMATURE', rotate_mode='NATIVE'
if
target
==
'
ARMATURE
'
:
if
target
==
'
ARMATURE
'
:
bvh_node_dict2armature
(
context
,
bvh_name
,
bvh_nodes
,
bvh_node_dict2armature
(
context
,
bvh_name
,
bvh_nodes
,
rotate_mode
=
rotate_mode
,
rotate_mode
=
rotate_mode
,
frame_start
=
frame_start
,
frame_start
=
frame_start
,
IMPORT_LOOP
=
use_cyclic
)
IMPORT_LOOP
=
use_cyclic
,
global_matrix
=
global_matrix
,
)
elif
target
==
'
OBJECT
'
:
elif
target
==
'
OBJECT
'
:
bvh_node_dict2objects
(
context
,
bvh_name
,
bvh_nodes
,
bvh_node_dict2objects
(
context
,
bvh_name
,
bvh_nodes
,
rotate_mode
=
rotate_mode
,
rotate_mode
=
rotate_mode
,
frame_start
=
frame_start
,
frame_start
=
frame_start
,
IMPORT_LOOP
=
use_cyclic
)
IMPORT_LOOP
=
use_cyclic
,
# global_matrix=global_matrix, # TODO
)
else
:
else
:
raise
Exception
(
"
invalid type
"
)
raise
Exception
(
"
invalid type
"
)
...
...
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