1/*
2Open Asset Import Library (assimp)
3----------------------------------------------------------------------
4
5Copyright (c) 2006-2017, assimp team
6
7All rights reserved.
8
9Redistribution and use of this software in source and binary forms,
10with or without modification, are permitted provided that the
11following conditions are met:
12
13* Redistributions of source code must retain the above
14 copyright notice, this list of conditions and the
15 following disclaimer.
16
17* Redistributions in binary form must reproduce the above
18 copyright notice, this list of conditions and the
19 following disclaimer in the documentation and/or other
20 materials provided with the distribution.
21
22* Neither the name of the assimp team, nor the names of its
23 contributors may be used to endorse or promote products
24 derived from this software without specific prior
25 written permission of the assimp team.
26
27THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38
39----------------------------------------------------------------------
40*/
41
42/** @file Definition of the .b3d importer class. */
43
44#ifndef AI_B3DIMPORTER_H_INC
45#define AI_B3DIMPORTER_H_INC
46
47#include <assimp/types.h>
48#include <assimp/mesh.h>
49#include <assimp/material.h>
50#include "BaseImporter.h"
51
52#include <vector>
53
54struct aiNodeAnim;
55struct aiNode;
56struct aiAnimation;
57
58namespace Assimp{
59
60class B3DImporter : public BaseImporter{
61public:
62 B3DImporter() = default;
63 virtual ~B3DImporter();
64
65 virtual bool CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const;
66
67protected:
68
69 virtual const aiImporterDesc* GetInfo () const;
70 virtual void InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler);
71
72private:
73
74 int ReadByte();
75 int ReadInt();
76 float ReadFloat();
77 aiVector2D ReadVec2();
78 aiVector3D ReadVec3();
79 aiQuaternion ReadQuat();
80 std::string ReadString();
81 std::string ReadChunk();
82 void ExitChunk();
83 unsigned ChunkSize();
84
85 template<class T>
86 T *to_array( const std::vector<T> &v );
87
88 struct Vertex{
89 aiVector3D vertex;
90 aiVector3D normal;
91 aiVector3D texcoords;
92 unsigned char bones[4];
93 float weights[4];
94 };
95
96 AI_WONT_RETURN void Oops() AI_WONT_RETURN_SUFFIX;
97 AI_WONT_RETURN void Fail( std::string str ) AI_WONT_RETURN_SUFFIX;
98
99 void ReadTEXS();
100 void ReadBRUS();
101
102 void ReadVRTS();
103 void ReadTRIS( int v0 );
104 void ReadMESH();
105 void ReadBONE( int id );
106 void ReadKEYS( aiNodeAnim *nodeAnim );
107 void ReadANIM();
108
109 aiNode *ReadNODE( aiNode *parent );
110
111 void ReadBB3D( aiScene *scene );
112
113 unsigned _pos;
114// unsigned _size;
115 std::vector<unsigned char> _buf;
116 std::vector<unsigned> _stack;
117
118 std::vector<std::string> _textures;
119 std::vector<aiMaterial*> _materials;
120
121 int _vflags,_tcsets,_tcsize;
122 std::vector<Vertex> _vertices;
123
124 std::vector<aiNode*> _nodes;
125 std::vector<aiMesh*> _meshes;
126 std::vector<aiNodeAnim*> _nodeAnims;
127 std::vector<aiAnimation*> _animations;
128};
129
130}
131
132#endif
133