Merge branch 'support_texture_files' into 'master'
- added param 'texture_file' to the Options class, it specifies the path to the texture file See merge request OpenMesh/OpenMesh!318
This commit is contained in:
@@ -32,7 +32,7 @@ echo "CPPCHECK Summary"
|
||||
echo "=============================================================================="
|
||||
echo -e "${NC}"
|
||||
|
||||
MAX_COUNT=23
|
||||
MAX_COUNT=33
|
||||
|
||||
if [ $COUNT -gt $MAX_COUNT ]; then
|
||||
echo -e ${WARNING}
|
||||
|
||||
@@ -8,6 +8,12 @@
|
||||
|
||||
<tr valign=top><td><b>9.1</b> (?/?/?)</td><td>
|
||||
|
||||
<b>IO</b>
|
||||
<ul>
|
||||
<li>OBJ writer: Added param 'texture_file' to the Options class, it specifies the path to the texture file (Thanks to Philipp Auersperg-Castell for the patch)</li>
|
||||
<li>OBJ writer: added param 'material_file_extension' to the Options class, it specifies the material file suffix, default is ".mat" as it was before. (Thanks to Philipp Auersperg-Castell for the patch)</li>
|
||||
</ul>
|
||||
|
||||
<b>Build System</b>
|
||||
<ul>
|
||||
<li>Removed globbing for Core and Tools library include and source files</li>
|
||||
|
||||
@@ -115,31 +115,24 @@ public:
|
||||
TexCoordST = 0x8000 ///< Write texture coordinates as ST instead of UV
|
||||
};
|
||||
|
||||
/// Texture filename. This will be written as
|
||||
/// map_Kd in the OBJ writer into the material file.
|
||||
std::string texture_file ;
|
||||
|
||||
/// Filename extension for material files when writing OBJs
|
||||
/// default is currently .mat
|
||||
std::string material_file_extension;
|
||||
|
||||
public:
|
||||
|
||||
/// Default constructor
|
||||
Options() : flags_( Default )
|
||||
Options() : texture_file(""), material_file_extension(".mat"), flags_( Default )
|
||||
{ }
|
||||
|
||||
|
||||
/// Copy constructor
|
||||
Options(const Options& _opt) : flags_(_opt.flags_)
|
||||
{ }
|
||||
|
||||
|
||||
/// Initializing constructor setting a single option
|
||||
Options(Flag _flg) : flags_( _flg)
|
||||
{ }
|
||||
|
||||
|
||||
/// Initializing constructor setting multiple options
|
||||
/// Initializing constructor setting multiple options
|
||||
Options(const value_type _flgs) : flags_( _flgs)
|
||||
{ }
|
||||
|
||||
|
||||
~Options()
|
||||
{ }
|
||||
|
||||
/// Restore state after default constructor.
|
||||
void cleanup(void)
|
||||
{ flags_ = Default; }
|
||||
@@ -154,17 +147,9 @@ public:
|
||||
public:
|
||||
|
||||
|
||||
//@{
|
||||
/// Copy options defined in _rhs.
|
||||
|
||||
Options& operator = ( const Options& _rhs )
|
||||
{ flags_ = _rhs.flags_; return *this; }
|
||||
|
||||
Options& operator = ( const value_type _rhs )
|
||||
{ flags_ = _rhs; return *this; }
|
||||
|
||||
//@}
|
||||
|
||||
|
||||
//@{
|
||||
/// Unset options defined in _rhs.
|
||||
|
||||
@@ -195,6 +195,9 @@ writeMaterial(std::ostream& _out, BaseExporter& _be, Options _opt) const
|
||||
_out << "illum 1" << '\n';
|
||||
}
|
||||
|
||||
if (_opt.texture_file != "") {
|
||||
_out << "map_Kd " << _opt.texture_file << std::endl;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -219,8 +222,10 @@ write(std::ostream& _out, BaseExporter& _be, Options _opt, std::streamsize _prec
|
||||
_out.precision(_precision);
|
||||
|
||||
// check exporter features
|
||||
if (!check( _be, _opt))
|
||||
return false;
|
||||
if (!check( _be, _opt)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// No binary mode for OBJ
|
||||
if ( _opt.check(Options::Binary) ) {
|
||||
@@ -240,9 +245,9 @@ write(std::ostream& _out, BaseExporter& _be, Options _opt, std::streamsize _prec
|
||||
}
|
||||
|
||||
//create material file if needed
|
||||
if ( _opt.check(Options::FaceColor) ){
|
||||
if ( _opt.check(Options::FaceColor) || _opt.texture_file != ""){
|
||||
|
||||
std::string matFile = path_ + objName_ + ".mat";
|
||||
std::string matFile = path_ + objName_ + _opt.material_file_extension;
|
||||
|
||||
std::fstream matStream(matFile.c_str(), std::ios_base::out );
|
||||
|
||||
@@ -262,8 +267,8 @@ write(std::ostream& _out, BaseExporter& _be, Options _opt, std::streamsize _prec
|
||||
_out << _be.n_faces() << " faces" << '\n';
|
||||
|
||||
// material file
|
||||
if (useMatrial && _opt.check(Options::FaceColor) )
|
||||
_out << "mtllib " << objName_ << ".mat" << '\n';
|
||||
if ( (useMatrial && _opt.check(Options::FaceColor)) || _opt.texture_file != "")
|
||||
_out << "mtllib " << objName_ << _opt.material_file_extension << '\n';
|
||||
|
||||
std::map<Vec2f,int> texMap;
|
||||
//collect Texturevertices from halfedges
|
||||
|
||||
Reference in New Issue
Block a user