Ocular Engine
ResourceLoader_OBJ.hpp
1 
17 #pragma once
18 #ifndef __H__OCULAR_GRAPHICS_RESOURCE_LOADER_OBJ__H__
19 #define __H__OCULAR_GRAPHICS_RESOURCE_LOADER_OBJ__H__
20 
21 #include "Resources/ResourceLoader.hpp"
22 #include "Graphics/Mesh/Vertex.hpp"
23 
24 #include <vector>
25 
26 //------------------------------------------------------------------------------------------
27 
28 class OBJState;
29 class OBJGroup;
30 class OBJMaterial;
31 
32 struct OBJFace;
33 struct OBJVertexGroup;
34 
39 namespace Ocular
40 {
41  namespace Core
42  {
43  class MultiResource;
44  }
45 
50  namespace Graphics
51  {
52  class Mesh;
53  class Material;
54 
67  {
68  public:
69 
71  virtual ~ResourceLoader_OBJ();
72 
79  virtual bool loadResource(Core::Resource* &resource, Core::File const& file, std::string const& mappingName) override;
80 
91  virtual bool loadSubResource(Core::Resource* &resource, Core::File const& file, std::string const& mappingName) override;
92 
100  virtual bool exploreResource(Core::File const& file) override;
101 
102  protected:
103 
104  //------------------------------------------------------------
105  // Mesh Methods
106  //------------------------------------------------------------
107 
108  void createMeshes(Core::MultiResource* multiResource);
109  void createMesh(Mesh* mesh, OBJGroup const* group);
110  void addFace(OBJFace const* face, std::vector<Vertex>* vertices, std::vector<uint32_t>* indices, Math::Vector3f& min, Math::Vector3f& max);
111  void faceToVertex(std::vector<Vertex>* vertices, OBJVertexGroup const& group, Math::Vector3f& min, Math::Vector3f& max);
112 
113  //------------------------------------------------------------
114  // Material Methods
115  //------------------------------------------------------------
116 
117  void createMaterials(Core::MultiResource* multiResource);
118  void createMaterial(Material* material, OBJMaterial const* objMaterial, std::string const& relPath);
119 
120  //------------------------------------------------------------
121  // Misc Methods
122  //------------------------------------------------------------
123 
124  bool isFileValid(Core::File const& file) const;
125  void splitParentSubNames(std::string const& mappingName, std::string& parent, std::string& sub) const;
126 
127  private:
128 
129  OBJState* m_CurrState;
130  };
131  }
135 }
140 //------------------------------------------------------------------------------------------
141 
142 #endif
Definition: ResourceLoader.hpp:55
Note: Once this library is made dynamic, this will no longer be needed.
Definition: Common.hpp:70
Combination of a VertexBuffer and IndexBuffer.
Definition: Mesh.hpp:49
Definition: MultiResource.hpp:55
Definition: File.hpp:41
Definition: ResourceLoader_OBJ.hpp:66
virtual bool loadSubResource(Core::Resource *&resource, Core::File const &file, std::string const &mappingName) override
Definition: ResourceLoader_OBJ.cpp:110
virtual bool exploreResource(Core::File const &file) override
Definition: ResourceLoader_OBJ.cpp:143
virtual bool loadResource(Core::Resource *&resource, Core::File const &file, std::string const &mappingName) override
Definition: ResourceLoader_OBJ.cpp:61
Definition: Material.hpp:62
Definition: Resource.hpp:46