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

#include <obj_reader.h>

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

Public Types

typedef T crd_type
 type of coordinates
 
typedef cgv::math::fvec< T, 2 > v2d_type
 type used to store texture coordinates
 
typedef cgv::math::fvec< T, 3 > v3d_type
 type used to store positions and normal vectors
 
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

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
 
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) More...
 
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_face (unsigned vcount, int *vertices, int *texcoords=0, int *normals=0)
 overide this function to process a face, the indices start with 0 More...
 
virtual void process_group (const std::string &name, const std::string &parameters)
 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 More...
 
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
 

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
 
 obj_reader_generic ()
 default constructor
 

Detailed Description

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

implements the pure reading of an obj file and calls virtual callback functions to allow a derived class to handle the read information. The default implementations of the processing methods are implemented to simply ignore the read information.

Member Function Documentation

◆ process_color()

void cgv::media::mesh::obj_reader_base::process_color ( const color_type c)
protectedvirtualinherited

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 >.

◆ process_face()

void cgv::media::mesh::obj_reader_base::process_face ( unsigned  vcount,
int *  vertices,
int *  texcoords = 0,
int *  normals = 0 
)
protectedvirtualinherited

overide this function to process a face, the indices start with 0

overide this function to process a face

Reimplemented in cgv::media::mesh::obj_loader_generic< T >.

◆ process_material()

void cgv::media::mesh::obj_reader_base::process_material ( const cgv::media::illum::obj_material mtl,
unsigned  idx 
)
protectedvirtualinherited

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 >.


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