2008-11-04 20:41:11 +00:00
|
|
|
/*
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
Open Asset Import Library (ASSIMP)
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
|
|
|
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
Redistribution and use of this software in source and binary forms,
|
|
|
|
with or without modification, are permitted provided that the following
|
|
|
|
conditions are met:
|
|
|
|
|
|
|
|
* Redistributions of source code must retain the above
|
|
|
|
copyright notice, this list of conditions and the
|
|
|
|
following disclaimer.
|
|
|
|
|
|
|
|
* Redistributions in binary form must reproduce the above
|
|
|
|
copyright notice, this list of conditions and the
|
|
|
|
following disclaimer in the documentation and/or other
|
|
|
|
materials provided with the distribution.
|
|
|
|
|
|
|
|
* Neither the name of the ASSIMP team, nor the names of its
|
|
|
|
contributors may be used to endorse or promote products
|
|
|
|
derived from this software without specific prior
|
|
|
|
written permission of the ASSIMP Development Team.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
/** @file B3DImporter.cpp
|
|
|
|
* @brief Implementation of the b3d importer class
|
|
|
|
*/
|
2008-11-04 20:41:11 +00:00
|
|
|
|
|
|
|
#include "AssimpPCH.h"
|
2009-01-18 23:48:25 +00:00
|
|
|
#ifndef ASSIMP_BUILD_NO_B3D_IMPORTER
|
2008-11-04 20:41:11 +00:00
|
|
|
|
|
|
|
// internal headers
|
|
|
|
#include "B3DImporter.h"
|
|
|
|
#include "TextureTransform.h"
|
|
|
|
|
|
|
|
using namespace Assimp;
|
|
|
|
using namespace std;
|
|
|
|
|
2009-01-18 23:48:25 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
bool B3DImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const{
|
2008-11-04 20:41:11 +00:00
|
|
|
|
|
|
|
int pos=pFile.find_last_of( '.' );
|
|
|
|
if( pos==string::npos ) return false;
|
|
|
|
|
|
|
|
string ext=pFile.substr( pos+1 );
|
|
|
|
if( ext.size()!=3 ) return false;
|
|
|
|
|
|
|
|
return (ext[0]=='b' || ext[0]=='B') && (ext[1]=='3') && (ext[2]=='d' || ext[2]=='D');
|
|
|
|
}
|
|
|
|
|
2009-01-18 23:48:25 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-11-04 20:41:11 +00:00
|
|
|
void B3DImporter::GetExtensionList( std::string& append ){
|
|
|
|
append.append("*.b3d");
|
|
|
|
}
|
|
|
|
|
2009-01-18 23:48:25 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-11-04 20:41:11 +00:00
|
|
|
void B3DImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler){
|
|
|
|
|
|
|
|
boost::scoped_ptr<IOStream> file( pIOHandler->Open( pFile));
|
|
|
|
|
|
|
|
// Check whether we can read from the file
|
|
|
|
if( file.get() == NULL)
|
|
|
|
throw new ImportErrorException( "Failed to open B3D file " + pFile + ".");
|
|
|
|
|
|
|
|
// check whether the .b3d file is large enough to contain
|
|
|
|
// at least one chunk.
|
|
|
|
size_t fileSize = file->FileSize();
|
2009-01-31 23:24:11 +00:00
|
|
|
if( fileSize<8 ) throw new ImportErrorException( "B3D File is too small.");
|
2008-11-04 20:41:11 +00:00
|
|
|
|
|
|
|
_pos=0;
|
|
|
|
_buf.resize( fileSize );
|
|
|
|
file->Read( &_buf[0],1,fileSize );
|
|
|
|
_stack.clear();
|
|
|
|
_textures.clear();
|
|
|
|
_materials.size();
|
|
|
|
_vertices.clear();
|
|
|
|
_meshes.clear();
|
|
|
|
|
|
|
|
ReadBB3D();
|
2009-01-31 23:24:11 +00:00
|
|
|
|
2008-11-04 20:41:11 +00:00
|
|
|
//materials
|
2009-01-31 23:24:11 +00:00
|
|
|
if( _materials.size() ){
|
|
|
|
aiMaterial **mats=new aiMaterial*[_materials.size()];
|
|
|
|
for( unsigned i=0;i<_materials.size();++i ){
|
|
|
|
mats[i]=_materials[i];
|
|
|
|
}
|
|
|
|
pScene->mNumMaterials=_materials.size();
|
|
|
|
pScene->mMaterials=mats;
|
2008-11-04 20:41:11 +00:00
|
|
|
}
|
2009-01-31 23:24:11 +00:00
|
|
|
|
2008-11-04 20:41:11 +00:00
|
|
|
//meshes
|
2009-01-31 23:24:11 +00:00
|
|
|
if( _meshes.size() ){
|
|
|
|
aiMesh **meshes=new aiMesh*[_meshes.size()];
|
|
|
|
for( unsigned i=0;i<_meshes.size();++i ){
|
|
|
|
meshes[i]=_meshes[i];
|
|
|
|
}
|
|
|
|
pScene->mNumMeshes=_meshes.size();
|
|
|
|
pScene->mMeshes=meshes;
|
|
|
|
}else{
|
|
|
|
throw new ImportErrorException( "B3D: No meshes loaded" );
|
2008-11-04 20:41:11 +00:00
|
|
|
}
|
|
|
|
|
2009-01-31 23:24:11 +00:00
|
|
|
//create root node
|
2008-11-04 20:41:11 +00:00
|
|
|
aiNode *node=new aiNode( "root" );
|
2009-02-04 00:39:32 +00:00
|
|
|
node->mTransformation=aiMatrix4x4(
|
|
|
|
1,0,0,0,
|
|
|
|
0,0,1,0,
|
|
|
|
0,1,0,0,
|
|
|
|
0,0,0,1 );
|
|
|
|
|
2008-11-04 20:41:11 +00:00
|
|
|
node->mNumMeshes=_meshes.size();
|
|
|
|
node->mMeshes=new unsigned[_meshes.size()];
|
|
|
|
for( unsigned i=0;i<_meshes.size();++i ){
|
|
|
|
node->mMeshes[i]=i;
|
|
|
|
}
|
|
|
|
pScene->mRootNode=node;
|
|
|
|
}
|
|
|
|
|
2009-01-18 23:48:25 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-11-04 20:41:11 +00:00
|
|
|
int B3DImporter::ReadByte(){
|
|
|
|
if( _pos<_buf.size() ) return _buf[_pos++];
|
|
|
|
throw new ImportErrorException( "B3D EOF Error" );
|
|
|
|
}
|
|
|
|
|
2009-01-18 23:48:25 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-11-04 20:41:11 +00:00
|
|
|
int B3DImporter::ReadInt(){
|
|
|
|
if( _pos+4<=_buf.size() ){
|
|
|
|
int n=*(int*)&_buf[_pos];
|
|
|
|
_pos+=4;
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
throw new ImportErrorException( "B3D EOF Error" );
|
|
|
|
}
|
|
|
|
|
2009-01-18 23:48:25 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-11-04 20:41:11 +00:00
|
|
|
float B3DImporter::ReadFloat(){
|
|
|
|
if( _pos+4<=_buf.size() ){
|
|
|
|
float n=*(float*)&_buf[_pos];
|
|
|
|
_pos+=4;
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
throw new ImportErrorException( "B3D EOF Error" );
|
|
|
|
}
|
|
|
|
|
2009-01-18 23:48:25 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-11-04 20:41:11 +00:00
|
|
|
B3DImporter::Vec2 B3DImporter::ReadVec2(){
|
|
|
|
Vec2 t;
|
|
|
|
t.x=ReadFloat();
|
|
|
|
t.y=ReadFloat();
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
2009-01-18 23:48:25 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-11-04 20:41:11 +00:00
|
|
|
B3DImporter::Vec3 B3DImporter::ReadVec3(){
|
|
|
|
Vec3 t;
|
|
|
|
t.x=ReadFloat();
|
|
|
|
t.y=ReadFloat();
|
|
|
|
t.z=ReadFloat();
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
2009-01-18 23:48:25 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-11-04 20:41:11 +00:00
|
|
|
B3DImporter::Vec4 B3DImporter::ReadVec4(){
|
|
|
|
Vec4 t;
|
|
|
|
t.x=ReadFloat();
|
|
|
|
t.y=ReadFloat();
|
|
|
|
t.z=ReadFloat();
|
|
|
|
t.w=ReadFloat();
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
2009-01-18 23:48:25 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-11-04 20:41:11 +00:00
|
|
|
string B3DImporter::ReadString(){
|
|
|
|
string str;
|
|
|
|
while( _pos<_buf.size() ){
|
|
|
|
char c=(char)ReadByte();
|
|
|
|
if( !c ) return str;
|
|
|
|
str+=c;
|
|
|
|
}
|
|
|
|
throw new ImportErrorException( "B3D EOF Error" );
|
|
|
|
}
|
|
|
|
|
2009-01-18 23:48:25 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-11-04 20:41:11 +00:00
|
|
|
string B3DImporter::ReadChunk(){
|
|
|
|
string tag;
|
|
|
|
for( int i=0;i<4;++i ){
|
|
|
|
tag+=char( ReadByte() );
|
|
|
|
}
|
|
|
|
// cout<<"ReadChunk:"<<tag<<endl;
|
|
|
|
unsigned sz=(unsigned)ReadInt();
|
|
|
|
_stack.push_back( _pos+sz );
|
|
|
|
return tag;
|
|
|
|
}
|
|
|
|
|
2009-01-18 23:48:25 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-11-04 20:41:11 +00:00
|
|
|
void B3DImporter::ExitChunk(){
|
|
|
|
_pos=_stack.back();
|
|
|
|
_stack.pop_back();
|
|
|
|
}
|
|
|
|
|
2009-01-18 23:48:25 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-11-04 20:41:11 +00:00
|
|
|
unsigned B3DImporter::ChunkSize(){
|
|
|
|
return _stack.back()-_pos;
|
|
|
|
}
|
|
|
|
|
2009-01-18 23:48:25 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-11-04 20:41:11 +00:00
|
|
|
void B3DImporter::ReadTEXS(){
|
|
|
|
while( ChunkSize() ){
|
|
|
|
string name=ReadString();
|
|
|
|
int flags=ReadInt();
|
|
|
|
int blend=ReadInt();
|
|
|
|
Vec2 pos=ReadVec2();
|
|
|
|
Vec2 scale=ReadVec2();
|
|
|
|
float rot=ReadFloat();
|
|
|
|
|
|
|
|
Texture tex;
|
|
|
|
tex.name=name;
|
|
|
|
_textures.push_back( tex );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-18 23:48:25 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-11-04 20:41:11 +00:00
|
|
|
void B3DImporter::ReadBRUS(){
|
|
|
|
int n_texs=ReadInt();
|
|
|
|
while( ChunkSize() ){
|
|
|
|
string name=ReadString();
|
|
|
|
Vec4 color=ReadVec4();
|
|
|
|
float shiny=ReadFloat();
|
|
|
|
int blend=ReadInt();
|
|
|
|
int fx=ReadInt();
|
|
|
|
|
|
|
|
MaterialHelper *mat=new MaterialHelper;
|
|
|
|
_materials.push_back( mat );
|
2009-01-11 21:51:45 +00:00
|
|
|
|
|
|
|
// Name
|
|
|
|
aiString ainame( name );
|
|
|
|
mat->AddProperty( &ainame,AI_MATKEY_NAME );
|
|
|
|
|
|
|
|
// Diffuse color
|
|
|
|
aiColor3D diffcolor( color.x,color.y,color.z );
|
|
|
|
mat->AddProperty( &diffcolor,1,AI_MATKEY_COLOR_DIFFUSE );
|
|
|
|
|
|
|
|
// Opacity
|
|
|
|
mat->AddProperty( &color.w,1,AI_MATKEY_OPACITY );
|
|
|
|
|
|
|
|
// Specular color
|
|
|
|
aiColor3D speccolor( shiny,shiny,shiny );
|
|
|
|
mat->AddProperty( &speccolor,1,AI_MATKEY_COLOR_SPECULAR );
|
|
|
|
|
|
|
|
// Specular power
|
|
|
|
float specpow=shiny*128;
|
|
|
|
mat->AddProperty( &specpow,1,AI_MATKEY_SHININESS );
|
|
|
|
|
|
|
|
// Double sided
|
|
|
|
if( fx & 0x10 ){
|
|
|
|
int i=1;
|
|
|
|
mat->AddProperty( &i,1,AI_MATKEY_TWOSIDED );
|
|
|
|
}
|
|
|
|
|
|
|
|
//Textures
|
2008-11-04 20:41:11 +00:00
|
|
|
for( int i=0;i<n_texs;++i ){
|
|
|
|
int texid=ReadInt();
|
2009-01-15 19:22:29 +00:00
|
|
|
if( !i && texid>=0 && texid<(int)_textures.size() ){
|
2008-11-04 20:41:11 +00:00
|
|
|
//just use tex 0 for now
|
|
|
|
const Texture &tex=_textures[texid];
|
2009-01-11 21:51:45 +00:00
|
|
|
aiString texname( tex.name );
|
|
|
|
mat->AddProperty( &texname,AI_MATKEY_TEXTURE_DIFFUSE(0) );
|
2008-11-04 20:41:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-18 23:48:25 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-11-04 20:41:11 +00:00
|
|
|
void B3DImporter::ReadVRTS(){
|
2009-01-31 23:24:11 +00:00
|
|
|
_vertFlags=ReadInt();
|
|
|
|
_tcSets=ReadInt();
|
|
|
|
_tcSize=ReadInt();
|
2008-11-04 20:41:11 +00:00
|
|
|
|
2009-01-31 23:24:11 +00:00
|
|
|
if( _tcSets<0 || _tcSets>4 || _tcSize<0 || _tcSize>4 ) throw new ImportErrorException( "B3D Param Error" );
|
2008-11-04 20:41:11 +00:00
|
|
|
|
|
|
|
while( ChunkSize() ){
|
|
|
|
Vertex vert;
|
|
|
|
|
|
|
|
vert.position=ReadVec3();
|
|
|
|
|
2009-01-31 23:24:11 +00:00
|
|
|
if( _vertFlags & 1 ){
|
2008-11-04 20:41:11 +00:00
|
|
|
vert.normal=ReadVec3();
|
|
|
|
}
|
|
|
|
|
2009-01-31 23:24:11 +00:00
|
|
|
if( _vertFlags & 2 ){
|
2008-11-04 20:41:11 +00:00
|
|
|
Vec4 color=ReadVec4();
|
|
|
|
}
|
|
|
|
|
2009-01-31 23:24:11 +00:00
|
|
|
for( int i=0;i<_tcSets;++i ){
|
2008-11-04 20:41:11 +00:00
|
|
|
float texcoords[4]={0,0,0,0};
|
2009-01-31 23:24:11 +00:00
|
|
|
for( int j=0;j<_tcSize;++j ){
|
2008-11-04 20:41:11 +00:00
|
|
|
texcoords[j]=ReadFloat();
|
|
|
|
}
|
2009-01-30 00:07:09 +00:00
|
|
|
texcoords[1]=1-texcoords[1];
|
2008-11-04 20:41:11 +00:00
|
|
|
if( !i ) memcpy( &vert.texcoords.x,texcoords,12 );
|
|
|
|
}
|
|
|
|
_vertices.push_back( vert );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-18 23:48:25 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-11-04 20:41:11 +00:00
|
|
|
void B3DImporter::ReadTRIS(){
|
|
|
|
int matid=ReadInt();
|
|
|
|
|
2008-11-11 19:02:51 +00:00
|
|
|
unsigned n_tris=ChunkSize()/12;
|
|
|
|
unsigned n_verts=n_tris*3;
|
|
|
|
|
2008-11-04 20:41:11 +00:00
|
|
|
aiMesh *mesh=new aiMesh;
|
2008-11-11 19:02:51 +00:00
|
|
|
_meshes.push_back( mesh );
|
2008-11-04 20:41:11 +00:00
|
|
|
|
|
|
|
mesh->mMaterialIndex=matid;
|
|
|
|
mesh->mNumVertices=n_verts;
|
|
|
|
mesh->mNumFaces=n_tris;
|
2008-11-11 19:02:51 +00:00
|
|
|
mesh->mPrimitiveTypes=aiPrimitiveType_TRIANGLE;
|
|
|
|
|
2009-01-31 23:24:11 +00:00
|
|
|
aiVector3D *mv,*mn=0,*mc=0;
|
|
|
|
|
|
|
|
mv=mesh->mVertices=new aiVector3D[n_verts];
|
|
|
|
if( _vertFlags & 1 ) mn=mesh->mNormals=new aiVector3D[n_verts];
|
|
|
|
if( _tcSets ) mc=mesh->mTextureCoords[0]=new aiVector3D[n_verts];
|
|
|
|
|
2008-11-11 19:02:51 +00:00
|
|
|
aiFace *face=mesh->mFaces=new aiFace[n_tris];
|
|
|
|
|
|
|
|
for( unsigned i=0;i<n_verts;i+=3 ){
|
|
|
|
face->mNumIndices=3;
|
|
|
|
unsigned *ip=face->mIndices=new unsigned[3];
|
2009-01-30 00:07:09 +00:00
|
|
|
int v[3];
|
|
|
|
v[0]=ReadInt();
|
|
|
|
v[2]=ReadInt();
|
|
|
|
v[1]=ReadInt();
|
2008-11-11 19:02:51 +00:00
|
|
|
for( unsigned j=0;j<3;++j ){
|
2009-01-31 23:24:11 +00:00
|
|
|
int k=v[j];
|
2008-11-11 19:02:51 +00:00
|
|
|
const Vertex &v=_vertices[k];
|
|
|
|
memcpy( mv++,&v.position.x,12 );
|
2009-01-31 23:24:11 +00:00
|
|
|
if( mn ) memcpy( mn++,&v.normal.x,12 );
|
|
|
|
if( mc ) memcpy( mc++,&v.texcoords.x,12 );
|
2008-11-11 19:02:51 +00:00
|
|
|
*ip++=i+j;
|
|
|
|
}
|
|
|
|
++face;
|
|
|
|
}
|
2008-11-04 20:41:11 +00:00
|
|
|
}
|
|
|
|
|
2009-01-18 23:48:25 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-11-04 20:41:11 +00:00
|
|
|
void B3DImporter::ReadMESH(){
|
|
|
|
int matid=ReadInt();
|
|
|
|
|
|
|
|
_vertices.clear();
|
2009-01-31 23:24:11 +00:00
|
|
|
|
2008-11-04 20:41:11 +00:00
|
|
|
while( ChunkSize() ){
|
|
|
|
string t=ReadChunk();
|
|
|
|
if( t=="VRTS" ){
|
|
|
|
ReadVRTS();
|
|
|
|
}else if( t=="TRIS" ){
|
|
|
|
ReadTRIS();
|
|
|
|
}
|
|
|
|
ExitChunk();
|
|
|
|
}
|
|
|
|
|
|
|
|
_vertices.clear();
|
|
|
|
}
|
|
|
|
|
2009-01-18 23:48:25 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-11-04 20:41:11 +00:00
|
|
|
void B3DImporter::ReadNODE(){
|
|
|
|
|
|
|
|
string name=ReadString();
|
|
|
|
Vec3 trans=ReadVec3();
|
|
|
|
Vec3 scale=ReadVec3();
|
|
|
|
Vec4 rot=ReadVec4();
|
|
|
|
|
|
|
|
while( ChunkSize() ){
|
|
|
|
string t=ReadChunk();
|
|
|
|
if( t=="MESH" ){
|
|
|
|
ReadMESH();
|
|
|
|
}
|
|
|
|
ExitChunk();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-18 23:48:25 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-11-04 20:41:11 +00:00
|
|
|
void B3DImporter::ReadBB3D(){
|
|
|
|
string t=ReadChunk();
|
|
|
|
if( t=="BB3D" ){
|
|
|
|
int version=ReadInt();
|
|
|
|
while( ChunkSize() ){
|
|
|
|
string t=ReadChunk();
|
|
|
|
if( t=="TEXS" ){
|
|
|
|
ReadTEXS();
|
|
|
|
}else if( t=="BRUS" ){
|
|
|
|
ReadBRUS();
|
|
|
|
}else if( t=="NODE" ){
|
|
|
|
ReadNODE();
|
|
|
|
}
|
|
|
|
ExitChunk();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ExitChunk();
|
|
|
|
}
|
2009-01-18 23:48:25 +00:00
|
|
|
|
|
|
|
#endif // !! ASSIMP_BUILD_NO_B3D_IMPORTER
|