OgreMesh.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. /*
  2. Open Asset Import Library (assimp)
  3. ----------------------------------------------------------------------
  4. Copyright (c) 2006-2012, assimp 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 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 "AssimpPCH.h"
  34. #ifndef ASSIMP_BUILD_NO_OGRE_IMPORTER
  35. #include "OgreImporter.hpp"
  36. #include "TinyFormatter.h"
  37. using namespace std;
  38. namespace Assimp
  39. {
  40. namespace Ogre
  41. {
  42. void OgreImporter::ReadSubMesh(SubMesh &theSubMesh, XmlReader *Reader)
  43. {
  44. if(Reader->getAttributeValue("usesharedvertices"))
  45. theSubMesh.SharedData=GetAttribute<bool>(Reader, "usesharedvertices");
  46. XmlRead(Reader);
  47. //TODO: maybe we have alsways just 1 faces and 1 geometry and always in this order. this loop will only work correct, when the order
  48. //of faces and geometry changed, and not if we have more than one of one
  49. while( Reader->getNodeName()==string("faces")
  50. || Reader->getNodeName()==string("geometry")
  51. || Reader->getNodeName()==string("boneassignments"))
  52. {
  53. if(string(Reader->getNodeName())=="faces")//Read the face list
  54. {
  55. //some info logging:
  56. unsigned int NumFaces=GetAttribute<int>(Reader, "count");
  57. ostringstream ss; ss <<"Submesh has " << NumFaces << " Faces.";
  58. DefaultLogger::get()->debug(ss.str());
  59. while(XmlRead(Reader) && Reader->getNodeName()==string("face"))
  60. {
  61. Face NewFace;
  62. NewFace.VertexIndices[0]=GetAttribute<int>(Reader, "v1");
  63. NewFace.VertexIndices[1]=GetAttribute<int>(Reader, "v2");
  64. NewFace.VertexIndices[2]=GetAttribute<int>(Reader, "v3");
  65. if(Reader->getAttributeValue("v4"))//this should be supported in the future
  66. {
  67. DefaultLogger::get()->warn("Submesh has quads, only traingles are supported!");
  68. //throw DeadlyImportError("Submesh has quads, only traingles are supported!");
  69. }
  70. theSubMesh.FaceList.push_back(NewFace);
  71. }
  72. }//end of faces
  73. else if(string(Reader->getNodeName())=="geometry")//Read the vertexdata
  74. {
  75. //some info logging:
  76. unsigned int NumVertices=GetAttribute<int>(Reader, "vertexcount");
  77. ostringstream ss; ss<<"VertexCount: " << NumVertices;
  78. DefaultLogger::get()->debug(ss.str());
  79. //General Informations about vertices
  80. XmlRead(Reader);
  81. while(Reader->getNodeName()==string("vertexbuffer"))
  82. {
  83. ReadVertexBuffer(theSubMesh, Reader, NumVertices);
  84. }
  85. //some error checking on the loaded data
  86. if(!theSubMesh.HasPositions)
  87. throw DeadlyImportError("No positions could be loaded!");
  88. if(theSubMesh.HasNormals && theSubMesh.Normals.size() != NumVertices)
  89. throw DeadlyImportError("Wrong Number of Normals loaded!");
  90. if(theSubMesh.HasTangents && theSubMesh.Tangents.size() != NumVertices)
  91. throw DeadlyImportError("Wrong Number of Tangents loaded!");
  92. for(unsigned int i=0; i<theSubMesh.Uvs.size(); ++i)
  93. {
  94. if(theSubMesh.Uvs[i].size() != NumVertices)
  95. throw DeadlyImportError("Wrong Number of Uvs loaded!");
  96. }
  97. }//end of "geometry
  98. else if(Reader->getNodeName()==string("boneassignments"))
  99. {
  100. ReadBoneWeights(theSubMesh, Reader);
  101. }
  102. }
  103. DefaultLogger::get()->debug((Formatter::format(),
  104. "Positionen: ",theSubMesh.Positions.size(),
  105. " Normale: ",theSubMesh.Normals.size(),
  106. " TexCoords: ",theSubMesh.Uvs.size(),
  107. " Tantents: ",theSubMesh.Tangents.size()
  108. ));
  109. DefaultLogger::get()->warn(Reader->getNodeName());
  110. }
  111. void OgreImporter::ReadVertexBuffer(SubMesh &theSubMesh, XmlReader *Reader, unsigned int NumVertices)
  112. {
  113. DefaultLogger::get()->debug("new Vertex Buffer");
  114. bool ReadPositions=false;
  115. bool ReadNormals=false;
  116. bool ReadTangents=false;
  117. unsigned int NumUvs=0;
  118. //-------------------- check, what we need to read: --------------------------------
  119. if(Reader->getAttributeValue("positions") && GetAttribute<bool>(Reader, "positions"))
  120. {
  121. ReadPositions=theSubMesh.HasPositions=true;
  122. theSubMesh.Positions.reserve(NumVertices);
  123. DefaultLogger::get()->debug("reading positions");
  124. }
  125. if(Reader->getAttributeValue("normals") && GetAttribute<bool>(Reader, "normals"))
  126. {
  127. ReadNormals=theSubMesh.HasNormals=true;
  128. theSubMesh.Normals.reserve(NumVertices);
  129. DefaultLogger::get()->debug("reading normals");
  130. }
  131. if(Reader->getAttributeValue("tangents") && GetAttribute<bool>(Reader, "tangents"))
  132. {
  133. ReadTangents=theSubMesh.HasTangents=true;
  134. theSubMesh.Tangents.reserve(NumVertices);
  135. DefaultLogger::get()->debug("reading tangents");
  136. }
  137. if(Reader->getAttributeValue("texture_coords"))
  138. {
  139. NumUvs=GetAttribute<unsigned int>(Reader, "texture_coords");
  140. theSubMesh.Uvs.resize(NumUvs);
  141. for(unsigned int i=0; i<theSubMesh.Uvs.size(); ++i) theSubMesh.Uvs[i].reserve(NumVertices);
  142. DefaultLogger::get()->debug("reading texture coords");
  143. }
  144. //___________________________________________________________________
  145. //check if we will load anything
  146. if(!( ReadPositions || ReadNormals || ReadTangents || (NumUvs>0) ))
  147. DefaultLogger::get()->warn("vertexbuffer seams to be empty!");
  148. //read all the vertices:
  149. XmlRead(Reader);
  150. /*it might happen, that we have more than one attribute per vertex (they are not splitted to different buffers)
  151. so the break condition is a bit tricky (well, IrrXML just sucks :( )*/
  152. while(Reader->getNodeName()==string("vertex")
  153. ||Reader->getNodeName()==string("position")
  154. ||Reader->getNodeName()==string("normal")
  155. ||Reader->getNodeName()==string("tangent")
  156. ||Reader->getNodeName()==string("texcoord")
  157. ||Reader->getNodeName()==string("colour_diffuse"))
  158. {
  159. if(Reader->getNodeName()==string("vertex"))
  160. XmlRead(Reader);//Read an attribute tag
  161. //Position
  162. if(ReadPositions && Reader->getNodeName()==string("position"))
  163. {
  164. aiVector3D NewPos;
  165. NewPos.x=GetAttribute<float>(Reader, "x");
  166. NewPos.y=GetAttribute<float>(Reader, "y");
  167. NewPos.z=GetAttribute<float>(Reader, "z");
  168. theSubMesh.Positions.push_back(NewPos);
  169. }
  170. //Normal
  171. else if(ReadNormals && Reader->getNodeName()==string("normal"))
  172. {
  173. aiVector3D NewNormal;
  174. NewNormal.x=GetAttribute<float>(Reader, "x");
  175. NewNormal.y=GetAttribute<float>(Reader, "y");
  176. NewNormal.z=GetAttribute<float>(Reader, "z");
  177. theSubMesh.Normals.push_back(NewNormal);
  178. }
  179. //Tangent
  180. else if(ReadTangents && Reader->getNodeName()==string("tangent"))
  181. {
  182. aiVector3D NewTangent;
  183. NewTangent.x=GetAttribute<float>(Reader, "x");
  184. NewTangent.y=GetAttribute<float>(Reader, "y");
  185. NewTangent.z=GetAttribute<float>(Reader, "z");
  186. theSubMesh.Tangents.push_back(NewTangent);
  187. }
  188. //Uv:
  189. else if(NumUvs>0 && Reader->getNodeName()==string("texcoord"))
  190. {
  191. for(unsigned int i=0; i<NumUvs; ++i)
  192. {
  193. if(Reader->getNodeName()!=string("texcoord"))
  194. {
  195. DefaultLogger::get()->warn(string("Not enough UVs in Vertex: ")+Reader->getNodeName());
  196. }
  197. aiVector3D NewUv;
  198. NewUv.x=GetAttribute<float>(Reader, "u");
  199. NewUv.y=GetAttribute<float>(Reader, "v")*(-1)+1;//flip the uv vertikal, blender exports them so!
  200. theSubMesh.Uvs[i].push_back(NewUv);
  201. XmlRead(Reader);
  202. }
  203. continue;//because we already read the next node...
  204. }
  205. //Color:
  206. //TODO: actually save this data!
  207. else if(Reader->getNodeName()==string("colour_diffuse"))
  208. {
  209. //do nothing, because we not yet support them
  210. }
  211. //Attribute could not be read
  212. else
  213. {
  214. DefaultLogger::get()->warn(string("Attribute was not read: ")+Reader->getNodeName());
  215. }
  216. XmlRead(Reader);//Read the Vertex tag
  217. }
  218. }
  219. void OgreImporter::ReadBoneWeights(SubMesh &theSubMesh, XmlReader *Reader)
  220. {
  221. theSubMesh.Weights.resize(theSubMesh.Positions.size());
  222. while(XmlRead(Reader) && Reader->getNodeName()==string("vertexboneassignment"))
  223. {
  224. Weight NewWeight;
  225. unsigned int VertexId=GetAttribute<int>(Reader, "vertexindex");
  226. NewWeight.BoneId=GetAttribute<int>(Reader, "boneindex");
  227. NewWeight.Value=GetAttribute<float>(Reader, "weight");
  228. //calculate the number of bones used (this is the highest id +1 becuase bone ids start at 0)
  229. theSubMesh.BonesUsed=max(theSubMesh.BonesUsed, NewWeight.BoneId+1);
  230. theSubMesh.Weights[VertexId].push_back(NewWeight);
  231. }
  232. }
  233. void OgreImporter::ProcessSubMesh(SubMesh &theSubMesh, SubMesh &theSharedGeometry)
  234. {
  235. //---------------Make all Vertexes unique: (this is required by assimp)-----------------------
  236. vector<Face> UniqueFaceList(theSubMesh.FaceList.size());
  237. unsigned int UniqueVertexCount=theSubMesh.FaceList.size()*3;//*3 because each face consists of 3 vertexes, because we only support triangles^^
  238. vector<aiVector3D> UniquePositions(UniqueVertexCount);
  239. vector<aiVector3D> UniqueNormals(UniqueVertexCount);
  240. vector<aiVector3D> UniqueTangents(UniqueVertexCount);
  241. vector< vector<Weight> > UniqueWeights(UniqueVertexCount);
  242. vector< vector<aiVector3D> > UniqueUvs(theSubMesh.Uvs.size());
  243. for(unsigned int i=0; i<UniqueUvs.size(); ++i) UniqueUvs[i].resize(UniqueVertexCount);
  244. //Support for shared data:
  245. /*We can use this loop to copy vertex informations from the shared data pool. In order to do so
  246. we just use a reference to a submodel instead of our submodel itself*/
  247. SubMesh& VertexSource= theSubMesh.SharedData ? theSharedGeometry : theSubMesh;
  248. if(theSubMesh.SharedData)//copy vertexinformations to our mesh:
  249. {
  250. theSubMesh.HasPositions=theSharedGeometry.HasPositions;
  251. theSubMesh.HasNormals=theSharedGeometry.HasNormals;
  252. theSubMesh.HasTangents=theSharedGeometry.HasTangents;
  253. theSubMesh.BonesUsed=theSharedGeometry.BonesUsed;
  254. UniqueUvs.resize(theSharedGeometry.Uvs.size());
  255. for(unsigned int i=0; i<UniqueUvs.size(); ++i) UniqueUvs[i].resize(UniqueVertexCount);
  256. }
  257. for(unsigned int i=0; i<theSubMesh.FaceList.size(); ++i)
  258. {
  259. //We precalculate the index vlaues her, because we need them in all vertex attributes
  260. unsigned int Vertex1=theSubMesh.FaceList[i].VertexIndices[0];
  261. unsigned int Vertex2=theSubMesh.FaceList[i].VertexIndices[1];
  262. unsigned int Vertex3=theSubMesh.FaceList[i].VertexIndices[2];
  263. UniquePositions[3*i+0]=VertexSource.Positions[Vertex1];
  264. UniquePositions[3*i+1]=VertexSource.Positions[Vertex2];
  265. UniquePositions[3*i+2]=VertexSource.Positions[Vertex3];
  266. if(VertexSource.HasNormals)
  267. {
  268. UniqueNormals[3*i+0]=VertexSource.Normals[Vertex1];
  269. UniqueNormals[3*i+1]=VertexSource.Normals[Vertex2];
  270. UniqueNormals[3*i+2]=VertexSource.Normals[Vertex3];
  271. }
  272. if(VertexSource.HasTangents)
  273. {
  274. UniqueTangents[3*i+0]=VertexSource.Tangents[Vertex1];
  275. UniqueTangents[3*i+1]=VertexSource.Tangents[Vertex2];
  276. UniqueTangents[3*i+2]=VertexSource.Tangents[Vertex3];
  277. }
  278. if(UniqueUvs.size()>0)
  279. {
  280. for(unsigned int j=0; j<UniqueUvs.size(); ++j)
  281. {
  282. UniqueUvs[j][3*i+0]=VertexSource.Uvs[j][Vertex1];
  283. UniqueUvs[j][3*i+1]=VertexSource.Uvs[j][Vertex2];
  284. UniqueUvs[j][3*i+2]=VertexSource.Uvs[j][Vertex3];
  285. }
  286. }
  287. if(VertexSource.Weights.size() > 0)
  288. {
  289. UniqueWeights[3*i+0]=VertexSource.Weights[Vertex1];
  290. UniqueWeights[3*i+1]=VertexSource.Weights[Vertex2];
  291. UniqueWeights[3*i+2]=VertexSource.Weights[Vertex3];
  292. }
  293. //The indexvalues a just continuous numbers (0, 1, 2, 3, 4, 5, 6...)
  294. UniqueFaceList[i].VertexIndices[0]=3*i+0;
  295. UniqueFaceList[i].VertexIndices[1]=3*i+1;
  296. UniqueFaceList[i].VertexIndices[2]=3*i+2;
  297. }
  298. //_________________________________________________________________________________________
  299. //now we have the unique datas, but want them in the SubMesh, so we swap all the containers:
  300. //if we don't have one of them, we just swap empty containers, so everything is ok
  301. theSubMesh.FaceList.swap(UniqueFaceList);
  302. theSubMesh.Positions.swap(UniquePositions);
  303. theSubMesh.Normals.swap(UniqueNormals);
  304. theSubMesh.Tangents.swap(UniqueTangents);
  305. theSubMesh.Uvs.swap(UniqueUvs);
  306. theSubMesh.Weights.swap(UniqueWeights);
  307. //------------- normalize weights -----------------------------
  308. //The Blender exporter doesn't care about whether the sum of all boneweights for a single vertex equals 1 or not,
  309. //so we have to make this sure:
  310. for(unsigned int VertexId=0; VertexId<theSubMesh.Weights.size(); ++VertexId)//iterate over all vertices
  311. {
  312. float WeightSum=0.0f;
  313. for(unsigned int BoneId=0; BoneId<theSubMesh.Weights[VertexId].size(); ++BoneId)//iterate over all bones
  314. {
  315. WeightSum+=theSubMesh.Weights[VertexId][BoneId].Value;
  316. }
  317. //check if the sum is too far away from 1
  318. if(WeightSum<1.0f-0.05f || WeightSum>1.0f+0.05f)
  319. {
  320. //normalize all weights:
  321. for(unsigned int BoneId=0; BoneId<theSubMesh.Weights[VertexId].size(); ++BoneId)//iterate over all bones
  322. {
  323. theSubMesh.Weights[VertexId][BoneId].Value/=WeightSum;
  324. }
  325. }
  326. }
  327. //_________________________________________________________
  328. }
  329. aiMesh* OgreImporter::CreateAssimpSubMesh(const SubMesh& theSubMesh, const vector<Bone>& Bones) const
  330. {
  331. const aiScene* const m_CurrentScene=this->m_CurrentScene;//make sure, that we can access but not change the scene
  332. (void)m_CurrentScene;
  333. aiMesh* NewAiMesh=new aiMesh();
  334. //Positions
  335. NewAiMesh->mVertices=new aiVector3D[theSubMesh.Positions.size()];
  336. memcpy(NewAiMesh->mVertices, &theSubMesh.Positions[0], theSubMesh.Positions.size()*sizeof(aiVector3D));
  337. NewAiMesh->mNumVertices=theSubMesh.Positions.size();
  338. //Normals
  339. if(theSubMesh.HasNormals)
  340. {
  341. NewAiMesh->mNormals=new aiVector3D[theSubMesh.Normals.size()];
  342. memcpy(NewAiMesh->mNormals, &theSubMesh.Normals[0], theSubMesh.Normals.size()*sizeof(aiVector3D));
  343. }
  344. //until we have support for bitangents, no tangents will be written
  345. /*
  346. //Tangents
  347. if(theSubMesh.HasTangents)
  348. {
  349. NewAiMesh->mTangents=new aiVector3D[theSubMesh.Tangents.size()];
  350. memcpy(NewAiMesh->mTangents, &theSubMesh.Tangents[0], theSubMesh.Tangents.size()*sizeof(aiVector3D));
  351. }
  352. */
  353. //Uvs
  354. if(theSubMesh.Uvs.size()>0)
  355. {
  356. for(unsigned int i=0; i<theSubMesh.Uvs.size(); ++i)
  357. {
  358. NewAiMesh->mNumUVComponents[i]=2;
  359. NewAiMesh->mTextureCoords[i]=new aiVector3D[theSubMesh.Uvs[i].size()];
  360. memcpy(NewAiMesh->mTextureCoords[i], &(theSubMesh.Uvs[i][0]), theSubMesh.Uvs[i].size()*sizeof(aiVector3D));
  361. }
  362. }
  363. //---------------------------------------- Bones --------------------------------------------
  364. //Copy the weights in in Bone-Vertices Struktur
  365. //(we have them in a Vertex-Bones Structur, this is much easier for making them unique, which is required by assimp
  366. vector< vector<aiVertexWeight> > aiWeights(theSubMesh.BonesUsed);//now the outer list are the bones, and the inner vector the vertices
  367. for(unsigned int VertexId=0; VertexId<theSubMesh.Weights.size(); ++VertexId)//iterate over all vertices
  368. {
  369. for(unsigned int BoneId=0; BoneId<theSubMesh.Weights[VertexId].size(); ++BoneId)//iterate over all bones
  370. {
  371. aiVertexWeight NewWeight;
  372. NewWeight.mVertexId=VertexId;//the current Vertex, we can't use the Id form the submehs weights, because they are bone id's
  373. NewWeight.mWeight=theSubMesh.Weights[VertexId][BoneId].Value;
  374. aiWeights[theSubMesh.Weights[VertexId][BoneId].BoneId].push_back(NewWeight);
  375. }
  376. }
  377. vector<aiBone*> aiBones;
  378. aiBones.reserve(theSubMesh.BonesUsed);//the vector might be smaller, because there might be empty bones (bones that are not attached to any vertex)
  379. //create all the bones and fill them with informations
  380. for(unsigned int i=0; i<theSubMesh.BonesUsed; ++i)
  381. {
  382. if(aiWeights[i].size()>0)
  383. {
  384. aiBone* NewBone=new aiBone();
  385. NewBone->mNumWeights=aiWeights[i].size();
  386. NewBone->mWeights=new aiVertexWeight[aiWeights[i].size()];
  387. memcpy(NewBone->mWeights, &(aiWeights[i][0]), sizeof(aiVertexWeight)*aiWeights[i].size());
  388. NewBone->mName=Bones[i].Name;//The bone list should be sorted after its id's, this was done in LoadSkeleton
  389. NewBone->mOffsetMatrix=Bones[i].BoneToWorldSpace;
  390. aiBones.push_back(NewBone);
  391. }
  392. }
  393. NewAiMesh->mNumBones=aiBones.size();
  394. // mBones must be NULL if mNumBones is non 0 or the validation fails.
  395. if (aiBones.size()) {
  396. NewAiMesh->mBones=new aiBone* [aiBones.size()];
  397. memcpy(NewAiMesh->mBones, &(aiBones[0]), aiBones.size()*sizeof(aiBone*));
  398. }
  399. //______________________________________________________________________________________________________
  400. //Faces
  401. NewAiMesh->mFaces=new aiFace[theSubMesh.FaceList.size()];
  402. for(unsigned int i=0; i<theSubMesh.FaceList.size(); ++i)
  403. {
  404. NewAiMesh->mFaces[i].mNumIndices=3;
  405. NewAiMesh->mFaces[i].mIndices=new unsigned int[3];
  406. NewAiMesh->mFaces[i].mIndices[0]=theSubMesh.FaceList[i].VertexIndices[0];
  407. NewAiMesh->mFaces[i].mIndices[1]=theSubMesh.FaceList[i].VertexIndices[1];
  408. NewAiMesh->mFaces[i].mIndices[2]=theSubMesh.FaceList[i].VertexIndices[2];
  409. }
  410. NewAiMesh->mNumFaces=theSubMesh.FaceList.size();
  411. //Link the material:
  412. NewAiMesh->mMaterialIndex=theSubMesh.MaterialIndex;//the index is set by the function who called ReadSubMesh
  413. return NewAiMesh;
  414. }
  415. }//namespace Ogre
  416. }//namespace Assimp
  417. #endif // !! ASSIMP_BUILD_NO_OGRE_IMPORTER