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
4a25a2ba
Commit
4a25a2ba
authored
12 years ago
by
Campbell Barton
Browse files
Options
Downloads
Patches
Plain Diff
initialize start_frame/end_frame from the scene, dont transform the verts on export.
parent
9ef28b56
No related branches found
Branches containing commit
Tags
v2.65
v2.65a
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
io_shape_mdd/__init__.py
+19
-20
19 additions, 20 deletions
io_shape_mdd/__init__.py
io_shape_mdd/export_mdd.py
+4
-19
4 additions, 19 deletions
io_shape_mdd/export_mdd.py
io_shape_mdd/import_mdd.py
+36
-36
36 additions, 36 deletions
io_shape_mdd/import_mdd.py
with
59 additions
and
75 deletions
io_shape_mdd/__init__.py
+
19
−
20
View file @
4a25a2ba
...
@@ -40,7 +40,7 @@ if "bpy" in locals():
...
@@ -40,7 +40,7 @@ if "bpy" in locals():
import
bpy
import
bpy
from
bpy.props
import
StringProperty
,
IntProperty
from
bpy.props
import
StringProperty
,
IntProperty
,
FloatProperty
from
bpy_extras.io_utils
import
ExportHelper
,
ImportHelper
from
bpy_extras.io_utils
import
ExportHelper
,
ImportHelper
...
@@ -70,16 +70,16 @@ class ImportMDD(bpy.types.Operator, ImportHelper):
...
@@ -70,16 +70,16 @@ class ImportMDD(bpy.types.Operator, ImportHelper):
@classmethod
@classmethod
def
poll
(
cls
,
context
):
def
poll
(
cls
,
context
):
ob
=
context
.
active_object
obj
=
context
.
active_object
return
(
ob
and
ob
.
type
==
'
MESH
'
)
return
(
obj
and
obj
.
type
==
'
MESH
'
)
def
execute
(
self
,
context
):
# initialize from scene if unset
def
invoke
(
self
,
context
,
event
):
scene
=
context
.
scene
scene
=
context
.
scene
if
not
self
.
frame_start
:
self
.
frame_start
=
scene
.
frame_start
self
.
frame_start
=
scene
.
frame_current
return
super
().
invoke
(
context
,
event
)
def
execute
(
self
,
context
):
keywords
=
self
.
as_keywords
(
ignore
=
(
"
filter_glob
"
,))
keywords
=
self
.
as_keywords
(
ignore
=
(
"
filter_glob
"
,))
from
.
import
import_mdd
from
.
import
import_mdd
...
@@ -98,16 +98,16 @@ class ExportMDD(bpy.types.Operator, ExportHelper):
...
@@ -98,16 +98,16 @@ class ExportMDD(bpy.types.Operator, ExportHelper):
minframe
=
1
minframe
=
1
maxframe
=
300000
maxframe
=
300000
minfps
=
1
minfps
=
1
.0
maxfps
=
120
maxfps
=
120
.0
# List of operator properties, the attributes will be assigned
# List of operator properties, the attributes will be assigned
# to the class instance from the operator settings before calling.
# to the class instance from the operator settings before calling.
fps
=
In
tProperty
(
fps
=
Floa
tProperty
(
name
=
"
Frames Per Second
"
,
name
=
"
Frames Per Second
"
,
description
=
"
Number of frames/second
"
,
description
=
"
Number of frames/second
"
,
min
=
minfps
,
max
=
maxfps
,
min
=
minfps
,
max
=
maxfps
,
default
=
25
,
default
=
25
.0
,
)
)
frame_start
=
IntProperty
(
frame_start
=
IntProperty
(
name
=
"
Start Frame
"
,
name
=
"
Start Frame
"
,
...
@@ -127,16 +127,15 @@ class ExportMDD(bpy.types.Operator, ExportHelper):
...
@@ -127,16 +127,15 @@ class ExportMDD(bpy.types.Operator, ExportHelper):
obj
=
context
.
active_object
obj
=
context
.
active_object
return
(
obj
and
obj
.
type
==
'
MESH
'
)
return
(
obj
and
obj
.
type
==
'
MESH
'
)
def
execute
(
self
,
context
):
def
invoke
(
self
,
context
,
event
):
# initialize from scene if unset
scene
=
context
.
scene
scene
=
context
.
scene
if
not
self
.
frame_start
:
self
.
frame_start
=
scene
.
frame_start
self
.
frame_start
=
scene
.
frame_start
self
.
frame_end
=
scene
.
frame_end
if
not
self
.
frame_end
:
self
.
fps
=
scene
.
render
.
fps
/
scene
.
render
.
fps_base
self
.
frame_end
=
scene
.
frame_end
if
not
self
.
fps
:
self
.
fps
=
scene
.
render
.
fps
return
super
().
invoke
(
context
,
event
)
def
execute
(
self
,
context
):
keywords
=
self
.
as_keywords
(
ignore
=
(
"
check_existing
"
,
"
filter_glob
"
))
keywords
=
self
.
as_keywords
(
ignore
=
(
"
check_existing
"
,
"
filter_glob
"
))
from
.
import
export_mdd
from
.
import
export_mdd
...
...
This diff is collapsed.
Click to expand it.
io_shape_mdd/export_mdd.py
+
4
−
19
View file @
4a25a2ba
...
@@ -51,7 +51,7 @@ def check_vertcount(mesh, vertcount):
...
@@ -51,7 +51,7 @@ def check_vertcount(mesh, vertcount):
raise
Exception
(
'
Error, number of verts has changed during animation, cannot export
'
)
raise
Exception
(
'
Error, number of verts has changed during animation, cannot export
'
)
def
save
(
operator
,
context
,
filepath
=
""
,
frame_start
=
1
,
frame_end
=
300
,
fps
=
25
):
def
save
(
operator
,
context
,
filepath
=
""
,
frame_start
=
1
,
frame_end
=
300
,
fps
=
25
.0
):
"""
"""
Blender.Window.WaitCursor(1)
Blender.Window.WaitCursor(1)
...
@@ -70,16 +70,18 @@ def save(operator, context, filepath="", frame_start=1, frame_end=300, fps=25):
...
@@ -70,16 +70,18 @@ def save(operator, context, filepath="", frame_start=1, frame_end=300, fps=25):
me
=
obj
.
to_mesh
(
scene
,
True
,
'
PREVIEW
'
)
me
=
obj
.
to_mesh
(
scene
,
True
,
'
PREVIEW
'
)
#Flip y and z
#Flip y and z
'''
mat_flip = mathutils.Matrix(((1.0, 0.0, 0.0, 0.0),
mat_flip = mathutils.Matrix(((1.0, 0.0, 0.0, 0.0),
(0.0, 0.0, 1.0, 0.0),
(0.0, 0.0, 1.0, 0.0),
(0.0, 1.0, 0.0, 0.0),
(0.0, 1.0, 0.0, 0.0),
(0.0, 0.0, 0.0, 1.0),
(0.0, 0.0, 0.0, 1.0),
))
))
'''
mat_flip
=
mathutils
.
Matrix
()
numverts
=
len
(
me
.
vertices
)
numverts
=
len
(
me
.
vertices
)
numframes
=
frame_end
-
frame_start
+
1
numframes
=
frame_end
-
frame_start
+
1
fps
=
float
(
fps
)
f
=
open
(
filepath
,
'
wb
'
)
# no Errors yet:Safe to create file
f
=
open
(
filepath
,
'
wb
'
)
# no Errors yet:Safe to create file
# Write the header
# Write the header
...
@@ -89,21 +91,11 @@ def save(operator, context, filepath="", frame_start=1, frame_end=300, fps=25):
...
@@ -89,21 +91,11 @@ def save(operator, context, filepath="", frame_start=1, frame_end=300, fps=25):
f
.
write
(
pack
(
"
>%df
"
%
(
numframes
),
*
[
frame
/
fps
for
frame
in
range
(
numframes
)]))
# seconds
f
.
write
(
pack
(
"
>%df
"
%
(
numframes
),
*
[
frame
/
fps
for
frame
in
range
(
numframes
)]))
# seconds
#rest frame needed to keep frames in sync
#rest frame needed to keep frames in sync
"""
Blender.Set(
'
curframe
'
, frame_start)
me_tmp.getFromObject(obj.name)
"""
check_vertcount
(
me
,
numverts
)
check_vertcount
(
me
,
numverts
)
me
.
transform
(
mat_flip
*
obj
.
matrix_world
)
me
.
transform
(
mat_flip
*
obj
.
matrix_world
)
f
.
write
(
pack
(
"
>%df
"
%
(
numverts
*
3
),
*
[
axis
for
v
in
me
.
vertices
for
axis
in
v
.
co
]))
f
.
write
(
pack
(
"
>%df
"
%
(
numverts
*
3
),
*
[
axis
for
v
in
me
.
vertices
for
axis
in
v
.
co
]))
for
frame
in
range
(
frame_start
,
frame_end
+
1
):
# in order to start at desired frame
for
frame
in
range
(
frame_start
,
frame_end
+
1
):
# in order to start at desired frame
"""
Blender.Set(
'
curframe
'
, frame)
me_tmp.getFromObject(obj.name)
"""
scene
.
frame_set
(
frame
)
scene
.
frame_set
(
frame
)
me
=
obj
.
to_mesh
(
scene
,
True
,
'
PREVIEW
'
)
me
=
obj
.
to_mesh
(
scene
,
True
,
'
PREVIEW
'
)
check_vertcount
(
me
,
numverts
)
check_vertcount
(
me
,
numverts
)
...
@@ -112,16 +104,9 @@ def save(operator, context, filepath="", frame_start=1, frame_end=300, fps=25):
...
@@ -112,16 +104,9 @@ def save(operator, context, filepath="", frame_start=1, frame_end=300, fps=25):
# Write the vertex data
# Write the vertex data
f
.
write
(
pack
(
"
>%df
"
%
(
numverts
*
3
),
*
[
axis
for
v
in
me
.
vertices
for
axis
in
v
.
co
]))
f
.
write
(
pack
(
"
>%df
"
%
(
numverts
*
3
),
*
[
axis
for
v
in
me
.
vertices
for
axis
in
v
.
co
]))
"""
me_tmp.vertices= None
"""
f
.
close
()
f
.
close
()
print
(
'
MDD Exported: %r frames:%d
\n
'
%
(
filepath
,
numframes
-
1
))
print
(
'
MDD Exported: %r frames:%d
\n
'
%
(
filepath
,
numframes
-
1
))
"""
Blender.Window.WaitCursor(0)
Blender.Set(
'
curframe
'
, orig_frame)
"""
scene
.
frame_set
(
orig_frame
)
scene
.
frame_set
(
orig_frame
)
return
{
'
FINISHED
'
}
return
{
'
FINISHED
'
}
This diff is collapsed.
Click to expand it.
io_shape_mdd/import_mdd.py
+
36
−
36
View file @
4a25a2ba
...
@@ -34,6 +34,41 @@
...
@@ -34,6 +34,41 @@
import
bpy
import
bpy
from
struct
import
unpack
from
struct
import
unpack
def
obj_update_frame
(
file
,
scene
,
obj
,
fr
,
step
):
# Insert new shape key
new_shapekey
=
obj
.
shape_key_add
()
new_shapekey
.
name
=
(
"
frame_%.4d
"
%
fr
)
obj
.
active_shape_key_index
=
len
(
obj
.
data
.
shape_keys
.
key_blocks
)
-
1
index
=
len
(
obj
.
data
.
shape_keys
.
key_blocks
)
-
1
obj
.
show_only_shape_key
=
True
verts
=
obj
.
data
.
shape_keys
.
key_blocks
[
len
(
obj
.
data
.
shape_keys
.
key_blocks
)
-
1
].
data
for
v
in
verts
:
# 12 is the size of 3 floats
v
.
co
[:]
=
unpack
(
'
>3f
'
,
file
.
read
(
12
))
# me.update()
obj
.
show_only_shape_key
=
False
# insert keyframes
shape_keys
=
obj
.
data
.
shape_keys
scene
.
frame_current
-=
step
obj
.
data
.
shape_keys
.
key_blocks
[
index
].
value
=
0.0
shape_keys
.
key_blocks
[
len
(
obj
.
data
.
shape_keys
.
key_blocks
)
-
1
].
keyframe_insert
(
"
value
"
)
scene
.
frame_current
+=
step
obj
.
data
.
shape_keys
.
key_blocks
[
index
].
value
=
1.0
shape_keys
.
key_blocks
[
len
(
obj
.
data
.
shape_keys
.
key_blocks
)
-
1
].
keyframe_insert
(
"
value
"
)
scene
.
frame_current
+=
step
obj
.
data
.
shape_keys
.
key_blocks
[
index
].
value
=
0.0
shape_keys
.
key_blocks
[
len
(
obj
.
data
.
shape_keys
.
key_blocks
)
-
1
].
keyframe_insert
(
"
value
"
)
obj
.
data
.
update
()
def
load
(
operator
,
context
,
filepath
,
frame_start
=
0
,
frame_step
=
1
):
def
load
(
operator
,
context
,
filepath
,
frame_start
=
0
,
frame_step
=
1
):
...
@@ -60,42 +95,7 @@ def load(operator, context, filepath, frame_start=0, frame_step=1):
...
@@ -60,42 +95,7 @@ def load(operator, context, filepath, frame_start=0, frame_step=1):
scene
.
frame_current
=
frame_start
scene
.
frame_current
=
frame_start
def
UpdateMesh
(
ob
,
fr
,
step
):
# Insert new shape key
new_shapekey
=
obj
.
shape_key_add
()
new_shapekey
.
name
=
(
"
frame_%.4d
"
%
fr
)
obj
.
active_shape_key_index
=
len
(
obj
.
data
.
shape_keys
.
key_blocks
)
-
1
index
=
len
(
obj
.
data
.
shape_keys
.
key_blocks
)
-
1
obj
.
show_only_shape_key
=
True
verts
=
obj
.
data
.
shape_keys
.
key_blocks
[
len
(
obj
.
data
.
shape_keys
.
key_blocks
)
-
1
].
data
for
v
in
verts
:
# 12 is the size of 3 floats
v
.
co
[:]
=
unpack
(
'
>3f
'
,
file
.
read
(
12
))
# me.update()
obj
.
show_only_shape_key
=
False
# insert keyframes
shape_keys
=
obj
.
data
.
shape_keys
scene
.
frame_current
-=
step
obj
.
data
.
shape_keys
.
key_blocks
[
index
].
value
=
0.0
shape_keys
.
key_blocks
[
len
(
obj
.
data
.
shape_keys
.
key_blocks
)
-
1
].
keyframe_insert
(
"
value
"
)
scene
.
frame_current
+=
step
obj
.
data
.
shape_keys
.
key_blocks
[
index
].
value
=
1.0
shape_keys
.
key_blocks
[
len
(
obj
.
data
.
shape_keys
.
key_blocks
)
-
1
].
keyframe_insert
(
"
value
"
)
scene
.
frame_current
+=
step
obj
.
data
.
shape_keys
.
key_blocks
[
index
].
value
=
0.0
shape_keys
.
key_blocks
[
len
(
obj
.
data
.
shape_keys
.
key_blocks
)
-
1
].
keyframe_insert
(
"
value
"
)
obj
.
data
.
update
()
for
i
in
range
(
frames
):
for
i
in
range
(
frames
):
UpdateMesh
(
obj
,
i
,
frame_step
)
obj_update_frame
(
file
,
scene
,
obj
,
i
,
frame_step
)
return
{
'
FINISHED
'
}
return
{
'
FINISHED
'
}
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