OpenPolygon  1.0.0
OpenPolygon is a Rendering Engine
wavefrontloader.h
1 /*
2  Copyright (C) 2014 - 2016 Mutzii
3 
4  This program is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 */
18 #ifndef WAVEFRONTLOADER_H
19 #define WAVEFRONTLOADER_H
20 
21 #include "index.h"
22 #include "meshdata.h"
23 #include "logmanager.h"
24 
25 namespace Engine
26 {
27 
31 class WaveFrontLoader : public MeshData
32 {
33  public:
34 
40  {
41  VertexGroups vgroups;
44  std::string line;
45  std::list<int> group_id_list;
46  };
47  using WaveFrontStateStore = struct WFL_StateStore;
48 
49  //different Index Versions
50  enum IndicesVersion
51  {
52  VERSION_1,
53  VERSION_2,
54  VERSION_3,
55  VERSION_4,
56  UNKNOWN
57  };
58 
59  public:
60 
66  ~WaveFrontLoader(){}
67 
73  void load( const std::string & obj_file_name );
74 
80  void writeVertex ( WaveFrontStateStore * store );
81 
87  void writeNormal ( WaveFrontStateStore * store );
88 
94  void writeTexCoord ( WaveFrontStateStore * store );
95 
101  void writeIndex ( WaveFrontStateStore * store );
102 
108  void createGroup ( WaveFrontStateStore * store );
109 
116  void addGroupData ( VertexGroup * group , int index );
117 
124  const Vector3f & getVertexByIndex( int index );
125 
132  IndicesVersion getVersion( const std::string & line );
133 
141  std::string getString( std::string & data , int index );
142 
143  private:
144 
150  void wfl_readLine ( WaveFrontStateStore * store );
151 
159  void wfl_string_split( const std::string &line , char delim , Strings &items);
160 
168  void wfl_string_split_extended( const std::string &line , const std::string &delim , Strings &tokens );
169 
176  IndicesVersion wfl_detect_indicies_version( const std::string &line );
177 
178 
179  int group_id_counter;
180 };
181 
182 }
183 
184 #endif // WAVEFRONTLOADER_H
void writeIndex(WaveFrontStateStore *store)
writeIndex
Definition: WaveFrontLoader.cpp:217
WaveFrontLoader()
WaveFrontLoader.
Definition: WaveFrontLoader.cpp:22
std::string line
Definition: wavefrontloader.h:44
void writeVertex(WaveFrontStateStore *store)
writeVertex
Definition: WaveFrontLoader.cpp:119
The MeshData - abstract class.
Definition: meshdata.h:32
The VertexGroup class.
Definition: vertexgroup.h:30
Definition: element.h:23
void createGroup(WaveFrontStateStore *store)
createGroup
Definition: WaveFrontLoader.cpp:176
void load(const std::string &obj_file_name)
load
Definition: WaveFrontLoader.cpp:27
std::string getString(std::string &data, int index)
getString
Definition: WaveFrontLoader.cpp:362
const Vector3f & getVertexByIndex(int index)
getVertexByIndex
Definition: WaveFrontLoader.cpp:369
void addGroupData(VertexGroup *group, int index)
addGroupData
Definition: WaveFrontLoader.cpp:374
void writeTexCoord(WaveFrontStateStore *store)
writeTexCoord
Definition: WaveFrontLoader.cpp:157
The WaveFrontLoader - Wave Front File Loader ( .obj )
Definition: wavefrontloader.h:31
bool groups_enabled
Definition: wavefrontloader.h:43
void writeNormal(WaveFrontStateStore *store)
writeNormal
Definition: WaveFrontLoader.cpp:138
The WFL_StateStore struct.
Definition: wavefrontloader.h:39
VertexGroups vgroups
Definition: wavefrontloader.h:41
IndicesVersion getVersion(const std::string &line)
getVersion
Definition: WaveFrontLoader.cpp:383
VertexGroup * current_group
Definition: wavefrontloader.h:42