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
d3811cba
Commit
d3811cba
authored
5 years ago
by
Campbell Barton
Browse files
Options
Downloads
Patches
Plain Diff
PLY Format: ngon support for import/export
D5865 by @cmbasnett with minor edits.
parent
6a382b66
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
io_mesh_ply/export_ply.py
+16
-13
16 additions, 13 deletions
io_mesh_ply/export_ply.py
io_mesh_ply/import_ply.py
+1
-7
1 addition, 7 deletions
io_mesh_ply/import_ply.py
with
17 additions
and
20 deletions
io_mesh_ply/export_ply.py
+
16
−
13
View file @
d3811cba
...
...
@@ -45,10 +45,6 @@ def save_mesh(
file
=
open
(
filepath
,
"
w
"
,
encoding
=
"
utf8
"
,
newline
=
"
\n
"
)
fw
=
file
.
write
# Be sure tessellated loop trianlges are available!
if
not
mesh
.
loop_triangles
and
mesh
.
polygons
:
mesh
.
calc_loop_triangles
()
has_uv
=
bool
(
mesh
.
uv_layers
)
has_vcol
=
bool
(
mesh
.
vertex_colors
)
...
...
@@ -85,9 +81,9 @@ def save_mesh(
ply_verts
=
[]
# list of dictionaries
# vdict = {} # (index, normal, uv) -> new index
vdict
=
[{}
for
i
in
range
(
len
(
mesh_verts
))]
ply_faces
=
[[]
for
f
in
range
(
len
(
mesh
.
loop_triangle
s
))]
ply_faces
=
[[]
for
f
in
range
(
len
(
mesh
.
polygon
s
))]
vert_count
=
0
for
i
,
f
in
enumerate
(
mesh
.
loop_triangle
s
):
for
i
,
f
in
enumerate
(
mesh
.
polygon
s
):
smooth
=
not
use_normals
or
f
.
use_smooth
if
not
smooth
:
...
...
@@ -95,9 +91,15 @@ def save_mesh(
normal_key
=
rvec3d
(
normal
)
if
has_uv
:
uv
=
[
active_uv_layer
[
l
].
uv
[:]
for
l
in
f
.
loops
]
uv
=
[
active_uv_layer
[
l
].
uv
[:]
for
l
in
range
(
f
.
loop_start
,
f
.
loop_start
+
f
.
loop_total
)
]
if
has_vcol
:
col
=
[
active_col_layer
[
l
].
color
[:]
for
l
in
f
.
loops
]
col
=
[
active_col_layer
[
l
].
color
[:]
for
l
in
range
(
f
.
loop_start
,
f
.
loop_start
+
f
.
loop_total
)
]
pf
=
ply_faces
[
i
]
for
j
,
vidx
in
enumerate
(
f
.
vertices
):
...
...
@@ -156,7 +158,7 @@ def save_mesh(
"
property uchar blue
\n
"
"
property uchar alpha
\n
"
)
fw
(
"
element face %d
\n
"
%
len
(
mesh
.
loop_triangle
s
))
fw
(
"
element face %d
\n
"
%
len
(
mesh
.
polygon
s
))
fw
(
"
property list uchar uint vertex_indices
\n
"
)
fw
(
"
end_header
\n
"
)
...
...
@@ -171,10 +173,11 @@ def save_mesh(
fw
(
"
\n
"
)
for
pf
in
ply_faces
:
if
len
(
pf
)
==
3
:
fw
(
"
3 %d %d %d
\n
"
%
tuple
(
pf
))
else
:
fw
(
"
4 %d %d %d %d
\n
"
%
tuple
(
pf
))
# fw(f"{len(pf)} {' '.join(str(x) for x in pf)}\n")
fw
(
"
%d
"
%
len
(
pf
))
for
v
in
pf
:
fw
(
"
%d
"
%
v
)
fw
(
"
\n
"
)
file
.
close
()
print
(
"
writing %r done
"
%
filepath
)
...
...
This diff is collapsed.
Click to expand it.
io_mesh_ply/import_ply.py
+
1
−
7
View file @
d3811cba
...
...
@@ -318,13 +318,7 @@ def load_ply_mesh(filepath, ply_name):
if
b
'
face
'
in
obj
:
for
f
in
obj
[
b
'
face
'
]:
ind
=
f
[
findex
]
len_ind
=
len
(
ind
)
if
len_ind
<=
4
:
add_face
(
verts
,
ind
,
uvindices
,
colindices
)
else
:
# Fan fill the face
for
j
in
range
(
len_ind
-
2
):
add_face
(
verts
,
(
ind
[
0
],
ind
[
j
+
1
],
ind
[
j
+
2
]),
uvindices
,
colindices
)
add_face
(
verts
,
ind
,
uvindices
,
colindices
)
if
b
'
tristrips
'
in
obj
:
for
t
in
obj
[
b
'
tristrips
'
]:
...
...
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