Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenFlipper-Free
Plugin-FileOBJ
Commits
c42cd9f4
Commit
c42cd9f4
authored
Aug 12, 2020
by
Jan Möbius
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Workaround uninitialized colors
parent
b2b2721e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
7 deletions
+16
-7
FileOBJT_impl.hh
FileOBJT_impl.hh
+16
-7
No files found.
FileOBJT_impl.hh
View file @
c42cd9f4
...
...
@@ -144,6 +144,15 @@ Material& FileOBJPlugin::getMaterial(MeshT& _mesh, const OpenMesh::FaceHandle& _
OpenMesh
::
Vec4f
c
=
_mesh
.
color
(
_fh
);
// If one of the entries is out of range, assume uninitialized color and set to default
// Ugly hack to ensure that materials will only be generated if initialized
if
(
c
[
0
]
>
255.0
||
c
[
1
]
>
255.0
||
c
[
2
]
>
255.0
||
c
[
0
]
<
0.0
||
c
[
1
]
<
0.0
||
c
[
2
]
<
0.0
)
{
c
[
0
]
=
155.0
;
c
[
1
]
=
155.0
;
c
[
2
]
=
155.0
;
c
[
3
]
=
1.0
;
}
// First off, try to fetch texture index of current face/object...
if
(
!
textureIndexPropFetched_
)
{
emit
textureIndexPropertyName
(
_objId
,
textureIndexPropertyName_
);
...
...
@@ -321,8 +330,8 @@ bool FileOBJPlugin::writeMesh(std::ostream& _out, QString _filename, MeshT& _mes
// If mesh has halfedge tex coords, write them out instead of vertex texcoords
if
(
optionVertexTexCoords
&&
_mesh
.
has_halfedge_texcoords2D
())
{
int
count
=
1
;
for
(
f_it
=
_mesh
.
faces_begin
();
f_it
!=
_mesh
.
faces
_end
();
++
f_it
)
{
for
(
fh_it
=
_mesh
.
fh_iter
(
*
f_it
);
fh_it
.
is_valid
();
++
fh_it
)
{
for
(
auto
f_it
:
_mesh
.
faces
()
)
{
for
(
fh_it
=
_mesh
.
fh_iter
(
f_it
);
fh_it
.
is_valid
();
++
fh_it
)
{
typename
MeshT
::
TexCoord2D
t
=
_mesh
.
texcoord2D
(
*
fh_it
);
_out
<<
"vt "
<<
t
[
0
]
<<
" "
<<
t
[
1
]
<<
'\n'
;
vtMap
.
insert
(
std
::
pair
<
typename
MeshT
::
HalfedgeHandle
,
int
>
(
*
fh_it
,
count
));
...
...
@@ -333,19 +342,19 @@ bool FileOBJPlugin::writeMesh(std::ostream& _out, QString _filename, MeshT& _mes
Material
lastMat
;
// we do not want to write sep
e
rators if we only write vertex indices
// we do not want to write sep
a
rators if we only write vertex indices
bool
vertexOnly
=
!
(
optionVertexTexCoords
&&
_mesh
.
has_halfedge_texcoords2D
())
&&
!
(
optionVertexTexCoords
&&
!
_mesh
.
has_halfedge_texcoords2D
()
&&
_mesh
.
has_vertex_texcoords2D
())
&&
!
(
optionVertexNormals
);
for
(
f_it
=
_mesh
.
faces_begin
();
f_it
!=
_mesh
.
faces
_end
();
++
f_it
){
for
(
auto
f_it
:
_mesh
.
faces
()
){
if
(
useMaterial
&&
optionFaceColors
)
{
Material
&
material
=
getMaterial
(
_mesh
,
*
f_it
,
_objId
);
Material
&
material
=
getMaterial
(
_mesh
,
f_it
,
_objId
);
// If we are ina a new material block, specify in the file which material to use
if
(
lastMat
!=
material
)
{
if
(
lastMat
.
material_number
()
!=
material
.
material_number
()
)
{
_out
<<
"usemtl "
<<
material
<<
'\n'
;
lastMat
=
material
;
}
...
...
@@ -354,7 +363,7 @@ bool FileOBJPlugin::writeMesh(std::ostream& _out, QString _filename, MeshT& _mes
_out
<<
"f"
;
// Write out face information
for
(
fh_it
=
_mesh
.
fh_iter
(
*
f_it
);
fh_it
.
is_valid
();
++
fh_it
)
{
for
(
fh_it
=
_mesh
.
fh_iter
(
f_it
);
fh_it
.
is_valid
();
++
fh_it
)
{
// Write vertex index
idx
=
_mesh
.
to_vertex_handle
(
*
fh_it
).
idx
()
+
1
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment