B3DImporter.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  1. /*
  2. ---------------------------------------------------------------------------
  3. Open Asset Import Library (ASSIMP)
  4. ---------------------------------------------------------------------------
  5. Copyright (c) 2006-2010, 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 B3DImporter.cpp
  35. * @brief Implementation of the b3d importer class
  36. */
  37. #include "AssimpPCH.h"
  38. #ifndef ASSIMP_BUILD_NO_B3D_IMPORTER
  39. // internal headers
  40. #include "B3DImporter.h"
  41. #include "TextureTransform.h"
  42. #include "ConvertToLHProcess.h"
  43. using namespace Assimp;
  44. using namespace std;
  45. // (fixme, Aramis) quick workaround to get rid of all those signed to unsigned warnings
  46. #ifdef _MSC_VER
  47. # pragma warning (disable: 4018)
  48. #endif
  49. //#define DEBUG_B3D
  50. // ------------------------------------------------------------------------------------------------
  51. bool B3DImporter::CanRead( const std::string& pFile, IOSystem* /*pIOHandler*/, bool /*checkSig*/) const{
  52. size_t pos=pFile.find_last_of( '.' );
  53. if( pos==string::npos ) return false;
  54. string ext=pFile.substr( pos+1 );
  55. if( ext.size()!=3 ) return false;
  56. return (ext[0]=='b' || ext[0]=='B') && (ext[1]=='3') && (ext[2]=='d' || ext[2]=='D');
  57. }
  58. // ------------------------------------------------------------------------------------------------
  59. void B3DImporter::GetExtensionList( std::set<std::string>& extensions ){
  60. extensions.insert("b3d");
  61. }
  62. #ifdef DEBUG_B3D
  63. extern "C"{ void _stdcall AllocConsole(); }
  64. #endif
  65. // ------------------------------------------------------------------------------------------------
  66. void B3DImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler){
  67. #ifdef DEBUG_B3D
  68. AllocConsole();
  69. freopen( "conin$","r",stdin );
  70. freopen( "conout$","w",stdout );
  71. freopen( "conout$","w",stderr );
  72. cout<<"Hello world from the B3DImporter!"<<endl;
  73. #endif
  74. boost::scoped_ptr<IOStream> file( pIOHandler->Open( pFile));
  75. // Check whether we can read from the file
  76. if( file.get() == NULL)
  77. throw DeadlyImportError( "Failed to open B3D file " + pFile + ".");
  78. // check whether the .b3d file is large enough to contain
  79. // at least one chunk.
  80. size_t fileSize = file->FileSize();
  81. if( fileSize<8 ) throw DeadlyImportError( "B3D File is too small.");
  82. _pos=0;
  83. _buf.resize( fileSize );
  84. file->Read( &_buf[0],1,fileSize );
  85. _stack.clear();
  86. ReadBB3D( pScene );
  87. }
  88. // ------------------------------------------------------------------------------------------------
  89. void B3DImporter::Oops(){
  90. throw DeadlyImportError( "B3D Importer - INTERNAL ERROR" );
  91. }
  92. // ------------------------------------------------------------------------------------------------
  93. void B3DImporter::Fail( string str ){
  94. #ifdef DEBUG_B3D
  95. cout<<"Error in B3D file data: "<<str<<endl;
  96. #endif
  97. throw DeadlyImportError( "B3D Importer - error in B3D file data: "+str );
  98. }
  99. // ------------------------------------------------------------------------------------------------
  100. int B3DImporter::ReadByte(){
  101. if( _pos<_buf.size() ) return _buf[_pos++];
  102. Fail( "EOF" );
  103. return 0;
  104. }
  105. // ------------------------------------------------------------------------------------------------
  106. int B3DImporter::ReadInt(){
  107. if( _pos+4<=_buf.size() ){
  108. int n=*(int*)&_buf[_pos];
  109. _pos+=4;
  110. return n;
  111. }
  112. Fail( "EOF" );
  113. return 0;
  114. }
  115. // ------------------------------------------------------------------------------------------------
  116. float B3DImporter::ReadFloat(){
  117. if( _pos+4<=_buf.size() ){
  118. float n=*(float*)&_buf[_pos];
  119. _pos+=4;
  120. return n;
  121. }
  122. Fail( "EOF" );
  123. return 0.0f;
  124. }
  125. // ------------------------------------------------------------------------------------------------
  126. aiVector2D B3DImporter::ReadVec2(){
  127. float x=ReadFloat();
  128. float y=ReadFloat();
  129. return aiVector2D( x,y );
  130. }
  131. // ------------------------------------------------------------------------------------------------
  132. aiVector3D B3DImporter::ReadVec3(){
  133. float x=ReadFloat();
  134. float y=ReadFloat();
  135. float z=ReadFloat();
  136. return aiVector3D( x,y,z );
  137. }
  138. // ------------------------------------------------------------------------------------------------
  139. aiQuaternion B3DImporter::ReadQuat(){
  140. // (aramis_acg) Fix to adapt the loader to changed quat orientation
  141. float w=-ReadFloat();
  142. float x=ReadFloat();
  143. float y=ReadFloat();
  144. float z=ReadFloat();
  145. return aiQuaternion( w,x,y,z );
  146. }
  147. // ------------------------------------------------------------------------------------------------
  148. string B3DImporter::ReadString(){
  149. string str;
  150. while( _pos<_buf.size() ){
  151. char c=(char)ReadByte();
  152. if( !c ) return str;
  153. str+=c;
  154. }
  155. Fail( "EOF" );
  156. return string();
  157. }
  158. // ------------------------------------------------------------------------------------------------
  159. string B3DImporter::ReadChunk(){
  160. string tag;
  161. for( int i=0;i<4;++i ){
  162. tag+=char( ReadByte() );
  163. }
  164. #ifdef DEBUG_B3D
  165. // cout<<"ReadChunk:"<<tag<<endl;
  166. #endif
  167. unsigned sz=(unsigned)ReadInt();
  168. _stack.push_back( _pos+sz );
  169. return tag;
  170. }
  171. // ------------------------------------------------------------------------------------------------
  172. void B3DImporter::ExitChunk(){
  173. _pos=_stack.back();
  174. _stack.pop_back();
  175. }
  176. // ------------------------------------------------------------------------------------------------
  177. unsigned B3DImporter::ChunkSize(){
  178. return _stack.back()-_pos;
  179. }
  180. // ------------------------------------------------------------------------------------------------
  181. template<class T>
  182. T *B3DImporter::to_array( const vector<T> &v ){
  183. if( !v.size() ) return 0;
  184. T *p=new T[v.size()];
  185. for( size_t i=0;i<v.size();++i ){
  186. p[i]=v[i];
  187. }
  188. return p;
  189. }
  190. // ------------------------------------------------------------------------------------------------
  191. void B3DImporter::ReadTEXS(){
  192. while( ChunkSize() ){
  193. string name=ReadString();
  194. /*int flags=*/ReadInt();
  195. /*int blend=*/ReadInt();
  196. /*aiVector2D pos=*/ReadVec2();
  197. /*aiVector2D scale=*/ReadVec2();
  198. /*float rot=*/ReadFloat();
  199. _textures.push_back( name );
  200. }
  201. }
  202. // ------------------------------------------------------------------------------------------------
  203. void B3DImporter::ReadBRUS(){
  204. int n_texs=ReadInt();
  205. if( n_texs<0 || n_texs>8 ){
  206. Fail( "Bad texture count" );
  207. }
  208. while( ChunkSize() ){
  209. string name=ReadString();
  210. aiVector3D color=ReadVec3();
  211. float alpha=ReadFloat();
  212. float shiny=ReadFloat();
  213. /*int blend=**/ReadInt();
  214. int fx=ReadInt();
  215. MaterialHelper *mat=new MaterialHelper;
  216. _materials.push_back( mat );
  217. // Name
  218. aiString ainame( name );
  219. mat->AddProperty( &ainame,AI_MATKEY_NAME );
  220. // Diffuse color
  221. mat->AddProperty( &color,1,AI_MATKEY_COLOR_DIFFUSE );
  222. // Opacity
  223. mat->AddProperty( &alpha,1,AI_MATKEY_OPACITY );
  224. // Specular color
  225. aiColor3D speccolor( shiny,shiny,shiny );
  226. mat->AddProperty( &speccolor,1,AI_MATKEY_COLOR_SPECULAR );
  227. // Specular power
  228. float specpow=shiny*128;
  229. mat->AddProperty( &specpow,1,AI_MATKEY_SHININESS );
  230. // Double sided
  231. if( fx & 0x10 ){
  232. int i=1;
  233. mat->AddProperty( &i,1,AI_MATKEY_TWOSIDED );
  234. }
  235. //Textures
  236. for( int i=0;i<n_texs;++i ){
  237. int texid=ReadInt();
  238. if( texid<-1 || (texid>=0 && texid>=static_cast<int>(_textures.size())) ){
  239. Fail( "Bad texture id" );
  240. }
  241. if( i==0 && texid>=0 ){
  242. aiString texname( _textures[texid] );
  243. mat->AddProperty( &texname,AI_MATKEY_TEXTURE_DIFFUSE(0) );
  244. }
  245. }
  246. }
  247. }
  248. // ------------------------------------------------------------------------------------------------
  249. void B3DImporter::ReadVRTS(){
  250. _vflags=ReadInt();
  251. _tcsets=ReadInt();
  252. _tcsize=ReadInt();
  253. if( _tcsets<0 || _tcsets>4 || _tcsize<0 || _tcsize>4 ){
  254. Fail( "Bad texcoord data" );
  255. }
  256. int sz=12+(_vflags&1?12:0)+(_vflags&2?16:0)+(_tcsets*_tcsize*4);
  257. int n_verts=ChunkSize()/sz;
  258. int v0=_vertices.size();
  259. _vertices.resize( v0+n_verts );
  260. for( int i=0;i<n_verts;++i ){
  261. Vertex &v=_vertices[v0+i];
  262. memset( v.bones,0,sizeof(v.bones) );
  263. memset( v.weights,0,sizeof(v.weights) );
  264. v.vertex=ReadVec3();
  265. if( _vflags & 1 ) v.normal=ReadVec3();
  266. if( _vflags & 2 ) ReadQuat(); //skip v 4bytes...
  267. for( int i=0;i<_tcsets;++i ){
  268. float t[4]={0,0,0,0};
  269. for( int j=0;j<_tcsize;++j ){
  270. t[j]=ReadFloat();
  271. }
  272. t[1]=1-t[1];
  273. if( !i ) v.texcoords=aiVector3D( t[0],t[1],t[2] );
  274. }
  275. }
  276. }
  277. // ------------------------------------------------------------------------------------------------
  278. void B3DImporter::ReadTRIS( int v0 ){
  279. int matid=ReadInt();
  280. if( matid==-1 ){
  281. matid=0;
  282. }else if( matid<0 || matid>=(int)_materials.size() ){
  283. #ifdef DEBUG_B3D
  284. cout<<"material id="<<matid<<endl;
  285. #endif
  286. Fail( "Bad material id" );
  287. }
  288. aiMesh *mesh=new aiMesh;
  289. _meshes.push_back( mesh );
  290. mesh->mMaterialIndex=matid;
  291. mesh->mNumFaces=0;
  292. mesh->mPrimitiveTypes=aiPrimitiveType_TRIANGLE;
  293. int n_tris=ChunkSize()/12;
  294. aiFace *face=mesh->mFaces=new aiFace[n_tris];
  295. for( int i=0;i<n_tris;++i ){
  296. int i0=ReadInt()+v0;
  297. int i1=ReadInt()+v0;
  298. int i2=ReadInt()+v0;
  299. if( i0<0 || i0>=(int)_vertices.size() || i1<0 || i1>=(int)_vertices.size() || i2<0 || i2>=(int)_vertices.size() ){
  300. #ifdef DEBUG_B3D
  301. cout<<"Bad triangle index: i0="<<i0<<", i1="<<i1<<", i2="<<i2<<endl;
  302. #endif
  303. Fail( "Bad triangle index" );
  304. continue;
  305. }
  306. face->mNumIndices=3;
  307. face->mIndices=new unsigned[3];
  308. face->mIndices[0]=i0;
  309. face->mIndices[1]=i1;
  310. face->mIndices[2]=i2;
  311. ++mesh->mNumFaces;
  312. ++face;
  313. }
  314. }
  315. // ------------------------------------------------------------------------------------------------
  316. void B3DImporter::ReadMESH(){
  317. /*int matid=*/ReadInt();
  318. int v0=_vertices.size();
  319. while( ChunkSize() ){
  320. string t=ReadChunk();
  321. if( t=="VRTS" ){
  322. ReadVRTS();
  323. }else if( t=="TRIS" ){
  324. ReadTRIS( v0 );
  325. }
  326. ExitChunk();
  327. }
  328. }
  329. // ------------------------------------------------------------------------------------------------
  330. void B3DImporter::ReadBONE( int id ){
  331. while( ChunkSize() ){
  332. int vertex=ReadInt();
  333. float weight=ReadFloat();
  334. if( vertex<0 || vertex>=(int)_vertices.size() ){
  335. Fail( "Bad vertex index" );
  336. }
  337. Vertex &v=_vertices[vertex];
  338. int i;
  339. for( i=0;i<4;++i ){
  340. if( !v.weights[i] ){
  341. v.bones[i]=id;
  342. v.weights[i]=weight;
  343. break;
  344. }
  345. }
  346. #ifdef DEBUG_B3D
  347. if( i==4 ){
  348. cout<<"Too many bone weights"<<endl;
  349. }
  350. #endif
  351. }
  352. }
  353. // ------------------------------------------------------------------------------------------------
  354. void B3DImporter::ReadKEYS( aiNodeAnim *nodeAnim ){
  355. vector<aiVectorKey> trans,scale;
  356. vector<aiQuatKey> rot;
  357. int flags=ReadInt();
  358. while( ChunkSize() ){
  359. int frame=ReadInt();
  360. if( flags & 1 ){
  361. trans.push_back( aiVectorKey( frame,ReadVec3() ) );
  362. }
  363. if( flags & 2 ){
  364. scale.push_back( aiVectorKey( frame,ReadVec3() ) );
  365. }
  366. if( flags & 4 ){
  367. rot.push_back( aiQuatKey( frame,ReadQuat() ) );
  368. }
  369. }
  370. if( flags & 1 ){
  371. nodeAnim->mNumPositionKeys=trans.size();
  372. nodeAnim->mPositionKeys=to_array( trans );
  373. }
  374. if( flags & 2 ){
  375. nodeAnim->mNumScalingKeys=scale.size();
  376. nodeAnim->mScalingKeys=to_array( scale );
  377. }
  378. if( flags & 4 ){
  379. nodeAnim->mNumRotationKeys=rot.size();
  380. nodeAnim->mRotationKeys=to_array( rot );
  381. }
  382. }
  383. // ------------------------------------------------------------------------------------------------
  384. void B3DImporter::ReadANIM(){
  385. /*int flags=*/ReadInt();
  386. int frames=ReadInt();
  387. float fps=ReadFloat();
  388. aiAnimation *anim=new aiAnimation;
  389. _animations.push_back( anim );
  390. anim->mDuration=frames;
  391. anim->mTicksPerSecond=fps;
  392. }
  393. // ------------------------------------------------------------------------------------------------
  394. aiNode *B3DImporter::ReadNODE( aiNode *parent ){
  395. string name=ReadString();
  396. aiVector3D t=ReadVec3();
  397. aiVector3D s=ReadVec3();
  398. aiQuaternion r=ReadQuat();
  399. aiMatrix4x4 trans,scale,rot;
  400. aiMatrix4x4::Translation( t,trans );
  401. aiMatrix4x4::Scaling( s,scale );
  402. rot=aiMatrix4x4( r.GetMatrix() );
  403. aiMatrix4x4 tform=trans * rot * scale;
  404. int nodeid=_nodes.size();
  405. aiNode *node=new aiNode( name );
  406. _nodes.push_back( node );
  407. node->mParent=parent;
  408. node->mTransformation=tform;
  409. aiNodeAnim *nodeAnim=0;
  410. vector<unsigned> meshes;
  411. vector<aiNode*> children;
  412. while( ChunkSize() ){
  413. string t=ReadChunk();
  414. if( t=="MESH" ){
  415. int n=_meshes.size();
  416. ReadMESH();
  417. for( int i=n;i<(int)_meshes.size();++i ){
  418. meshes.push_back( i );
  419. }
  420. }else if( t=="BONE" ){
  421. ReadBONE( nodeid );
  422. }else if( t=="ANIM" ){
  423. ReadANIM();
  424. }else if( t=="KEYS" ){
  425. if( !nodeAnim ){
  426. nodeAnim=new aiNodeAnim;
  427. _nodeAnims.push_back( nodeAnim );
  428. nodeAnim->mNodeName=node->mName;
  429. }
  430. ReadKEYS( nodeAnim );
  431. }else if( t=="NODE" ){
  432. aiNode *child=ReadNODE( node );
  433. children.push_back( child );
  434. }
  435. ExitChunk();
  436. }
  437. node->mNumMeshes=meshes.size();
  438. node->mMeshes=to_array( meshes );
  439. node->mNumChildren=children.size();
  440. node->mChildren=to_array( children );
  441. return node;
  442. }
  443. // ------------------------------------------------------------------------------------------------
  444. void B3DImporter::ReadBB3D( aiScene *scene ){
  445. _textures.clear();
  446. _materials.size();
  447. _vertices.clear();
  448. _meshes.clear();
  449. _nodes.clear();
  450. _nodeAnims.clear();
  451. _animations.clear();
  452. string t=ReadChunk();
  453. if( t=="BB3D" ){
  454. int version=ReadInt();
  455. if (!DefaultLogger::isNullLogger()) {
  456. char dmp[128];
  457. sprintf(dmp,"B3D file format version: %i",version);
  458. DefaultLogger::get()->info(dmp);
  459. }
  460. while( ChunkSize() ){
  461. string t=ReadChunk();
  462. if( t=="TEXS" ){
  463. ReadTEXS();
  464. }else if( t=="BRUS" ){
  465. ReadBRUS();
  466. }else if( t=="NODE" ){
  467. ReadNODE( 0 );
  468. }
  469. ExitChunk();
  470. }
  471. }
  472. ExitChunk();
  473. if( !_nodes.size() ) Fail( "No nodes" );
  474. if( !_meshes.size() ) Fail( "No meshes" );
  475. //Fix nodes/meshes/bones
  476. for(size_t i=0;i<_nodes.size();++i ){
  477. aiNode *node=_nodes[i];
  478. for( size_t j=0;j<node->mNumMeshes;++j ){
  479. aiMesh *mesh=_meshes[node->mMeshes[j]];
  480. int n_tris=mesh->mNumFaces;
  481. int n_verts=mesh->mNumVertices=n_tris * 3;
  482. aiVector3D *mv=mesh->mVertices=new aiVector3D[ n_verts ],*mn=0,*mc=0;
  483. if( _vflags & 1 ) mn=mesh->mNormals=new aiVector3D[ n_verts ];
  484. if( _tcsets ) mc=mesh->mTextureCoords[0]=new aiVector3D[ n_verts ];
  485. aiFace *face=mesh->mFaces;
  486. vector< vector<aiVertexWeight> > vweights( _nodes.size() );
  487. for( int i=0;i<n_verts;i+=3 ){
  488. for( int j=0;j<3;++j ){
  489. Vertex &v=_vertices[face->mIndices[j]];
  490. *mv++=v.vertex;
  491. if( mn ) *mn++=v.normal;
  492. if( mc ) *mc++=v.texcoords;
  493. face->mIndices[j]=i+j;
  494. for( int k=0;k<4;++k ){
  495. if( !v.weights[k] ) break;
  496. int bone=v.bones[k];
  497. float weight=v.weights[k];
  498. vweights[bone].push_back( aiVertexWeight(i+j,weight) );
  499. }
  500. }
  501. ++face;
  502. }
  503. vector<aiBone*> bones;
  504. for(size_t i=0;i<vweights.size();++i ){
  505. vector<aiVertexWeight> &weights=vweights[i];
  506. if( !weights.size() ) continue;
  507. aiBone *bone=new aiBone;
  508. bones.push_back( bone );
  509. aiNode *bnode=_nodes[i];
  510. bone->mName=bnode->mName;
  511. bone->mNumWeights=weights.size();
  512. bone->mWeights=to_array( weights );
  513. aiMatrix4x4 mat=bnode->mTransformation;
  514. while( bnode->mParent ){
  515. bnode=bnode->mParent;
  516. mat=bnode->mTransformation * mat;
  517. }
  518. bone->mOffsetMatrix=mat.Inverse();
  519. }
  520. mesh->mNumBones=bones.size();
  521. mesh->mBones=to_array( bones );
  522. }
  523. }
  524. //nodes
  525. scene->mRootNode=_nodes[0];
  526. //material
  527. if( !_materials.size() ){
  528. _materials.push_back( new MaterialHelper );
  529. }
  530. scene->mNumMaterials=_materials.size();
  531. scene->mMaterials=to_array( _materials );
  532. //meshes
  533. scene->mNumMeshes=_meshes.size();
  534. scene->mMeshes=to_array( _meshes );
  535. //animations
  536. if( _animations.size()==1 && _nodeAnims.size() ){
  537. aiAnimation *anim=_animations.back();
  538. anim->mNumChannels=_nodeAnims.size();
  539. anim->mChannels=to_array( _nodeAnims );
  540. scene->mNumAnimations=_animations.size();
  541. scene->mAnimations=to_array( _animations );
  542. }
  543. // convert to RH
  544. MakeLeftHandedProcess makeleft;
  545. makeleft.Execute( scene );
  546. FlipWindingOrderProcess flip;
  547. flip.Execute( scene );
  548. }
  549. #endif // !! ASSIMP_BUILD_NO_B3D_IMPORTER