cgv
|
implements the virtual interface of the obj_reader and stores all read information. More...
#include <obj_loader.h>
Public Types | |
typedef obj_reader_generic< T >::vec3_type | vec3_type |
typedef obj_reader_generic< T >::vec2_type | vec2_type |
typedef obj_reader_base::color_type | color_type |
![]() | |
typedef T | coord_type |
type of coordinates | |
typedef cgv::math::fvec< T, 2 > | vec2_type |
type used to store texture coordinates | |
typedef cgv::math::fvec< T, 3 > | vec3_type |
type used to store positions and normal vectors | |
![]() | |
typedef illum::obj_material::color_type | color_type |
type used for rgba colors | |
Public Attributes | |
std::vector< vec3_type > | vertices |
std::vector< vec3_type > | normals |
std::vector< vec2_type > | texcoords |
std::vector< color_type > | colors |
std::vector< unsigned > | vertex_indices |
std::vector< unsigned > | normal_indices |
std::vector< unsigned > | texcoord_indices |
std::vector< line_info > | lines |
std::vector< face_info > | faces |
std::vector< group_info > | groups |
std::vector< cgv::media::illum::obj_material > | materials |
virtual interface | |
void | process_vertex (const vec3_type &p) |
overide this function to process a vertex | |
void | process_texcoord (const vec2_type &t) |
overide this function to process a texcoord | |
void | process_normal (const vec3_type &n) |
overide this function to process a normal | |
void | process_color (const color_type &c) |
overide this function to process a color (this called for vc prefixes which is is not in the standard but for example used in pobj-files) | |
void | process_line (unsigned vcount, int *vertices, int *texcoords=0, int *normals=0) |
overide this function to process a line | |
void | process_face (unsigned vcount, int *vertices, int *texcoords=0, int *normals=0) |
overide this function to process a face | |
void | process_group (const std::string &name, const std::string ¶meters) |
overide this function to process a group given by name | |
void | process_material (const cgv::media::illum::obj_material &mtl, unsigned idx) |
process a material definition | |
bool | read_obj (const std::string &file_name) |
overloads reading to support binary file format | |
bool | read_obj_bin (const std::string &file_name) |
read a binary version of an obj file | |
bool | write_obj_bin (const std::string &file_name) const |
write the information from the last read obj file in binary format | |
void | show_stats () const |
use this after reading to show status information about the number of read entities | |
void | clear () |
prepare for reading another file | |
Additional Inherited Members | |
![]() | |
obj_reader_generic () | |
default constructor | |
![]() | |
virtual bool | parse_obj (const std::string &content, const std::string path_name="") |
parse the content of an obj file already read to memory, where path_name is used to find material files | |
virtual bool | read_mtl (const std::string &file_name) |
read a material file | |
![]() | |
static bool | is_double (const char *begin, const char *end, coord_type &value) |
![]() | |
vec2_type | parse_vec2 (const std::vector< cgv::utils::token > &t) const |
parse 2d vector | |
vec3_type | parse_vec3 (const std::vector< cgv::utils::token > &t) const |
parse 3d vector | |
void | parse_and_process_vertex (const std::vector< cgv::utils::token > &tokens) |
void | parse_and_process_normal (const std::vector< cgv::utils::token > &tokens) |
void | parse_and_process_texcoord (const std::vector< cgv::utils::token > &tokens) |
![]() | |
color_type | parse_color (const std::vector< cgv::utils::token > &t, unsigned off=0) const |
parse a color, if alpha not given it defaults to 1 | |
void | parse_face (const std::vector< cgv::utils::token > &tokens, bool is_line=false) |
void | parse_material (const std::vector< cgv::utils::token > &tokens) |
unsigned | get_current_group () const |
return the index of the currently selected group or -1 if no group is defined | |
unsigned | get_current_material () const |
return the index of the currently selected material or -1 if no material is defined | |
virtual void | process_comment (const std::string &comment) |
overide this function to process a comment | |
void | convert_to_positive (unsigned vcount, int *vertices, int *texcoords, int *normals, unsigned v, unsigned n, unsigned t) |
convert negative indices to positive ones by adding the number of elements | |
![]() | |
unsigned | group_index |
keep track of the current group | |
unsigned | nr_groups |
number of groups | |
unsigned | material_index |
keep track of current material index | |
unsigned | nr_materials |
number of materials | |
std::map< std::string, unsigned > | material_index_lut |
mapping from material names to material indices | |
int | minus |
unsigned | nr_normals |
unsigned | nr_texcoords |
bool | have_default_material |
std::set< std::string > | mtl_lib_files |
std::string | path_name |
store the path name | |
implements the virtual interface of the obj_reader and stores all read information.
The read information is automatically stored in binary form to accelerate the second loading of the same obj file.
Definition at line 64 of file obj_loader.h.
typedef obj_reader_base::color_type cgv::media::mesh::obj_loader_generic< T >::color_type |
Definition at line 70 of file obj_loader.h.
typedef obj_reader_generic<T>::vec2_type cgv::media::mesh::obj_loader_generic< T >::vec2_type |
Definition at line 69 of file obj_loader.h.
typedef obj_reader_generic<T>::vec3_type cgv::media::mesh::obj_loader_generic< T >::vec3_type |
Definition at line 68 of file obj_loader.h.
|
virtual |
prepare for reading another file
Reimplemented from cgv::media::mesh::obj_reader_base.
Definition at line 299 of file obj_loader.cxx.
References cgv::media::mesh::obj_reader_base::clear().
|
protectedvirtual |
overide this function to process a color (this called for vc prefixes which is is not in the standard but for example used in pobj-files)
Reimplemented from cgv::media::mesh::obj_reader_base.
Definition at line 57 of file obj_loader.cxx.
|
protectedvirtual |
overide this function to process a face
Reimplemented from cgv::media::mesh::obj_reader_base.
Definition at line 86 of file obj_loader.cxx.
|
protectedvirtual |
overide this function to process a group given by name
Reimplemented from cgv::media::mesh::obj_reader_base.
Definition at line 109 of file obj_loader.cxx.
References cgv::media::mesh::group_info::name, and cgv::media::mesh::group_info::parameters.
|
protectedvirtual |
overide this function to process a line
Reimplemented from cgv::media::mesh::obj_reader_base.
Definition at line 64 of file obj_loader.cxx.
|
protectedvirtual |
process a material definition
Reimplemented from cgv::media::mesh::obj_reader_base.
Definition at line 119 of file obj_loader.cxx.
|
protectedvirtual |
overide this function to process a normal
Reimplemented from cgv::media::mesh::obj_reader_generic< T >.
Definition at line 51 of file obj_loader.cxx.
|
protectedvirtual |
overide this function to process a texcoord
Reimplemented from cgv::media::mesh::obj_reader_generic< T >.
Definition at line 45 of file obj_loader.cxx.
|
protectedvirtual |
overide this function to process a vertex
Reimplemented from cgv::media::mesh::obj_reader_generic< T >.
Definition at line 38 of file obj_loader.cxx.
|
virtual |
overloads reading to support binary file format
Reimplemented from cgv::media::mesh::obj_reader_base.
Definition at line 141 of file obj_loader.cxx.
bool cgv::media::mesh::obj_loader_generic< T >::read_obj_bin | ( | const std::string & | file_name | ) |
read a binary version of an obj file
Definition at line 182 of file obj_loader.cxx.
References cgv::media::mesh::obj_reader_base::read_mtl().
void cgv::media::mesh::obj_loader_generic< T >::show_stats | ( | ) | const |
use this after reading to show status information about the number of read entities
Definition at line 428 of file obj_loader.cxx.
bool cgv::media::mesh::obj_loader_generic< T >::write_obj_bin | ( | const std::string & | file_name | ) | const |
write the information from the last read obj file in binary format
Definition at line 317 of file obj_loader.cxx.
std::vector<color_type> cgv::media::mesh::obj_loader_generic< T >::colors |
Definition at line 75 of file obj_loader.h.
std::vector<face_info> cgv::media::mesh::obj_loader_generic< T >::faces |
Definition at line 82 of file obj_loader.h.
std::vector<group_info> cgv::media::mesh::obj_loader_generic< T >::groups |
Definition at line 83 of file obj_loader.h.
std::vector<line_info> cgv::media::mesh::obj_loader_generic< T >::lines |
Definition at line 81 of file obj_loader.h.
std::vector<cgv::media::illum::obj_material> cgv::media::mesh::obj_loader_generic< T >::materials |
Definition at line 84 of file obj_loader.h.
std::vector<unsigned> cgv::media::mesh::obj_loader_generic< T >::normal_indices |
Definition at line 78 of file obj_loader.h.
std::vector<vec3_type> cgv::media::mesh::obj_loader_generic< T >::normals |
Definition at line 73 of file obj_loader.h.
std::vector<unsigned> cgv::media::mesh::obj_loader_generic< T >::texcoord_indices |
Definition at line 79 of file obj_loader.h.
std::vector<vec2_type> cgv::media::mesh::obj_loader_generic< T >::texcoords |
Definition at line 74 of file obj_loader.h.
std::vector<unsigned> cgv::media::mesh::obj_loader_generic< T >::vertex_indices |
Definition at line 77 of file obj_loader.h.
std::vector<vec3_type> cgv::media::mesh::obj_loader_generic< T >::vertices |
Definition at line 72 of file obj_loader.h.