MaterialSystem.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. /*
  2. Open Asset Import Library (ASSIMP)
  3. ----------------------------------------------------------------------
  4. Copyright (c) 2006-2008, ASSIMP Development Team
  5. All rights reserved.
  6. Redistribution and use of this software in source and binary forms,
  7. with or without modification, are permitted provided that the
  8. following conditions are met:
  9. * Redistributions of source code must retain the above
  10. copyright notice, this list of conditions and the
  11. following disclaimer.
  12. * Redistributions in binary form must reproduce the above
  13. copyright notice, this list of conditions and the
  14. following disclaimer in the documentation and/or other
  15. materials provided with the distribution.
  16. * Neither the name of the ASSIMP team, nor the names of its
  17. contributors may be used to endorse or promote products
  18. derived from this software without specific prior
  19. written permission of the ASSIMP Development Team.
  20. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  23. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  24. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  25. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  26. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. ----------------------------------------------------------------------
  32. */
  33. #include "MaterialSystem.h"
  34. #include "StringComparison.h"
  35. #include "../include/aiMaterial.h"
  36. #include "../include/aiAssert.h"
  37. using namespace Assimp;
  38. // ------------------------------------------------------------------------------------------------
  39. aiReturn aiGetMaterialProperty(const aiMaterial* pMat,
  40. const char* pKey,
  41. const aiMaterialProperty** pPropOut)
  42. {
  43. ai_assert (pMat != NULL);
  44. ai_assert (pKey != NULL);
  45. ai_assert (pPropOut != NULL);
  46. for (unsigned int i = 0; i < pMat->mNumProperties;++i)
  47. {
  48. if (NULL != pMat->mProperties[i])
  49. {
  50. if (0 == ASSIMP_stricmp( pMat->mProperties[i]->mKey->data, pKey ))
  51. {
  52. *pPropOut = pMat->mProperties[i];
  53. return AI_SUCCESS;
  54. }
  55. }
  56. }
  57. *pPropOut = NULL;
  58. return AI_FAILURE;
  59. }
  60. // ------------------------------------------------------------------------------------------------
  61. aiReturn aiGetMaterialFloatArray(const aiMaterial* pMat,
  62. const char* pKey,
  63. float* pOut,
  64. unsigned int* pMax)
  65. {
  66. ai_assert (pMat != NULL);
  67. ai_assert (pKey != NULL);
  68. ai_assert (pOut != NULL);
  69. for (unsigned int i = 0; i < pMat->mNumProperties;++i)
  70. {
  71. if (NULL != pMat->mProperties[i])
  72. {
  73. if (0 == ASSIMP_stricmp( pMat->mProperties[i]->mKey->data, pKey ))
  74. {
  75. // data is given in floats, simply copy it
  76. if( aiPTI_Float == pMat->mProperties[i]->mType ||
  77. aiPTI_Buffer == pMat->mProperties[i]->mType)
  78. {
  79. unsigned int iWrite = pMat->mProperties[i]->
  80. mDataLength / sizeof(float);
  81. if (NULL != pMax)
  82. iWrite = *pMax < iWrite ? *pMax : iWrite;
  83. memcpy (pOut, pMat->mProperties[i]->mData, iWrite * sizeof (float));
  84. if (NULL != pMax)
  85. *pMax = iWrite;
  86. }
  87. // data is given in ints, convert to float
  88. else if( aiPTI_Integer == pMat->mProperties[i]->mType)
  89. {
  90. unsigned int iWrite = pMat->mProperties[i]->
  91. mDataLength / sizeof(int);
  92. if (NULL != pMax)
  93. iWrite = *pMax < iWrite ? *pMax : iWrite;
  94. for (unsigned int a = 0; a < iWrite;++a)
  95. {
  96. pOut[a] = (float) ((int*)pMat->mProperties[i]->mData)[a];
  97. }
  98. if (NULL != pMax)
  99. *pMax = iWrite;
  100. }
  101. // it is a string ... no way to read something out of this
  102. else
  103. {
  104. if (NULL != pMax)
  105. *pMax = 0;
  106. return AI_FAILURE;
  107. }
  108. return AI_SUCCESS;
  109. }
  110. }
  111. }
  112. return AI_FAILURE;
  113. }
  114. // ------------------------------------------------------------------------------------------------
  115. aiReturn aiGetMaterialIntegerArray(const aiMaterial* pMat,
  116. const char* pKey,
  117. int* pOut,
  118. unsigned int* pMax)
  119. {
  120. ai_assert (pMat != NULL);
  121. ai_assert (pKey != NULL);
  122. ai_assert (pOut != NULL);
  123. for (unsigned int i = 0; i < pMat->mNumProperties;++i)
  124. {
  125. if (NULL != pMat->mProperties[i])
  126. {
  127. if (0 == ASSIMP_stricmp( pMat->mProperties[i]->mKey->data, pKey ))
  128. {
  129. // data is given in ints, simply copy it
  130. if( aiPTI_Integer == pMat->mProperties[i]->mType ||
  131. aiPTI_Buffer == pMat->mProperties[i]->mType)
  132. {
  133. unsigned int iWrite = pMat->mProperties[i]->
  134. mDataLength / sizeof(int);
  135. if (NULL != pMax)
  136. iWrite = *pMax < iWrite ? *pMax : iWrite;
  137. memcpy (pOut, pMat->mProperties[i]->mData, iWrite * sizeof (int));
  138. if (NULL != pMax)
  139. *pMax = iWrite;
  140. }
  141. // data is given in floats convert to int (lossy!)
  142. else if( aiPTI_Float == pMat->mProperties[i]->mType)
  143. {
  144. unsigned int iWrite = pMat->mProperties[i]->
  145. mDataLength / sizeof(float);
  146. if (NULL != pMax)
  147. iWrite = *pMax < iWrite ? *pMax : iWrite;
  148. for (unsigned int a = 0; a < iWrite;++a)
  149. {
  150. pOut[a] = (int) ((float*)pMat->mProperties[i]->mData)[a];
  151. }
  152. if (NULL != pMax)
  153. *pMax = iWrite;
  154. }
  155. // it is a string ... no way to read something out of this
  156. else
  157. {
  158. if (NULL != pMax)
  159. *pMax = 0;
  160. return AI_FAILURE;
  161. }
  162. return AI_SUCCESS;
  163. }
  164. }
  165. }
  166. return AI_FAILURE;
  167. }
  168. // ------------------------------------------------------------------------------------------------
  169. aiReturn aiGetMaterialColor(const aiMaterial* pMat,
  170. const char* pKey,
  171. aiColor4D* pOut)
  172. {
  173. unsigned int iMax = 4;
  174. aiReturn eRet = aiGetMaterialFloatArray(pMat,pKey,(float*)pOut,&iMax);
  175. // if no alpha channel is provided set it to 1.0 by default
  176. if (3 == iMax)pOut->a = 1.0f;
  177. return eRet;
  178. }
  179. // ------------------------------------------------------------------------------------------------
  180. aiReturn aiGetMaterialString(const aiMaterial* pMat,
  181. const char* pKey,
  182. aiString* pOut)
  183. {
  184. ai_assert (pMat != NULL);
  185. ai_assert (pKey != NULL);
  186. ai_assert (pOut != NULL);
  187. for (unsigned int i = 0; i < pMat->mNumProperties;++i)
  188. {
  189. if (NULL != pMat->mProperties[i])
  190. {
  191. if (0 == ASSIMP_stricmp( pMat->mProperties[i]->mKey->data, pKey ))
  192. {
  193. if( aiPTI_String == pMat->mProperties[i]->mType)
  194. {
  195. memcpy (pOut, pMat->mProperties[i]->mData,
  196. sizeof(aiString));
  197. }
  198. // wrong type
  199. else return AI_FAILURE;
  200. return AI_SUCCESS;
  201. }
  202. }
  203. }
  204. return AI_FAILURE;
  205. }
  206. // ------------------------------------------------------------------------------------------------
  207. aiReturn MaterialHelper::RemoveProperty (const char* pKey)
  208. {
  209. ai_assert(NULL != pKey);
  210. for (unsigned int i = 0; i < this->mNumProperties;++i)
  211. {
  212. if (NULL != this->mProperties[i])
  213. {
  214. if (0 == ASSIMP_stricmp( this->mProperties[i]->mKey->data, pKey ))
  215. {
  216. // delete this entry
  217. delete[] this->mProperties[i]->mData;
  218. delete this->mProperties[i];
  219. // collapse the array behind --.
  220. --this->mNumProperties;
  221. for (unsigned int a = i; a < this->mNumProperties;++a)
  222. {
  223. this->mProperties[a] = this->mProperties[a+1];
  224. }
  225. return AI_SUCCESS;
  226. }
  227. }
  228. }
  229. return AI_FAILURE;
  230. }
  231. // ------------------------------------------------------------------------------------------------
  232. aiReturn MaterialHelper::AddBinaryProperty (const void* pInput,
  233. const unsigned int pSizeInBytes,
  234. const char* pKey,
  235. aiPropertyTypeInfo pType)
  236. {
  237. ai_assert (pInput != NULL);
  238. ai_assert (pKey != NULL);
  239. ai_assert (0 != pSizeInBytes);
  240. // first search the list whether there is already an entry
  241. // with this name.
  242. unsigned int iOutIndex = 0xFFFFFFFF;
  243. for (unsigned int i = 0; i < this->mNumProperties;++i)
  244. {
  245. if (NULL != this->mProperties[i])
  246. {
  247. if (0 == ASSIMP_stricmp( this->mProperties[i]->mKey->data, pKey ))
  248. {
  249. // delete this entry
  250. delete[] this->mProperties[i]->mData;
  251. delete this->mProperties[i];
  252. iOutIndex = i;
  253. }
  254. }
  255. }
  256. aiMaterialProperty* pcNew = new aiMaterialProperty();
  257. // fill this
  258. pcNew->mKey = new aiString();
  259. pcNew->mType = pType;
  260. pcNew->mDataLength = pSizeInBytes;
  261. pcNew->mData = new char[pSizeInBytes];
  262. memcpy (pcNew->mData,pInput,pSizeInBytes);
  263. pcNew->mKey->length = strlen(pKey);
  264. ai_assert ( MAXLEN > pcNew->mKey->length);
  265. strcpy( pcNew->mKey->data, pKey );
  266. if (0xFFFFFFFF != iOutIndex)
  267. {
  268. this->mProperties[iOutIndex] = pcNew;
  269. return AI_SUCCESS;
  270. }
  271. // resize the array ... allocate
  272. // storage for 5 other properties
  273. if (this->mNumProperties == this->mNumAllocated)
  274. {
  275. unsigned int iOld = this->mNumAllocated;
  276. this->mNumAllocated += 5;
  277. aiMaterialProperty** ppTemp = new aiMaterialProperty*[this->mNumAllocated];
  278. if (NULL == ppTemp)return AI_OUTOFMEMORY;
  279. memcpy (ppTemp,this->mProperties,iOld * sizeof(void*));
  280. delete[] this->mProperties;
  281. this->mProperties = ppTemp;
  282. }
  283. // push back ...
  284. this->mProperties[this->mNumProperties++] = pcNew;
  285. return AI_SUCCESS;
  286. }
  287. // ------------------------------------------------------------------------------------------------
  288. aiReturn MaterialHelper::AddProperty (const aiString* pInput,
  289. const char* pKey)
  290. {
  291. return this->AddBinaryProperty(pInput,
  292. sizeof(aiString),pKey,aiPTI_String);
  293. }
  294. // ------------------------------------------------------------------------------------------------
  295. void MaterialHelper::CopyPropertyList(MaterialHelper* pcDest,
  296. const MaterialHelper* pcSrc)
  297. {
  298. ai_assert(NULL != pcDest);
  299. ai_assert(NULL != pcSrc);
  300. unsigned int iOldNum = pcDest->mNumProperties;
  301. pcDest->mNumAllocated += pcSrc->mNumAllocated;
  302. pcDest->mNumProperties += pcSrc->mNumProperties;
  303. aiMaterialProperty** pcOld = pcDest->mProperties;
  304. pcDest->mProperties = new aiMaterialProperty*[pcDest->mNumAllocated];
  305. if (pcOld)
  306. {
  307. for (unsigned int i = 0; i < iOldNum;++i)
  308. pcDest->mProperties[i] = pcOld[i];
  309. delete[] pcDest->mProperties;
  310. }
  311. for (unsigned int i = iOldNum; i< pcDest->mNumProperties;++i)
  312. {
  313. pcDest->mProperties[i]->mKey = new aiString(*pcSrc->mProperties[i]->mKey);
  314. pcDest->mProperties[i]->mDataLength = pcSrc->mProperties[i]->mDataLength;
  315. pcDest->mProperties[i]->mType = pcSrc->mProperties[i]->mType;
  316. pcDest->mProperties[i]->mData = new char[pcDest->mProperties[i]->mDataLength];
  317. memcpy(pcDest->mProperties[i]->mData,pcSrc->mProperties[i]->mData,
  318. pcDest->mProperties[i]->mDataLength);
  319. }
  320. return;
  321. }
  322. // ------------------------------------------------------------------------------------------------
  323. // we need this dummy because the compiler would otherwise complain about
  324. // empty, but controlled statements ...
  325. void DummyAssertFunction()
  326. {
  327. ai_assert(false);
  328. }
  329. // ------------------------------------------------------------------------------------------------
  330. aiReturn aiGetMaterialTexture(const aiMaterial* pcMat,
  331. unsigned int iIndex,
  332. unsigned int iTexType,
  333. aiString* szOut,
  334. unsigned int* piUVIndex,
  335. float* pfBlendFactor,
  336. aiTextureOp* peTextureOp,
  337. aiTextureMapMode* peMapMode)
  338. {
  339. ai_assert(NULL != pcMat);
  340. ai_assert(NULL != szOut);
  341. const char* szPathBase;
  342. const char* szUVBase;
  343. const char* szBlendBase;
  344. const char* szOpBase;
  345. const char* aszMapModeBase[3];
  346. switch (iTexType)
  347. {
  348. case AI_TEXTYPE_DIFFUSE:
  349. szPathBase = AI_MATKEY_TEXTURE_DIFFUSE_;
  350. szUVBase = AI_MATKEY_UVWSRC_DIFFUSE_;
  351. szBlendBase = AI_MATKEY_TEXBLEND_DIFFUSE_;
  352. szOpBase = AI_MATKEY_TEXOP_DIFFUSE_;
  353. aszMapModeBase[0] = AI_MATKEY_MAPPINGMODE_U_DIFFUSE_;
  354. aszMapModeBase[1] = AI_MATKEY_MAPPINGMODE_V_DIFFUSE_;
  355. aszMapModeBase[2] = AI_MATKEY_MAPPINGMODE_W_DIFFUSE_;
  356. break;
  357. case AI_TEXTYPE_SPECULAR:
  358. szPathBase = AI_MATKEY_TEXTURE_SPECULAR_;
  359. szUVBase = AI_MATKEY_UVWSRC_SPECULAR_;
  360. szBlendBase = AI_MATKEY_TEXBLEND_SPECULAR_;
  361. szOpBase = AI_MATKEY_TEXOP_SPECULAR_;
  362. aszMapModeBase[0] = AI_MATKEY_MAPPINGMODE_U_SPECULAR_;
  363. aszMapModeBase[1] = AI_MATKEY_MAPPINGMODE_V_SPECULAR_;
  364. aszMapModeBase[2] = AI_MATKEY_MAPPINGMODE_W_SPECULAR_;
  365. break;
  366. case AI_TEXTYPE_AMBIENT:
  367. szPathBase = AI_MATKEY_TEXTURE_AMBIENT_;
  368. szUVBase = AI_MATKEY_UVWSRC_AMBIENT_;
  369. szBlendBase = AI_MATKEY_TEXBLEND_AMBIENT_;
  370. szOpBase = AI_MATKEY_TEXOP_AMBIENT_;
  371. aszMapModeBase[0] = AI_MATKEY_MAPPINGMODE_U_AMBIENT_;
  372. aszMapModeBase[1] = AI_MATKEY_MAPPINGMODE_V_AMBIENT_;
  373. aszMapModeBase[2] = AI_MATKEY_MAPPINGMODE_W_AMBIENT_;
  374. break;
  375. case AI_TEXTYPE_EMISSIVE:
  376. szPathBase = AI_MATKEY_TEXTURE_EMISSIVE_;
  377. szUVBase = AI_MATKEY_UVWSRC_EMISSIVE_;
  378. szBlendBase = AI_MATKEY_TEXBLEND_EMISSIVE_;
  379. szOpBase = AI_MATKEY_TEXOP_EMISSIVE_;
  380. aszMapModeBase[0] = AI_MATKEY_MAPPINGMODE_U_EMISSIVE_;
  381. aszMapModeBase[1] = AI_MATKEY_MAPPINGMODE_V_EMISSIVE_;
  382. aszMapModeBase[2] = AI_MATKEY_MAPPINGMODE_W_EMISSIVE_;
  383. break;
  384. case AI_TEXTYPE_HEIGHT:
  385. szPathBase = AI_MATKEY_TEXTURE_HEIGHT_;
  386. szUVBase = AI_MATKEY_UVWSRC_HEIGHT_;
  387. szBlendBase = AI_MATKEY_TEXBLEND_HEIGHT_;
  388. szOpBase = AI_MATKEY_TEXOP_HEIGHT_;
  389. aszMapModeBase[0] = AI_MATKEY_MAPPINGMODE_U_HEIGHT_;
  390. aszMapModeBase[1] = AI_MATKEY_MAPPINGMODE_V_HEIGHT_;
  391. aszMapModeBase[2] = AI_MATKEY_MAPPINGMODE_W_HEIGHT_;
  392. break;
  393. case AI_TEXTYPE_NORMALS:
  394. szPathBase = AI_MATKEY_TEXTURE_NORMALS_;
  395. szUVBase = AI_MATKEY_UVWSRC_NORMALS_;
  396. szBlendBase = AI_MATKEY_TEXBLEND_NORMALS_;
  397. szOpBase = AI_MATKEY_TEXOP_NORMALS_;
  398. aszMapModeBase[0] = AI_MATKEY_MAPPINGMODE_U_NORMALS_;
  399. aszMapModeBase[1] = AI_MATKEY_MAPPINGMODE_V_NORMALS_;
  400. aszMapModeBase[2] = AI_MATKEY_MAPPINGMODE_W_NORMALS_;
  401. break;
  402. case AI_TEXTYPE_SHININESS:
  403. szPathBase = AI_MATKEY_TEXTURE_SHININESS_;
  404. szUVBase = AI_MATKEY_UVWSRC_SHININESS_;
  405. szBlendBase = AI_MATKEY_TEXBLEND_SHININESS_;
  406. szOpBase = AI_MATKEY_TEXOP_SHININESS_;
  407. aszMapModeBase[0] = AI_MATKEY_MAPPINGMODE_U_SHININESS_;
  408. aszMapModeBase[1] = AI_MATKEY_MAPPINGMODE_V_SHININESS_;
  409. aszMapModeBase[2] = AI_MATKEY_MAPPINGMODE_W_SHININESS_;
  410. break;
  411. case AI_TEXTYPE_OPACITY:
  412. szPathBase = AI_MATKEY_TEXTURE_OPACITY_;
  413. szUVBase = AI_MATKEY_UVWSRC_OPACITY_;
  414. szBlendBase = AI_MATKEY_TEXBLEND_OPACITY_;
  415. szOpBase = AI_MATKEY_TEXOP_OPACITY_;
  416. aszMapModeBase[0] = AI_MATKEY_MAPPINGMODE_U_OPACITY_;
  417. aszMapModeBase[1] = AI_MATKEY_MAPPINGMODE_V_OPACITY_;
  418. aszMapModeBase[2] = AI_MATKEY_MAPPINGMODE_W_OPACITY_;
  419. break;
  420. default: return AI_FAILURE;
  421. };
  422. char szKey[256];
  423. // get the path to the texture
  424. #if _MSC_VER >= 1400
  425. if(0 >= sprintf_s(szKey,"%s[%i]",szPathBase,iIndex))DummyAssertFunction();
  426. #else
  427. if(0 >= sprintf(szKey,"%s[%i]",szPathBase,iIndex))DummyAssertFunction();
  428. #endif
  429. if (AI_SUCCESS != aiGetMaterialString(pcMat,szKey,szOut))
  430. {
  431. return AI_FAILURE;
  432. }
  433. // get the UV index of the texture
  434. if (piUVIndex)
  435. {
  436. int iUV;
  437. #if _MSC_VER >= 1400
  438. if(0 >= sprintf_s(szKey,"%s[%i]",szUVBase,iIndex))DummyAssertFunction();
  439. #else
  440. if(0 >= sprintf(szKey,"%s[%i]",szUVBase,iIndex))DummyAssertFunction();
  441. #endif
  442. if (AI_SUCCESS != aiGetMaterialInteger(pcMat,szKey,&iUV))
  443. iUV = 0;
  444. *piUVIndex = iUV;
  445. }
  446. // get the blend factor of the texture
  447. if (pfBlendFactor)
  448. {
  449. float fBlend;
  450. #if _MSC_VER >= 1400
  451. if(0 >= sprintf_s(szKey,"%s[%i]",szBlendBase,iIndex))DummyAssertFunction();
  452. #else
  453. if(0 >= sprintf(szKey,"%s[%i]",szBlendBase,iIndex))DummyAssertFunction();
  454. #endif
  455. if (AI_SUCCESS != aiGetMaterialFloat(pcMat,szKey,&fBlend))
  456. fBlend = 1.0f;
  457. *pfBlendFactor = fBlend;
  458. }
  459. // get the texture operation of the texture
  460. if (peTextureOp)
  461. {
  462. aiTextureOp op;
  463. #if _MSC_VER >= 1400
  464. if(0 >= sprintf_s(szKey,"%s[%i]",szOpBase,iIndex))DummyAssertFunction();
  465. #else
  466. if(0 >= sprintf(szKey,"%s[%i]",szOpBase,iIndex))DummyAssertFunction();
  467. #endif
  468. if (AI_SUCCESS != aiGetMaterialInteger(pcMat,szKey,(int*)&op))
  469. op = aiTextureOp_Multiply;
  470. *peTextureOp = op;
  471. }
  472. // get the texture mapping modes for the texture
  473. if (peMapMode)
  474. {
  475. aiTextureMapMode eMode;
  476. for (unsigned int q = 0; q < 3;++q)
  477. {
  478. #if _MSC_VER >= 1400
  479. if(0 >= sprintf_s(szKey,"%s[%i]",aszMapModeBase[q],iIndex))DummyAssertFunction();
  480. #else
  481. if(0 >= sprintf(szKey,"%s[%i]",aszMapModeBase[q],iIndex))DummyAssertFunction();
  482. #endif
  483. if (AI_SUCCESS != aiGetMaterialInteger(pcMat,szKey,(int*)&eMode))
  484. {
  485. eMode = aiTextureMapMode_Wrap;
  486. }
  487. peMapMode[q] = eMode;
  488. }
  489. }
  490. return AI_SUCCESS;
  491. }