|
cgv
|
base class for obj reader with implementation that is independent of coordinate type. More...
#include <obj_reader.h>
Public Types | |
| typedef illum::obj_material::color_type | color_type |
| type used for rgba colors | |
Protected Attributes | |
| 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 | |
helpers for reading | |
| int | minus |
| unsigned | nr_normals |
| unsigned | nr_texcoords |
| bool | have_default_material |
| std::set< std::string > | mtl_lib_files |
| 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) |
| virtual void | parse_and_process_vertex (const std::vector< cgv::utils::token > &tokens)=0 |
| virtual void | parse_and_process_normal (const std::vector< cgv::utils::token > &tokens)=0 |
| virtual void | parse_and_process_texcoord (const std::vector< cgv::utils::token > &tokens)=0 |
status info during reading | |
| std::string | path_name |
| store the path name | |
| 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 interface | |
| virtual void | process_comment (const std::string &comment) |
| overide this function to process a comment | |
| virtual 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 | 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 | |
| virtual void | process_line (unsigned vcount, int *vertices, int *texcoords=0, int *normals=0) |
| overide this function to process a line strip, the indices start with 0 | |
| virtual void | process_face (unsigned vcount, int *vertices, int *texcoords=0, int *normals=0) |
| overide this function to process a face, the indices start with 0 | |
| virtual void | process_group (const std::string &name, const std::string ¶meters) |
| overide this function to process a group given by name and parameter string | |
| virtual void | process_material (const cgv::media::illum::obj_material &mtl, unsigned idx) |
| process a material definition. If a material with a certain name is overwritten, it will receive the same index | |
| 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_obj (const std::string &file_name) |
| read an obj file | |
| virtual bool | read_mtl (const std::string &file_name) |
| read a material file | |
| virtual void | clear () |
| clear the reader such that a new file can be read | |
base class for obj reader with implementation that is independent of coordinate type.
Definition at line 18 of file obj_reader.h.
type used for rgba colors
Definition at line 22 of file obj_reader.h.
| cgv::media::mesh::obj_reader_base::obj_reader_base | ( | ) |
Definition at line 87 of file obj_reader.cxx.
|
virtual |
clear the reader such that a new file can be read
Reimplemented in cgv::media::mesh::obj_loader_generic< T >.
Definition at line 92 of file obj_reader.cxx.
References material_index, material_index_lut, nr_groups, and nr_materials.
Referenced by cgv::media::mesh::obj_loader_generic< T >::clear().
|
protected |
convert negative indices to positive ones by adding the number of elements
Definition at line 138 of file obj_reader.cxx.
Referenced by cgv::media::mesh::simple_mesh_obj_reader< T >::process_face().
|
protected |
return the index of the currently selected group or -1 if no group is defined
Definition at line 76 of file obj_reader.cxx.
References group_index.
Referenced by cgv::media::mesh::simple_mesh_obj_reader< T >::process_face().
|
protected |
return the index of the currently selected material or -1 if no material is defined
Definition at line 82 of file obj_reader.cxx.
References material_index.
Referenced by cgv::media::mesh::simple_mesh_obj_reader< T >::process_face().
|
protected |
parse a color, if alpha not given it defaults to 1
Definition at line 63 of file obj_reader.cxx.
Referenced by parse_obj(), and read_mtl().
|
protected |
Definition at line 419 of file obj_reader.cxx.
|
protected |
Definition at line 407 of file obj_reader.cxx.
|
virtual |
parse the content of an obj file already read to memory, where path_name is used to find material files
Definition at line 207 of file obj_reader.cxx.
References group_index, material_index, material_index_lut, cgv::media::illum::obj_material::name, nr_groups, nr_materials, parse_color(), process_color(), process_group(), process_material(), read_mtl(), cgv::utils::split_to_lines(), and cgv::utils::to_string().
Referenced by read_obj().
|
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)
overide this function to process a normal
Reimplemented in cgv::media::mesh::obj_loader_generic< T >, and cgv::media::mesh::simple_mesh_obj_reader< T >.
Definition at line 133 of file obj_reader.cxx.
Referenced by parse_obj().
|
protectedvirtual |
overide this function to process a comment
Definition at line 110 of file obj_reader.cxx.
|
protectedvirtual |
overide this function to process a face, the indices start with 0
overide this function to process a face
Reimplemented in cgv::media::mesh::simple_mesh_obj_reader< T >, and cgv::media::mesh::obj_loader_generic< T >.
Definition at line 162 of file obj_reader.cxx.
|
protectedvirtual |
overide this function to process a group given by name and parameter string
Reimplemented in cgv::media::mesh::obj_loader_generic< T >, and cgv::media::mesh::simple_mesh_obj_reader< T >.
Definition at line 167 of file obj_reader.cxx.
Referenced by parse_obj().
|
protectedvirtual |
overide this function to process a line strip, the indices start with 0
overide this function to process a line given by two indices that start with 0
Reimplemented in cgv::media::mesh::obj_loader_generic< T >.
Definition at line 157 of file obj_reader.cxx.
|
protectedvirtual |
process a material definition. If a material with a certain name is overwritten, it will receive the same index
process a material definition
Reimplemented in cgv::media::mesh::obj_loader_generic< T >, and cgv::media::mesh::simple_mesh_obj_reader< T >.
Definition at line 172 of file obj_reader.cxx.
Referenced by parse_obj(), and read_mtl().
|
virtual |
read a material file
Definition at line 311 of file obj_reader.cxx.
References cgv::media::illum::phong_material::ambient, cgv::media::illum::obj_material::ambient_texture_name, cgv::media::illum::obj_material::bump_scale, cgv::media::illum::obj_material::bump_texture_name, cgv::media::illum::phong_material::diffuse, cgv::media::illum::obj_material::diffuse_texture_name, cgv::media::illum::phong_material::emission, cgv::media::illum::obj_material::emission_texture_name, cgv::base::find_data_file(), material_index_lut, cgv::media::illum::obj_material::name, nr_materials, cgv::media::illum::obj_material::opacity, cgv::media::illum::obj_material::opacity_texture_name, parse_color(), path_name, process_material(), cgv::media::illum::phong_material::shininess, cgv::media::illum::phong_material::specular, cgv::media::illum::obj_material::specular_texture_name, cgv::utils::split_to_lines(), and cgv::utils::to_string().
Referenced by parse_obj(), and cgv::media::mesh::obj_loader_generic< T >::read_obj_bin().
|
virtual |
read an obj file
Reimplemented in cgv::media::mesh::obj_loader_generic< T >.
Definition at line 195 of file obj_reader.cxx.
References parse_obj(), path_name, and cgv::base::read_data_file().
Referenced by cgv::media::mesh::simple_mesh< T >::read().
|
protected |
keep track of the current group
Definition at line 25 of file obj_reader.h.
Referenced by get_current_group(), and parse_obj().
|
protected |
Definition at line 40 of file obj_reader.h.
|
protected |
keep track of current material index
Definition at line 29 of file obj_reader.h.
Referenced by clear(), get_current_material(), and parse_obj().
|
protected |
mapping from material names to material indices
Definition at line 33 of file obj_reader.h.
Referenced by clear(), parse_obj(), and read_mtl().
|
protected |
Definition at line 38 of file obj_reader.h.
|
protected |
Definition at line 41 of file obj_reader.h.
|
protected |
number of groups
Definition at line 27 of file obj_reader.h.
Referenced by clear(), and parse_obj().
|
protected |
number of materials
Definition at line 31 of file obj_reader.h.
Referenced by clear(), parse_obj(), and read_mtl().
|
protected |
Definition at line 39 of file obj_reader.h.
|
protected |
Definition at line 39 of file obj_reader.h.
|
protected |
store the path name
Definition at line 52 of file obj_reader.h.
Referenced by read_mtl(), and read_obj().