@@ -23,6 +23,7 @@ THE SOFTWARE.
2323*/
2424
2525//
26+ // version 1.4.0 : Modifed ParseTextureNameAndOption API
2627// version 1.3.1 : Make ParseTextureNameAndOption API public
2728// version 1.3.0 : Separate warning and error message(breaking API of LoadObj)
2829// version 1.2.3 : Added color space extension('-colorspace') to tex opts.
@@ -158,8 +159,8 @@ typedef struct {
158159 real_t bump_multiplier; // -bm (for bump maps only, default 1.0)
159160
160161 // extension
161- std::string colorspace; // Explicitly specify color space of stored value.
162- // Usually `sRGB` or `linear` (default empty).
162+ std::string colorspace; // Explicitly specify color space of stored texel
163+ // value. Usually `sRGB` or `linear` (default empty).
163164} texture_option_t ;
164165
165166typedef struct {
@@ -388,15 +389,14 @@ void LoadMtl(std::map<std::string, int> *material_map,
388389 std::string *warning, std::string *err);
389390
390391// /
391- // / Parse texture name and texture option for custom texture parameter through material::unknown_parameter
392+ // / Parse texture name and texture option for custom texture parameter through
393+ // / material::unknown_parameter
392394// /
393395// / @param[out] texname Parsed texture name
394396// / @param[out] texopt Parsed texopt
395397// / @param[in] linebuf Input string
396- // / @param[in] is_bump Is this texture bump/normal?
397398// /
398- bool ParseTextureNameAndOption (std::string *texname,
399- texture_option_t *texopt,
399+ bool ParseTextureNameAndOption (std::string *texname, texture_option_t *texopt,
400400 const char *linebuf);
401401} // namespace tinyobj
402402
@@ -903,9 +903,8 @@ static vertex_index_t parseRawTriple(const char **token) {
903903 return vi;
904904}
905905
906- bool ParseTextureNameAndOption (std::string *texname,
907- texture_option_t *texopt,
908- const char *linebuf) {
906+ bool ParseTextureNameAndOption (std::string *texname, texture_option_t *texopt,
907+ const char *linebuf) {
909908 // @todo { write more robust lexer and parser. }
910909 bool found_texname = false ;
911910 std::string texture_name;
@@ -1012,19 +1011,20 @@ static void InitTexOpt(texture_option_t *texopt, const bool is_bump) {
10121011}
10131012
10141013static void InitMaterial (material_t *material) {
1015- InitTexOpt (&material->ambient_texopt , /* is_bump */ false );
1016- InitTexOpt (&material->diffuse_texopt , /* is_bump */ false );
1017- InitTexOpt (&material->specular_texopt , /* is_bump */ false );
1014+ InitTexOpt (&material->ambient_texopt , /* is_bump */ false );
1015+ InitTexOpt (&material->diffuse_texopt , /* is_bump */ false );
1016+ InitTexOpt (&material->specular_texopt , /* is_bump */ false );
10181017 InitTexOpt (&material->specular_highlight_texopt , /* is_bump */ false );
1019- InitTexOpt (&material->bump_texopt , /* is_bump */ true );
1020- InitTexOpt (&material->displacement_texopt , /* is_bump */ false );
1021- InitTexOpt (&material->alpha_texopt , /* is_bump */ false );
1022- InitTexOpt (&material->reflection_texopt , /* is_bump */ false );
1023- InitTexOpt (&material->roughness_texopt , /* is_bump */ false );
1024- InitTexOpt (&material->metallic_texopt , /* is_bump */ false );
1025- InitTexOpt (&material->sheen_texopt , /* is_bump */ false );
1026- InitTexOpt (&material->emissive_texopt , /* is_bump */ false );
1027- InitTexOpt (&material->normal_texopt , /* is_bump */ false ); // @fixme { is_bump will be true? }
1018+ InitTexOpt (&material->bump_texopt , /* is_bump */ true );
1019+ InitTexOpt (&material->displacement_texopt , /* is_bump */ false );
1020+ InitTexOpt (&material->alpha_texopt , /* is_bump */ false );
1021+ InitTexOpt (&material->reflection_texopt , /* is_bump */ false );
1022+ InitTexOpt (&material->roughness_texopt , /* is_bump */ false );
1023+ InitTexOpt (&material->metallic_texopt , /* is_bump */ false );
1024+ InitTexOpt (&material->sheen_texopt , /* is_bump */ false );
1025+ InitTexOpt (&material->emissive_texopt , /* is_bump */ false );
1026+ InitTexOpt (&material->normal_texopt ,
1027+ /* is_bump */ false ); // @fixme { is_bump will be true? }
10281028 material->name = " " ;
10291029 material->ambient_texname = " " ;
10301030 material->diffuse_texname = " " ;
@@ -1355,7 +1355,7 @@ void LoadMtl(std::map<std::string, int> *material_map,
13551355 std::string linebuf;
13561356 while (inStream->peek () != -1 ) {
13571357 safeGetline (*inStream, linebuf);
1358- line_no++;
1358+ line_no++;
13591359
13601360 // Trim trailing whitespace.
13611361 if (linebuf.size () > 0 ) {
@@ -1495,9 +1495,9 @@ void LoadMtl(std::map<std::string, int> *material_map,
14951495
14961496 if (has_tr) {
14971497 warn_ss << " Both `d` and `Tr` parameters defined for \" "
1498- << material.name << " \" . Use the value of `d` for dissolve (line "
1499- << line_no << " in .mtl.) "
1500- << std::endl;
1498+ << material.name
1499+ << " \" . Use the value of `d` for dissolve (line " << line_no
1500+ << " in .mtl.) " << std::endl;
15011501 }
15021502 has_d = true ;
15031503 continue ;
@@ -1507,9 +1507,9 @@ void LoadMtl(std::map<std::string, int> *material_map,
15071507 if (has_d) {
15081508 // `d` wins. Ignore `Tr` value.
15091509 warn_ss << " Both `d` and `Tr` parameters defined for \" "
1510- << material.name << " \" . Use the value of `d` for dissolve (line "
1511- << line_no << " in .mtl.) "
1512- << std::endl;
1510+ << material.name
1511+ << " \" . Use the value of `d` for dissolve (line " << line_no
1512+ << " in .mtl.) " << std::endl;
15131513 } else {
15141514 // We invert value of Tr(assume Tr is in range [0, 1])
15151515 // NOTE: Interpretation of Tr is application(exporter) dependent. For
@@ -1945,7 +1945,8 @@ bool LoadObj(attrib_t *attrib, std::vector<shape_t> *shapes,
19451945 static_cast <int >(vt.size () / 2 ), &vi)) {
19461946 if (err) {
19471947 std::stringstream ss;
1948- ss << " Failed parse `f' line(e.g. zero value for face index. line " << line_num << " .)\n " ;
1948+ ss << " Failed parse `f' line(e.g. zero value for face index. line "
1949+ << line_num << " .)\n " ;
19491950 (*err) += ss.str ();
19501951 }
19511952 return false ;
@@ -2007,7 +2008,8 @@ bool LoadObj(attrib_t *attrib, std::vector<shape_t> *shapes,
20072008 if (warn) {
20082009 std::stringstream ss;
20092010 ss << " Looks like empty filename for mtllib. Use default "
2010- " material (line " << line_num << " .)\n " ;
2011+ " material (line "
2012+ << line_num << " .)\n " ;
20112013
20122014 (*warn) += ss.str ();
20132015 }
@@ -2216,21 +2218,24 @@ bool LoadObj(attrib_t *attrib, std::vector<shape_t> *shapes,
22162218 if (greatest_v_idx >= static_cast <int >(v.size () / 3 )) {
22172219 if (warn) {
22182220 std::stringstream ss;
2219- ss << " Vertex indices out of bounds (line " << line_num << " .)\n " << std::endl;
2221+ ss << " Vertex indices out of bounds (line " << line_num << " .)\n "
2222+ << std::endl;
22202223 (*warn) += ss.str ();
22212224 }
22222225 }
22232226 if (greatest_vn_idx >= static_cast <int >(vn.size () / 3 )) {
22242227 if (warn) {
22252228 std::stringstream ss;
2226- ss << " Vertex normal indices out of bounds (line " << line_num << " .)\n " << std::endl;
2229+ ss << " Vertex normal indices out of bounds (line " << line_num << " .)\n "
2230+ << std::endl;
22272231 (*warn) += ss.str ();
22282232 }
22292233 }
22302234 if (greatest_vt_idx >= static_cast <int >(vt.size () / 2 )) {
22312235 if (warn) {
22322236 std::stringstream ss;
2233- ss << " Vertex texcoord indices out of bounds (line " << line_num << " .)\n " << std::endl;
2237+ ss << " Vertex texcoord indices out of bounds (line " << line_num << " .)\n "
2238+ << std::endl;
22342239 (*warn) += ss.str ();
22352240 }
22362241 }
0 commit comments