4 #include <unordered_map>
5 #include <boost/bind.hpp>
10 #include "vmmlib/matrix.hpp"
11 #include "external/obj_parser/obj_parser.hpp"
20 typedef std::unordered_map< std::string, MaterialData >
MaterialMap;
41 GLfloat
x() {
return position.x(); }
42 GLfloat
y() {
return position.y(); }
43 GLfloat
z() {
return position.z(); }
75 bool load(std::istream& istream);
99 void createGroup(
const std::string& name)
102 auto &group = _groups[_groupName];
110 void info_callback(
const std::string& filename, std::size_t line_number,
const std::string& message);
111 void warning_callback(
const std::string& filename, std::size_t line_number,
const std::string& message);
112 void error_callback(
const std::string& filename, std::size_t line_number,
const std::string& message);
113 void geometric_vertex_callback(obj::float_type x, obj::float_type y, obj::float_type z);
114 void texture_vertex_callback(obj::float_type u, obj::float_type v);
115 void vertex_normal_callback(obj::float_type x, obj::float_type y, obj::float_type z);
116 void triangular_face_geometric_vertices_callback(obj::index_type v1, obj::index_type v2, obj::index_type v3);
117 void triangular_face_geometric_vertices_texture_vertices_callback(
const obj::index_2_tuple_type& v1_vt1,
const obj::index_2_tuple_type& v2_vt2,
const obj::index_2_tuple_type& v3_vt3);
118 void triangular_face_geometric_vertices_vertex_normals_callback(
const obj::index_2_tuple_type& v1_vn1,
const obj::index_2_tuple_type& v2_vn2,
const obj::index_2_tuple_type& v3_vn3);
119 void triangular_face_geometric_vertices_texture_vertices_vertex_normals_callback(
const obj::index_3_tuple_type& v1_vt1_vn1,
const obj::index_3_tuple_type& v2_vt2_vn2,
const obj::index_3_tuple_type& v3_vt3_vn3);
120 void polygonal_face_geometric_vertices_begin_callback(obj::index_type v1, obj::index_type v2, obj::index_type v3);
121 void polygonal_face_geometric_vertices_vertex_callback(obj::index_type v);
122 void polygonal_face_geometric_vertices_end_callback();
123 void polygonal_face_geometric_vertices_texture_vertices_begin_callback(
const obj::index_2_tuple_type& v1_vt1,
const obj::index_2_tuple_type& v2_vt2,
const obj::index_2_tuple_type& v3_vt3);
124 void polygonal_face_geometric_vertices_texture_vertices_vertex_callback(
const obj::index_2_tuple_type& v_vt);
125 void polygonal_face_geometric_vertices_texture_vertices_end_callback();
126 void polygonal_face_geometric_vertices_vertex_normals_begin_callback(
const obj::index_2_tuple_type& v1_vn1,
const obj::index_2_tuple_type& v2_vn2,
const obj::index_2_tuple_type& v3_vn3);
127 void polygonal_face_geometric_vertices_vertex_normals_vertex_callback(
const obj::index_2_tuple_type& v_vn);
128 void polygonal_face_geometric_vertices_vertex_normals_end_callback();
129 void polygonal_face_geometric_vertices_texture_vertices_vertex_normals_begin_callback(
const obj::index_3_tuple_type& v1_vt1_vn1,
const obj::index_3_tuple_type& v2_vt2_vn2,
const obj::index_3_tuple_type& v3_vt3_vn3);
130 void polygonal_face_geometric_vertices_texture_vertices_vertex_normals_vertex_callback(
const obj::index_3_tuple_type& v_vt_vn);
131 void polygonal_face_geometric_vertices_texture_vertices_vertex_normals_end_callback();
132 void group_name_callback(
const std::string& group_name);
133 void smoothing_group_callback(obj::size_type group_number);
134 void object_name_callback(
const std::string& object_name);
135 void material_library_callback(
const std::string& filename);
136 void material_name_callback(
const std::string& material_name);
137 void comment_callback(
const std::string& comment);
139 template<
bool POSITION,
bool TEX_COORD,
bool NORMAL >
142 template<
bool NORMAL >
150 static void loadObjMtl(
const std::string &fileName, MaterialMap &materials,
const std::string &materialName =
"");
154 obj::obj_parser::flags_type _flags;
156 MaterialMap _materials;
157 std::string _groupName;
161 std::vector<FaceData> _faces;
162 std::vector<VertexData> _vertices;
163 std::vector<vmml::Vector2f> _texCoords;
164 std::vector<vmml::Vector3f> _normals;
165 std::vector<vmml::Vector3f> _tangents;
166 std::vector<vmml::Vector3f> _bitangents;
vmml::Vector3f bitangent
Definition: OBJLoader.h:30
vmml::Vector3f position
Definition: OBJLoader.h:36
Index v2
Definition: OBJLoader.h:26
Index v3
Definition: OBJLoader.h:27
OBJLoader(obj::obj_parser::flags_type flags)
Constructor.
Definition: OBJLoader.h:55
GLfloat x()
Definition: OBJLoader.h:41
bool load(std::istream &istream)
Loads the model data from an input stream.
Definition: OBJLoader.cpp:282
vmml::Vector3f normal
Definition: OBJLoader.h:37
void createVertexNormals()
Creates the normal vectors of the vertex.
Definition: OBJLoader.cpp:529
std::vector< Index > faces
Definition: OBJLoader.h:35
Definition: OBJLoader.h:23
Definition: GeometryData.h:10
OBJLoader(ModelData *data, obj::obj_parser::flags_type flags)
Constructor.
Definition: OBJLoader.h:63
vmml::Vector3f tangent
Definition: OBJLoader.h:38
std::shared_ptr< GeometryData > GeometryDataPtr
Definition: GeometryData.h:138
std::unordered_map< std::string, MaterialData > MaterialMap
Definition: OBJLoader.h:20
VertexData(const vmml::Vector3f &position)
Definition: OBJLoader.h:45
vmml::Vector3f bitangent
Definition: OBJLoader.h:39
virtual ~OBJLoader()
Virtual destructor.
Definition: OBJLoader.h:70
Definition: OBJLoader.h:33
vmml::Vector3f normal
Definition: OBJLoader.h:28
vmml::Vector3f tangent
Definition: OBJLoader.h:29
GLfloat y()
Definition: OBJLoader.h:42
The underlying data of a geometry object.
Definition: GeometryData.h:125
The underlying data of a material.
Definition: MaterialData.h:10
void createFaceNormals()
Creates the normal vectors of the face.
Definition: OBJLoader.cpp:476
GLfloat z()
Definition: OBJLoader.h:43
Index v1
Definition: OBJLoader.h:25
GLushort Index
Definition: GeometryData.h:120
ModelData::GroupMap getData()
Returns the geometry groups.
Definition: OBJLoader.h:93
Definition: ModelData.h:11
std::unordered_map< std::string, GeometryDataPtr > GroupMap
Definition: ModelData.h:15
Loads and processes OBJ models and materials.
Definition: OBJLoader.h:16
static MaterialData loadMaterial(const std::string &fileName, const std::string &materialName)
Loads an obj material.
Definition: OBJLoader.cpp:367