cgv
cgv::media::mesh::obj_loader_generic< T > Class Template Reference

#include <obj_loader.h>

Inheritance diagram for cgv::media::mesh::obj_loader_generic< T >:
cgv::media::mesh::obj_reader_generic< T > cgv::media::mesh::obj_reader_base

Public Types

typedef T crd_type
 type of coordinates
 

Protected Member Functions

virtual interface
virtual void process_vertex (const v3d_type &p)
 overide this function to process a vertex
 
virtual void process_texcoord (const v2d_type &t)
 overide this function to process a texcoord
 
virtual void process_normal (const v3d_type &n)
 overide this function to process a normal
 

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
 

virtual interface

void process_vertex (const v3d_type &p)
 overide this function to process a vertex
 
void process_texcoord (const v2d_type &t)
 overide this function to process a texcoord
 
void process_normal (const v3d_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_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 &parameters)
 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
 

helpers for reading

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)
 
void parse_material (const std::vector< cgv::utils::token > &tokens)
 
int minus
 
unsigned nr_normals
 
unsigned nr_texcoords
 
bool have_default_material
 
std::set< std::string > mtl_lib_files
 

status info during reading

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
 
std::string path_name
 store the path name
 

virtual interface

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
 
virtual bool read_mtl (const std::string &file_name)
 read a material file
 

Detailed Description

template<typename T>
class cgv::media::mesh::obj_loader_generic< T >

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.


The documentation for this class was generated from the following files: