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
4eb42874
Commit
4eb42874
authored
Jan 16, 2019
by
Jan Möbius
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed some texture related issues (They were loaded but not displayed)
parent
48cbdd97
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
128 additions
and
82 deletions
+128
-82
FileOBJ.cc
FileOBJ.cc
+26
-24
OBJImporter.cc
OBJImporter.cc
+74
-50
OBJImporter.hh
OBJImporter.hh
+28
-8
No files found.
FileOBJ.cc
View file @
4eb42874
...
...
@@ -411,13 +411,14 @@ void FileOBJPlugin::createAllGroupObjects(OBJImporter& _importer) {
if
(
OpenFlipper
::
Options
::
gui
()
&&
loadOptions_
!=
0
)
{
if
(
!
loadFaceColor_
->
isChecked
())
_importer
.
objec
tOption
s
()[
i
]
|=
OBJImporter
::
FORCE_NOCOLOR
;
_importer
.
se
tOption
(
OBJImporter
::
FORCE_NOCOLOR
,
i
)
;
if
(
!
loadNormals_
->
isChecked
())
_importer
.
objec
tOption
s
()[
i
]
|=
OBJImporter
::
FORCE_NONORMALS
;
_importer
.
se
tOption
(
OBJImporter
::
FORCE_NONORMALS
,
i
)
;
if
(
!
loadTexCoords_
->
isChecked
()
||
!
loadTextures_
->
isChecked
())
_importer
.
objectOptions
()[
i
]
|=
OBJImporter
::
FORCE_NOTEXTURES
;
_importer
.
setOption
(
OBJImporter
::
FORCE_NOTEXTURES
,
i
);
}
}
}
...
...
@@ -532,9 +533,9 @@ void FileOBJPlugin::addTextures(OBJImporter& _importer, int _objectID ){
QString
fullName
=
_importer
.
path
()
+
QDir
::
separator
()
+
options
.
join
(
" "
);
QFileInfo
info
(
fullName
);
if
(
info
.
exists
()
)
if
(
info
.
exists
()
)
{
emit
addMultiTexture
(
"OBJ Data"
,
info
.
baseName
().
trimmed
(),
fullName
,
object
->
id
(),
textureId
);
else
{
}
else
{
emit
log
(
LOGWARN
,
tr
(
"Unable to load texture image %1"
).
arg
(
QString
(
material
.
map_Kd
().
c_str
())
)
);
addMultiTexture
(
"OBJ Data"
,
"Unknown Texture image "
+
QString
::
number
(
textureId
),
"unknown.png"
,
object
->
id
(),
textureId
);
}
...
...
@@ -731,9 +732,12 @@ void FileOBJPlugin::readOBJFile(QByteArray& _bufferedFile, QString _filename, OB
Material
&
mat
=
_importer
.
materials
()[
matname
.
toStdString
()];
if
(
mat
.
has_Texture
()
){
//add object if not already there
_importer
.
useMaterial
(
matname
.
toStdString
()
);
}
}
}
else
if
(
mode
==
NONE
&&
keyWrd
==
QLatin1String
(
"v"
))
...
...
@@ -1096,7 +1100,7 @@ void FileOBJPlugin::readOBJFile(QByteArray& _bufferedFile, QString _filename, OB
// end
else
if
(
mode
==
CURVE
&&
keyWrd
==
QLatin1String
(
"end"
)){
if
(
_importer
.
isCurve
(
_importer
.
current
Object
()
)
){
if
(
_importer
.
isCurve
(
_importer
.
current
Group
()
)
){
// set up the spline curve
_importer
.
currentCurve
()
->
set_degree
(
_importer
.
degreeU
()
);
_importer
.
currentCurve
()
->
autocompute_knotvector
(
false
);
...
...
@@ -1224,7 +1228,7 @@ void FileOBJPlugin::readOBJFile(QByteArray& _bufferedFile, QString _filename, OB
// end
else
if
(
mode
==
SURFACE
&&
keyWrd
==
QLatin1String
(
"end"
)){
if
(
_importer
.
isSurface
(
_importer
.
current
Object
()
)
){
if
(
_importer
.
isSurface
(
_importer
.
current
Group
()
)
){
// remove first 4 entries since they are the first and last knot (for both direction)
cpIndices
.
erase
(
cpIndices
.
begin
());
...
...
@@ -1268,10 +1272,9 @@ void FileOBJPlugin::readOBJFile(QByteArray& _bufferedFile, QString _filename, OB
#endif
}
//checks, if an object with a specified type was added. if not, point cloud was read
bool
isType
=
faceCount
!=
0
;
#ifdef ENABLE_BSPLINECURVE_SUPPORT
isType
=
isType
||
curveCount
!=
0
;
#endif
...
...
@@ -1287,6 +1290,7 @@ void FileOBJPlugin::readOBJFile(QByteArray& _bufferedFile, QString _filename, OB
if
(
!
inGroup
)
_importer
.
setCurrentGroup
(
0
);
}
}
///check file types and read general info like vertices
...
...
@@ -1734,12 +1738,11 @@ void FileOBJPlugin::checkTypes(QByteArray& _bufferedFile, QString _filename, OBJ
for
(
unsigned
int
i
=
0
;
i
<
_importer
.
n_vertices
();
++
i
)
_importer
.
useVertex
(
i
);
}
else
{
unsigned
int
currentOptions
=
_importer
.
objectOptions
()[
_importer
.
currentObject
()];
// this is only a triangle mesh if the object is not a curve and not a surface
// also ignore if it is set to NONE
if
(
!
(
currentOptions
&
OBJImporter
::
CURVE
)
&&
!
(
currentOptions
&
OBJImporter
::
SURFACE
)
&&
(
currentOptions
!=
OBJImporter
::
NONE
)
)
if
(
!
(
_importer
.
isCurve
(
_importer
.
currentGroup
())
)
&&
!
(
_importer
.
isSurface
(
_importer
.
currentGroup
())
)
&&
(
_importer
.
isNone
(
_importer
.
currentGroup
()))
)
_importer
.
setObjectOptions
(
OBJImporter
::
TRIMESH
);
}
}
...
...
@@ -1854,7 +1857,7 @@ int FileOBJPlugin::loadObject(QString _filename) {
importer
.
addGroup
(
QFileInfo
(
_filename
).
fileName
()
);
//check if something was found
if
(
importer
.
o
bject
Options
()
.
empty
()
&&
objIDs
.
empty
()
){
if
(
importer
.
n
oOptions
()
&&
objIDs
.
empty
()
){
forceTriangleMesh_
=
false
;
forcePolyMesh_
=
false
;
...
...
@@ -1862,7 +1865,7 @@ int FileOBJPlugin::loadObject(QString _filename) {
return
-
1
;
}
//then parse the obj
//then parse the obj
readOBJFile
(
bufferedFile
,
_filename
,
importer
);
// finish up
...
...
@@ -1877,8 +1880,6 @@ int FileOBJPlugin::loadObject(QString _filename) {
pluginExists
(
"datacontrol"
,
dataControlExists
);
if
(
dataControlExists
){
std
::
vector
<
OBJImporter
::
ObjectOptions
>
options
=
importer
.
objectOptions
();
#if defined ENABLE_BSPLINECURVE_SUPPORT || defined ENABLE_BSPLINESURFACE_SUPPORT
std
::
map
<
int
,
QString
>
groupNames
;
#endif
...
...
@@ -1894,14 +1895,14 @@ int FileOBJPlugin::loadObject(QString _filename) {
std
::
vector
<
int
>
surfaceIds
;
int
lastSurfaceParent
=
-
2
;
#endif
for
(
unsigned
int
i
=
0
;
i
<
importer
.
object
Count
();
i
++
)
{
for
(
unsigned
int
i
=
0
;
i
<
importer
.
group
Count
();
i
++
)
{
// skip the object if it has no option
// this can happen if the object only included other objects
if
(
options
[
i
]
!=
NONE
)
{
if
(
!
importer
.
isNone
(
i
)
)
{
BaseObject
*
obj
=
importer
.
object
(
i
);
if
(
obj
)
{
#ifdef ENABLE_BSPLINECURVE_SUPPORT
if
(
options
[
i
]
&
OBJImporter
::
CURVE
)
{
if
(
importer
.
isCurve
(
i
)
)
{
// store the parent group name for later grouping
groupNames
[
obj
->
id
()]
=
importer
.
groupName
(
importer
.
getCurveParentId
(
i
));
...
...
@@ -1938,7 +1939,7 @@ int FileOBJPlugin::loadObject(QString _filename) {
#endif
#ifdef ENABLE_BSPLINESURFACE_SUPPORT
if
(
options
[
i
]
&
OBJImporter
::
SURFACE
)
{
if
(
importer
.
isSurface
(
i
)
)
{
// store the parent group name for later grouping
groupNames
[
obj
->
id
()]
=
importer
.
groupName
(
importer
.
getSurfaceParentId
(
i
));
...
...
@@ -1972,7 +1973,7 @@ int FileOBJPlugin::loadObject(QString _filename) {
}
#endif
if
(
(
options
[
i
]
&
OBJImporter
::
TRIMESH
)
||
(
options
[
i
]
&
OBJImporter
::
POLYMESH
)
)
if
(
(
importer
.
isTriangleMesh
(
i
)
||
importer
.
isPolyMesh
(
i
)
)
)
objIDs
.
push_back
(
obj
->
id
()
);
}
else
{
std
::
cerr
<<
"Object is NULL!"
<<
std
::
endl
;
...
...
@@ -2016,8 +2017,8 @@ int FileOBJPlugin::loadObject(QString _filename) {
}
}
//check all new objects
for
(
unsigned
int
i
=
0
;
i
<
importer
.
object
Count
();
i
++
){
//check all new objects
which are created for each group
for
(
unsigned
int
i
=
0
;
i
<
importer
.
group
Count
();
i
++
){
BaseObject
*
object
=
importer
.
object
(
i
);
if
(
object
==
NULL
)
continue
;
...
...
@@ -2059,6 +2060,7 @@ int FileOBJPlugin::loadObject(QString _filename) {
}
#endif
//textures
if
(
importer
.
hasTexture
(
i
)
&&
!
importer
.
hasOption
(
i
,
OBJImporter
::
FORCE_NOTEXTURES
)
){
...
...
OBJImporter.cc
View file @
4eb42874
...
...
@@ -156,7 +156,7 @@ void OBJImporter::setObject(BaseObject* _object, int _groupId) {
//-----------------------------------------------------------------------------
/// get id of the active object
int
OBJImporter
::
current
Object
(){
int
OBJImporter
::
current
Group
(){
return
currentGroup_
;
}
...
...
@@ -259,7 +259,7 @@ void OBJImporter::addUsedVertices(int _groupId) {
/// set vertex texture coordinate
void
OBJImporter
::
setVertexTexCoord
(
VertexHandle
_vh
,
int
_texCoordID
){
if
(
isTriangleMesh
(
current
Object
()
)
){
if
(
isTriangleMesh
(
current
Group
()
)
){
//handle triangle meshes
if
(
!
currentTriMesh
()
)
return
;
...
...
@@ -278,7 +278,7 @@ void OBJImporter::setVertexTexCoord(VertexHandle _vh, int _texCoordID){
std
::
cerr
<<
"Error: TexCoord ID too large"
<<
std
::
endl
;
}
}
else
if
(
isPolyMesh
(
current
Object
()
)
){
}
else
if
(
isPolyMesh
(
current
Group
()
)
){
//handle poly meshes
if
(
!
currentPolyMesh
()
)
return
;
...
...
@@ -304,7 +304,7 @@ void OBJImporter::setVertexTexCoord(VertexHandle _vh, int _texCoordID){
/// set vertex normal
void
OBJImporter
::
setNormal
(
int
_index
,
int
_normalID
){
if
(
isTriangleMesh
(
current
Object
()
)
){
if
(
isTriangleMesh
(
current
Group
()
)
){
//handle triangle meshes
if
(
!
currentTriMesh
()
)
return
;
...
...
@@ -326,7 +326,7 @@ void OBJImporter::setNormal(int _index, int _normalID){
std
::
cerr
<<
"Error: normal ID too large"
<<
std
::
endl
;
}
}
else
if
(
isPolyMesh
(
current
Object
()
)
){
}
else
if
(
isPolyMesh
(
current
Group
()
)
){
//handle poly meshes
if
(
!
currentPolyMesh
()
)
return
;
...
...
@@ -355,7 +355,7 @@ void OBJImporter::setNormal(int _index, int _normalID){
bool
OBJImporter
::
addFace
(
const
VHandles
&
_indices
,
OpenMesh
::
FaceHandle
&
_outFH
,
std
::
vector
<
TriMesh
::
VertexHandle
>
&
_outTriVertices
,
std
::
vector
<
PolyMesh
::
VertexHandle
>
&
_outPolyVertices
)
{
if
(
isTriangleMesh
(
current
Object
()
)
){
if
(
isTriangleMesh
(
current
Group
()
)
){
//handle triangle meshes
if
(
!
currentTriMesh
()
)
return
false
;
...
...
@@ -409,7 +409,7 @@ bool OBJImporter::addFace(const VHandles& _indices, OpenMesh::FaceHandle &_outFH
_outFH
=
fh
;
return
true
;
}
else
if
(
isPolyMesh
(
current
Object
()
)
){
}
else
if
(
isPolyMesh
(
current
Group
()
)
){
//handle poly meshes
if
(
!
currentPolyMesh
()
)
return
false
;
...
...
@@ -498,7 +498,7 @@ void OBJImporter::addFace(const VHandles& _indices, const std::vector<int>& _fac
if
(
!
addFace
(
_indices
,
fh
,
triVertices
,
polyVertices
)
||
!
fh
.
is_valid
())
return
;
if
(
isTriangleMesh
(
current
Object
())
)
if
(
isTriangleMesh
(
current
Group
())
)
{
//perhaps request texCoords for the mesh
if
(
!
currentTriMesh
()
->
has_halfedge_texcoords2D
()
)
...
...
@@ -526,7 +526,7 @@ void OBJImporter::addFace(const VHandles& _indices, const std::vector<int>& _fac
}
else
std
::
cerr
<<
"Error: cannot set texture coordinates. undefined index."
<<
std
::
endl
;
}
}
else
if
(
isPolyMesh
(
current
Object
()))
}
else
if
(
isPolyMesh
(
current
Group
()))
{
addedFacePoly_
=
fh
;
...
...
@@ -566,7 +566,7 @@ void OBJImporter::addFace(const VHandles& _indices, const std::vector<int>& _fac
void
OBJImporter
::
addMaterial
(
std
::
string
_materialName
){
if
(
isTriangleMesh
(
current
Object
()
)
){
if
(
isTriangleMesh
(
current
Group
()
)
){
//handle triangle meshes
if
(
!
currentTriMesh
()
)
return
;
...
...
@@ -579,11 +579,11 @@ void OBJImporter::addMaterial(std::string _materialName){
//get textureIndex Property
OpenMesh
::
FPropHandleT
<
int
>
indexProperty
;
BaseObjectData
*
triMeshObj
=
PluginFunctions
::
baseObjectData
(
object
(
current
Object
()));
BaseObjectData
*
triMeshObj
=
PluginFunctions
::
baseObjectData
(
object
(
current
Group
()));
if
(
hasTexture
(
current
Object
()
)
){
if
(
hasTexture
(
current
Group
()
)
){
bool
textureAllowed
=
!
(
objectOptions_
[
current
Object
()
]
&
FORCE_NOTEXTURES
);
bool
textureAllowed
=
!
(
objectOptions_
[
current
Group
()
]
&
FORCE_NOTEXTURES
);
if
(
textureAllowed
){
...
...
@@ -632,7 +632,7 @@ void OBJImporter::addMaterial(std::string _materialName){
for
(
unsigned
int
i
=
0
;
i
<
addedFacesTri_
[
currentGroup_
].
size
();
i
++
){
if
(
mat
.
has_Kd
()
)
{
bool
colorAllowed
=
!
(
objectOptions_
[
current
Object
()
]
&
FORCE_NOCOLOR
);
bool
colorAllowed
=
!
(
objectOptions_
[
current
Group
()
]
&
FORCE_NOCOLOR
);
if
(
currentTriMesh
()
->
has_face_colors
()
&&
colorAllowed
){
...
...
@@ -645,28 +645,28 @@ void OBJImporter::addMaterial(std::string _materialName){
color
[
3
]
=
1.0
;
}
currentTriMesh
()
->
set_color
(
addedFacesTri_
[
currentGroup_
][
i
],
color
);
objectOptions_
[
current
Object
()
]
|=
FACECOLOR
;
objectOptions_
[
current
Group
()
]
|=
FACECOLOR
;
}
}
bool
textureAllowed
=
!
(
objectOptions_
[
current
Object
()
]
&
FORCE_NOTEXTURES
);
bool
textureAllowed
=
!
(
objectOptions_
[
current
Group
()
]
&
FORCE_NOTEXTURES
);
// Set the texture index in the face index property
if
(
mat
.
has_Texture
()
)
{
if
(
hasTexture
(
current
Object
()
)
&&
textureAllowed
)
if
(
hasTexture
(
current
Group
()
)
&&
textureAllowed
)
currentTriMesh
()
->
property
(
indexProperty
,
addedFacesTri_
[
currentGroup_
][
i
])
=
mat
.
map_Kd_index
();
}
else
{
// If we don't have the info, set it to no texture
if
(
hasTexture
(
current
Object
()
)
&&
textureAllowed
)
if
(
hasTexture
(
current
Group
()
)
&&
textureAllowed
)
currentTriMesh
()
->
property
(
indexProperty
,
addedFacesTri_
[
currentGroup_
][
i
])
=
0
;
}
}
}
}
else
if
(
isPolyMesh
(
current
Object
()
)
){
}
else
if
(
isPolyMesh
(
current
Group
()
)
){
//handle poly meshes
if
(
!
currentPolyMesh
()
)
return
;
...
...
@@ -678,11 +678,11 @@ void OBJImporter::addMaterial(std::string _materialName){
//get textureIndex Property
OpenMesh
::
FPropHandleT
<
int
>
indexProperty
;
BaseObjectData
*
polyMeshObj
=
PluginFunctions
::
baseObjectData
(
object
(
current
Object
()));
BaseObjectData
*
polyMeshObj
=
PluginFunctions
::
baseObjectData
(
object
(
current
Group
()));
if
(
hasTexture
(
current
Object
()
)
){
if
(
hasTexture
(
current
Group
()
)
){
bool
textureAllowed
=
!
(
objectOptions_
[
current
Object
()
]
&
FORCE_NOTEXTURES
);
bool
textureAllowed
=
!
(
objectOptions_
[
current
Group
()
]
&
FORCE_NOTEXTURES
);
if
(
textureAllowed
){
...
...
@@ -692,7 +692,7 @@ void OBJImporter::addMaterial(std::string _materialName){
}
if
(
mat
.
has_Kd
()
)
{
bool
colorAllowed
=
!
(
objectOptions_
[
current
Object
()
]
&
FORCE_NOCOLOR
);
bool
colorAllowed
=
!
(
objectOptions_
[
current
Group
()
]
&
FORCE_NOCOLOR
);
if
(
currentPolyMesh
()
->
has_face_colors
()
&&
colorAllowed
&&
addedFacePoly_
.
is_valid
()
){
...
...
@@ -707,7 +707,7 @@ void OBJImporter::addMaterial(std::string _materialName){
currentPolyMesh
()
->
set_color
(
addedFacePoly_
,
color
);
polyMeshObj
->
materialNode
()
->
set_diffuse_color
(
color
);
objectOptions_
[
current
Object
()
]
|=
FACECOLOR
;
objectOptions_
[
current
Group
()
]
|=
FACECOLOR
;
}
}
...
...
@@ -741,17 +741,17 @@ void OBJImporter::addMaterial(std::string _materialName){
polyMeshObj
->
materialNode
()
->
set_refractive
(
mat
.
isRefractive
());
}
bool
textureAllowed
=
!
(
objectOptions_
[
current
Object
()
]
&
FORCE_NOTEXTURES
);
bool
textureAllowed
=
!
(
objectOptions_
[
current
Group
()
]
&
FORCE_NOTEXTURES
);
// Set the texture index in the face index property
if
(
mat
.
has_Texture
()
)
{
if
(
hasTexture
(
current
Object
()
)
&&
textureAllowed
&&
addedFacePoly_
.
is_valid
())
if
(
hasTexture
(
current
Group
()
)
&&
textureAllowed
&&
addedFacePoly_
.
is_valid
())
currentPolyMesh
()
->
property
(
indexProperty
,
addedFacePoly_
)
=
mat
.
map_Kd_index
();
}
else
{
// If we don't have the info, set it to no texture
if
(
hasTexture
(
current
Object
()
)
&&
textureAllowed
&&
addedFacePoly_
.
is_valid
())
if
(
hasTexture
(
current
Group
()
)
&&
textureAllowed
&&
addedFacePoly_
.
is_valid
())
currentPolyMesh
()
->
property
(
indexProperty
,
addedFacePoly_
)
=
0
;
}
}
...
...
@@ -763,14 +763,22 @@ void OBJImporter::addMaterial(std::string _materialName){
// force all meshes to be opened with specific type
void
OBJImporter
::
forceMeshType
(
ObjectOptions
_meshType
){
for
(
unsigned
int
i
=
0
;
i
<
objectOptions_
.
size
();
i
++
){
bool
isMesh
=
(
objectOptions_
[
i
]
&
TRIMESH
)
|
(
objectOptions_
[
i
]
&
POLYMESH
);
bool
correctType
=
objectOptions_
[
i
]
&
_meshType
;
if
(
isMesh
&&
!
correctType
)
objectOptions_
[
i
]
=
_meshType
;
}
bool
isMesh
=
(
objectOptions_
[
currentGroup_
]
&
TRIMESH
)
|
(
objectOptions_
[
currentGroup_
]
&
POLYMESH
);
bool
correctType
=
objectOptions_
[
currentGroup_
]
&
_meshType
;
if
(
isMesh
&&
!
correctType
)
{
ObjectOptions
options
=
objectOptions_
[
currentGroup_
];
options
&=
~
(
1
<<
1
);
options
&=
~
(
1
<<
2
);
options
&=
~
(
1
<<
3
);
options
|=
_meshType
;
objectOptions_
[
currentGroup_
]
=
options
;
}
}
//-----------------------------------------------------------------------------
...
...
@@ -797,6 +805,10 @@ bool OBJImporter::isSurface(int _objectID){
return
objectOptions_
[
_objectID
]
&
SURFACE
;
}
bool
OBJImporter
::
isNone
(
int
_objectID
)
{
return
objectOptions_
[
_objectID
]
==
NONE
;
}
//-----------------------------------------------------------------------------
bool
OBJImporter
::
hasNormals
(
int
_objectID
){
...
...
@@ -819,6 +831,17 @@ bool OBJImporter::hasTextureCoords(int _objectID){
//-----------------------------------------------------------------------------
void
OBJImporter
::
setOption
(
ObjectOptionsE
_option
)
{
objectOptions_
[
currentGroup_
]
|=
_option
;
}
/// Set Object Option
void
OBJImporter
::
setOption
(
ObjectOptionsE
_option
,
int
_groupId
)
{
objectOptions_
[
_groupId
]
|=
_option
;
}
//-----------------------------------------------------------------------------
unsigned
int
OBJImporter
::
n_vertices
(){
return
vertices_
.
size
();
}
...
...
@@ -837,24 +860,24 @@ unsigned int OBJImporter::n_texCoords(){
//-----------------------------------------------------------------------------
unsigned
int
OBJImporter
::
object
Count
(){
unsigned
int
OBJImporter
::
group
Count
(){
return
groupNames_
.
size
();
}
//-----------------------------------------------------------------------------
BaseObject
*
OBJImporter
::
object
(
int
_
objectID
)
{
BaseObject
*
OBJImporter
::
object
(
int
_
groupId
)
{
if
(
object
Count
()
==
0
||
object
Count
()
<=
(
unsigned
int
)
_
objectID
)
if
(
group
Count
()
==
0
||
group
Count
()
<=
(
unsigned
int
)
_
groupId
)
return
NULL
;
if
(
triMeshes_
[
_
objectID
]
!=
NULL
)
return
triMeshes_
[
_
objectID
];
else
if
(
polyMeshes_
[
_
objectID
]
!=
NULL
)
return
polyMeshes_
[
_
objectID
];
if
(
triMeshes_
[
_
groupId
]
!=
NULL
)
return
triMeshes_
[
_
groupId
];
else
if
(
polyMeshes_
[
_
groupId
]
!=
NULL
)
return
polyMeshes_
[
_
groupId
];
#ifdef ENABLE_BSPLINECURVE_SUPPORT
else
if
(
bSplineCurves_
[
_
objectID
]
!=
NULL
)
return
bSplineCurves_
[
_
objectID
];
else
if
(
bSplineCurves_
[
_
groupId
]
!=
NULL
)
return
bSplineCurves_
[
_
groupId
];
#endif
#ifdef ENABLE_BSPLINESURFACE_SUPPORT
else
if
(
bSplineSurfaces_
[
_
objectID
]
!=
NULL
)
return
bSplineSurfaces_
[
_
objectID
];
else
if
(
bSplineSurfaces_
[
_
groupId
]
!=
NULL
)
return
bSplineSurfaces_
[
_
groupId
];
#endif
return
NULL
;
...
...
@@ -891,8 +914,8 @@ void OBJImporter::setObjectOptions(ObjectOptions _options) {
//-----------------------------------------------------------------------------
std
::
vector
<
OBJImporter
::
ObjectOptions
>&
OBJImporter
::
object
Options
(){
return
objectOptions_
;
bool
OBJImporter
::
no
Options
()
{
return
objectOptions_
.
empty
()
;
}
//-----------------------------------------------------------------------------
...
...
@@ -993,7 +1016,7 @@ void OBJImporter::finish() {
// and add them as new isolated face
if
(
invalidFaces_
[
currentGroup_
].
empty
())
return
;
if
(
isTriangleMesh
(
current
Object
()))
{
if
(
isTriangleMesh
(
current
Group
()))
{
// Handle triangle meshes
if
(
!
currentTriMesh
()
)
return
;
...
...
@@ -1157,17 +1180,18 @@ const std::vector<std::string> OBJImporter::usedMaterials(unsigned int _objectID
void
OBJImporter
::
useMaterial
(
std
::
string
_materialName
){
while
(
(
int
)
usedMaterials_
.
size
()
-
1
<
current
Object
()
)
while
(
(
int
)
usedMaterials_
.
size
()
-
1
<
current
Group
()
)
usedMaterials_
.
push_back
(
std
::
vector
<
std
::
string
>
()
);
//check that it is not added already
for
(
unsigned
int
i
=
0
;
i
<
usedMaterials_
[
current
Object
()
].
size
();
i
++
)
if
(
usedMaterials_
[
current
Object
()
][
i
]
==
_materialName
)
for
(
unsigned
int
i
=
0
;
i
<
usedMaterials_
[
current
Group
()
].
size
();
i
++
)
if
(
usedMaterials_
[
current
Group
()
][
i
]
==
_materialName
)
return
;
usedMaterials_
[
current
Object
()
].
push_back
(
_materialName
);
usedMaterials_
[
current
Group
()
].
push_back
(
_materialName
);
objectOptions_
[
currentObject
()
]
|=
TEXTURE
;
objectOptions_
[
currentGroup
()
]
|=
TEXTURE
;
}
///used vertices
...
...
OBJImporter.hh
View file @
4eb42874
...
...
@@ -134,8 +134,15 @@ class OBJImporter
/// add an object
void
setObject
(
BaseObject
*
_object
,
int
_groupId
);
/// get id of the active object
int
currentObject
();
/**\brief Get the id of the current group
*
* OBJ files can contain groups which are handled inside OpenFlipper as separate Objects.
* When loading a file, the importer has to keep track of the current group and store a state
* for each group with its properties (materials) )
*
* @return Id of the current group
*/
int
currentGroup
();
/// get a pointer to the active polyMesh
PolyMesh
*
currentPolyMesh
();
...
...
@@ -201,16 +208,29 @@ class OBJImporter
bool
isPolyMesh
(
int
_objectID
);
bool
isCurve
(
int
_objectID
);
bool
isSurface
(
int
_objectID
);
bool
isNone
(
int
_objectID
);
/// Set Object Option
void
setOption
(
ObjectOptionsE
_option
);
/// Set Object Option
void
setOption
(
ObjectOptionsE
_option
,
int
_groupId
);
/// Global Properties
unsigned
int
n_vertices
();
unsigned
int
n_normals
();
unsigned
int
n_texCoords
();
unsigned
int
objectCount
();
/** \brief Number of groups currently stored in the importer
*
* As OBJ files can contain several groups, we need to store information per group.
*
* @return Number of groups currently found by the importer
*/
unsigned
int
groupCount
();
/// return object
wi
th given
index
BaseObject
*
object
(
int
_
objectID
);
/// return object
for
th
e
given
group
BaseObject
*
object
(
int
_
groupId
);
/// return all loaded materials
MaterialList
&
materials
();
...
...
@@ -233,8 +253,8 @@ class OBJImporter
/// containing info about the meshType
void
setObjectOptions
(
ObjectOptions
_options
);
///
Object Options for all objects
std
::
vector
<
ObjectOptions
>&
object
Options
();
///
Return true if the importer has no options stored
bool
no
Options
();
/// check if object with given id has given option
bool
hasOption
(
unsigned
int
_id
,
ObjectOptions
_option
);
...
...
@@ -258,7 +278,7 @@ class OBJImporter
void
finish
();
private:
bool
vertexListIsManifold
(
const
std
::
vector
<
PolyMesh
::
VertexHandle
>&
_vertices
)
const
;
// general data
...
...
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