Fixing problem with SU reader with no textures on faces

parent 07bf0828
......@@ -50,7 +50,7 @@ namespace ITAGeo
class ITA_GEO_API CModelBase
{
public:
inline CModelBase() {};
inline CModelBase() : m_pMaterialManager( nullptr ) {};
inline virtual ~CModelBase() {};
void SetName( const std::string& sName );
......
......@@ -110,22 +110,6 @@ bool CITAGeoHalfedgeSketchUpReader::read( const std::string& sFilePath, OpenMesh
const SUFaceRef& rFace( vrFaces[ n ] );
// Material / textures
SUMaterialRef rMaterial = SU_INVALID;
if( ( sur = SUFaceGetFrontMaterial( rFace, &rMaterial ) ) != SU_ERROR_NONE )
return sur;
std::string sMaterialName;
SUStringRef rMaterialName = SU_INVALID;
SUStringCreate( &rMaterialName );
if( SUMaterialGetName( rMaterial, &rMaterialName ) == SU_ERROR_NONE )
sMaterialName = SUStringToStdString( rMaterialName );
if( mTextures.find( sMaterialName ) == mTextures.end() )
mTextures[ sMaterialName ] = iTextureIndex++;
// Geometry
size_t nNumEdges = 0;
......@@ -164,8 +148,31 @@ bool CITAGeoHalfedgeSketchUpReader::read( const std::string& sFilePath, OpenMesh
vhVertices[ m ] = hVertex;
}
// Add face
CITAMesh::FaceHandle hFace = oBaseImporter.add_face( vhVertices );
oBaseImporter.set_face_texindex( hFace, mTextures[ sMaterialName ] );
// Material / textures
SUMaterialRef rMaterial = SU_INVALID;
sur = SUFaceGetFrontMaterial( rFace, &rMaterial );
if( sur != SU_ERROR_NO_DATA )
{
std::string sMaterialName;
SUStringRef rMaterialName = SU_INVALID;
SUStringCreate( &rMaterialName );
if( SUMaterialGetName( rMaterial, &rMaterialName ) == SU_ERROR_NONE )
sMaterialName = SUStringToStdString( rMaterialName );
if( mTextures.find( sMaterialName ) == mTextures.end() )
mTextures[ sMaterialName ] = iTextureIndex++;
oBaseImporter.set_face_texindex( hFace, mTextures[ sMaterialName ] );
}
}
// Add material information
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment