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
17696ce3
Commit
17696ce3
authored
14 years ago
by
Campbell Barton
Browse files
Options
Downloads
Patches
Plain Diff
bugfix [#25382] Loading 3ds file messed up when the file has hierachy
from Dominique Lorre with own modifications.
parent
79f0394d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
io_scene_3ds/import_3ds.py
+24
-3
24 additions, 3 deletions
io_scene_3ds/import_3ds.py
with
24 additions
and
3 deletions
io_scene_3ds/import_3ds.py
+
24
−
3
View file @
17696ce3
...
@@ -124,7 +124,7 @@ ED_KEY_OBJECT_NODE = 0xB002
...
@@ -124,7 +124,7 @@ ED_KEY_OBJECT_NODE = 0xB002
EK_OB_NODE_HEADER
=
0xB010
EK_OB_NODE_HEADER
=
0xB010
EK_OB_INSTANCE_NAME
=
0xB011
EK_OB_INSTANCE_NAME
=
0xB011
# EK_OB_PRESCALE = 0xB012
# EK_OB_PRESCALE = 0xB012
#
EK_OB_PIVOT = 0xB013
EK_OB_PIVOT
=
0xB013
# EK_OB_BOUNDBOX = 0xB014
# EK_OB_BOUNDBOX = 0xB014
# EK_OB_MORPH_SMOOTH = 0xB015
# EK_OB_MORPH_SMOOTH = 0xB015
EK_OB_POSITION_TRACK
=
0xB020
EK_OB_POSITION_TRACK
=
0xB020
...
@@ -143,8 +143,9 @@ ROOT_OBJECT = 0xFFFF
...
@@ -143,8 +143,9 @@ ROOT_OBJECT = 0xFFFF
global
scn
global
scn
scn
=
None
scn
=
None
global
object_dictionary
# dictionary for object hierarchy
object_dictionary
=
{}
object_dictionary
=
{}
object_matrix
=
{}
#the chunk class
#the chunk class
...
@@ -265,6 +266,7 @@ def process_next_chunk(file, previous_chunk, importedObjects, IMAGE_SEARCH):
...
@@ -265,6 +266,7 @@ def process_next_chunk(file, previous_chunk, importedObjects, IMAGE_SEARCH):
# only init once
# only init once
object_list
=
[]
# for hierarchy
object_list
=
[]
# for hierarchy
object_parent
=
[]
# index of parent in hierarchy, 0xFFFF = no parent
object_parent
=
[]
# index of parent in hierarchy, 0xFFFF = no parent
pivot_list
=
[]
# pivots with hierarchy handling
def
putContextMesh
(
myContextMesh_vertls
,
myContextMesh_facels
,
myContextMeshMaterials
):
def
putContextMesh
(
myContextMesh_vertls
,
myContextMesh_facels
,
myContextMeshMaterials
):
bmesh
=
bpy
.
data
.
meshes
.
new
(
contextObName
)
bmesh
=
bpy
.
data
.
meshes
.
new
(
contextObName
)
...
@@ -333,6 +335,7 @@ def process_next_chunk(file, previous_chunk, importedObjects, IMAGE_SEARCH):
...
@@ -333,6 +335,7 @@ def process_next_chunk(file, previous_chunk, importedObjects, IMAGE_SEARCH):
if
contextMatrix_rot
:
if
contextMatrix_rot
:
ob
.
matrix_local
=
contextMatrix_rot
ob
.
matrix_local
=
contextMatrix_rot
object_matrix
[
ob
]
=
contextMatrix_rot
.
copy
()
importedObjects
.
append
(
ob
)
importedObjects
.
append
(
ob
)
bmesh
.
update_tag
()
bmesh
.
update_tag
()
...
@@ -648,12 +651,20 @@ def process_next_chunk(file, previous_chunk, importedObjects, IMAGE_SEARCH):
...
@@ -648,12 +651,20 @@ def process_next_chunk(file, previous_chunk, importedObjects, IMAGE_SEARCH):
object_list
.
append
(
child
)
object_list
.
append
(
child
)
object_parent
.
append
(
hierarchy
)
object_parent
.
append
(
hierarchy
)
pivot_list
.
append
(
mathutils
.
Vector
((
0.0
,
0.0
,
0.0
)))
elif
new_chunk
.
ID
==
EK_OB_INSTANCE_NAME
:
elif
new_chunk
.
ID
==
EK_OB_INSTANCE_NAME
:
object_name
,
read_str_len
=
read_string
(
file
)
object_name
,
read_str_len
=
read_string
(
file
)
child
.
name
=
object_name
child
.
name
=
object_name
object_dictionary
[
object_name
]
=
child
object_dictionary
[
object_name
]
=
child
new_chunk
.
bytes_read
+=
read_str_len
new_chunk
.
bytes_read
+=
read_str_len
# print("new instance object:", object_name)
elif
new_chunk
.
ID
==
EK_OB_PIVOT
:
# translation
temp_data
=
file
.
read
(
STRUCT_SIZE_3FLOAT
)
pivot
=
struct
.
unpack
(
'
<3f
'
,
temp_data
)
new_chunk
.
bytes_read
+=
STRUCT_SIZE_3FLOAT
pivot_list
[
len
(
pivot_list
)
-
1
]
=
mathutils
.
Vector
(
pivot
)
elif
new_chunk
.
ID
==
EK_OB_POSITION_TRACK
:
# translation
elif
new_chunk
.
ID
==
EK_OB_POSITION_TRACK
:
# translation
new_chunk
.
bytes_read
+=
STRUCT_SIZE_UNSIGNED_SHORT
*
5
new_chunk
.
bytes_read
+=
STRUCT_SIZE_UNSIGNED_SHORT
*
5
...
@@ -740,6 +751,14 @@ def process_next_chunk(file, previous_chunk, importedObjects, IMAGE_SEARCH):
...
@@ -740,6 +751,14 @@ def process_next_chunk(file, previous_chunk, importedObjects, IMAGE_SEARCH):
ob
.
parent
=
None
ob
.
parent
=
None
else
:
else
:
ob
.
parent
=
object_list
[
parent
]
ob
.
parent
=
object_list
[
parent
]
# pivot_list[ind] += pivot_list[parent] # XXX, not sure this is correct, should parent space matrix be applied before combining?
# fix pivots
for
ind
,
ob
in
enumerate
(
object_list
):
if
ob
.
type
==
'
MESH
'
:
pivot
=
pivot_list
[
ind
]
pivot_matrix
=
object_matrix
.
get
(
ob
,
mathutils
.
Matrix
())
# unlikely to fail
pivot_matrix
=
mathutils
.
Matrix
.
Translation
(
-
pivot
*
pivot_matrix
.
to_3x3
())
ob
.
data
.
transform
(
pivot_matrix
)
def
load_3ds
(
filepath
,
context
,
IMPORT_CONSTRAIN_BOUNDS
=
10.0
,
IMAGE_SEARCH
=
True
,
APPLY_MATRIX
=
True
):
def
load_3ds
(
filepath
,
context
,
IMPORT_CONSTRAIN_BOUNDS
=
10.0
,
IMAGE_SEARCH
=
True
,
APPLY_MATRIX
=
True
):
...
@@ -800,6 +819,7 @@ def load_3ds(filepath, context, IMPORT_CONSTRAIN_BOUNDS=10.0, IMAGE_SEARCH=True,
...
@@ -800,6 +819,7 @@ def load_3ds(filepath, context, IMPORT_CONSTRAIN_BOUNDS=10.0, IMAGE_SEARCH=True,
# fixme, make unglobal, clear incase
# fixme, make unglobal, clear incase
object_dictionary
.
clear
()
object_dictionary
.
clear
()
object_matrix
.
clear
()
scn
=
context
.
scene
scn
=
context
.
scene
# scn = bpy.data.scenes.active
# scn = bpy.data.scenes.active
...
@@ -812,6 +832,7 @@ def load_3ds(filepath, context, IMPORT_CONSTRAIN_BOUNDS=10.0, IMAGE_SEARCH=True,
...
@@ -812,6 +832,7 @@ def load_3ds(filepath, context, IMPORT_CONSTRAIN_BOUNDS=10.0, IMAGE_SEARCH=True,
# fixme, make unglobal
# fixme, make unglobal
object_dictionary
.
clear
()
object_dictionary
.
clear
()
object_matrix
.
clear
()
# Link the objects into this scene.
# Link the objects into this scene.
# Layers = scn.Layers
# Layers = scn.Layers
...
...
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