| 382 | } |
| 383 | |
| 384 | Expected<void> parseMtlTexture( const std::string_view& str, std::string& textureFile ) |
| 385 | { |
| 386 | using namespace boost::spirit::x3; |
| 387 | |
| 388 | auto file = [&] ( auto& ctx ) |
| 389 | { |
| 390 | textureFile = _attr( ctx ); |
| 391 | }; |
| 392 | |
| 393 | bool r = phrase_parse( |
| 394 | str.begin(), |
| 395 | str.end(), |
| 396 | ( |
| 397 | lit( "map_" ) >> ( lit( "Ka" ) | lit( "Kd" ) | lit( "Ks" ) | lit( "Ns" ) | lit( "d" ) ) |
| 398 | >> *( |
| 399 | ( lit( "-blendu" ) >> ( lit( "on" ) | lit( "off" ) ) ) | |
| 400 | ( lit( "-blendv" ) >> ( lit( "on" ) | lit( "off" ) ) ) | |
| 401 | ( lit( "-cc" ) >> ( lit( "on" ) | lit( "off" ) ) ) | |
| 402 | ( lit( "-clamp" ) >> ( lit( "on" ) | lit( "off" ) ) ) | |
| 403 | ( lit( "-imfchan" ) >> ( char_( 'r' ) | char_( 'b' ) | char_( 'g' ) | char_( 'm' ) | char_( 'l' ) | char_( 'z' ) ) ) | |
| 404 | ( lit( "-mm" ) >> float_ >> float_ ) | |
| 405 | ( lit( "-bm" ) >> float_ ) | |
| 406 | ( lit( "-o" ) >> float_ >> float_ >> float_ ) | |
| 407 | ( lit( "-s" ) >> float_ >> float_ >> float_ ) | |
| 408 | ( lit( "-t" ) >> float_ >> float_ >> float_ ) | |
| 409 | ( lit( "-texres" ) >> float_ ) |
| 410 | ) |
| 411 | >> no_skip[+char_][file] |
| 412 | ), |
| 413 | space |
| 414 | ); |
| 415 | if ( !r ) |
| 416 | return unexpected( "Failed to parse texture in MTL-file" ); |
| 417 | |
| 418 | boost::trim( textureFile ); |
| 419 | return {}; |
| 420 | } |
| 421 | |
| 422 | struct MtlMaterial |
| 423 | { |
no test coverage detected