ObjFileMtlImporter.cpp 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. /*
  2. ---------------------------------------------------------------------------
  3. Open Asset Import Library (assimp)
  4. ---------------------------------------------------------------------------
  5. Copyright (c) 2006-2020, assimp team
  6. All rights reserved.
  7. Redistribution and use of this software in source and binary forms,
  8. with or without modification, are permitted provided that the following
  9. conditions are met:
  10. * Redistributions of source code must retain the above
  11. copyright notice, this list of conditions and the
  12. following disclaimer.
  13. * Redistributions in binary form must reproduce the above
  14. copyright notice, this list of conditions and the
  15. following disclaimer in the documentation and/or other
  16. materials provided with the distribution.
  17. * Neither the name of the assimp team, nor the names of its
  18. contributors may be used to endorse or promote products
  19. derived from this software without specific prior
  20. written permission of the assimp team.
  21. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  25. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  26. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  27. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  28. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  29. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. ---------------------------------------------------------------------------
  33. */
  34. #ifndef ASSIMP_BUILD_NO_OBJ_IMPORTER
  35. #include "ObjFileMtlImporter.h"
  36. #include "ObjFileData.h"
  37. #include "ObjTools.h"
  38. #include <assimp/ParsingUtils.h>
  39. #include <assimp/fast_atof.h>
  40. #include <assimp/material.h>
  41. #include <stdlib.h>
  42. #include <assimp/DefaultLogger.hpp>
  43. namespace Assimp {
  44. // Material specific token (case insensitive compare)
  45. static const std::string DiffuseTexture = "map_Kd";
  46. static const std::string AmbientTexture = "map_Ka";
  47. static const std::string SpecularTexture = "map_Ks";
  48. static const std::string OpacityTexture = "map_d";
  49. static const std::string EmissiveTexture1 = "map_emissive";
  50. static const std::string EmissiveTexture2 = "map_Ke";
  51. static const std::string BumpTexture1 = "map_bump";
  52. static const std::string BumpTexture2 = "bump";
  53. static const std::string NormalTextureV1 = "map_Kn";
  54. static const std::string NormalTextureV2 = "norm";
  55. static const std::string ReflectionTexture = "refl";
  56. static const std::string DisplacementTexture1 = "map_disp";
  57. static const std::string DisplacementTexture2 = "disp";
  58. static const std::string SpecularityTexture = "map_ns";
  59. static const std::string RoughnessTexture = "map_Pr";
  60. static const std::string MetallicTexture = "map_Pm";
  61. static const std::string SheenTexture = "map_Ps";
  62. static const std::string RMATexture = "map_Ps";
  63. // texture option specific token
  64. static const std::string BlendUOption = "-blendu";
  65. static const std::string BlendVOption = "-blendv";
  66. static const std::string BoostOption = "-boost";
  67. static const std::string ModifyMapOption = "-mm";
  68. static const std::string OffsetOption = "-o";
  69. static const std::string ScaleOption = "-s";
  70. static const std::string TurbulenceOption = "-t";
  71. static const std::string ResolutionOption = "-texres";
  72. static const std::string ClampOption = "-clamp";
  73. static const std::string BumpOption = "-bm";
  74. static const std::string ChannelOption = "-imfchan";
  75. static const std::string TypeOption = "-type";
  76. // -------------------------------------------------------------------
  77. // Constructor
  78. ObjFileMtlImporter::ObjFileMtlImporter(std::vector<char> &buffer,
  79. const std::string &,
  80. ObjFile::Model *pModel) :
  81. m_DataIt(buffer.begin()),
  82. m_DataItEnd(buffer.end()),
  83. m_pModel(pModel),
  84. m_uiLine(0),
  85. m_buffer() {
  86. ai_assert(nullptr != m_pModel);
  87. m_buffer.resize(BUFFERSIZE);
  88. std::fill(m_buffer.begin(), m_buffer.end(), '\0');
  89. if (nullptr == m_pModel->mDefaultMaterial) {
  90. m_pModel->mDefaultMaterial = new ObjFile::Material;
  91. m_pModel->mDefaultMaterial->MaterialName.Set("default");
  92. }
  93. load();
  94. }
  95. // -------------------------------------------------------------------
  96. // Destructor
  97. ObjFileMtlImporter::~ObjFileMtlImporter() = default;
  98. // -------------------------------------------------------------------
  99. // Loads the material description
  100. void ObjFileMtlImporter::load() {
  101. if (m_DataIt == m_DataItEnd)
  102. return;
  103. while (m_DataIt != m_DataItEnd) {
  104. switch (*m_DataIt) {
  105. case 'k':
  106. case 'K': {
  107. ++m_DataIt;
  108. if (*m_DataIt == 'a') // Ambient color
  109. {
  110. ++m_DataIt;
  111. if (m_pModel->mCurrentMaterial != nullptr)
  112. getColorRGBA(&m_pModel->mCurrentMaterial->ambient);
  113. } else if (*m_DataIt == 'd') {
  114. // Diffuse color
  115. ++m_DataIt;
  116. if (m_pModel->mCurrentMaterial != nullptr)
  117. getColorRGBA(&m_pModel->mCurrentMaterial->diffuse);
  118. } else if (*m_DataIt == 's') {
  119. ++m_DataIt;
  120. if (m_pModel->mCurrentMaterial != nullptr)
  121. getColorRGBA(&m_pModel->mCurrentMaterial->specular);
  122. } else if (*m_DataIt == 'e') {
  123. ++m_DataIt;
  124. if (m_pModel->mCurrentMaterial != nullptr)
  125. getColorRGBA(&m_pModel->mCurrentMaterial->emissive);
  126. }
  127. m_DataIt = skipLine<DataArrayIt>(m_DataIt, m_DataItEnd, m_uiLine);
  128. } break;
  129. case 'T': {
  130. ++m_DataIt;
  131. // Material transmission color
  132. if (*m_DataIt == 'f') {
  133. ++m_DataIt;
  134. if (m_pModel->mCurrentMaterial != nullptr)
  135. getColorRGBA(&m_pModel->mCurrentMaterial->transparent);
  136. } else if (*m_DataIt == 'r') {
  137. // Material transmission alpha value
  138. ++m_DataIt;
  139. ai_real d;
  140. getFloatValue(d);
  141. if (m_pModel->mCurrentMaterial != nullptr)
  142. m_pModel->mCurrentMaterial->alpha = static_cast<ai_real>(1.0) - d;
  143. }
  144. m_DataIt = skipLine<DataArrayIt>(m_DataIt, m_DataItEnd, m_uiLine);
  145. } break;
  146. case 'd': {
  147. if (*(m_DataIt + 1) == 'i' && *(m_DataIt + 2) == 's' && *(m_DataIt + 3) == 'p') {
  148. // A displacement map
  149. getTexture();
  150. } else {
  151. // Alpha value
  152. ++m_DataIt;
  153. if (m_pModel->mCurrentMaterial != nullptr)
  154. getFloatValue(m_pModel->mCurrentMaterial->alpha);
  155. m_DataIt = skipLine<DataArrayIt>(m_DataIt, m_DataItEnd, m_uiLine);
  156. }
  157. } break;
  158. case 'N':
  159. case 'n': {
  160. ++m_DataIt;
  161. switch (*m_DataIt) {
  162. case 's': // Specular exponent
  163. ++m_DataIt;
  164. if (m_pModel->mCurrentMaterial != nullptr)
  165. getFloatValue(m_pModel->mCurrentMaterial->shineness);
  166. break;
  167. case 'i': // Index Of refraction
  168. ++m_DataIt;
  169. if (m_pModel->mCurrentMaterial != nullptr)
  170. getFloatValue(m_pModel->mCurrentMaterial->ior);
  171. break;
  172. case 'e': // New material
  173. createMaterial();
  174. break;
  175. case 'o': // Norm texture
  176. --m_DataIt;
  177. getTexture();
  178. break;
  179. }
  180. m_DataIt = skipLine<DataArrayIt>(m_DataIt, m_DataItEnd, m_uiLine);
  181. } break;
  182. case 'P':
  183. {
  184. ++m_DataIt;
  185. switch(*m_DataIt)
  186. {
  187. case 'r':
  188. ++m_DataIt;
  189. if (m_pModel->mCurrentMaterial != nullptr)
  190. getFloatValue(m_pModel->mCurrentMaterial->roughness);
  191. break;
  192. case 'm':
  193. ++m_DataIt;
  194. if (m_pModel->mCurrentMaterial != nullptr)
  195. getFloatValue(m_pModel->mCurrentMaterial->metallic);
  196. break;
  197. case 's':
  198. ++m_DataIt;
  199. if (m_pModel->mCurrentMaterial != nullptr)
  200. getColorRGBA(m_pModel->mCurrentMaterial->sheen);
  201. break;
  202. case 'c':
  203. ++m_DataIt;
  204. if (*m_DataIt == 'r') {
  205. ++m_DataIt;
  206. if (m_pModel->mCurrentMaterial != nullptr)
  207. getFloatValue(m_pModel->mCurrentMaterial->clearcoat_roughness);
  208. } else {
  209. if (m_pModel->mCurrentMaterial != nullptr)
  210. getFloatValue(m_pModel->mCurrentMaterial->clearcoat_thickness);
  211. }
  212. break;
  213. }
  214. m_DataIt = skipLine<DataArrayIt>(m_DataIt, m_DataItEnd, m_uiLine);
  215. }
  216. break;
  217. case 'm': // Texture
  218. case 'b': // quick'n'dirty - for 'bump' sections
  219. case 'r': // quick'n'dirty - for 'refl' sections
  220. {
  221. getTexture();
  222. m_DataIt = skipLine<DataArrayIt>(m_DataIt, m_DataItEnd, m_uiLine);
  223. } break;
  224. case 'i': // Illumination model
  225. {
  226. m_DataIt = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
  227. if (m_pModel->mCurrentMaterial != nullptr)
  228. getIlluminationModel(m_pModel->mCurrentMaterial->illumination_model);
  229. m_DataIt = skipLine<DataArrayIt>(m_DataIt, m_DataItEnd, m_uiLine);
  230. } break;
  231. case 'a': // Anisotropy
  232. {
  233. ++m_DataIt;
  234. getFloatValue(m_pModel->mCurrentMaterial->anisotropy);
  235. if (m_pModel->mCurrentMaterial != nullptr)
  236. m_DataIt = skipLine<DataArrayIt>(m_DataIt, m_DataItEnd, m_uiLine);
  237. } break;
  238. default: {
  239. m_DataIt = skipLine<DataArrayIt>(m_DataIt, m_DataItEnd, m_uiLine);
  240. } break;
  241. }
  242. }
  243. }
  244. // -------------------------------------------------------------------
  245. // Loads a color definition
  246. void ObjFileMtlImporter::getColorRGBA(aiColor3D *pColor) {
  247. ai_assert(nullptr != pColor);
  248. ai_real r(0.0), g(0.0), b(0.0);
  249. m_DataIt = getFloat<DataArrayIt>(m_DataIt, m_DataItEnd, r);
  250. pColor->r = r;
  251. // we have to check if color is default 0 with only one token
  252. if (!IsLineEnd(*m_DataIt)) {
  253. m_DataIt = getFloat<DataArrayIt>(m_DataIt, m_DataItEnd, g);
  254. m_DataIt = getFloat<DataArrayIt>(m_DataIt, m_DataItEnd, b);
  255. }
  256. pColor->g = g;
  257. pColor->b = b;
  258. }
  259. void ObjFileMtlImporter::getColorRGBA(Maybe<aiColor3D> &value) {
  260. aiColor3D v;
  261. getColorRGBA(&v);
  262. value = Maybe<aiColor3D>(v);
  263. }
  264. // -------------------------------------------------------------------
  265. // Loads the kind of illumination model.
  266. void ObjFileMtlImporter::getIlluminationModel(int &illum_model) {
  267. m_DataIt = CopyNextWord<DataArrayIt>(m_DataIt, m_DataItEnd, &m_buffer[0], BUFFERSIZE);
  268. illum_model = atoi(&m_buffer[0]);
  269. }
  270. // -------------------------------------------------------------------
  271. // Loads a single float value.
  272. void ObjFileMtlImporter::getFloatValue(ai_real &value) {
  273. m_DataIt = CopyNextWord<DataArrayIt>(m_DataIt, m_DataItEnd, &m_buffer[0], BUFFERSIZE);
  274. size_t len = std::strlen(&m_buffer[0]);
  275. if (0 == len) {
  276. value = 0.0f;
  277. return;
  278. }
  279. value = (ai_real)fast_atof(&m_buffer[0]);
  280. }
  281. void ObjFileMtlImporter::getFloatValue(Maybe<ai_real> &value) {
  282. m_DataIt = CopyNextWord<DataArrayIt>(m_DataIt, m_DataItEnd, &m_buffer[0], BUFFERSIZE);
  283. size_t len = std::strlen(&m_buffer[0]);
  284. if (len)
  285. value = Maybe<ai_real>(fast_atof(&m_buffer[0]));
  286. else
  287. value = Maybe<ai_real>();
  288. }
  289. // -------------------------------------------------------------------
  290. // Creates a material from loaded data.
  291. void ObjFileMtlImporter::createMaterial() {
  292. std::string line;
  293. while (!IsLineEnd(*m_DataIt)) {
  294. line += *m_DataIt;
  295. ++m_DataIt;
  296. }
  297. std::vector<std::string> token;
  298. const unsigned int numToken = tokenize<std::string>(line, token, " \t");
  299. std::string name;
  300. if (numToken == 1) {
  301. name = AI_DEFAULT_MATERIAL_NAME;
  302. } else {
  303. // skip newmtl and all following white spaces
  304. std::size_t first_ws_pos = line.find_first_of(" \t");
  305. std::size_t first_non_ws_pos = line.find_first_not_of(" \t", first_ws_pos);
  306. if (first_non_ws_pos != std::string::npos) {
  307. name = line.substr(first_non_ws_pos);
  308. }
  309. }
  310. name = trim_whitespaces(name);
  311. std::map<std::string, ObjFile::Material *>::iterator it = m_pModel->mMaterialMap.find(name);
  312. if (m_pModel->mMaterialMap.end() == it) {
  313. // New Material created
  314. m_pModel->mCurrentMaterial = new ObjFile::Material();
  315. m_pModel->mCurrentMaterial->MaterialName.Set(name);
  316. m_pModel->mMaterialLib.push_back(name);
  317. m_pModel->mMaterialMap[name] = m_pModel->mCurrentMaterial;
  318. if (m_pModel->mCurrentMesh) {
  319. m_pModel->mCurrentMesh->m_uiMaterialIndex = static_cast<unsigned int>(m_pModel->mMaterialLib.size() - 1);
  320. }
  321. } else {
  322. // Use older material
  323. m_pModel->mCurrentMaterial = (*it).second;
  324. }
  325. }
  326. // -------------------------------------------------------------------
  327. // Gets a texture name from data.
  328. void ObjFileMtlImporter::getTexture() {
  329. aiString *out(nullptr);
  330. int clampIndex = -1;
  331. const char *pPtr(&(*m_DataIt));
  332. if (!ASSIMP_strincmp(pPtr, DiffuseTexture.c_str(), static_cast<unsigned int>(DiffuseTexture.size()))) {
  333. // Diffuse texture
  334. out = &m_pModel->mCurrentMaterial->texture;
  335. clampIndex = ObjFile::Material::TextureDiffuseType;
  336. } else if (!ASSIMP_strincmp(pPtr, AmbientTexture.c_str(), static_cast<unsigned int>(AmbientTexture.size()))) {
  337. // Ambient texture
  338. out = &m_pModel->mCurrentMaterial->textureAmbient;
  339. clampIndex = ObjFile::Material::TextureAmbientType;
  340. } else if (!ASSIMP_strincmp(pPtr, SpecularTexture.c_str(), static_cast<unsigned int>(SpecularTexture.size()))) {
  341. // Specular texture
  342. out = &m_pModel->mCurrentMaterial->textureSpecular;
  343. clampIndex = ObjFile::Material::TextureSpecularType;
  344. } else if (!ASSIMP_strincmp(pPtr, DisplacementTexture1.c_str(), static_cast<unsigned int>(DisplacementTexture1.size())) ||
  345. !ASSIMP_strincmp(pPtr, DisplacementTexture2.c_str(), static_cast<unsigned int>(DisplacementTexture2.size()))) {
  346. // Displacement texture
  347. out = &m_pModel->mCurrentMaterial->textureDisp;
  348. clampIndex = ObjFile::Material::TextureDispType;
  349. } else if (!ASSIMP_strincmp(pPtr, OpacityTexture.c_str(), static_cast<unsigned int>(OpacityTexture.size()))) {
  350. // Opacity texture
  351. out = &m_pModel->mCurrentMaterial->textureOpacity;
  352. clampIndex = ObjFile::Material::TextureOpacityType;
  353. } else if (!ASSIMP_strincmp(pPtr, EmissiveTexture1.c_str(), static_cast<unsigned int>(EmissiveTexture1.size())) ||
  354. !ASSIMP_strincmp(pPtr, EmissiveTexture2.c_str(), static_cast<unsigned int>(EmissiveTexture2.size()))) {
  355. // Emissive texture
  356. out = &m_pModel->mCurrentMaterial->textureEmissive;
  357. clampIndex = ObjFile::Material::TextureEmissiveType;
  358. } else if (!ASSIMP_strincmp(pPtr, BumpTexture1.c_str(), static_cast<unsigned int>(BumpTexture1.size())) ||
  359. !ASSIMP_strincmp(pPtr, BumpTexture2.c_str(), static_cast<unsigned int>(BumpTexture2.size()))) {
  360. // Bump texture
  361. out = &m_pModel->mCurrentMaterial->textureBump;
  362. clampIndex = ObjFile::Material::TextureBumpType;
  363. } else if (!ASSIMP_strincmp(pPtr, NormalTextureV1.c_str(), static_cast<unsigned int>(NormalTextureV1.size())) || !ASSIMP_strincmp(pPtr, NormalTextureV2.c_str(), static_cast<unsigned int>(NormalTextureV2.size()))) {
  364. // Normal map
  365. out = &m_pModel->mCurrentMaterial->textureNormal;
  366. clampIndex = ObjFile::Material::TextureNormalType;
  367. } else if (!ASSIMP_strincmp(pPtr, ReflectionTexture.c_str(), static_cast<unsigned int>(ReflectionTexture.size()))) {
  368. // Reflection texture(s)
  369. //Do nothing here
  370. return;
  371. } else if (!ASSIMP_strincmp(pPtr, SpecularityTexture.c_str(), static_cast<unsigned int>(SpecularityTexture.size()))) {
  372. // Specularity scaling (glossiness)
  373. out = &m_pModel->mCurrentMaterial->textureSpecularity;
  374. clampIndex = ObjFile::Material::TextureSpecularityType;
  375. } else if ( !ASSIMP_strincmp( pPtr, RoughnessTexture.c_str(), static_cast<unsigned int>(RoughnessTexture.size()))) {
  376. // PBR Roughness texture
  377. out = & m_pModel->mCurrentMaterial->textureRoughness;
  378. clampIndex = ObjFile::Material::TextureRoughnessType;
  379. } else if ( !ASSIMP_strincmp( pPtr, MetallicTexture.c_str(), static_cast<unsigned int>(MetallicTexture.size()))) {
  380. // PBR Metallic texture
  381. out = & m_pModel->mCurrentMaterial->textureMetallic;
  382. clampIndex = ObjFile::Material::TextureMetallicType;
  383. } else if (!ASSIMP_strincmp( pPtr, SheenTexture.c_str(), static_cast<unsigned int>(SheenTexture.size()))) {
  384. // PBR Sheen (reflectance) texture
  385. out = & m_pModel->mCurrentMaterial->textureSheen;
  386. clampIndex = ObjFile::Material::TextureSheenType;
  387. } else if (!ASSIMP_strincmp( pPtr, RMATexture.c_str(), static_cast<unsigned int>(RMATexture.size()))) {
  388. // PBR Rough/Metal/AO texture
  389. out = & m_pModel->mCurrentMaterial->textureRMA;
  390. clampIndex = ObjFile::Material::TextureRMAType;
  391. } else {
  392. ASSIMP_LOG_ERROR("OBJ/MTL: Encountered unknown texture type");
  393. return;
  394. }
  395. bool clamp = false;
  396. getTextureOption(clamp, clampIndex, out);
  397. m_pModel->mCurrentMaterial->clamp[clampIndex] = clamp;
  398. std::string texture;
  399. m_DataIt = getName<DataArrayIt>(m_DataIt, m_DataItEnd, texture);
  400. if (nullptr != out) {
  401. out->Set(texture);
  402. }
  403. }
  404. /* /////////////////////////////////////////////////////////////////////////////
  405. * Texture Option
  406. * /////////////////////////////////////////////////////////////////////////////
  407. * According to http://en.wikipedia.org/wiki/Wavefront_.obj_file#Texture_options
  408. * Texture map statement can contains various texture option, for example:
  409. *
  410. * map_Ka -o 1 1 1 some.png
  411. * map_Kd -clamp on some.png
  412. *
  413. * So we need to parse and skip these options, and leave the last part which is
  414. * the url of image, otherwise we will get a wrong url like "-clamp on some.png".
  415. *
  416. * Because aiMaterial supports clamp option, so we also want to return it
  417. * /////////////////////////////////////////////////////////////////////////////
  418. */
  419. void ObjFileMtlImporter::getTextureOption(bool &clamp, int &clampIndex, aiString *&out) {
  420. m_DataIt = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
  421. // If there is any more texture option
  422. while (!isEndOfBuffer(m_DataIt, m_DataItEnd) && *m_DataIt == '-') {
  423. const char *pPtr(&(*m_DataIt));
  424. //skip option key and value
  425. int skipToken = 1;
  426. if (!ASSIMP_strincmp(pPtr, ClampOption.c_str(), static_cast<unsigned int>(ClampOption.size()))) {
  427. DataArrayIt it = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
  428. char value[3];
  429. CopyNextWord(it, m_DataItEnd, value, sizeof(value) / sizeof(*value));
  430. if (!ASSIMP_strincmp(value, "on", 2)) {
  431. clamp = true;
  432. }
  433. skipToken = 2;
  434. } else if (!ASSIMP_strincmp(pPtr, TypeOption.c_str(), static_cast<unsigned int>(TypeOption.size()))) {
  435. DataArrayIt it = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
  436. char value[12];
  437. CopyNextWord(it, m_DataItEnd, value, sizeof(value) / sizeof(*value));
  438. if (!ASSIMP_strincmp(value, "cube_top", 8)) {
  439. clampIndex = ObjFile::Material::TextureReflectionCubeTopType;
  440. out = &m_pModel->mCurrentMaterial->textureReflection[0];
  441. } else if (!ASSIMP_strincmp(value, "cube_bottom", 11)) {
  442. clampIndex = ObjFile::Material::TextureReflectionCubeBottomType;
  443. out = &m_pModel->mCurrentMaterial->textureReflection[1];
  444. } else if (!ASSIMP_strincmp(value, "cube_front", 10)) {
  445. clampIndex = ObjFile::Material::TextureReflectionCubeFrontType;
  446. out = &m_pModel->mCurrentMaterial->textureReflection[2];
  447. } else if (!ASSIMP_strincmp(value, "cube_back", 9)) {
  448. clampIndex = ObjFile::Material::TextureReflectionCubeBackType;
  449. out = &m_pModel->mCurrentMaterial->textureReflection[3];
  450. } else if (!ASSIMP_strincmp(value, "cube_left", 9)) {
  451. clampIndex = ObjFile::Material::TextureReflectionCubeLeftType;
  452. out = &m_pModel->mCurrentMaterial->textureReflection[4];
  453. } else if (!ASSIMP_strincmp(value, "cube_right", 10)) {
  454. clampIndex = ObjFile::Material::TextureReflectionCubeRightType;
  455. out = &m_pModel->mCurrentMaterial->textureReflection[5];
  456. } else if (!ASSIMP_strincmp(value, "sphere", 6)) {
  457. clampIndex = ObjFile::Material::TextureReflectionSphereType;
  458. out = &m_pModel->mCurrentMaterial->textureReflection[0];
  459. }
  460. skipToken = 2;
  461. } else if (!ASSIMP_strincmp(pPtr, BumpOption.c_str(), static_cast<unsigned int>(BumpOption.size()))) {
  462. DataArrayIt it = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
  463. getFloat(it, m_DataItEnd, m_pModel->mCurrentMaterial->bump_multiplier);
  464. skipToken = 2;
  465. } else if (!ASSIMP_strincmp(pPtr, BlendUOption.c_str(), static_cast<unsigned int>(BlendUOption.size())) || !ASSIMP_strincmp(pPtr, BlendVOption.c_str(), static_cast<unsigned int>(BlendVOption.size())) || !ASSIMP_strincmp(pPtr, BoostOption.c_str(), static_cast<unsigned int>(BoostOption.size())) || !ASSIMP_strincmp(pPtr, ResolutionOption.c_str(), static_cast<unsigned int>(ResolutionOption.size())) || !ASSIMP_strincmp(pPtr, ChannelOption.c_str(), static_cast<unsigned int>(ChannelOption.size()))) {
  466. skipToken = 2;
  467. } else if (!ASSIMP_strincmp(pPtr, ModifyMapOption.c_str(), static_cast<unsigned int>(ModifyMapOption.size()))) {
  468. skipToken = 3;
  469. } else if (!ASSIMP_strincmp(pPtr, OffsetOption.c_str(), static_cast<unsigned int>(OffsetOption.size())) || !ASSIMP_strincmp(pPtr, ScaleOption.c_str(), static_cast<unsigned int>(ScaleOption.size())) || !ASSIMP_strincmp(pPtr, TurbulenceOption.c_str(), static_cast<unsigned int>(TurbulenceOption.size()))) {
  470. skipToken = 4;
  471. }
  472. for (int i = 0; i < skipToken; ++i) {
  473. m_DataIt = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
  474. }
  475. }
  476. }
  477. // -------------------------------------------------------------------
  478. } // Namespace Assimp
  479. #endif // !! ASSIMP_BUILD_NO_OBJ_IMPORTER