Simulant  21.12-574
A portable game engine for Windows, OSX, Linux, Dreamcast, and PSP
obj_loader.h
1 /* * Copyright (c) 2011-2017 Luke Benstead https://simulant-engine.appspot.com
2  *
3  * This file is part of Simulant.
4  *
5  * Simulant is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * Simulant is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with Simulant. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef OBJ_LOADER_H
20 #define OBJ_LOADER_H
21 
22 #include "../loader.h"
23 
24 namespace smlt {
25 namespace loaders {
26 
27 class OBJLoader : public Loader {
28 public:
29  OBJLoader(const Path& filename, std::shared_ptr<std::istream> data):
30  Loader(filename, data) {}
31 
32  void into(Loadable& resource, const LoaderOptions& options = LoaderOptions());
33 };
34 
35 void parse_face(const std::string& input, int32_t& vertex_index, int32_t& tex_index, int32_t& normal_index);
36 
37 class OBJLoaderType : public LoaderType {
38 public:
39  OBJLoaderType() {
40 
41  }
42 
43  virtual ~OBJLoaderType() {}
44 
45  const char* name() override { return "obj"; }
46  bool supports(const Path& filename) const override {
47  return filename.ext() == ".obj";
48  }
49 
50  Loader::ptr loader_for(const Path& filename, std::shared_ptr<std::istream> data) const override {
51  return Loader::ptr(new OBJLoader(filename, data));
52  }
53 };
54 
55 }
56 }
57 
58 #endif // OBJ_LOADER_H
smlt::loaders::OBJLoaderType
Definition: obj_loader.h:37
smlt
Definition: animation.cpp:25
smlt::LoaderType
Definition: loader.h:111
smlt::Loader
Definition: loader.h:66
smlt::Path
Definition: path.h:7
smlt::Loadable
Definition: loadable.h:26
smlt::loaders::OBJLoader
Definition: obj_loader.h:27