Container class for a generic mesh with normal, color, texture, ... More...
Public Member Functions | |
const vec3 & | vertex (const unsigned int &index) const |
Accessor to the vertex value. More... | |
vec3 & | vertex (const unsigned int &index) |
Accessor to the vertex value. More... | |
const vec3 & | vertex_of_polygon (const unsigned int &index_polygon, const unsigned int &index_vertex) const |
Accessor to the vertex value. More... | |
vec3 & | vertex_of_polygon (const unsigned int &index_polygon, const unsigned int &index_vertex) |
Accessor to the vertex value. More... | |
const vec3 & | normal (const unsigned int &index) const |
Accessor to the normal value. More... | |
vec3 & | normal (const unsigned int &index) |
Accessor to the normal value. More... | |
const vec3 & | color (const unsigned int &index) const |
Accessor to the color value. More... | |
vec3 & | color (const unsigned int &index) |
Accessor to the color value. More... | |
const int & | connectivity (const unsigned int &index) const |
Accessor to the connectivity value. More... | |
int & | connectivity (const unsigned int &index) |
Accessor to the connectivity value. More... | |
const vec2 & | texture (const unsigned int &index) const |
Accessor to the uv-texture value. More... | |
vec2 & | texture (const unsigned int &index) |
Accessor to the uv-texture value. More... | |
const std::vector< vec3 > & | get_vertices () const |
return internal vertices vector More... | |
const std::vector< vec3 > & | get_normal () const |
return internal normal vector More... | |
const std::vector< vec3 > & | get_color () const |
return internal color vector More... | |
const std::vector< int > & | get_connectivity () const |
return internal connectivity vector More... | |
const std::vector< vec2 > & | get_texture () const |
return internal uv texture vector More... | |
std::vector< vec3 > & | get_vertices () |
return internal vertices vector More... | |
std::vector< vec3 > & | get_normal () |
return internal normal vector More... | |
std::vector< vec3 > & | get_color () |
return internal color vector More... | |
std::vector< int > & | get_connectivity () |
return internal connectivity vector More... | |
std::vector< vec2 > & | get_texture () |
return internal uv texture vector More... | |
void | add_vertex (const vec3 &vertex_to_add) |
Add a vertex to the mesh. More... | |
void | add_texture (const vec2 &texture_to_add) |
Add a texture to the mesh. More... | |
void | add_triangle (const int u0, const int u1, const int u2) |
Add a triangle to the mesh. More... | |
unsigned int | number_of_triangle () const |
get the number of triangle More... | |
unsigned int | number_of_vertices () const |
get the number of vertices More... | |
void | fill_color (const vec3 &c) |
fill mesh with constant color More... | |
void | fill_color_xyz () |
fill mesh with color depending of (x,y,z)-coordinates More... | |
void | fill_color_normal () |
fill mesh with color depending of normal orientation More... | |
void | compute_normal () |
Compute a per-vertex normal and fill the internal vector. More... | |
void | normal_inversion () |
Inverse the direction of the normal. More... | |
std::vector< vec3 > | get_normal_per_vertex () const |
get the vector per vertex More... | |
std::vector< vec3 > | get_normal_per_polygon () const |
get the vector per polygon More... | |
mesh & | operator+= (const vec3 &x) |
internal translation More... | |
mesh & | operator-= (const vec3 &x) |
internal translation More... | |
mesh & | operator*= (const float &s) |
uniform scaling More... | |
void | scale (const float &sx, const float &sy, const float &sz) |
scale the mesh with anisotropical values More... | |
void | auto_scale (const float &scale=1.0) |
Set vertices to fit in scalex[-1,1]x[-1,1]. More... | |
void | apply (const cpe::matrix3 R) |
Apply matrix to every vertices. More... | |
void | load_file (const std::string &filename) |
load a off file More... | |
Private Attributes | |
std::vector< vec3 > | v_vertices |
internal vertices storage More... | |
std::vector< vec3 > | v_normal |
internal normal storage More... | |
std::vector< vec3 > | v_color |
internal color storage More... | |
std::vector< vec2 > | v_texture |
internal texture coordinate storage More... | |
std::vector< int > | v_connectivity |
internal connectivity storage More... | |
Friends | |
mesh | operator+ (const vec3 &x, const mesh &m) |
translation More... | |
mesh | operator+ (const mesh &m, const vec3 &x) |
translation More... | |
mesh | operator- (const mesh &m, const vec3 &x) |
translation More... | |
mesh | operator* (const float &s, const mesh &m) |
uniform scaling More... | |
mesh | operator* (const mesh &m, const float &s) |
uniform scaling More... | |
Container class for a generic mesh with normal, color, texture, ...
void cpe::mesh::add_texture | ( | const vec2 & | texture_to_add | ) |
void cpe::mesh::add_triangle | ( | const int | u0, |
const int | u1, | ||
const int | u2 | ||
) |
void cpe::mesh::add_vertex | ( | const vec3 & | vertex_to_add | ) |
void cpe::mesh::apply | ( | const cpe::matrix3 | R | ) |
Apply matrix to every vertices.
References v_vertices.
void cpe::mesh::auto_scale | ( | const float & | scale = 1.0 | ) |
Set vertices to fit in scalex[-1,1]x[-1,1].
z-coordinate is set to start at -1 Auto fit the unit square ((-1,-1,1),(-1,1,1),(1,-1,1),(1,1,1))
References v_vertices, cpe::vec3::x(), cpe::vec3::y(), and cpe::vec3::z().
const vec3 & cpe::mesh::color | ( | const unsigned int & | index | ) | const |
vec3 & cpe::mesh::color | ( | const unsigned int & | index | ) |
Accessor to the color value.
References v_color.
void cpe::mesh::compute_normal | ( | ) |
Compute a per-vertex normal and fill the internal vector.
References get_normal_per_vertex(), and v_normal.
const int & cpe::mesh::connectivity | ( | const unsigned int & | index | ) | const |
Accessor to the connectivity value.
References v_color, and v_connectivity.
Referenced by cpe::render_engine::render().
int & cpe::mesh::connectivity | ( | const unsigned int & | index | ) |
Accessor to the connectivity value.
References v_color, and v_connectivity.
void cpe::mesh::fill_color | ( | const vec3 & | c | ) |
fill mesh with constant color
References v_color, and v_vertices.
void cpe::mesh::fill_color_normal | ( | ) |
fill mesh with color depending of normal orientation
References v_color, v_normal, v_vertices, cpe::vec3::x(), cpe::vec3::y(), and cpe::vec3::z().
void cpe::mesh::fill_color_xyz | ( | ) |
fill mesh with color depending of (x,y,z)-coordinates
References v_color, v_vertices, cpe::vec3::x(), cpe::vec3::y(), and cpe::vec3::z().
const std::vector< vec3 > & cpe::mesh::get_color | ( | ) | const |
return internal color vector
References v_color.
const std::vector< int > & cpe::mesh::get_connectivity | ( | ) | const |
return internal connectivity vector
References v_connectivity.
Referenced by cpe::mesh_io::load_off_file().
std::vector< int > & cpe::mesh::get_connectivity | ( | ) |
return internal connectivity vector
References v_connectivity.
const std::vector< vec3 > & cpe::mesh::get_normal | ( | ) | const |
return internal normal vector
References v_normal.
std::vector< vec3 > cpe::mesh::get_normal_per_polygon | ( | ) | const |
get the vector per polygon
References v_connectivity, and v_vertices.
Referenced by get_normal_per_vertex().
std::vector< vec3 > cpe::mesh::get_normal_per_vertex | ( | ) | const |
get the vector per vertex
References get_normal_per_polygon(), cpe::vec3::normalized(), v_connectivity, and v_vertices.
Referenced by compute_normal().
const std::vector< vec2 > & cpe::mesh::get_texture | ( | ) | const |
return internal uv texture vector
References v_texture.
std::vector< vec2 > & cpe::mesh::get_texture | ( | ) |
return internal uv texture vector
References v_texture.
const std::vector< vec3 > & cpe::mesh::get_vertices | ( | ) | const |
std::vector< vec3 > & cpe::mesh::get_vertices | ( | ) |
return internal vertices vector
References v_vertices.
void cpe::mesh::load_file | ( | const std::string & | filename | ) |
load a off file
References cpe::mesh_io::load_obj_file(), and cpe::mesh_io::load_off_file().
const vec3 & cpe::mesh::normal | ( | const unsigned int & | index | ) | const |
vec3 & cpe::mesh::normal | ( | const unsigned int & | index | ) |
Accessor to the normal value.
References v_normal.
void cpe::mesh::normal_inversion | ( | ) |
Inverse the direction of the normal.
References v_normal.
unsigned int cpe::mesh::number_of_triangle | ( | ) | const |
unsigned int cpe::mesh::number_of_vertices | ( | ) | const |
get the number of vertices
References v_vertices.
mesh & cpe::mesh::operator*= | ( | const float & | s | ) |
uniform scaling
References v_vertices.
internal translation
References v_vertices.
internal translation
References v_vertices.
void cpe::mesh::scale | ( | const float & | sx, |
const float & | sy, | ||
const float & | sz | ||
) |
scale the mesh with anisotropical values
References v_vertices.
const vec2 & cpe::mesh::texture | ( | const unsigned int & | index | ) | const |
Accessor to the uv-texture value.
References v_texture.
vec2 & cpe::mesh::texture | ( | const unsigned int & | index | ) |
Accessor to the uv-texture value.
References v_texture.
const vec3 & cpe::mesh::vertex | ( | const unsigned int & | index | ) | const |
vec3 & cpe::mesh::vertex | ( | const unsigned int & | index | ) |
Accessor to the vertex value.
References v_vertices.
const vec3 & cpe::mesh::vertex_of_polygon | ( | const unsigned int & | index_polygon, |
const unsigned int & | index_vertex | ||
) | const |
Accessor to the vertex value.
References v_connectivity, and v_vertices.
vec3 & cpe::mesh::vertex_of_polygon | ( | const unsigned int & | index_polygon, |
const unsigned int & | index_vertex | ||
) |
Accessor to the vertex value.
References v_connectivity, and v_vertices.
|
private |
internal color storage
Referenced by color(), connectivity(), fill_color(), fill_color_normal(), fill_color_xyz(), and get_color().
|
private |
internal connectivity storage
Referenced by add_triangle(), connectivity(), get_connectivity(), get_normal_per_polygon(), get_normal_per_vertex(), number_of_triangle(), and vertex_of_polygon().
|
private |
internal normal storage
Referenced by compute_normal(), fill_color_normal(), get_normal(), normal(), and normal_inversion().
|
private |
internal texture coordinate storage
Referenced by add_texture(), get_texture(), and texture().
|
private |
internal vertices storage
Referenced by add_vertex(), apply(), auto_scale(), fill_color(), fill_color_normal(), fill_color_xyz(), get_normal_per_polygon(), get_normal_per_vertex(), get_vertices(), number_of_vertices(), operator*=(), operator+=(), operator-=(), scale(), vertex(), and vertex_of_polygon().