MDCLoader.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  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. /** @file Implementation of the MDC importer class */
  35. #ifndef ASSIMP_BUILD_NO_MDC_IMPORTER
  36. // internal headers
  37. #include "AssetLib/MDC/MDCLoader.h"
  38. #include "AssetLib/MD3/MD3FileData.h"
  39. #include "AssetLib/MDC/MDCNormalTable.h" // shouldn't be included by other units
  40. #include <assimp/importerdesc.h>
  41. #include <assimp/scene.h>
  42. #include <assimp/DefaultLogger.hpp>
  43. #include <assimp/IOSystem.hpp>
  44. #include <assimp/Importer.hpp>
  45. #include <memory>
  46. using namespace Assimp;
  47. using namespace Assimp::MDC;
  48. static const aiImporterDesc desc = {
  49. "Return To Castle Wolfenstein Mesh Importer",
  50. "",
  51. "",
  52. "",
  53. aiImporterFlags_SupportBinaryFlavour,
  54. 0,
  55. 0,
  56. 0,
  57. 0,
  58. "mdc"
  59. };
  60. // ------------------------------------------------------------------------------------------------
  61. void MDC::BuildVertex(const Frame &frame,
  62. const BaseVertex &bvert,
  63. const CompressedVertex &cvert,
  64. aiVector3D &vXYZOut,
  65. aiVector3D &vNorOut) {
  66. // compute the position
  67. const float xd = (cvert.xd - AI_MDC_CVERT_BIAS) * AI_MDC_DELTA_SCALING;
  68. const float yd = (cvert.yd - AI_MDC_CVERT_BIAS) * AI_MDC_DELTA_SCALING;
  69. const float zd = (cvert.zd - AI_MDC_CVERT_BIAS) * AI_MDC_DELTA_SCALING;
  70. vXYZOut.x = frame.localOrigin.x + AI_MDC_BASE_SCALING * (bvert.x + xd);
  71. vXYZOut.y = frame.localOrigin.y + AI_MDC_BASE_SCALING * (bvert.y + yd);
  72. vXYZOut.z = frame.localOrigin.z + AI_MDC_BASE_SCALING * (bvert.z + zd);
  73. // compute the normal vector .. ehm ... lookup it in the table :-)
  74. vNorOut.x = mdcNormals[cvert.nd][0];
  75. vNorOut.y = mdcNormals[cvert.nd][1];
  76. vNorOut.z = mdcNormals[cvert.nd][2];
  77. }
  78. // ------------------------------------------------------------------------------------------------
  79. // Constructor to be privately used by Importer
  80. MDCImporter::MDCImporter() :
  81. configFrameID(),
  82. pcHeader(),
  83. mBuffer(),
  84. fileSize() {
  85. // empty
  86. }
  87. // ------------------------------------------------------------------------------------------------
  88. // Destructor, private as well
  89. MDCImporter::~MDCImporter() {
  90. // empty
  91. }
  92. // ------------------------------------------------------------------------------------------------
  93. // Returns whether the class can handle the format of the given file.
  94. bool MDCImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool checkSig) const {
  95. const std::string extension = GetExtension(pFile);
  96. if (extension == "mdc") {
  97. return true;
  98. }
  99. // if check for extension is not enough, check for the magic tokens
  100. if (!extension.length() || checkSig) {
  101. uint32_t tokens[1];
  102. tokens[0] = AI_MDC_MAGIC_NUMBER_LE;
  103. return CheckMagicToken(pIOHandler, pFile, tokens, 1);
  104. }
  105. return false;
  106. }
  107. // ------------------------------------------------------------------------------------------------
  108. const aiImporterDesc *MDCImporter::GetInfo() const {
  109. return &desc;
  110. }
  111. // ------------------------------------------------------------------------------------------------
  112. // Validate the header of the given MDC file
  113. void MDCImporter::ValidateHeader() {
  114. AI_SWAP4(this->pcHeader->ulVersion);
  115. AI_SWAP4(this->pcHeader->ulFlags);
  116. AI_SWAP4(this->pcHeader->ulNumFrames);
  117. AI_SWAP4(this->pcHeader->ulNumTags);
  118. AI_SWAP4(this->pcHeader->ulNumSurfaces);
  119. AI_SWAP4(this->pcHeader->ulNumSkins);
  120. AI_SWAP4(this->pcHeader->ulOffsetBorderFrames);
  121. if (pcHeader->ulIdent != AI_MDC_MAGIC_NUMBER_BE &&
  122. pcHeader->ulIdent != AI_MDC_MAGIC_NUMBER_LE) {
  123. char szBuffer[5];
  124. szBuffer[0] = ((char *)&pcHeader->ulIdent)[0];
  125. szBuffer[1] = ((char *)&pcHeader->ulIdent)[1];
  126. szBuffer[2] = ((char *)&pcHeader->ulIdent)[2];
  127. szBuffer[3] = ((char *)&pcHeader->ulIdent)[3];
  128. szBuffer[4] = '\0';
  129. throw DeadlyImportError("Invalid MDC magic word: should be IDPC, the "
  130. "magic word found is " +
  131. std::string(szBuffer));
  132. }
  133. if (pcHeader->ulVersion != AI_MDC_VERSION) {
  134. ASSIMP_LOG_WARN("Unsupported MDC file version (2 (AI_MDC_VERSION) was expected)");
  135. }
  136. if (pcHeader->ulOffsetBorderFrames + pcHeader->ulNumFrames * sizeof(MDC::Frame) > this->fileSize ||
  137. pcHeader->ulOffsetSurfaces + pcHeader->ulNumSurfaces * sizeof(MDC::Surface) > this->fileSize) {
  138. throw DeadlyImportError("Some of the offset values in the MDC header are invalid "
  139. "and point to something behind the file.");
  140. }
  141. if (this->configFrameID >= this->pcHeader->ulNumFrames) {
  142. throw DeadlyImportError("The requested frame is not available");
  143. }
  144. }
  145. // ------------------------------------------------------------------------------------------------
  146. // Validate the header of a given MDC file surface
  147. void MDCImporter::ValidateSurfaceHeader(BE_NCONST MDC::Surface *pcSurf) {
  148. AI_SWAP4(pcSurf->ulFlags);
  149. AI_SWAP4(pcSurf->ulNumCompFrames);
  150. AI_SWAP4(pcSurf->ulNumBaseFrames);
  151. AI_SWAP4(pcSurf->ulNumShaders);
  152. AI_SWAP4(pcSurf->ulNumVertices);
  153. AI_SWAP4(pcSurf->ulNumTriangles);
  154. AI_SWAP4(pcSurf->ulOffsetTriangles);
  155. AI_SWAP4(pcSurf->ulOffsetTexCoords);
  156. AI_SWAP4(pcSurf->ulOffsetBaseVerts);
  157. AI_SWAP4(pcSurf->ulOffsetCompVerts);
  158. AI_SWAP4(pcSurf->ulOffsetFrameBaseFrames);
  159. AI_SWAP4(pcSurf->ulOffsetFrameCompFrames);
  160. AI_SWAP4(pcSurf->ulOffsetEnd);
  161. const unsigned int iMax = this->fileSize - (unsigned int)((int8_t *)pcSurf - (int8_t *)pcHeader);
  162. if (pcSurf->ulOffsetBaseVerts + pcSurf->ulNumVertices * sizeof(MDC::BaseVertex) > iMax ||
  163. (pcSurf->ulNumCompFrames && pcSurf->ulOffsetCompVerts + pcSurf->ulNumVertices * sizeof(MDC::CompressedVertex) > iMax) ||
  164. pcSurf->ulOffsetTriangles + pcSurf->ulNumTriangles * sizeof(MDC::Triangle) > iMax ||
  165. pcSurf->ulOffsetTexCoords + pcSurf->ulNumVertices * sizeof(MDC::TexturCoord) > iMax ||
  166. pcSurf->ulOffsetShaders + pcSurf->ulNumShaders * sizeof(MDC::Shader) > iMax ||
  167. pcSurf->ulOffsetFrameBaseFrames + pcSurf->ulNumBaseFrames * 2 > iMax ||
  168. (pcSurf->ulNumCompFrames && pcSurf->ulOffsetFrameCompFrames + pcSurf->ulNumCompFrames * 2 > iMax)) {
  169. throw DeadlyImportError("Some of the offset values in the MDC surface header "
  170. "are invalid and point somewhere behind the file.");
  171. }
  172. }
  173. // ------------------------------------------------------------------------------------------------
  174. // Setup configuration properties
  175. void MDCImporter::SetupProperties(const Importer *pImp) {
  176. // The AI_CONFIG_IMPORT_MDC_KEYFRAME option overrides the
  177. // AI_CONFIG_IMPORT_GLOBAL_KEYFRAME option.
  178. if (static_cast<unsigned int>(-1) == (configFrameID = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_MDC_KEYFRAME, -1))) {
  179. configFrameID = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_GLOBAL_KEYFRAME, 0);
  180. }
  181. }
  182. // ------------------------------------------------------------------------------------------------
  183. // Imports the given file into the given scene structure.
  184. void MDCImporter::InternReadFile(
  185. const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) {
  186. std::unique_ptr<IOStream> file(pIOHandler->Open(pFile));
  187. // Check whether we can read from the file
  188. if (file.get() == nullptr) {
  189. throw DeadlyImportError("Failed to open MDC file " + pFile + ".");
  190. }
  191. // check whether the mdc file is large enough to contain the file header
  192. fileSize = static_cast<unsigned int>(file->FileSize());
  193. if (fileSize < sizeof(MDC::Header)) {
  194. throw DeadlyImportError("MDC File is too small.");
  195. }
  196. std::vector<unsigned char> mBuffer2(fileSize);
  197. file->Read(&mBuffer2[0], 1, fileSize);
  198. mBuffer = &mBuffer2[0];
  199. // validate the file header
  200. this->pcHeader = (BE_NCONST MDC::Header *)this->mBuffer;
  201. this->ValidateHeader();
  202. std::vector<std::string> aszShaders;
  203. // get a pointer to the frame we want to read
  204. BE_NCONST MDC::Frame *pcFrame = (BE_NCONST MDC::Frame *)(this->mBuffer +
  205. this->pcHeader->ulOffsetBorderFrames);
  206. // no need to swap the other members, we won't need them
  207. pcFrame += configFrameID;
  208. AI_SWAP4(pcFrame->localOrigin[0]);
  209. AI_SWAP4(pcFrame->localOrigin[1]);
  210. AI_SWAP4(pcFrame->localOrigin[2]);
  211. // get the number of valid surfaces
  212. BE_NCONST MDC::Surface *pcSurface, *pcSurface2;
  213. pcSurface = pcSurface2 = new (mBuffer + pcHeader->ulOffsetSurfaces) MDC::Surface;
  214. unsigned int iNumShaders = 0;
  215. for (unsigned int i = 0; i < pcHeader->ulNumSurfaces; ++i) {
  216. // validate the surface header
  217. this->ValidateSurfaceHeader(pcSurface2);
  218. if (pcSurface2->ulNumVertices && pcSurface2->ulNumTriangles) {
  219. ++pScene->mNumMeshes;
  220. }
  221. iNumShaders += pcSurface2->ulNumShaders;
  222. pcSurface2 = new ((int8_t *)pcSurface2 + pcSurface2->ulOffsetEnd) MDC::Surface;
  223. }
  224. aszShaders.reserve(iNumShaders);
  225. pScene->mMeshes = new aiMesh *[pScene->mNumMeshes];
  226. // necessary that we don't crash if an exception occurs
  227. for (unsigned int i = 0; i < pScene->mNumMeshes; ++i) {
  228. pScene->mMeshes[i] = nullptr;
  229. }
  230. // now read all surfaces
  231. unsigned int iDefaultMatIndex = UINT_MAX;
  232. for (unsigned int i = 0, iNum = 0; i < pcHeader->ulNumSurfaces; ++i) {
  233. if (!pcSurface->ulNumVertices || !pcSurface->ulNumTriangles) continue;
  234. aiMesh *pcMesh = pScene->mMeshes[iNum++] = new aiMesh();
  235. pcMesh->mNumFaces = pcSurface->ulNumTriangles;
  236. pcMesh->mNumVertices = pcMesh->mNumFaces * 3;
  237. // store the name of the surface for use as node name.
  238. pcMesh->mName.Set(std::string(pcSurface->ucName, strnlen(pcSurface->ucName, AI_MDC_MAXQPATH - 1)));
  239. // go to the first shader in the file. ignore the others.
  240. if (pcSurface->ulNumShaders) {
  241. const MDC::Shader *pcShader = (const MDC::Shader *)((int8_t *)pcSurface + pcSurface->ulOffsetShaders);
  242. pcMesh->mMaterialIndex = (unsigned int)aszShaders.size();
  243. // create a new shader
  244. aszShaders.push_back(std::string(pcShader->ucName,
  245. ::strnlen(pcShader->ucName, sizeof(pcShader->ucName))));
  246. }
  247. // need to create a default material
  248. else if (UINT_MAX == iDefaultMatIndex) {
  249. pcMesh->mMaterialIndex = iDefaultMatIndex = (unsigned int)aszShaders.size();
  250. aszShaders.push_back(std::string());
  251. }
  252. // otherwise assign a reference to the default material
  253. else
  254. pcMesh->mMaterialIndex = iDefaultMatIndex;
  255. // allocate output storage for the mesh
  256. aiVector3D *pcVertCur = pcMesh->mVertices = new aiVector3D[pcMesh->mNumVertices];
  257. aiVector3D *pcNorCur = pcMesh->mNormals = new aiVector3D[pcMesh->mNumVertices];
  258. aiVector3D *pcUVCur = pcMesh->mTextureCoords[0] = new aiVector3D[pcMesh->mNumVertices];
  259. aiFace *pcFaceCur = pcMesh->mFaces = new aiFace[pcMesh->mNumFaces];
  260. // create all vertices/faces
  261. BE_NCONST MDC::Triangle *pcTriangle = (BE_NCONST MDC::Triangle *)((int8_t *)pcSurface + pcSurface->ulOffsetTriangles);
  262. BE_NCONST MDC::TexturCoord *const pcUVs = (BE_NCONST MDC::TexturCoord *)((int8_t *)pcSurface + pcSurface->ulOffsetTexCoords);
  263. // get a pointer to the uncompressed vertices
  264. int16_t iOfs = *((int16_t *)((int8_t *)pcSurface +
  265. pcSurface->ulOffsetFrameBaseFrames) +
  266. this->configFrameID);
  267. AI_SWAP2(iOfs);
  268. BE_NCONST MDC::BaseVertex *const pcVerts = (BE_NCONST MDC::BaseVertex *)((int8_t *)pcSurface + pcSurface->ulOffsetBaseVerts) +
  269. ((int)iOfs * pcSurface->ulNumVertices * 4);
  270. // do the main swapping stuff ...
  271. #if (defined AI_BUILD_BIG_ENDIAN)
  272. // swap all triangles
  273. for (unsigned int i = 0; i < pcSurface->ulNumTriangles; ++i) {
  274. AI_SWAP4(pcTriangle[i].aiIndices[0]);
  275. AI_SWAP4(pcTriangle[i].aiIndices[1]);
  276. AI_SWAP4(pcTriangle[i].aiIndices[2]);
  277. }
  278. // swap all vertices
  279. for (unsigned int i = 0; i < pcSurface->ulNumVertices * pcSurface->ulNumBaseFrames; ++i) {
  280. AI_SWAP2(pcVerts->normal);
  281. AI_SWAP2(pcVerts->x);
  282. AI_SWAP2(pcVerts->y);
  283. AI_SWAP2(pcVerts->z);
  284. }
  285. // swap all texture coordinates
  286. for (unsigned int i = 0; i < pcSurface->ulNumVertices; ++i) {
  287. AI_SWAP4(pcUVs->u);
  288. AI_SWAP4(pcUVs->v);
  289. }
  290. #endif
  291. const MDC::CompressedVertex *pcCVerts = nullptr;
  292. int16_t *mdcCompVert = nullptr;
  293. // access compressed frames for large frame numbers, but never for the first
  294. if (this->configFrameID && pcSurface->ulNumCompFrames > 0) {
  295. mdcCompVert = (int16_t *)((int8_t *)pcSurface + pcSurface->ulOffsetFrameCompFrames) + this->configFrameID;
  296. AI_SWAP2P(mdcCompVert);
  297. if (*mdcCompVert >= 0) {
  298. pcCVerts = (const MDC::CompressedVertex *)((int8_t *)pcSurface +
  299. pcSurface->ulOffsetCompVerts) +
  300. *mdcCompVert * pcSurface->ulNumVertices;
  301. } else
  302. mdcCompVert = nullptr;
  303. }
  304. // copy all faces
  305. for (unsigned int iFace = 0; iFace < pcSurface->ulNumTriangles; ++iFace,
  306. ++pcTriangle, ++pcFaceCur) {
  307. const unsigned int iOutIndex = iFace * 3;
  308. pcFaceCur->mNumIndices = 3;
  309. pcFaceCur->mIndices = new unsigned int[3];
  310. for (unsigned int iIndex = 0; iIndex < 3; ++iIndex,
  311. ++pcVertCur, ++pcUVCur, ++pcNorCur) {
  312. uint32_t quak = pcTriangle->aiIndices[iIndex];
  313. if (quak >= pcSurface->ulNumVertices) {
  314. ASSIMP_LOG_ERROR("MDC vertex index is out of range");
  315. quak = pcSurface->ulNumVertices - 1;
  316. }
  317. // compressed vertices?
  318. if (mdcCompVert) {
  319. MDC::BuildVertex(*pcFrame, pcVerts[quak], pcCVerts[quak],
  320. *pcVertCur, *pcNorCur);
  321. } else {
  322. // copy position
  323. pcVertCur->x = pcVerts[quak].x * AI_MDC_BASE_SCALING;
  324. pcVertCur->y = pcVerts[quak].y * AI_MDC_BASE_SCALING;
  325. pcVertCur->z = pcVerts[quak].z * AI_MDC_BASE_SCALING;
  326. // copy normals
  327. MD3::LatLngNormalToVec3(pcVerts[quak].normal, &pcNorCur->x);
  328. // copy texture coordinates
  329. pcUVCur->x = pcUVs[quak].u;
  330. pcUVCur->y = ai_real(1.0) - pcUVs[quak].v; // DX to OGL
  331. }
  332. pcVertCur->x += pcFrame->localOrigin[0];
  333. pcVertCur->y += pcFrame->localOrigin[1];
  334. pcVertCur->z += pcFrame->localOrigin[2];
  335. }
  336. // swap the face order - DX to OGL
  337. pcFaceCur->mIndices[0] = iOutIndex + 2;
  338. pcFaceCur->mIndices[1] = iOutIndex + 1;
  339. pcFaceCur->mIndices[2] = iOutIndex + 0;
  340. }
  341. pcSurface = new ((int8_t *)pcSurface + pcSurface->ulOffsetEnd) MDC::Surface;
  342. }
  343. // create a flat node graph with a root node and one child for each surface
  344. if (!pScene->mNumMeshes)
  345. throw DeadlyImportError("Invalid MDC file: File contains no valid mesh");
  346. else if (1 == pScene->mNumMeshes) {
  347. pScene->mRootNode = new aiNode();
  348. if (nullptr != pScene->mMeshes[0]) {
  349. pScene->mRootNode->mName = pScene->mMeshes[0]->mName;
  350. pScene->mRootNode->mNumMeshes = 1;
  351. pScene->mRootNode->mMeshes = new unsigned int[1];
  352. pScene->mRootNode->mMeshes[0] = 0;
  353. }
  354. } else {
  355. pScene->mRootNode = new aiNode();
  356. pScene->mRootNode->mNumChildren = pScene->mNumMeshes;
  357. pScene->mRootNode->mChildren = new aiNode *[pScene->mNumMeshes];
  358. pScene->mRootNode->mName.Set("<root>");
  359. for (unsigned int i = 0; i < pScene->mNumMeshes; ++i) {
  360. aiNode *pcNode = pScene->mRootNode->mChildren[i] = new aiNode();
  361. pcNode->mParent = pScene->mRootNode;
  362. pcNode->mName = pScene->mMeshes[i]->mName;
  363. pcNode->mNumMeshes = 1;
  364. pcNode->mMeshes = new unsigned int[1];
  365. pcNode->mMeshes[0] = i;
  366. }
  367. }
  368. // create materials
  369. pScene->mNumMaterials = (unsigned int)aszShaders.size();
  370. pScene->mMaterials = new aiMaterial *[pScene->mNumMaterials];
  371. for (unsigned int i = 0; i < pScene->mNumMaterials; ++i) {
  372. aiMaterial *pcMat = new aiMaterial();
  373. pScene->mMaterials[i] = pcMat;
  374. const std::string &name = aszShaders[i];
  375. int iMode = (int)aiShadingMode_Gouraud;
  376. pcMat->AddProperty<int>(&iMode, 1, AI_MATKEY_SHADING_MODEL);
  377. // add a small ambient color value - RtCW seems to have one
  378. aiColor3D clr;
  379. clr.b = clr.g = clr.r = 0.05f;
  380. pcMat->AddProperty<aiColor3D>(&clr, 1, AI_MATKEY_COLOR_AMBIENT);
  381. if (name.length())
  382. clr.b = clr.g = clr.r = 1.0f;
  383. else
  384. clr.b = clr.g = clr.r = 0.6f;
  385. pcMat->AddProperty<aiColor3D>(&clr, 1, AI_MATKEY_COLOR_DIFFUSE);
  386. pcMat->AddProperty<aiColor3D>(&clr, 1, AI_MATKEY_COLOR_SPECULAR);
  387. if (name.length()) {
  388. aiString path;
  389. path.Set(name);
  390. pcMat->AddProperty(&path, AI_MATKEY_TEXTURE_DIFFUSE(0));
  391. }
  392. }
  393. }
  394. #endif // !! ASSIMP_BUILD_NO_MDC_IMPORTER