Vis 2 Demo
1.0
Technical illustration type real-time rendering of geometry
|
This class is for reading and parsing geometry from a Wavefront Object (OBJ) or a binary (DAT) file. More...
Public Member Functions | |
LoaderOBJ (const std::string &) | |
Constructor. More... | |
~LoaderOBJ () | |
Destructor. More... | |
int | obj2Container () |
This function starts the loading / parsing process. More... | |
const unsigned int | getNrFaceInd () const |
A getter for the number of face indices. More... | |
const unsigned int | getNrVertices () const |
A getter for the number of vertices. More... | |
Public Attributes | |
GLfloat * | vert_positions |
holds the vertex positions as a 1-dimensional array (every 3 consecutive values are 1 vertex position) More... | |
GLfloat * | vert_normals |
holds the vertex normals as a 1-dimensional array (every 3 consecutive values are 1 vertex normal) More... | |
GLfloat * | vert_uvs |
holds the vertex texture coordinates as a 1-dimensional array (every 2 consecutive values are 1 texture coordinate) More... | |
GLuint * | face_ind |
holds the face indices as a 1-dimensional array (every 3 consecutive values describe one triangle) More... | |
Private Member Functions | |
LoaderOBJ (const LoaderOBJ &) | |
Hidden copy-contructor. More... | |
int | readDataFromOBJ () |
This function reads and parses the OBJ file. More... | |
int | readDataFromDAT () |
This function reads and parses the DAT file. More... | |
int | writeDataToDAT () |
This function is called by readDataFromOBJ() to write the DAT file. More... | |
void | checkForErrors (std::ios &_ofs) |
This is the error-handling function. More... | |
void | parseOBJ (std::FILE *_f) |
This function contains the main parsing functionality. More... | |
vertAttribContainer | string2VertAttr (std::string &_line) |
This function converts a string to a std::vector of 3 floats. More... | |
indexContainer | string2Index (std::string &_line) |
This function converts a string to a std::vector of 9 uints. More... | |
bool | iCareEqual (const indexContainer &_ic1, const indexContainer &_ic2) |
This is function a for comparing two index containers. More... | |
void | mult2singleIndex () |
This function converts the multiple-index geometry in the OBJ file into single-index geometry for use in OpenGL. More... | |
Private Attributes | |
std::string | file_path |
holds the full path to the OBJ or DAT file More... | |
unsigned int | file_type |
is VIS2_FILE_TYPE_OBJ if the read file is OBJ, VIS2_FILE_TYPE_DAT therwise More... | |
multIndexContainer | new_mult_indices |
contains all old index triples that caused new elements to be added to the vertex attribute arrays More... | |
vertAttribContainer | vert_positions_OBJ |
holds the old vertex positions as a 1-dimensional array (every 3 consecutive values are 1 vertex position) More... | |
vertAttribContainer | vert_normals_OBJ |
holds the old vertex normals as a 1-dimensional array (every 3 consecutive values are 1 vertex normal) More... | |
vertAttribContainer | vert_uvs_OBJ |
holds the old vertex texture coordinates as a 1-dimensional array (every 2 consecutive values are 1 texture coordinate) More... | |
indexContainer | face_ind_OBJ |
holds the old face multi-indices as a 1-dimensional array (every 9 consecutive values describe one triangle) More... | |
unsigned int | nr_face_ind |
is the number of new face indices in total More... | |
unsigned int | single_ind |
is the number of single-indices (unique) needed for drawing More... | |
This class is for reading and parsing geometry from a Wavefront Object (OBJ) or a binary (DAT) file.
The class parses an OBJ file and writes a binary file with extension DAT it in the same
directory as the original. If the input file is an already parsed DAT file, the class loads it directy.
Definition at line 26 of file LoaderOBJ.h.
LoaderOBJ::LoaderOBJ | ( | const std::string & | _file_path | ) |
Constructor.
Only checks if the file has a valid extension. No parsing takes place yet.
Definition at line 8 of file LoaderOBJ.cpp.
LoaderOBJ::~LoaderOBJ | ( | ) |
Destructor.
Definition at line 26 of file LoaderOBJ.cpp.
|
private |
Hidden copy-contructor.
|
private |
This is the error-handling function.
Definition at line 152 of file LoaderOBJ.cpp.
|
inline |
A getter for the number of face indices.
Definition at line 44 of file LoaderOBJ.h.
|
inline |
A getter for the number of vertices.
Definition at line 46 of file LoaderOBJ.h.
|
private |
This is function a for comparing two index containers.
[in] | _ic1 | is the one, |
[in] | _ic2 | is the other index container. The comparison is based on the first 3 entries only. |
Definition at line 295 of file LoaderOBJ.cpp.
|
private |
This function converts the multiple-index geometry in the OBJ file into single-index geometry for use in OpenGL.
Definition at line 310 of file LoaderOBJ.cpp.
int LoaderOBJ::obj2Container | ( | ) |
This function starts the loading / parsing process.
Definition at line 38 of file LoaderOBJ.cpp.
|
private |
This function contains the main parsing functionality.
[in] | _f | is the openend file handle. |
Definition at line 181 of file LoaderOBJ.cpp.
|
private |
This function reads and parses the DAT file.
Definition at line 82 of file LoaderOBJ.cpp.
|
private |
This function reads and parses the OBJ file.
Definition at line 59 of file LoaderOBJ.cpp.
|
private |
This function converts a string to a std::vector of 9 uints.
As the OBJ file contains multi-indexed face indices, each index of a triangle
constists of 3 indices into the vertex, normals and texture coordinate arrays.
[in] | _line | is the string read from the OBJ file. |
Definition at line 265 of file LoaderOBJ.cpp.
|
private |
This function converts a string to a std::vector of 3 floats.
[in] | _line | is the string read from the OBJ file. |
Definition at line 242 of file LoaderOBJ.cpp.
|
private |
This function is called by readDataFromOBJ() to write the DAT file.
Definition at line 117 of file LoaderOBJ.cpp.
GLuint* vis2::LoaderOBJ::face_ind |
holds the face indices as a 1-dimensional array
(every 3 consecutive values describe one triangle)
Definition at line 41 of file LoaderOBJ.h.
|
private |
holds the old face multi-indices as a 1-dimensional array
(every 9 consecutive values describe one triangle)
Definition at line 116 of file LoaderOBJ.h.
|
private |
holds the full path to the OBJ or DAT file
Definition at line 107 of file LoaderOBJ.h.
|
private |
is VIS2_FILE_TYPE_OBJ if the read file is OBJ, VIS2_FILE_TYPE_DAT therwise
Definition at line 108 of file LoaderOBJ.h.
|
private |
contains all old index triples that caused new elements to be added to the vertex attribute arrays
Definition at line 110 of file LoaderOBJ.h.
|
private |
is the number of new face indices in total
Definition at line 118 of file LoaderOBJ.h.
|
private |
is the number of single-indices (unique) needed for drawing
Definition at line 119 of file LoaderOBJ.h.
GLfloat* vis2::LoaderOBJ::vert_normals |
holds the vertex normals as a 1-dimensional array
(every 3 consecutive values are 1 vertex normal)
Definition at line 39 of file LoaderOBJ.h.
|
private |
holds the old vertex normals as a 1-dimensional array
(every 3 consecutive values are 1 vertex normal)
Definition at line 114 of file LoaderOBJ.h.
GLfloat* vis2::LoaderOBJ::vert_positions |
holds the vertex positions as a 1-dimensional array
(every 3 consecutive values are 1 vertex position)
Definition at line 38 of file LoaderOBJ.h.
|
private |
holds the old vertex positions as a 1-dimensional array
(every 3 consecutive values are 1 vertex position)
Definition at line 113 of file LoaderOBJ.h.
GLfloat* vis2::LoaderOBJ::vert_uvs |
holds the vertex texture coordinates as a 1-dimensional array
(every 2 consecutive values are 1 texture coordinate)
Definition at line 40 of file LoaderOBJ.h.
|
private |
holds the old vertex texture coordinates as a 1-dimensional array
(every 2 consecutive values are 1 texture coordinate)
Definition at line 115 of file LoaderOBJ.h.