vrshoot

view libs/assimp/COBLoader.h @ 0:b2f14e535253

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 01 Feb 2014 19:58:19 +0200
parents
children
line source
1 /*
2 Open Asset Import Library (assimp)
3 ----------------------------------------------------------------------
5 Copyright (c) 2006-2012, assimp team
6 All rights reserved.
8 Redistribution and use of this software in source and binary forms,
9 with or without modification, are permitted provided that the
10 following conditions are met:
12 * Redistributions of source code must retain the above
13 copyright notice, this list of conditions and the
14 following disclaimer.
16 * Redistributions in binary form must reproduce the above
17 copyright notice, this list of conditions and the
18 following disclaimer in the documentation and/or other
19 materials provided with the distribution.
21 * Neither the name of the assimp team, nor the names of its
22 contributors may be used to endorse or promote products
23 derived from this software without specific prior
24 written permission of the assimp team.
26 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 ----------------------------------------------------------------------
39 */
41 /** @file COBLoader.h
42 * @brief Declaration of the TrueSpace (*.cob,*.scn) importer class.
43 */
44 #ifndef INCLUDED_AI_COB_LOADER_H
45 #define INCLUDED_AI_COB_LOADER_H
47 #include "BaseImporter.h"
48 namespace Assimp {
49 class LineSplitter;
51 // TinyFormatter.h
52 namespace Formatter {
53 template <typename T,typename TR, typename A> class basic_formatter;
54 typedef class basic_formatter< char, std::char_traits<char>, std::allocator<char> > format;
55 }
57 // COBScene.h
58 namespace COB {
59 struct ChunkInfo;
60 struct Node;
61 struct Scene;
62 }
64 // -------------------------------------------------------------------------------------------
65 /** Importer class to load TrueSpace files (cob,scn) up to v6.
66 *
67 * Currently relatively limited, loads only ASCII files and needs more test coverage. */
68 // -------------------------------------------------------------------------------------------
69 class COBImporter : public BaseImporter
70 {
71 public:
72 COBImporter();
73 ~COBImporter();
76 public:
78 // --------------------
79 bool CanRead( const std::string& pFile, IOSystem* pIOHandler,
80 bool checkSig) const;
82 protected:
84 // --------------------
85 const aiImporterDesc* GetInfo () const;
87 // --------------------
88 void SetupProperties(const Importer* pImp);
90 // --------------------
91 void InternReadFile( const std::string& pFile, aiScene* pScene,
92 IOSystem* pIOHandler);
94 private:
96 // -------------------------------------------------------------------
97 /** Prepend 'COB: ' and throw msg.*/
98 static void ThrowException(const std::string& msg);
100 // -------------------------------------------------------------------
101 /** @brief Read from an ascii scene/object file
102 * @param out Receives output data.
103 * @param stream Stream to read from. */
104 void ReadAsciiFile(COB::Scene& out, StreamReaderLE* stream);
106 // -------------------------------------------------------------------
107 /** @brief Read from a binary scene/object file
108 * @param out Receives output data.
109 * @param stream Stream to read from. */
110 void ReadBinaryFile(COB::Scene& out, StreamReaderLE* stream);
113 private:
115 // Conversion to Assimp output format
117 aiNode* BuildNodes(const COB::Node& root,const COB::Scene& scin,aiScene* fill);
119 private:
121 // ASCII file support
123 void UnsupportedChunk_Ascii(LineSplitter& splitter, const COB::ChunkInfo& nfo, const char* name);
124 void ReadChunkInfo_Ascii(COB::ChunkInfo& out, const LineSplitter& splitter);
125 void ReadBasicNodeInfo_Ascii(COB::Node& msh, LineSplitter& splitter, const COB::ChunkInfo& nfo);
126 template <typename T> void ReadFloat3Tuple_Ascii(T& fill, const char** in);
128 void ReadPolH_Ascii(COB::Scene& out, LineSplitter& splitter, const COB::ChunkInfo& nfo);
129 void ReadBitM_Ascii(COB::Scene& out, LineSplitter& splitter, const COB::ChunkInfo& nfo);
130 void ReadMat1_Ascii(COB::Scene& out, LineSplitter& splitter, const COB::ChunkInfo& nfo);
131 void ReadGrou_Ascii(COB::Scene& out, LineSplitter& splitter, const COB::ChunkInfo& nfo);
132 void ReadBone_Ascii(COB::Scene& out, LineSplitter& splitter, const COB::ChunkInfo& nfo);
133 void ReadCame_Ascii(COB::Scene& out, LineSplitter& splitter, const COB::ChunkInfo& nfo);
134 void ReadLght_Ascii(COB::Scene& out, LineSplitter& splitter, const COB::ChunkInfo& nfo);
135 void ReadUnit_Ascii(COB::Scene& out, LineSplitter& splitter, const COB::ChunkInfo& nfo);
136 void ReadChan_Ascii(COB::Scene& out, LineSplitter& splitter, const COB::ChunkInfo& nfo);
139 // ASCII file logging stuff to add proper line numbers to messages
141 static void LogWarn_Ascii (const LineSplitter& splitter, const Formatter::format& message);
142 static void LogError_Ascii(const LineSplitter& splitter, const Formatter::format& message);
143 static void LogInfo_Ascii (const LineSplitter& splitter, const Formatter::format& message);
144 static void LogDebug_Ascii(const LineSplitter& splitter, const Formatter::format& message);
146 static void LogWarn_Ascii (const Formatter::format& message);
147 static void LogError_Ascii (const Formatter::format& message);
148 static void LogInfo_Ascii (const Formatter::format& message);
149 static void LogDebug_Ascii (const Formatter::format& message);
152 // Binary file support
154 void UnsupportedChunk_Binary(StreamReaderLE& reader, const COB::ChunkInfo& nfo, const char* name);
155 void ReadString_Binary(std::string& out, StreamReaderLE& reader);
156 void ReadBasicNodeInfo_Binary(COB::Node& msh, StreamReaderLE& reader, const COB::ChunkInfo& nfo);
158 void ReadPolH_Binary(COB::Scene& out, StreamReaderLE& reader, const COB::ChunkInfo& nfo);
159 void ReadBitM_Binary(COB::Scene& out, StreamReaderLE& reader, const COB::ChunkInfo& nfo);
160 void ReadMat1_Binary(COB::Scene& out, StreamReaderLE& reader, const COB::ChunkInfo& nfo);
161 void ReadCame_Binary(COB::Scene& out, StreamReaderLE& reader, const COB::ChunkInfo& nfo);
162 void ReadLght_Binary(COB::Scene& out, StreamReaderLE& reader, const COB::ChunkInfo& nfo);
163 void ReadGrou_Binary(COB::Scene& out, StreamReaderLE& reader, const COB::ChunkInfo& nfo);
164 void ReadUnit_Binary(COB::Scene& out, StreamReaderLE& reader, const COB::ChunkInfo& nfo);
167 }; // !class COBImporter
169 } // end of namespace Assimp
170 #endif // AI_UNREALIMPORTER_H_INC