NFFLoader.cpp 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226
  1. /*
  2. ---------------------------------------------------------------------------
  3. Open Asset Import Library (ASSIMP)
  4. ---------------------------------------------------------------------------
  5. Copyright (c) 2006-2008, ASSIMP Development 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 Development 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 STL importer class */
  35. #include "AssimpPCH.h"
  36. // internal headers
  37. #include "NFFLoader.h"
  38. #include "ParsingUtils.h"
  39. #include "StandardShapes.h"
  40. #include "fast_atof.h"
  41. #include "RemoveComments.h"
  42. using namespace Assimp;
  43. // ------------------------------------------------------------------------------------------------
  44. // Constructor to be privately used by Importer
  45. NFFImporter::NFFImporter()
  46. {
  47. }
  48. // ------------------------------------------------------------------------------------------------
  49. // Destructor, private as well
  50. NFFImporter::~NFFImporter()
  51. {
  52. }
  53. // ------------------------------------------------------------------------------------------------
  54. // Returns whether the class can handle the format of the given file.
  55. bool NFFImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler) const
  56. {
  57. // simple check of file extension is enough for the moment
  58. std::string::size_type pos = pFile.find_last_of('.');
  59. // no file extension - can't read
  60. if( pos == std::string::npos)return false;
  61. std::string extension = pFile.substr( pos);
  62. // extensions: enff and nff
  63. for( std::string::iterator it = extension.begin(); it != extension.end(); ++it)
  64. *it = tolower( *it);
  65. if( extension == ".nff" || extension == ".enff")
  66. return true;
  67. return false;
  68. }
  69. // ------------------------------------------------------------------------------------------------
  70. #define AI_NFF_PARSE_FLOAT(f) \
  71. SkipSpaces(&sz); \
  72. if (!::IsLineEnd(*sz))sz = fast_atof_move(sz, (float&)f);
  73. // ------------------------------------------------------------------------------------------------
  74. #define AI_NFF_PARSE_TRIPLE(v) \
  75. AI_NFF_PARSE_FLOAT(v[0]) \
  76. AI_NFF_PARSE_FLOAT(v[1]) \
  77. AI_NFF_PARSE_FLOAT(v[2])
  78. // ------------------------------------------------------------------------------------------------
  79. #define AI_NFF_PARSE_SHAPE_INFORMATION() \
  80. aiVector3D center, radius(1.0f,std::numeric_limits<float>::quiet_NaN(),std::numeric_limits<float>::quiet_NaN()); \
  81. AI_NFF_PARSE_TRIPLE(center); \
  82. AI_NFF_PARSE_TRIPLE(radius); \
  83. if (is_qnan(radius.z))radius.z = radius.x; \
  84. if (is_qnan(radius.y))radius.y = radius.x; \
  85. currentMesh.radius = radius; \
  86. currentMesh.center = center;
  87. // ------------------------------------------------------------------------------------------------
  88. #define AI_NFF2_GET_NEXT_TOKEN() \
  89. do \
  90. { \
  91. if (!GetNextLine(buffer,line)) \
  92. {DefaultLogger::get()->warn("NFF2: Unexpected EOF, can't read next token");break;} \
  93. SkipSpaces(line,&sz); \
  94. } \
  95. while(IsLineEnd(*sz))
  96. // ------------------------------------------------------------------------------------------------
  97. // Loads the materail table for the NFF2 file format from an external file
  98. void NFFImporter::LoadNFF2MaterialTable(std::vector<ShadingInfo>& output,
  99. const std::string& path, IOSystem* pIOHandler)
  100. {
  101. boost::scoped_ptr<IOStream> file( pIOHandler->Open( path, "rb"));
  102. // Check whether we can read from the file
  103. if( !file.get())
  104. {
  105. DefaultLogger::get()->error("NFF2: Unable to open material library " + path + ".");
  106. return;
  107. }
  108. // get the size of the file
  109. const unsigned int m = (unsigned int)file->FileSize();
  110. // allocate storage and copy the contents of the file to a memory buffer
  111. // (terminate it with zero)
  112. std::vector<char> mBuffer2(m+1);
  113. file->Read(&mBuffer2[0],m,1);
  114. const char* buffer = &mBuffer2[0];
  115. mBuffer2[m] = '\0';
  116. // First of all: remove all comments from the file
  117. CommentRemover::RemoveLineComments("//",&mBuffer2[0]);
  118. // The file should start with the magic sequence "mat"
  119. if (!TokenMatch(buffer,"mat",3))
  120. {
  121. DefaultLogger::get()->error("NFF2: Not a valid material library " + path + ".");
  122. return;
  123. }
  124. ShadingInfo* curShader = NULL;
  125. // No read the file line per line
  126. char line[4096];
  127. const char* sz;
  128. while (GetNextLine(buffer,line))
  129. {
  130. SkipSpaces(line,&sz);
  131. // 'version' defines the version of the file format
  132. if (TokenMatch(sz,"version",7))
  133. {
  134. DefaultLogger::get()->info("NFF (Sense8) material library file format: " + std::string(sz));
  135. }
  136. // 'matdef' starts a new material in the file
  137. else if (TokenMatch(sz,"matdef",6))
  138. {
  139. // add a new material to the list
  140. output.push_back( ShadingInfo() );
  141. curShader = & output.back();
  142. // parse the name of the material
  143. }
  144. else if (!TokenMatch(sz,"valid",5))
  145. {
  146. // check whether we have an active material at the moment
  147. if (!IsLineEnd(*sz))
  148. {
  149. if (!curShader)
  150. {
  151. DefaultLogger::get()->error(std::string("NFF2 material library: Found element ") +
  152. sz + "but there is no active material");
  153. continue;
  154. }
  155. }
  156. else continue;
  157. // now read the material property and determine its type
  158. aiColor3D c;
  159. if (TokenMatch(sz,"ambient",7))
  160. {
  161. AI_NFF_PARSE_TRIPLE(c);
  162. curShader->ambient = c;
  163. }
  164. else if (TokenMatch(sz,"diffuse",7) || TokenMatch(sz,"ambientdiffuse",14) /* correct? */)
  165. {
  166. AI_NFF_PARSE_TRIPLE(c);
  167. curShader->diffuse = c;
  168. }
  169. else if (TokenMatch(sz,"specular",8))
  170. {
  171. AI_NFF_PARSE_TRIPLE(c);
  172. curShader->specular = c;
  173. }
  174. else if (TokenMatch(sz,"emission",8))
  175. {
  176. AI_NFF_PARSE_TRIPLE(c);
  177. curShader->emissive = c;
  178. }
  179. else if (TokenMatch(sz,"shininess",9))
  180. {
  181. AI_NFF_PARSE_FLOAT(curShader->shininess);
  182. }
  183. else if (TokenMatch(sz,"opacity",7))
  184. {
  185. AI_NFF_PARSE_FLOAT(curShader->opacity);
  186. }
  187. }
  188. }
  189. }
  190. // ------------------------------------------------------------------------------------------------
  191. // Imports the given file into the given scene structure.
  192. void NFFImporter::InternReadFile( const std::string& pFile,
  193. aiScene* pScene, IOSystem* pIOHandler)
  194. {
  195. boost::scoped_ptr<IOStream> file( pIOHandler->Open( pFile, "rb"));
  196. // Check whether we can read from the file
  197. if( !file.get())
  198. throw new ImportErrorException( "Failed to open NFF file " + pFile + ".");
  199. unsigned int m = (unsigned int)file->FileSize();
  200. // allocate storage and copy the contents of the file to a memory buffer
  201. // (terminate it with zero)
  202. std::vector<char> mBuffer2(m+1);
  203. file->Read(&mBuffer2[0],m,1);
  204. const char* buffer = &mBuffer2[0];
  205. mBuffer2[m] = '\0';
  206. // mesh arrays - separate here to make the handling of
  207. // the pointers below easier.
  208. std::vector<MeshInfo> meshes;
  209. std::vector<MeshInfo> meshesWithNormals;
  210. std::vector<MeshInfo> meshesWithUVCoords;
  211. std::vector<MeshInfo> meshesLocked;
  212. char line[4096];
  213. const char* sz;
  214. // camera parameters
  215. aiVector3D camPos, camUp(0.f,1.f,0.f), camLookAt(0.f,0.f,1.f);
  216. float angle = 45.f;
  217. aiVector2D resolution;
  218. bool hasCam = false;
  219. MeshInfo* currentMeshWithNormals = NULL;
  220. MeshInfo* currentMesh = NULL;
  221. MeshInfo* currentMeshWithUVCoords = NULL;
  222. ShadingInfo s; // current material info
  223. // degree of tesselation
  224. unsigned int iTesselation = 4;
  225. // some temporary variables we need to parse the file
  226. unsigned int sphere = 0,
  227. cylinder = 0,
  228. cone = 0,
  229. numNamed = 0,
  230. dodecahedron = 0,
  231. octahedron = 0,
  232. tetrahedron = 0,
  233. hexahedron = 0;
  234. // lights imported from the file
  235. std::vector<Light> lights;
  236. // check whether this is the NFF2 file format
  237. if (TokenMatch(buffer,"nff",3))
  238. {
  239. const float qnan = std::numeric_limits<float>::quiet_NaN();
  240. const aiColor4D cQNAN = aiColor4D (qnan,0.f,0.f,1.f);
  241. const aiVector3D vQNAN = aiVector3D(qnan,0.f,0.f);
  242. // another NFF file format ... just a raw parser has been implemented
  243. // no support for further details, I don't think it is worth the effort
  244. // http://ozviz.wasp.uwa.edu.au/~pbourke/dataformats/nff/nff2.html
  245. // http://www.netghost.narod.ru/gff/graphics/summary/sense8.htm
  246. // First of all: remove all comments from the file
  247. CommentRemover::RemoveLineComments("//",&mBuffer2[0]);
  248. while (GetNextLine(buffer,line))
  249. {
  250. SkipSpaces(line,&sz);
  251. if (TokenMatch(sz,"version",7))
  252. {
  253. DefaultLogger::get()->info("NFF (Sense8) file format: " + std::string(sz));
  254. }
  255. else if (TokenMatch(sz,"viewpos",7))
  256. {
  257. AI_NFF_PARSE_TRIPLE(camPos);
  258. hasCam = true;
  259. }
  260. else if (TokenMatch(sz,"viewdir",7))
  261. {
  262. AI_NFF_PARSE_TRIPLE(camLookAt);
  263. hasCam = true;
  264. }
  265. // This starts a new object section
  266. else if (!IsSpaceOrNewLine(*sz))
  267. {
  268. unsigned int subMeshIdx = 0;
  269. // read the name of the object, skip all spaces
  270. // at the end of it.
  271. const char* sz3 = sz;
  272. while (!IsSpaceOrNewLine(*sz))++sz;
  273. std::string objectName = std::string(sz3,(unsigned int)(sz-sz3));
  274. const unsigned int objStart = (unsigned int)meshes.size();
  275. // There could be a material table in a separate file
  276. std::vector<ShadingInfo> materialTable;
  277. while (true)
  278. {
  279. AI_NFF2_GET_NEXT_TOKEN();
  280. // material table - an external file
  281. if (TokenMatch(sz,"mtable",6))
  282. {
  283. SkipSpaces(&sz);
  284. sz3 = sz;
  285. while (!IsSpaceOrNewLine(*sz))++sz;
  286. const unsigned int diff = (unsigned int)(sz-sz3);
  287. if (!diff)DefaultLogger::get()->warn("NFF2: Found empty mtable token");
  288. else
  289. {
  290. // The material table has the file extension .mat.
  291. // If it is not there, we need to append it
  292. std::string path = std::string(sz3,diff);
  293. if(std::string::npos == path.find_last_of(".mat"))
  294. {
  295. path.append(".mat");
  296. }
  297. // Now extract the working directory from the path to
  298. // this file and append the material library filename
  299. // to it.
  300. std::string::size_type s;
  301. if ((std::string::npos == (s = path.find_last_of('\\')) || !s) &&
  302. (std::string::npos == (s = path.find_last_of('/')) || !s) )
  303. {
  304. s = pFile.find_last_of('\\');
  305. if (std::string::npos == s)s = pFile.find_last_of('/');
  306. if (std::string::npos != s)
  307. {
  308. path = pFile.substr(0,s+1) + path;
  309. }
  310. }
  311. LoadNFF2MaterialTable(materialTable,path,pIOHandler);
  312. }
  313. }
  314. else break;
  315. }
  316. // read the numbr of vertices
  317. unsigned int num = ::strtol10(sz,&sz);
  318. // temporary storage
  319. std::vector<aiColor4D> tempColors;
  320. std::vector<aiVector3D> tempPositions,tempTextureCoords,tempNormals;
  321. bool hasNormals = false,hasUVs = false,hasColor = false;
  322. tempPositions.reserve (num);
  323. tempColors.reserve (num);
  324. tempNormals.reserve (num);
  325. tempTextureCoords.reserve (num);
  326. for (unsigned int i = 0; i < num; ++i)
  327. {
  328. AI_NFF2_GET_NEXT_TOKEN();
  329. aiVector3D v;
  330. AI_NFF_PARSE_TRIPLE(v);
  331. tempPositions.push_back(v);
  332. // parse all other attributes in the line
  333. while (true)
  334. {
  335. SkipSpaces(&sz);
  336. if (IsLineEnd(*sz))break;
  337. // color definition
  338. if (TokenMatch(sz,"0x",2))
  339. {
  340. hasColor = true;
  341. register unsigned int numIdx = ::strtol16(sz,&sz);
  342. aiColor4D clr;
  343. clr.a = 1.f;
  344. // 0xRRGGBB
  345. clr.r = ((numIdx >> 16u) & 0xff) / 255.f;
  346. clr.g = ((numIdx >> 8u) & 0xff) / 255.f;
  347. clr.b = ((numIdx) & 0xff) / 255.f;
  348. tempColors.push_back(clr);
  349. }
  350. // normal vector
  351. else if (TokenMatch(sz,"norm",4))
  352. {
  353. hasNormals = true;
  354. AI_NFF_PARSE_TRIPLE(v);
  355. tempNormals.push_back(v);
  356. }
  357. // UV coordinate
  358. else if (TokenMatch(sz,"uv",2))
  359. {
  360. hasUVs = true;
  361. AI_NFF_PARSE_FLOAT(v.x);
  362. AI_NFF_PARSE_FLOAT(v.y);
  363. v.z = 0.f;
  364. tempTextureCoords.push_back(v);
  365. }
  366. }
  367. // fill in dummies for all attributes that have not been set
  368. if (tempNormals.size() != tempPositions.size())
  369. tempNormals.push_back(vQNAN);
  370. if (tempTextureCoords.size() != tempPositions.size())
  371. tempTextureCoords.push_back(vQNAN);
  372. if (tempColors.size() != tempPositions.size())
  373. tempColors.push_back(cQNAN);
  374. }
  375. AI_NFF2_GET_NEXT_TOKEN();
  376. if (!num)throw new ImportErrorException("NFF2: There are zero vertices");
  377. num = ::strtol10(sz,&sz);
  378. std::vector<unsigned int> tempIdx;
  379. tempIdx.reserve(10);
  380. for (unsigned int i = 0; i < num; ++i)
  381. {
  382. AI_NFF2_GET_NEXT_TOKEN();
  383. SkipSpaces(line,&sz);
  384. unsigned int numIdx = ::strtol10(sz,&sz);
  385. // read all faces indices
  386. if (numIdx)
  387. {
  388. // mesh.faces.push_back(numIdx);
  389. // tempIdx.erase(tempIdx.begin(),tempIdx.end());
  390. tempIdx.resize(numIdx);
  391. for (unsigned int a = 0; a < numIdx;++a)
  392. {
  393. SkipSpaces(sz,&sz);
  394. m = ::strtol10(sz,&sz);
  395. if (m >= (unsigned int)tempPositions.size())
  396. {
  397. DefaultLogger::get()->error("NFF2: Vertex index overflow");
  398. m= 0;
  399. }
  400. // mesh.vertices.push_back (tempPositions[idx]);
  401. tempIdx[a] = m;
  402. }
  403. }
  404. // build a temporary shader object for the face.
  405. ShadingInfo shader;
  406. unsigned int matIdx = 0;
  407. // white material color - we have vertex colors
  408. shader.color = aiColor3D(1.f,1.f,1.f);
  409. aiColor4D c = aiColor4D(1.f,1.f,1.f,1.f);
  410. while (true)
  411. {
  412. SkipSpaces(sz,&sz);
  413. if(IsLineEnd(*sz))break;
  414. // per-polygon colors
  415. if (TokenMatch(sz,"0x",2))
  416. {
  417. hasColor = true;
  418. const char* sz2 = sz;
  419. numIdx = ::strtol16(sz,&sz);
  420. const unsigned int diff = (unsigned int)(sz-sz2);
  421. // 0xRRGGBB
  422. if (diff > 3)
  423. {
  424. c.r = ((numIdx >> 16u) & 0xff) / 255.f;
  425. c.g = ((numIdx >> 8u) & 0xff) / 255.f;
  426. c.b = ((numIdx) & 0xff) / 255.f;
  427. }
  428. // 0xRGB
  429. else
  430. {
  431. c.r = ((numIdx >> 8u) & 0xf) / 16.f;
  432. c.g = ((numIdx >> 4u) & 0xf) / 16.f;
  433. c.b = ((numIdx) & 0xf) / 16.f;
  434. }
  435. }
  436. // TODO - implement texture mapping here
  437. #if 0
  438. // mirror vertex texture coordinate?
  439. else if (TokenMatch(sz,"mirror",6))
  440. {
  441. }
  442. // texture coordinate scaling
  443. else if (TokenMatch(sz,"scale",5))
  444. {
  445. }
  446. // texture coordinate translation
  447. else if (TokenMatch(sz,"trans",5))
  448. {
  449. }
  450. // texture coordinate rotation angle
  451. else if (TokenMatch(sz,"rot",3))
  452. {
  453. }
  454. #endif
  455. // texture file name for this polygon + mapping information
  456. else if ('_' == sz[0])
  457. {
  458. // get mapping information
  459. switch (sz[1])
  460. {
  461. case 'v':
  462. case 'V':
  463. shader.shaded = false;
  464. break;
  465. case 't':
  466. case 'T':
  467. case 'u':
  468. case 'U':
  469. DefaultLogger::get()->warn("Unsupported NFF2 texture attribute: trans");
  470. };
  471. if (!sz[1] || '_' != sz[2])
  472. {
  473. DefaultLogger::get()->warn("NFF2: Expected underscore after texture attributes");
  474. continue;
  475. }
  476. const char* sz2 = sz+3;
  477. while (!IsSpaceOrNewLine( *sz ))++sz;
  478. const unsigned int diff = (unsigned int)(sz-sz2);
  479. if (diff)shader.texFile = std::string(sz2,diff);
  480. }
  481. // Two-sided material?
  482. else if (TokenMatch(sz,"both",4))
  483. {
  484. shader.twoSided = true;
  485. }
  486. // Material ID?
  487. else if (!materialTable.empty() && TokenMatch(sz,"matid",5))
  488. {
  489. SkipSpaces(&sz);
  490. matIdx = ::strtol10(sz,&sz);
  491. if (matIdx >= materialTable.size())
  492. {
  493. DefaultLogger::get()->error("NFF2: Material index overflow.");
  494. matIdx = 0;
  495. }
  496. // now combine our current shader with the shader we
  497. // read from the material table.
  498. ShadingInfo& mat = materialTable[matIdx];
  499. shader.ambient = mat.ambient;
  500. shader.diffuse = mat.diffuse;
  501. shader.emissive = mat.emissive;
  502. shader.opacity = mat.opacity;
  503. shader.specular = mat.specular;
  504. shader.shininess = mat.shininess;
  505. }
  506. else SkipToken(sz);
  507. }
  508. // search the list of all shaders we have for this object whether
  509. // there is an identical one. In this case, we append our mesh
  510. // data to it.
  511. MeshInfo* mesh = NULL;
  512. for (std::vector<MeshInfo>::iterator it = meshes.begin() + objStart, end = meshes.end();
  513. it != end; ++it)
  514. {
  515. if ((*it).shader == shader && (*it).matIndex == matIdx)
  516. {
  517. // we have one, we can append our data to it
  518. mesh = &(*it);
  519. }
  520. }
  521. if (!mesh)
  522. {
  523. meshes.push_back(MeshInfo(PatchType_Simple,false));
  524. mesh = &meshes.back();
  525. mesh->matIndex = matIdx;
  526. // We need to add a new mesh to the list. We assign
  527. // an unique name to it to make sure the scene will
  528. // pass the validation step for the moment.
  529. // TODO: fix naming of objects in the scenegraph later
  530. if (objectName.length())
  531. {
  532. ::strcpy(mesh->name,objectName.c_str());
  533. itoa10(&mesh->name[objectName.length()],30,subMeshIdx++);
  534. }
  535. // copy the shader to the mesh.
  536. mesh->shader = shader;
  537. }
  538. // fill the mesh with data
  539. if (!tempIdx.empty())
  540. {
  541. mesh->faces.push_back((unsigned int)tempIdx.size());
  542. for (std::vector<unsigned int>::const_iterator it = tempIdx.begin(), end = tempIdx.end();
  543. it != end;++it)
  544. {
  545. m = *it;
  546. // copy colors -vertex color specifications override polygon color specifications
  547. if (hasColor)
  548. {
  549. const aiColor4D& clr = tempColors[m];
  550. mesh->colors.push_back((is_qnan( clr.r ) ? c : clr));
  551. }
  552. // positions should always be there
  553. mesh->vertices.push_back (tempPositions[m]);
  554. // copy normal vectors
  555. if (hasNormals)
  556. mesh->normals.push_back (tempNormals[m]);
  557. // copy texture coordinates
  558. if (hasUVs)
  559. mesh->uvs.push_back (tempTextureCoords[m]);
  560. }
  561. }
  562. }
  563. if (!num)throw new ImportErrorException("NFF2: There are zero faces");
  564. }
  565. }
  566. camLookAt = camLookAt + camPos;
  567. }
  568. else // "Normal" Neutral file format that is quite more common
  569. {
  570. while (GetNextLine(buffer,line))
  571. {
  572. sz = line;
  573. if ('p' == line[0] || TokenMatch(sz,"tpp",3))
  574. {
  575. MeshInfo* out = NULL;
  576. // 'tpp' - texture polygon patch primitive
  577. if ('t' == line[0])
  578. {
  579. if (meshesWithUVCoords.empty())
  580. {
  581. meshesWithUVCoords.push_back(MeshInfo(PatchType_UVAndNormals));
  582. currentMeshWithUVCoords = &meshesWithUVCoords.back();
  583. }
  584. out = currentMeshWithUVCoords;
  585. }
  586. // 'pp' - polygon patch primitive
  587. else if ('p' == line[1])
  588. {
  589. if (meshesWithNormals.empty())
  590. {
  591. meshesWithNormals.push_back(MeshInfo(PatchType_Normals));
  592. currentMeshWithNormals = &meshesWithNormals.back();
  593. }
  594. sz = &line[2];out = currentMeshWithNormals;
  595. }
  596. // 'p' - polygon primitive
  597. else
  598. {
  599. if (meshes.empty())
  600. {
  601. meshes.push_back(MeshInfo(PatchType_Simple));
  602. currentMesh = &meshes.back();
  603. }
  604. sz = &line[1];out = currentMesh;
  605. }
  606. SkipSpaces(sz,&sz);
  607. m = strtol10(sz);
  608. // ---- flip the face order
  609. out->vertices.resize(out->vertices.size()+m);
  610. if (out != currentMesh)
  611. {
  612. out->normals.resize(out->vertices.size());
  613. }
  614. if (out == currentMeshWithUVCoords)
  615. {
  616. out->uvs.resize(out->vertices.size());
  617. }
  618. for (unsigned int n = 0; n < m;++n)
  619. {
  620. if(!GetNextLine(buffer,line))
  621. {
  622. DefaultLogger::get()->error("NFF: Unexpected EOF was encountered");
  623. continue;
  624. }
  625. aiVector3D v; sz = &line[0];
  626. AI_NFF_PARSE_TRIPLE(v);
  627. out->vertices[out->vertices.size()-n-1] = v;
  628. if (out != currentMesh)
  629. {
  630. AI_NFF_PARSE_TRIPLE(v);
  631. out->normals[out->vertices.size()-n-1] = v;
  632. }
  633. if (out == currentMeshWithUVCoords)
  634. {
  635. // FIX: in one test file this wraps over multiple lines
  636. SkipSpaces(&sz);
  637. if (IsLineEnd(*sz))
  638. {
  639. GetNextLine(buffer,line);
  640. sz = line;
  641. }
  642. AI_NFF_PARSE_FLOAT(v.x);
  643. SkipSpaces(&sz);
  644. if (IsLineEnd(*sz))
  645. {
  646. GetNextLine(buffer,line);
  647. sz = line;
  648. }
  649. AI_NFF_PARSE_FLOAT(v.y);
  650. v.y = 1.f - v.y;
  651. out->uvs[out->vertices.size()-n-1] = v;
  652. }
  653. }
  654. out->faces.push_back(m);
  655. }
  656. // 'f' - shading information block
  657. else if (TokenMatch(sz,"f",1))
  658. {
  659. float d;
  660. // read the RGB colors
  661. AI_NFF_PARSE_TRIPLE(s.color);
  662. // read the other properties
  663. AI_NFF_PARSE_FLOAT(s.diffuse.r);
  664. AI_NFF_PARSE_FLOAT(s.specular.r);
  665. AI_NFF_PARSE_FLOAT(d); // skip shininess and transmittance
  666. AI_NFF_PARSE_FLOAT(d);
  667. AI_NFF_PARSE_FLOAT(s.refracti);
  668. // NFF2 uses full colors here so we need to use them too
  669. // although NFF uses simple scaling factors
  670. s.diffuse.g = s.diffuse.b = s.diffuse.r;
  671. s.specular.g = s.specular.b = s.specular.r;
  672. // if the next one is NOT a number we assume it is a texture file name
  673. // this feature is used by some NFF files on the internet and it has
  674. // been implemented as it can be really useful
  675. SkipSpaces(&sz);
  676. if (!IsNumeric(*sz))
  677. {
  678. // TODO: Support full file names with spaces and quotation marks ...
  679. const char* p = sz;
  680. while (!IsSpaceOrNewLine( *sz ))++sz;
  681. unsigned int diff = (unsigned int)(sz-p);
  682. if (diff)
  683. {
  684. s.texFile = std::string(p,diff);
  685. }
  686. }
  687. else
  688. {
  689. AI_NFF_PARSE_FLOAT(s.ambient); // optional
  690. }
  691. // check whether we have this material already -
  692. // although we have the RRM-Step, this is necessary here.
  693. // otherwise we would generate hundreds of small meshes
  694. // with just a few faces - this is surely never wanted.
  695. currentMesh = currentMeshWithNormals = currentMeshWithUVCoords = NULL;
  696. for (std::vector<MeshInfo>::iterator it = meshes.begin(), end = meshes.end();
  697. it != end;++it)
  698. {
  699. if ((*it).bLocked)continue;
  700. if ((*it).shader == s)
  701. {
  702. switch ((*it).pType)
  703. {
  704. case PatchType_Normals:
  705. currentMeshWithNormals = &(*it);
  706. break;
  707. case PatchType_Simple:
  708. currentMesh = &(*it);
  709. break;
  710. default:
  711. currentMeshWithUVCoords = &(*it);
  712. break;
  713. };
  714. }
  715. }
  716. if (!currentMesh)
  717. {
  718. meshes.push_back(MeshInfo(PatchType_Simple));
  719. currentMesh = &meshes.back();
  720. currentMesh->shader = s;
  721. }
  722. if (!currentMeshWithNormals)
  723. {
  724. meshesWithNormals.push_back(MeshInfo(PatchType_Normals));
  725. currentMeshWithNormals = &meshesWithNormals.back();
  726. currentMeshWithNormals->shader = s;
  727. }
  728. if (!currentMeshWithUVCoords)
  729. {
  730. meshesWithUVCoords.push_back(MeshInfo(PatchType_UVAndNormals));
  731. currentMeshWithUVCoords = &meshesWithUVCoords.back();
  732. currentMeshWithUVCoords->shader = s;
  733. }
  734. }
  735. // 'l' - light source
  736. else if (TokenMatch(sz,"l",1))
  737. {
  738. lights.push_back(Light());
  739. Light& light = lights.back();
  740. AI_NFF_PARSE_TRIPLE(light.position);
  741. AI_NFF_PARSE_FLOAT (light.intensity);
  742. AI_NFF_PARSE_TRIPLE(light.color);
  743. }
  744. // 's' - sphere
  745. else if (TokenMatch(sz,"s",1))
  746. {
  747. meshesLocked.push_back(MeshInfo(PatchType_Simple,true));
  748. MeshInfo& currentMesh = meshesLocked.back();
  749. currentMesh.shader = s;
  750. AI_NFF_PARSE_SHAPE_INFORMATION();
  751. // we don't need scaling or translation here - we do it in the node's transform
  752. StandardShapes::MakeSphere(iTesselation, currentMesh.vertices);
  753. currentMesh.faces.resize(currentMesh.vertices.size()/3,3);
  754. // generate a name for the mesh
  755. ::sprintf(currentMesh.name,"sphere_%i",sphere++);
  756. }
  757. // 'dod' - dodecahedron
  758. else if (TokenMatch(sz,"dod",3))
  759. {
  760. meshesLocked.push_back(MeshInfo(PatchType_Simple,true));
  761. MeshInfo& currentMesh = meshesLocked.back();
  762. currentMesh.shader = s;
  763. AI_NFF_PARSE_SHAPE_INFORMATION();
  764. // we don't need scaling or translation here - we do it in the node's transform
  765. StandardShapes::MakeDodecahedron(currentMesh.vertices);
  766. currentMesh.faces.resize(currentMesh.vertices.size()/3,3);
  767. // generate a name for the mesh
  768. ::sprintf(currentMesh.name,"dodecahedron_%i",dodecahedron++);
  769. }
  770. // 'oct' - octahedron
  771. else if (TokenMatch(sz,"oct",3))
  772. {
  773. meshesLocked.push_back(MeshInfo(PatchType_Simple,true));
  774. MeshInfo& currentMesh = meshesLocked.back();
  775. currentMesh.shader = s;
  776. AI_NFF_PARSE_SHAPE_INFORMATION();
  777. // we don't need scaling or translation here - we do it in the node's transform
  778. StandardShapes::MakeOctahedron(currentMesh.vertices);
  779. currentMesh.faces.resize(currentMesh.vertices.size()/3,3);
  780. // generate a name for the mesh
  781. ::sprintf(currentMesh.name,"octahedron_%i",octahedron++);
  782. }
  783. // 'tet' - tetrahedron
  784. else if (TokenMatch(sz,"tet",3))
  785. {
  786. meshesLocked.push_back(MeshInfo(PatchType_Simple,true));
  787. MeshInfo& currentMesh = meshesLocked.back();
  788. currentMesh.shader = s;
  789. AI_NFF_PARSE_SHAPE_INFORMATION();
  790. // we don't need scaling or translation here - we do it in the node's transform
  791. StandardShapes::MakeTetrahedron(currentMesh.vertices);
  792. currentMesh.faces.resize(currentMesh.vertices.size()/3,3);
  793. // generate a name for the mesh
  794. ::sprintf(currentMesh.name,"tetrahedron_%i",tetrahedron++);
  795. }
  796. // 'hex' - hexahedron
  797. else if (TokenMatch(sz,"hex",3))
  798. {
  799. meshesLocked.push_back(MeshInfo(PatchType_Simple,true));
  800. MeshInfo& currentMesh = meshesLocked.back();
  801. currentMesh.shader = s;
  802. AI_NFF_PARSE_SHAPE_INFORMATION();
  803. // we don't need scaling or translation here - we do it in the node's transform
  804. StandardShapes::MakeHexahedron(currentMesh.vertices);
  805. currentMesh.faces.resize(currentMesh.vertices.size()/3,3);
  806. // generate a name for the mesh
  807. ::sprintf(currentMesh.name,"hexahedron_%i",hexahedron++);
  808. }
  809. // 'c' - cone
  810. else if (TokenMatch(sz,"c",1))
  811. {
  812. meshesLocked.push_back(MeshInfo(PatchType_Simple,true));
  813. MeshInfo& currentMesh = meshes.back();
  814. currentMesh.shader = s;
  815. aiVector3D center1, center2; float radius1, radius2;
  816. AI_NFF_PARSE_TRIPLE(center1);
  817. AI_NFF_PARSE_FLOAT(radius1);
  818. AI_NFF_PARSE_TRIPLE(center2);
  819. AI_NFF_PARSE_FLOAT(radius2);
  820. // compute the center point of the cone/cylinder
  821. center2 = (center2-center1)/2.f;
  822. currentMesh.center = center1+center2;
  823. center1 = -center2;
  824. // generate the cone - it consists of simple triangles
  825. StandardShapes::MakeCone(center1, radius1, center2, radius2, iTesselation, currentMesh.vertices);
  826. currentMesh.faces.resize(currentMesh.vertices.size()/3,3);
  827. // generate a name for the mesh
  828. if (radius1 != radius2)
  829. ::sprintf(currentMesh.name,"cone_%i",cone++);
  830. else ::sprintf(currentMesh.name,"cylinder_%i",cylinder++);
  831. }
  832. // 'tess' - tesselation
  833. else if (TokenMatch(sz,"tess",4))
  834. {
  835. SkipSpaces(&sz);
  836. iTesselation = strtol10(sz);
  837. }
  838. // 'from' - camera position
  839. else if (TokenMatch(sz,"from",4))
  840. {
  841. AI_NFF_PARSE_TRIPLE(camPos);
  842. hasCam = true;
  843. }
  844. // 'at' - camera look-at vector
  845. else if (TokenMatch(sz,"at",2))
  846. {
  847. AI_NFF_PARSE_TRIPLE(camLookAt);
  848. hasCam = true;
  849. }
  850. // 'up' - camera up vector
  851. else if (TokenMatch(sz,"up",2))
  852. {
  853. AI_NFF_PARSE_TRIPLE(camUp);
  854. hasCam = true;
  855. }
  856. // 'angle' - (half?) camera field of view
  857. else if (TokenMatch(sz,"angle",5))
  858. {
  859. AI_NFF_PARSE_FLOAT(angle);
  860. hasCam = true;
  861. }
  862. // 'resolution' - used to compute the screen aspect
  863. else if (TokenMatch(sz,"resolution",10))
  864. {
  865. AI_NFF_PARSE_FLOAT(resolution.x);
  866. AI_NFF_PARSE_FLOAT(resolution.y);
  867. hasCam = true;
  868. }
  869. // 'pb' - bezier patch. Not supported yet
  870. else if (TokenMatch(sz,"pb",2))
  871. {
  872. DefaultLogger::get()->error("NFF: Encountered unsupported ID: bezier patch");
  873. }
  874. // 'pn' - NURBS. Not supported yet
  875. else if (TokenMatch(sz,"pn",2) || TokenMatch(sz,"pnn",3))
  876. {
  877. DefaultLogger::get()->error("NFF: Encountered unsupported ID: NURBS");
  878. }
  879. // '' - comment
  880. else if ('#' == line[0])
  881. {
  882. const char* sz;SkipSpaces(&line[1],&sz);
  883. if (!IsLineEnd(*sz))DefaultLogger::get()->info(sz);
  884. }
  885. }
  886. }
  887. // copy all arrays into one large
  888. meshes.reserve (meshes.size()+meshesLocked.size()+meshesWithNormals.size()+meshesWithUVCoords.size());
  889. meshes.insert (meshes.end(),meshesLocked.begin(),meshesLocked.end());
  890. meshes.insert (meshes.end(),meshesWithNormals.begin(),meshesWithNormals.end());
  891. meshes.insert (meshes.end(),meshesWithUVCoords.begin(),meshesWithUVCoords.end());
  892. // now generate output meshes. first find out how many meshes we'll need
  893. std::vector<MeshInfo>::const_iterator it = meshes.begin(), end = meshes.end();
  894. for (;it != end;++it)
  895. {
  896. if (!(*it).faces.empty())
  897. {
  898. ++pScene->mNumMeshes;
  899. if ((*it).name[0])++numNamed;
  900. }
  901. }
  902. // generate a dummy root node - assign all unnamed elements such
  903. // as polygons and polygon patches to the root node and generate
  904. // sub nodes for named objects such as spheres and cones.
  905. aiNode* const root = new aiNode();
  906. root->mName.Set("<NFF_Root>");
  907. root->mNumChildren = numNamed + (hasCam ? 1 : 0) + (unsigned int) lights.size();
  908. root->mNumMeshes = pScene->mNumMeshes-numNamed;
  909. aiNode** ppcChildren;
  910. unsigned int* pMeshes;
  911. if (root->mNumMeshes)
  912. pMeshes = root->mMeshes = new unsigned int[root->mNumMeshes];
  913. if (root->mNumChildren)
  914. ppcChildren = root->mChildren = new aiNode*[root->mNumChildren];
  915. // generate the camera
  916. if (hasCam)
  917. {
  918. aiNode* nd = *ppcChildren = new aiNode();
  919. nd->mName.Set("<NFF_Camera>");
  920. nd->mParent = root;
  921. // allocate the camera in the scene
  922. pScene->mNumCameras = 1;
  923. pScene->mCameras = new aiCamera*[1];
  924. aiCamera* c = pScene->mCameras[0] = new aiCamera;
  925. c->mName = nd->mName; // make sure the names are identical
  926. c->mHorizontalFOV = AI_DEG_TO_RAD( angle );
  927. c->mLookAt = camLookAt - camPos;
  928. c->mPosition = camPos;
  929. c->mUp = camUp;
  930. // If the resolution is not specified in the file we
  931. // need to set 1.0 as aspect. The division would become
  932. // INF otherwise.
  933. c->mAspect = (!resolution.y ? 0.f : resolution.x / resolution.y);
  934. ++ppcChildren;
  935. }
  936. // generate light sources
  937. if (!lights.empty())
  938. {
  939. pScene->mNumLights = (unsigned int)lights.size();
  940. pScene->mLights = new aiLight*[pScene->mNumLights];
  941. for (unsigned int i = 0; i < pScene->mNumLights;++i,++ppcChildren)
  942. {
  943. const Light& l = lights[i];
  944. aiNode* nd = *ppcChildren = new aiNode();
  945. nd->mParent = root;
  946. nd->mName.length = ::sprintf(nd->mName.data,"<NFF_Light%i>",i);
  947. // allocate the light in the scene data structure
  948. aiLight* out = pScene->mLights[i] = new aiLight();
  949. out->mName = nd->mName; // make sure the names are identical
  950. out->mType = aiLightSource_POINT;
  951. out->mColorDiffuse = out->mColorSpecular = l.color * l.intensity;
  952. out->mPosition = l.position;
  953. }
  954. }
  955. if (!pScene->mNumMeshes)throw new ImportErrorException("NFF: No meshes loaded");
  956. pScene->mMeshes = new aiMesh*[pScene->mNumMeshes];
  957. pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials = pScene->mNumMeshes];
  958. for (it = meshes.begin(), m = 0; it != end;++it)
  959. {
  960. if ((*it).faces.empty())continue;
  961. const MeshInfo& src = *it;
  962. aiMesh* const mesh = pScene->mMeshes[m] = new aiMesh();
  963. mesh->mNumVertices = (unsigned int)src.vertices.size();
  964. mesh->mNumFaces = (unsigned int)src.faces.size();
  965. // Generate sub nodes for named meshes
  966. if (src.name[0])
  967. {
  968. aiNode* const node = *ppcChildren = new aiNode();
  969. node->mParent = root;
  970. node->mNumMeshes = 1;
  971. node->mMeshes = new unsigned int[1];
  972. node->mMeshes[0] = m;
  973. node->mName.Set(src.name);
  974. // setup the transformation matrix of the node
  975. node->mTransformation.a4 = src.center.x;
  976. node->mTransformation.b4 = src.center.y;
  977. node->mTransformation.c4 = src.center.z;
  978. node->mTransformation.a1 = src.radius.x;
  979. node->mTransformation.b2 = src.radius.y;
  980. node->mTransformation.c3 = src.radius.z;
  981. ++ppcChildren;
  982. }
  983. else *pMeshes++ = m;
  984. // copy vertex positions
  985. mesh->mVertices = new aiVector3D[mesh->mNumVertices];
  986. ::memcpy(mesh->mVertices,&src.vertices[0],
  987. sizeof(aiVector3D)*mesh->mNumVertices);
  988. // NFF2: there could be vertex colors
  989. if (!src.colors.empty())
  990. {
  991. ai_assert(src.colors.size() == src.vertices.size());
  992. // copy vertex colors
  993. mesh->mColors[0] = new aiColor4D[mesh->mNumVertices];
  994. ::memcpy(mesh->mColors[0],&src.colors[0],
  995. sizeof(aiColor4D)*mesh->mNumVertices);
  996. }
  997. if (!src.normals.empty())
  998. {
  999. ai_assert(src.normals.size() == src.vertices.size());
  1000. // copy normal vectors
  1001. mesh->mNormals = new aiVector3D[mesh->mNumVertices];
  1002. ::memcpy(mesh->mNormals,&src.normals[0],
  1003. sizeof(aiVector3D)*mesh->mNumVertices);
  1004. }
  1005. if (!src.uvs.empty())
  1006. {
  1007. ai_assert(src.uvs.size() == src.vertices.size());
  1008. // copy texture coordinates
  1009. mesh->mTextureCoords[0] = new aiVector3D[mesh->mNumVertices];
  1010. ::memcpy(mesh->mTextureCoords[0],&src.uvs[0],
  1011. sizeof(aiVector3D)*mesh->mNumVertices);
  1012. }
  1013. // generate faces
  1014. unsigned int p = 0;
  1015. aiFace* pFace = mesh->mFaces = new aiFace[mesh->mNumFaces];
  1016. for (std::vector<unsigned int>::const_iterator it2 = src.faces.begin(),
  1017. end2 = src.faces.end();
  1018. it2 != end2;++it2,++pFace)
  1019. {
  1020. pFace->mIndices = new unsigned int [ pFace->mNumIndices = *it2 ];
  1021. for (unsigned int o = 0; o < pFace->mNumIndices;++o)
  1022. pFace->mIndices[o] = p++;
  1023. }
  1024. // generate a material for the mesh
  1025. MaterialHelper* pcMat = (MaterialHelper*)(pScene->mMaterials[m] = new MaterialHelper());
  1026. mesh->mMaterialIndex = m++;
  1027. aiString s;
  1028. s.Set(AI_DEFAULT_MATERIAL_NAME);
  1029. pcMat->AddProperty(&s, AI_MATKEY_NAME);
  1030. aiColor3D c = src.shader.color * src.shader.diffuse;
  1031. pcMat->AddProperty(&c,1,AI_MATKEY_COLOR_DIFFUSE);
  1032. c = src.shader.color * src.shader.specular;
  1033. pcMat->AddProperty(&c,1,AI_MATKEY_COLOR_SPECULAR);
  1034. // NFF2 - default values for NFF
  1035. pcMat->AddProperty(&src.shader.ambient, 1,AI_MATKEY_COLOR_AMBIENT);
  1036. pcMat->AddProperty(&src.shader.emissive,1,AI_MATKEY_COLOR_EMISSIVE);
  1037. pcMat->AddProperty(&src.shader.opacity, 1,AI_MATKEY_OPACITY);
  1038. // setup the first texture layer, if existing
  1039. if (src.shader.texFile.length())
  1040. {
  1041. s.Set(src.shader.texFile);
  1042. pcMat->AddProperty(&s,AI_MATKEY_TEXTURE_DIFFUSE(0));
  1043. }
  1044. // setup the name of the material
  1045. if (src.shader.name.length())
  1046. {
  1047. s.Set(src.shader.texFile);
  1048. pcMat->AddProperty(&s,AI_MATKEY_NAME);
  1049. }
  1050. // setup some more material properties that are specific to NFF2
  1051. int i;
  1052. if (src.shader.twoSided)
  1053. {
  1054. i = 1;
  1055. pcMat->AddProperty(&i,1,AI_MATKEY_TWOSIDED);
  1056. }
  1057. i = (src.shader.shaded ? aiShadingMode_Gouraud : aiShadingMode_NoShading);
  1058. if (src.shader.shininess)
  1059. {
  1060. i = aiShadingMode_Phong;
  1061. pcMat->AddProperty(&src.shader.shininess,1,AI_MATKEY_SHININESS);
  1062. }
  1063. pcMat->AddProperty(&i,1,AI_MATKEY_SHADING_MODEL);
  1064. }
  1065. pScene->mRootNode = root;
  1066. }