- added param 'texture_file' to the Options class, it specifies the path to the texture file
- added param 'material_file_extension' to the Options class, it specifies the material file suffix, default is ".mat" as it was before, we needed it becuase Blender expects ".mtl" - removed default and copy constructor and destructor as well as assignment operator, because these are not necessary here, see https://en.cppreference.com/w/cpp/language/rule_of_three (Thanks to Philipp Auersperg-Castell for the patch )
This commit is contained in:
@@ -8,6 +8,12 @@
|
|||||||
|
|
||||||
<tr valign=top><td><b>9.1</b> (?/?/?)</td><td>
|
<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>
|
<b>Build System</b>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Removed globbing for Core and Tools library include and source files</li>
|
<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
|
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:
|
public:
|
||||||
|
|
||||||
/// Default constructor
|
/// 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(const value_type _flgs) : flags_( _flgs)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
|
||||||
~Options()
|
|
||||||
{ }
|
|
||||||
|
|
||||||
/// Restore state after default constructor.
|
/// Restore state after default constructor.
|
||||||
void cleanup(void)
|
void cleanup(void)
|
||||||
{ flags_ = Default; }
|
{ flags_ = Default; }
|
||||||
@@ -154,17 +147,9 @@ public:
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
//@{
|
|
||||||
/// Copy options defined in _rhs.
|
|
||||||
|
|
||||||
Options& operator = ( const Options& _rhs )
|
|
||||||
{ flags_ = _rhs.flags_; return *this; }
|
|
||||||
|
|
||||||
Options& operator = ( const value_type _rhs )
|
Options& operator = ( const value_type _rhs )
|
||||||
{ flags_ = _rhs; return *this; }
|
{ flags_ = _rhs; return *this; }
|
||||||
|
|
||||||
//@}
|
|
||||||
|
|
||||||
|
|
||||||
//@{
|
//@{
|
||||||
/// Unset options defined in _rhs.
|
/// Unset options defined in _rhs.
|
||||||
|
|||||||
@@ -195,6 +195,9 @@ writeMaterial(std::ostream& _out, BaseExporter& _be, Options _opt) const
|
|||||||
_out << "illum 1" << '\n';
|
_out << "illum 1" << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_opt.texture_file != "") {
|
||||||
|
_out << "map_Kd " << _opt.texture_file << std::endl;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,8 +222,10 @@ write(std::ostream& _out, BaseExporter& _be, Options _opt, std::streamsize _prec
|
|||||||
_out.precision(_precision);
|
_out.precision(_precision);
|
||||||
|
|
||||||
// check exporter features
|
// check exporter features
|
||||||
if (!check( _be, _opt))
|
if (!check( _be, _opt)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// No binary mode for OBJ
|
// No binary mode for OBJ
|
||||||
if ( _opt.check(Options::Binary) ) {
|
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
|
//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 );
|
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';
|
_out << _be.n_faces() << " faces" << '\n';
|
||||||
|
|
||||||
// material file
|
// material file
|
||||||
if (useMatrial && _opt.check(Options::FaceColor) )
|
if ( (useMatrial && _opt.check(Options::FaceColor)) || _opt.texture_file != "")
|
||||||
_out << "mtllib " << objName_ << ".mat" << '\n';
|
_out << "mtllib " << objName_ << _opt.material_file_extension << '\n';
|
||||||
|
|
||||||
std::map<Vec2f,int> texMap;
|
std::map<Vec2f,int> texMap;
|
||||||
//collect Texturevertices from halfedges
|
//collect Texturevertices from halfedges
|
||||||
|
|||||||
Reference in New Issue
Block a user