From 04ca1a72f7fafe7c6409008de541c08ba1c42b97 Mon Sep 17 00:00:00 2001 From: aramis_acg Date: Tue, 11 Nov 2008 19:02:51 +0000 Subject: [PATCH] Updated B3D Loader, added Mark Sibly to the list of contributors. git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@237 67173fc5-114c-0410-ac8e-9d2fd5bffc1f --- CREDITS | 5 ++- code/B3DImporter.cpp | 72 +++++++++++++++----------------------------- code/B3DImporter.h | 2 +- 3 files changed, 29 insertions(+), 50 deletions(-) diff --git a/CREDITS b/CREDITS index e4f9e3d9f..bdf4ce820 100644 --- a/CREDITS +++ b/CREDITS @@ -11,7 +11,7 @@ Thanks for your help! Configuration-Interface, AssImp-Viewer (Win32), Website (Admin and Design), admin. -Thomas Schulze, -X-Loader, Preprocessing framework. Data structure & Interface design, documentation. +X-, BVH-Loader, Postprocessing framework. Data structure & Interface design, documentation. -R.Schmidt, Linux build, eclipse support. @@ -23,6 +23,9 @@ Obj-Loader, Logging, Scons-build environment. Assimp.net Visual Studio 9 support, bugfixes. +- Mark Sibly +B3D-Loader, Assimp testing + - Sebastian Hempel, PyAssimp Compile-Bugfixes for mingw, add enviroment for static library support in make. diff --git a/code/B3DImporter.cpp b/code/B3DImporter.cpp index bce296d93..0cd4d8673 100644 --- a/code/B3DImporter.cpp +++ b/code/B3DImporter.cpp @@ -267,60 +267,36 @@ void B3DImporter::ReadVRTS(){ void B3DImporter::ReadTRIS(){ int matid=ReadInt(); - for( vector::iterator it=_vertices.begin();it!=_vertices.end();++it ){ - it->index=-1; - } - - vector verts,tris; - - while( ChunkSize() ){ - int i=ReadInt(); - Vertex &vert=_vertices[i]; - if( vert.index==-1 ){ - vert.index=verts.size(); - verts.push_back( i ); - } - tris.push_back( vert.index ); - } - - if( verts.empty() || tris.empty() ) return; - - unsigned n_verts=verts.size(); - unsigned n_tris=tris.size()/3; - - //OK, we have a whole mesh... - aiVector3D *mv=new aiVector3D[n_verts]; - aiVector3D *mn=new aiVector3D[n_verts]; - aiVector3D *mc=new aiVector3D[n_verts]; - for( unsigned i=0;imMaterialIndex=matid; - mesh->mNumVertices=n_verts; - mesh->mVertices=mv; - mesh->mNormals=mn; - mesh->mTextureCoords[0]=mc; - mesh->mNumFaces=n_tris; - mesh->mFaces=faces; + mesh->mPrimitiveTypes=aiPrimitiveType_TRIANGLE; - _meshes.push_back( mesh ); + aiVector3D *mv=mesh->mVertices=new aiVector3D[n_verts]; + aiVector3D *mn=mesh->mNormals=new aiVector3D[n_verts]; + aiVector3D *mc=mesh->mTextureCoords[0]=new aiVector3D[n_verts]; + + aiFace *face=mesh->mFaces=new aiFace[n_tris]; + + for( unsigned i=0;imNumIndices=3; + unsigned *ip=face->mIndices=new unsigned[3]; + for( unsigned j=0;j<3;++j ){ + int k=ReadInt(); + const Vertex &v=_vertices[k]; + memcpy( mv++,&v.position.x,12 ); + memcpy( mn++,&v.normal.x,12 ); + memcpy( mc++,&v.texcoords.x,12 ); + *ip++=i+j; + } + ++face; + } } void B3DImporter::ReadMESH(){ diff --git a/code/B3DImporter.h b/code/B3DImporter.h index d43e186a7..640edd4d4 100644 --- a/code/B3DImporter.h +++ b/code/B3DImporter.h @@ -69,7 +69,7 @@ private: struct Vec3{ float x,y,z; }; struct Vec4{ float x,y,z,w; }; struct Texture{ std::string name; }; - struct Vertex{ int index;Vec3 position,normal,texcoords; }; + struct Vertex{ Vec3 position,normal,texcoords; }; int ReadByte(); int ReadInt();