gKit2 light
Loading...
Searching...
No Matches

representation d'un objet / maillage. More...

#include <mesh.h>

Public Member Functions

construction.
 Mesh ()
 constructeur par defaut.
 Mesh (const GLenum primitives)
 constructeur.
int create (const GLenum primitives)
 construit les objets openGL.
 Mesh (const GLenum primitives, const std::vector< vec3 > &positions)
 constructeur. a partir d'un ensemble de positions.
 Mesh (const GLenum primitives, const std::vector< vec3 > &positions, const std::vector< unsigned > &indices)
 constructeur. a partir d'un ensemble de positions indexees.
 Mesh (const GLenum primitives, const std::vector< vec3 > &positions, const std::vector< vec2 > &texcoords, const std::vector< vec3 > &normals, const std::vector< vec4 > &colors, const std::vector< unsigned > &indices)
 constructeur. a partir d'un ensemble de positions + attributs indexes.
void release ()
 detruit les objets openGL.
description des attributs des sommets.
Meshcolor (const vec4 &c)
 definit la couleur du prochain sommet.
Meshcolor (const Color &c)
 definit la couleur du prochain sommet.
Meshcolor (const float r, const float g, const float b, const float a=1)
 definit la couleur du prochain sommet.
Meshnormal (const vec3 &n)
 definit la normale du prochain sommet.
Meshnormal (const Vector &n)
 definit la normale du prochain sommet.
Meshnormal (const float x, const float y, const float z)
 definit la normale du prochain sommet.
Meshtexcoord (const vec2 &uv)
 definit les coordonnees de texture du prochain sommet.
Meshtexcoord (const float x, const float y)
 definit les coordonnees de texture du prochain sommet.
unsigned int vertex (const vec3 &p)
 insere un sommet de position p, et ses attributs (s'ils sont definis par color(), texcoord(), normal()), dans l'objet. renvoie l'indice du sommet.
unsigned int vertex (const Point &p)
 insere un sommet de position p, et ses attributs (s'ils sont definis par color(), texcoord(), normal()), dans l'objet. renvoie l'indice du sommet.
unsigned int vertex (const float x, const float y, const float z)
 insere un sommet de position p, et ses attributs (s'ils sont definis par color(), texcoord(), normal()), dans l'objet. renvoie l'indice du sommet.
void clear ()
 vide la description.
description de triangles indexes.
Meshtriangle (const unsigned int a, const unsigned int b, const unsigned int c)
Meshtriangle_last (const int a, const int b, const int c)
Meshrestart_strip ()
 demarre un nouveau strip. a utiliser avec un objet composes de GL_TRIANGLE_STRIP, doit aussi fonctionner avec GL_TRIANGLE_FAN, GL_LINE_STRIP, GL_LINE_LOOP, etc.
Meshindex (const int a)
modification des attributs des sommets.
Meshcolor (const unsigned int id, const vec4 &c)
 modifie la couleur du sommet d'indice id.
Meshcolor (const unsigned int id, const Color &c)
 modifie la couleur du sommet d'indice id.
Meshcolor (const unsigned int id, const float r, const float g, const float b, const float a=1)
 modifie la couleur du sommet d'indice id.
Meshnormal (const unsigned int id, const vec3 &n)
 modifie la normale du sommet d'indice id.
Meshnormal (const unsigned int id, const Vector &n)
 modifie la normale du sommet d'indice id.
Meshnormal (const unsigned int id, const float x, const float y, const float z)
 modifie la normale du sommet d'indice id.
Meshtexcoord (const unsigned int id, const vec2 &uv)
 modifie les coordonnees du sommet d'indice id.
Meshtexcoord (const unsigned int id, const float x, const float y)
 modifie les coordonnees du sommet d'indice id.
void vertex (const unsigned int id, const vec3 &p)
 modifie la position du sommet d'indice id.
void vertex (const unsigned int id, const Point &p)
 modifie la position du sommet d'indice id.
void vertex (const unsigned int id, const float x, const float y, const float z)
 modifie la position du sommet d'indice id.
description des matieres.
const Materialsmaterials () const
 renvoie la description des matieres.
Materialsmaterials ()
 renvoie la description des matieres.
void materials (const Materials &materials)
 remplace la description des matieres.
const std::vector< unsigned int > & material_indices () const
 renvoie les indices des matieres des triangles.
Meshmaterial (const unsigned int id)
 definit la matiere du prochain triangle. id est l'indice d'une matiere ajoutee dans materials(), cf la classe Materials. ne fonctionne que pour les primitives GL_TRIANGLES, indexees ou pas.
description des triangles d'un maillage.
int triangle_count () const
 renvoie le nombre de triangles.
TriangleData triangle (const unsigned int id) const
 renvoie un triangle.
int triangle_material_index (const unsigned int id) const
 renvoie l'indice de la matiere d'un triangle.
const Materialtriangle_material (const unsigned int id) const
 renvoie la matiere d'un triangle.
std::vector< TriangleGroupgroups ()
 renvoie les groupes de triangles de meme matiere. re-organise les triangles. permet d'afficher l'objet matiere par matiere.
std::vector< TriangleGroupgroups (const std::vector< unsigned int > &triangle_properties)
 renvoie les groupes de triangles de meme 'propriete'. re-organise les triangles.
void bounds (Point &pmin, Point &pmax) const
 renvoie min et max les coordonnees des extremites des positions des sommets de l'objet (boite englobante alignee sur les axes, aabb).
Color default_color () const
 renvoie la couleur par defaut du mesh, utilisee si les sommets n'ont pas de couleur associee.
Meshdefault_color (const Color &color)
 modifie la couleur par defaut, utilisee si les sommets n'ont pas de couleur associee.

manipulation des buffers d'attributs.

int vertex_count () const
 renvoie le nombre de sommets.
int index_count () const
 renvoie le nombre d'indices de sommets.
const float * vertex_buffer () const
 renvoie l'adresse de la position du premier sommet. permet de construire les vertex buffers openGL. par convention, la position est un vec3, 3 GL_FLOAT.
std::size_t vertex_buffer_size () const
 renvoie la longueur (en octets) du vertex buffer.
const float * normal_buffer () const
 renvoie l'adresse de la normale du premier sommet. par convention, la normale est un vec3, 3 GL_FLOAT.
std::size_t normal_buffer_size () const
 renvoie la longueur (en octets) du normal buffer.
const float * texcoord_buffer () const
 renvoie l'adresse des coordonnees de textures du premier sommet. par convention, c'est un vec2, 2 GL_FLOAT.
std::size_t texcoord_buffer_size () const
 renvoie la taille (en octets) du texcoord buffer.
const float * color_buffer () const
 renvoie l'adresse de la couleur du premier sommet. par convention, la couleur est un vec4, 4 GL_FLOAT.
std::size_t color_buffer_size () const
 renvoie la taille (en octets) du color buffer.
const void * index_buffer () const
 renvoie l'adresse du premier indice du premier triangle. par convention c'est un uint, 1, GL_UNSIGNED_INT.
std::size_t index_buffer_size () const
 renvoie la taille (en octets) de l'index buffer.
const std::vector< vec3 > & positions () const
const std::vector< vec2 > & texcoords () const
const std::vector< vec3 > & normals () const
const std::vector< vec4 > & colors () const
const std::vector< unsigned int > & indices () const
bool has_position () const
 verifie que les attributs sont decrits de maniere coherente.
bool has_texcoord () const
bool has_normal () const
bool has_color () const
bool has_material_index () const
GLenum primitives () const
 renvoie le type de primitives.
GLuint create_buffers ()
 construit les buffers et le vertex array object necessaires pour dessiner l'objet avec openGL. utilitaire. detruit par release( ). ou release_buffers( ).
GLuint create_buffers (const bool use_texcoord, const bool use_normal, const bool use_color, const bool use_material_index)
 construit les buffers et le vertex array object necessaires pour dessiner l'objet avec openGL. utilitaire. detruit par release( ). ou release_buffers( ).
GLuint create_buffers (const unsigned flags)
 idem mais utilise une combinaison des flags USE_TEXCOORD, USE_NORMAL...
void draw (const GLuint program)
 dessine l'objet avec un shader program.
void draw (const int first, const int n, const GLuint program)
 dessine une partie de l'objet avec un shader program.

Detailed Description

representation d'un objet / maillage.

Definition at line 120 of file mesh.h.

Constructor & Destructor Documentation

◆ Mesh() [1/5]

Mesh::Mesh ( )
inline

constructeur par defaut.

Definition at line 126 of file mesh.h.

126 : m_positions(), m_texcoords(), m_normals(), m_colors(), m_indices(),
127 m_color(White()), m_primitives(GL_POINTS), m_vao(0), m_buffer(0), m_index_buffer(0), m_vertex_buffer_size(0), m_index_buffer_size(0), m_update_buffers(false) {}
Color White()
utilitaire. renvoie une couleur blanche.
Definition color.cpp:23

◆ Mesh() [2/5]

Mesh::Mesh ( const GLenum primitives)
inline

constructeur.

Definition at line 130 of file mesh.h.

130 : m_positions(), m_texcoords(), m_normals(), m_colors(), m_indices(),
131 m_color(White()), m_primitives(primitives), m_vao(0), m_buffer(0), m_index_buffer(0), m_vertex_buffer_size(0), m_index_buffer_size(0), m_update_buffers(false) {}
GLenum primitives() const
renvoie le type de primitives.
Definition mesh.h:345

◆ Mesh() [3/5]

Mesh::Mesh ( const GLenum primitives,
const std::vector< vec3 > & positions )

constructeur. a partir d'un ensemble de positions.

Definition at line 22 of file mesh.cpp.

22 :
23 m_positions(positions), m_texcoords(), m_normals(), m_colors(), m_indices(),
24 m_color(White()), m_primitives(primitives), m_vao(0), m_buffer(0), m_index_buffer(0), m_vertex_buffer_size(0), m_index_buffer_size(0), m_update_buffers(true)
25{}

◆ Mesh() [4/5]

Mesh::Mesh ( const GLenum primitives,
const std::vector< vec3 > & positions,
const std::vector< unsigned > & indices )

constructeur. a partir d'un ensemble de positions indexees.

Definition at line 27 of file mesh.cpp.

27 :
28 m_positions(positions), m_texcoords(), m_normals(), m_colors(), m_indices(indices),
29 m_color(White()), m_primitives(primitives), m_vao(0), m_buffer(0), m_index_buffer(0), m_vertex_buffer_size(0), m_index_buffer_size(0), m_update_buffers(true)
30{}

◆ Mesh() [5/5]

Mesh::Mesh ( const GLenum primitives,
const std::vector< vec3 > & positions,
const std::vector< vec2 > & texcoords,
const std::vector< vec3 > & normals,
const std::vector< vec4 > & colors,
const std::vector< unsigned > & indices )

constructeur. a partir d'un ensemble de positions + attributs indexes.

Definition at line 32 of file mesh.cpp.

36 :
37 m_positions(positions), m_texcoords(), m_normals(), m_colors(), m_indices(indices),
38 m_color(White()), m_primitives(primitives), m_vao(0), m_buffer(0), m_index_buffer(0), m_vertex_buffer_size(0), m_index_buffer_size(0), m_update_buffers(true)
39{
40 // n'initialise les autres attributs que s'ils sont definis
41 if(texcoords.size() > 0 && texcoords.size() == positions.size())
42 m_texcoords= texcoords;
43 if(normals.size() > 0 && normals.size() == positions.size())
44 m_normals= normals;
45 if(colors.size() > 0 && colors.size() == positions.size())
46 m_colors= colors;
47}

Member Function Documentation

◆ create()

int Mesh::create ( const GLenum primitives)

construit les objets openGL.

Definition at line 16 of file mesh.cpp.

17{
18 m_primitives= primitives;
19 return 0;
20}

◆ release()

void Mesh::release ( )

detruit les objets openGL.

Definition at line 50 of file mesh.cpp.

51{
52 printf("mesh release %d\n", m_vao);
53
54 glDeleteVertexArrays(1, &m_vao);
55 glDeleteBuffers(1, &m_buffer);
56 glDeleteBuffers(1, &m_index_buffer);
57}
void printf(Text &text, const int px, const int py, const char *format,...)
affiche un texte a la position x, y. meme utilisation que printf().
Definition text.cpp:140

◆ color() [1/6]

Mesh & Mesh::color ( const vec4 & c)

definit la couleur du prochain sommet.

Definition at line 66 of file mesh.cpp.

67{
68 if(m_colors.size() <= m_positions.size())
69 m_colors.push_back(color);
70 else
71 m_colors.back()= color;
72 m_update_buffers= true;
73 return *this;
74}
Mesh & color(const vec4 &c)
definit la couleur du prochain sommet.
Definition mesh.cpp:66

◆ color() [2/6]

Mesh & Mesh::color ( const Color & c)
inline

definit la couleur du prochain sommet.

Definition at line 156 of file mesh.h.

156{ return color(vec4(c.r, c.g, c.b, c.a)); }

◆ color() [3/6]

Mesh & Mesh::color ( const float r,
const float g,
const float b,
const float a = 1 )
inline

definit la couleur du prochain sommet.

Definition at line 158 of file mesh.h.

158{ return color(vec4(r, g, b, a)); }

◆ normal() [1/6]

Mesh & Mesh::normal ( const vec3 & n)

definit la normale du prochain sommet.

Definition at line 76 of file mesh.cpp.

77{
78 if(m_normals.size() <= m_positions.size())
79 m_normals.push_back(normal);
80 else
81 m_normals.back()= normal;
82 m_update_buffers= true;
83 return *this;
84}
Mesh & normal(const vec3 &n)
definit la normale du prochain sommet.
Definition mesh.cpp:76

◆ normal() [2/6]

Mesh & Mesh::normal ( const Vector & n)
inline

definit la normale du prochain sommet.

Definition at line 163 of file mesh.h.

163{ return normal(vec3(n)); }

◆ normal() [3/6]

Mesh & Mesh::normal ( const float x,
const float y,
const float z )
inline

definit la normale du prochain sommet.

Definition at line 165 of file mesh.h.

165{ return normal(vec3(x, y, z)); }

◆ texcoord() [1/4]

Mesh & Mesh::texcoord ( const vec2 & uv)

definit les coordonnees de texture du prochain sommet.

Definition at line 86 of file mesh.cpp.

87{
88 if(m_texcoords.size() <= m_positions.size())
89 m_texcoords.push_back(uv);
90 else
91 m_texcoords.back()= uv;
92 m_update_buffers= true;
93 return *this;
94}

◆ texcoord() [2/4]

Mesh & Mesh::texcoord ( const float x,
const float y )
inline

definit les coordonnees de texture du prochain sommet.

Definition at line 170 of file mesh.h.

170{ return texcoord(vec2(x, y)); }
Mesh & texcoord(const vec2 &uv)
definit les coordonnees de texture du prochain sommet.
Definition mesh.cpp:86

◆ vertex() [1/6]

unsigned int Mesh::vertex ( const vec3 & p)

insere un sommet de position p, et ses attributs (s'ils sont definis par color(), texcoord(), normal()), dans l'objet. renvoie l'indice du sommet.

Definition at line 97 of file mesh.cpp.

98{
99 m_update_buffers= true;
100 m_positions.push_back(position);
101
102 // copie les autres attributs du sommet, uniquement s'ils sont definis
103 if(m_texcoords.size() > 0 && m_texcoords.size() != m_positions.size())
104 m_texcoords.push_back(m_texcoords.back());
105 if(m_normals.size() > 0 && m_normals.size() != m_positions.size())
106 m_normals.push_back(m_normals.back());
107 if(m_colors.size() > 0 && m_colors.size() != m_positions.size())
108 m_colors.push_back(m_colors.back());
109
110 // copie la matiere courante, uniquement si elle est definie
111 if(m_triangle_materials.size() > 0 && int(m_triangle_materials.size()) < triangle_count())
112 m_triangle_materials.push_back(m_triangle_materials.back());
113
114 unsigned int index= m_positions.size() -1;
115 // construction de l'index buffer pour les strip
116 switch(m_primitives)
117 {
118 case GL_LINE_STRIP:
119 case GL_LINE_LOOP:
120 case GL_TRIANGLE_STRIP:
121 case GL_TRIANGLE_FAN:
122 m_indices.push_back(index);
123 break;
124 default:
125 break;
126 }
127
128 // renvoie l'indice du sommet
129 return index;
130}
int triangle_count() const
renvoie le nombre de triangles.
Definition mesh.cpp:421
Mesh & index(const int a)
Definition mesh.cpp:227

◆ vertex() [2/6]

unsigned int Mesh::vertex ( const Point & p)
inline

insere un sommet de position p, et ses attributs (s'ils sont definis par color(), texcoord(), normal()), dans l'objet. renvoie l'indice du sommet.

Definition at line 175 of file mesh.h.

175{ return vertex(vec3(p)); }
unsigned int vertex(const vec3 &p)
insere un sommet de position p, et ses attributs (s'ils sont definis par color(), texcoord(),...
Definition mesh.cpp:97

◆ vertex() [3/6]

unsigned int Mesh::vertex ( const float x,
const float y,
const float z )
inline

insere un sommet de position p, et ses attributs (s'ils sont definis par color(), texcoord(), normal()), dans l'objet. renvoie l'indice du sommet.

Definition at line 177 of file mesh.h.

177{ return vertex(vec3(x, y, z)); }

◆ clear()

void Mesh::clear ( )

vide la description.

Definition at line 164 of file mesh.cpp.

165{
166 m_update_buffers= true;
167
168 m_positions.clear();
169 m_texcoords.clear();
170 m_normals.clear();
171 m_colors.clear();
172 m_indices.clear();
173 //~ m_materials.clear();
174 m_triangle_materials.clear();
175}

◆ triangle() [1/2]

Mesh & Mesh::triangle ( const unsigned int a,
const unsigned int b,
const unsigned int c )

insere un triangle. a, b, c sont les indices des sommets deja inseres dans l'objet. ne fonctionne pas avec les strips et les fans.

Mesh m(GL_TRIANGLES);
unsigned int a= m.vertex( Point(ax, ay, az) );
unsigned int b= m.vertex( Point(bx, by, bz) );
unsigned int c= m.vertex( Point(cx, cy, cz) );
m.triangle(a, b, c);
Mesh()
constructeur par defaut.
Definition mesh.h:126
representation d'un point 3d.
Definition vec.h:21

Definition at line 178 of file mesh.cpp.

179{
180 assert(a < m_positions.size());
181 assert(b < m_positions.size());
182 assert(c < m_positions.size());
183 m_update_buffers= true;
184 m_indices.push_back(a);
185 m_indices.push_back(b);
186 m_indices.push_back(c);
187
188 // copie la matiere courante, uniquement si elle est definie
189 if(m_triangle_materials.size() > 0 && int(m_triangle_materials.size()) < triangle_count())
190 m_triangle_materials.push_back(m_triangle_materials.back());
191
192 m_update_buffers= true;
193 return *this;
194}

◆ triangle_last()

Mesh & Mesh::triangle_last ( const int a,
const int b,
const int c )

insere un triangle, a, b, c sont les indices des sommets deja inseres dans l'objet, en comptant en partant du dernier. ne fonctionne pas avec les strips et les fans.

Mesh m(GL_TRIANGLES);
m.vertex( Point(ax, ay, az) );
m.vertex( Point(bx, by, bz) );
m.vertex( Point(cx, cy, cz) );
m.triangle_last(-3, -2, -1);

Definition at line 196 of file mesh.cpp.

197{
198 assert(a < 0);
199 assert(b < 0);
200 assert(c < 0);
201 m_update_buffers= true;
202 m_indices.push_back(int(m_positions.size()) + a);
203 m_indices.push_back(int(m_positions.size()) + b);
204 m_indices.push_back(int(m_positions.size()) + c);
205
206 // copie la matiere courante, uniquement si elle est definie
207 if(m_triangle_materials.size() > 0 && int(m_triangle_materials.size()) < triangle_count())
208 m_triangle_materials.push_back(m_triangle_materials.back());
209
210 m_update_buffers= true;
211 return *this;
212}

◆ restart_strip()

Mesh & Mesh::restart_strip ( )

demarre un nouveau strip. a utiliser avec un objet composes de GL_TRIANGLE_STRIP, doit aussi fonctionner avec GL_TRIANGLE_FAN, GL_LINE_STRIP, GL_LINE_LOOP, etc.

Definition at line 214 of file mesh.cpp.

215{
216 m_update_buffers= true;
217 m_indices.push_back(~0u); // ~0u plus grand entier non signe representable, ou UINT_MAX...
218#if 1
219 glPrimitiveRestartIndex(~0u);
220 glEnable(GL_PRIMITIVE_RESTART);
221#else
222 glEnable(GL_PRIMITIVE_RESTART_FIXED_INDEX); // n'existe pas sur mac ?!
223#endif
224 return *this;
225}

◆ index()

Mesh & Mesh::index ( const int a)

insere un indice de sommet.

Mesh m(GL_TRIANGLES);
unsigned int a= m.vertex( Point(ax, ay, az) );
unsigned int b= m.vertex( Point(bx, by, bz) );
unsigned int c= m.vertex( Point(cx, cy, cz) );
// insere le triangle abc
m.index(a);
m.index(b);
m.index(c);

Definition at line 227 of file mesh.cpp.

228{
229 if(a < 0)
230 m_indices.push_back(int(m_positions.size()) + a);
231 else if(a < int(m_positions.size()))
232 m_indices.push_back(a);
233 else
234 {
235 printf("[error] Mesh::index(): invalid index...\n");
236 return *this; // erreur
237 }
238
239 // copie la matiere courante, uniquement si elle est definie
240 if(m_triangle_materials.size() > 0 && int(m_triangle_materials.size()) < triangle_count())
241 m_triangle_materials.push_back(m_triangle_materials.back());
242
243 m_update_buffers= true;
244 return *this;
245}

◆ color() [4/6]

Mesh & Mesh::color ( const unsigned int id,
const vec4 & c )

modifie la couleur du sommet d'indice id.

Definition at line 133 of file mesh.cpp.

134{
135 assert(id < m_colors.size());
136 m_update_buffers= true;
137 m_colors[id]= c;
138 return *this;
139}

◆ color() [5/6]

Mesh & Mesh::color ( const unsigned int id,
const Color & c )
inline

modifie la couleur du sommet d'indice id.

Definition at line 231 of file mesh.h.

231{ return color(id, vec4(c.r, c.g, c.b, c.a)); }

◆ color() [6/6]

Mesh & Mesh::color ( const unsigned int id,
const float r,
const float g,
const float b,
const float a = 1 )
inline

modifie la couleur du sommet d'indice id.

Definition at line 233 of file mesh.h.

233{ return color(id, vec4(r, g, b, a)); }

◆ normal() [4/6]

Mesh & Mesh::normal ( const unsigned int id,
const vec3 & n )

modifie la normale du sommet d'indice id.

Definition at line 141 of file mesh.cpp.

142{
143 assert(id < m_normals.size());
144 m_update_buffers= true;
145 m_normals[id]= n;
146 return *this;
147}

◆ normal() [5/6]

Mesh & Mesh::normal ( const unsigned int id,
const Vector & n )
inline

modifie la normale du sommet d'indice id.

Definition at line 238 of file mesh.h.

238{ return normal(id, vec3(n)); }

◆ normal() [6/6]

Mesh & Mesh::normal ( const unsigned int id,
const float x,
const float y,
const float z )
inline

modifie la normale du sommet d'indice id.

Definition at line 240 of file mesh.h.

240{ return normal(id, vec3(x, y, z)); }

◆ texcoord() [3/4]

Mesh & Mesh::texcoord ( const unsigned int id,
const vec2 & uv )

modifie les coordonnees du sommet d'indice id.

Definition at line 149 of file mesh.cpp.

150{
151 assert(id < m_texcoords.size());
152 m_update_buffers= true;
153 m_texcoords[id]= uv;
154 return *this;
155}

◆ texcoord() [4/4]

Mesh & Mesh::texcoord ( const unsigned int id,
const float x,
const float y )
inline

modifie les coordonnees du sommet d'indice id.

Definition at line 245 of file mesh.h.

245{ return texcoord(id, vec2(x, y)); }

◆ vertex() [4/6]

void Mesh::vertex ( const unsigned int id,
const vec3 & p )

modifie la position du sommet d'indice id.

Definition at line 157 of file mesh.cpp.

158{
159 assert(id < m_positions.size());
160 m_update_buffers= true;
161 m_positions[id]= p;
162}

◆ vertex() [5/6]

void Mesh::vertex ( const unsigned int id,
const Point & p )
inline

modifie la position du sommet d'indice id.

Definition at line 250 of file mesh.h.

250{ vertex(id, vec3(p)); }

◆ vertex() [6/6]

void Mesh::vertex ( const unsigned int id,
const float x,
const float y,
const float z )
inline

modifie la position du sommet d'indice id.

Definition at line 252 of file mesh.h.

252{ vertex(id, vec3(x, y, z)); }

◆ materials() [1/3]

const Materials & Mesh::materials ( ) const

renvoie la description des matieres.

Definition at line 253 of file mesh.cpp.

254{
255 return m_materials;
256}

◆ materials() [2/3]

Materials & Mesh::materials ( )

renvoie la description des matieres.

Definition at line 248 of file mesh.cpp.

249{
250 return m_materials;
251}

◆ materials() [3/3]

void Mesh::materials ( const Materials & materials)

remplace la description des matieres.

Definition at line 258 of file mesh.cpp.

259{
260 m_materials= materials;
261}
const Materials & materials() const
renvoie la description des matieres.
Definition mesh.cpp:253

◆ material_indices()

const std::vector< unsigned int > & Mesh::material_indices ( ) const

renvoie les indices des matieres des triangles.

Definition at line 273 of file mesh.cpp.

274{
275 return m_triangle_materials;
276}

◆ material()

Mesh & Mesh::material ( const unsigned int id)

definit la matiere du prochain triangle. id est l'indice d'une matiere ajoutee dans materials(), cf la classe Materials. ne fonctionne que pour les primitives GL_TRIANGLES, indexees ou pas.

Definition at line 263 of file mesh.cpp.

264{
265 if(int(m_triangle_materials.size()) <= triangle_count())
266 m_triangle_materials.push_back(id);
267 else
268 m_triangle_materials.back()= id;
269 m_update_buffers= true;
270 return *this;
271}

◆ triangle_count()

int Mesh::triangle_count ( ) const

renvoie le nombre de triangles.

Definition at line 421 of file mesh.cpp.

422{
423 if(m_primitives != GL_TRIANGLES)
424 return 0;
425
426 if(m_indices.size() > 0)
427 return int(m_indices.size() / 3);
428 else
429 return int(m_positions.size() / 3);
430}

◆ triangle() [2/2]

TriangleData Mesh::triangle ( const unsigned int id) const

renvoie un triangle.

Definition at line 432 of file mesh.cpp.

433{
434 unsigned int a, b, c;
435 if(m_indices.size() > 0)
436 {
437 assert((size_t) id*3+2 < m_indices.size());
438 a= m_indices[id*3];
439 b= m_indices[id*3 +1];
440 c= m_indices[id*3 +2];
441 }
442 else
443 {
444 assert((size_t) id*3+2 < m_positions.size());
445 a= id*3;
446 b= id*3 +1;
447 c= id*3 +2;
448 }
449
450 TriangleData triangle;
451 triangle.a= m_positions[a];
452 triangle.b= m_positions[b];
453 triangle.c= m_positions[c];
454
455 if(m_normals.size() == m_positions.size())
456 {
457 triangle.na= m_normals[a];
458 triangle.nb= m_normals[b];
459 triangle.nc= m_normals[c];
460 }
461 else
462 {
463 // calculer la normale geometrique
464 Vector ab= Point(m_positions[b]) - Point(m_positions[a]);
465 Vector ac= Point(m_positions[c]) - Point(m_positions[a]);
466 Vector n= normalize(cross(ab, ac));
467 triangle.na= vec3(n);
468 triangle.nb= vec3(n);
469 triangle.nc= vec3(n);
470 }
471
472 if(m_texcoords.size() == m_positions.size())
473 {
474 triangle.ta= m_texcoords[a];
475 triangle.tb= m_texcoords[b];
476 triangle.tc= m_texcoords[c];
477 }
478 else
479 {
480 // coordonnees barycentriques des sommets, convention p(u, v)= w*a + u*b + v*c, avec w= 1 - u -v
481 triangle.ta= vec2(0, 0); // w= 1
482 triangle.tb= vec2(1, 0); // w= 0
483 triangle.tc= vec2(0, 1); // w= 0
484 }
485
486 return triangle;
487}
Mesh & triangle(const unsigned int a, const unsigned int b, const unsigned int c)
Definition mesh.cpp:178
Vector normalize(const Vector &v)
renvoie un vecteur unitaire / longueur == 1.
Definition vec.cpp:167
Vector cross(const Vector &u, const Vector &v)
renvoie le produit vectoriel de 2 vecteurs.
Definition vec.cpp:173

◆ triangle_material_index()

int Mesh::triangle_material_index ( const unsigned int id) const

renvoie l'indice de la matiere d'un triangle.

Definition at line 278 of file mesh.cpp.

279{
280 assert((size_t) id < m_triangle_materials.size());
281 return m_triangle_materials[id];
282}

◆ triangle_material()

const Material & Mesh::triangle_material ( const unsigned int id) const

renvoie la matiere d'un triangle.

Definition at line 284 of file mesh.cpp.

285{
286 assert((size_t) id < m_triangle_materials.size());
287 return m_materials.material(m_triangle_materials[id]);
288}

◆ groups() [1/2]

std::vector< TriangleGroup > Mesh::groups ( )

renvoie les groupes de triangles de meme matiere. re-organise les triangles. permet d'afficher l'objet matiere par matiere.

Definition at line 291 of file mesh.cpp.

292{
293 return groups(m_triangle_materials);
294}
std::vector< TriangleGroup > groups()
renvoie les groupes de triangles de meme matiere. re-organise les triangles. permet d'afficher l'obje...
Definition mesh.cpp:291

◆ groups() [2/2]

std::vector< TriangleGroup > Mesh::groups ( const std::vector< unsigned int > & triangle_properties)

renvoie les groupes de triangles de meme 'propriete'. re-organise les triangles.

Definition at line 296 of file mesh.cpp.

297{
298 if(m_primitives != GL_TRIANGLES)
299 return {};
300
301 // pas le bon nombre d'infos, renvoyer un seul groupe
302 if(int(triangle_properties.size()) != triangle_count())
303 {
304 if(m_indices.size())
305 return { {0, 0, int(m_indices.size())} };
306 else
307 return { {0, 0, int(m_positions.size())} };
308 }
309
310 // trie les triangles
311 std::vector<int> remap(triangle_count());
312 for(unsigned i= 0; i < remap.size(); i++)
313 remap[i]= i;
314
315 struct triangle_sort
316 {
317 const std::vector<unsigned int>& properties;
318
319 triangle_sort( const std::vector<unsigned int>& _properties ) : properties(_properties) {}
320
321 bool operator() ( const int& a, const int& b ) const
322 {
323 return properties[a] < properties[b];
324 }
325 };
326
327 std::stable_sort(remap.begin(), remap.end(), triangle_sort(triangle_properties));
328
329 // re-organise les triangles, et construit les groupes
330 std::vector<TriangleGroup> groups;
331 if(m_indices.size())
332 {
333 int first= 0;
334 int property_id= triangle_properties[remap[0]];
335
336 // re-organise l'index buffer...
337 std::vector<unsigned int> indices;
338 std::vector<unsigned int> material_indices;
339 for(unsigned i= 0; i < remap.size(); i++)
340 {
341 int id= triangle_properties[remap[i]];
342 if(id != property_id)
343 {
344 groups.push_back( {property_id, first, int(3*i) - first} );
345 first= 3*i;
346 property_id= id;
347 }
348
349 indices.push_back(m_indices[3*remap[i]]);
350 indices.push_back(m_indices[3*remap[i]+1]);
351 indices.push_back(m_indices[3*remap[i]+2]);
352
353 material_indices.push_back(m_triangle_materials[remap[i]]);
354 }
355
356 // dernier groupe
357 groups.push_back( {property_id, first, int(3 * remap.size()) - first} );
358
359 std::swap(m_indices, indices);
360 std::swap(m_triangle_materials, material_indices);
361 }
362 else
363 {
364 int first= 0;
365 int property_id= triangle_properties[remap[0]];
366
367 // re-organise les attributs !!
368 std::vector<vec3> positions;
369 std::vector<vec2> texcoords;
370 std::vector<vec3> normals;
371 std::vector<vec4> colors;
372 std::vector<unsigned int> material_indices;
373 for(unsigned i= 0; i < remap.size(); i++)
374 {
375 int id= triangle_properties[remap[i]];
376 if(id != property_id)
377 {
378 groups.push_back( {property_id, first, int(3*i) - first} );
379 first= 3*i;
380 property_id= id;
381 }
382
383 positions.push_back(m_positions[3*remap[i]]);
384 positions.push_back(m_positions[3*remap[i]+1]);
385 positions.push_back(m_positions[3*remap[i]+2]);
386 if(has_texcoord())
387 {
388 texcoords.push_back(m_texcoords[3*remap[i]]);
389 texcoords.push_back(m_texcoords[3*remap[i]+1]);
390 texcoords.push_back(m_texcoords[3*remap[i]+2]);
391 }
392 if(has_normal())
393 {
394 normals.push_back(m_normals[3*remap[i]]);
395 normals.push_back(m_normals[3*remap[i]+1]);
396 normals.push_back(m_normals[3*remap[i]+2]);
397 }
398 if(has_color())
399 {
400 colors.push_back(m_colors[3*remap[i]]);
401 colors.push_back(m_colors[3*remap[i]+1]);
402 colors.push_back(m_colors[3*remap[i]+2]);
403 }
404
405 material_indices.push_back(m_triangle_materials[remap[i]]);
406 }
407
408 // dernier groupe
409 groups.push_back( {property_id, first, int(3 * remap.size()) - first} );
410
411 std::swap(m_positions, positions);
412 std::swap(m_texcoords, texcoords);
413 std::swap(m_normals, normals);
414 std::swap(m_colors, colors);
415 std::swap(m_triangle_materials, material_indices);
416 }
417
418 return groups;
419}
const std::vector< unsigned int > & material_indices() const
renvoie les indices des matieres des triangles.
Definition mesh.cpp:273

◆ bounds()

void Mesh::bounds ( Point & pmin,
Point & pmax ) const

renvoie min et max les coordonnees des extremites des positions des sommets de l'objet (boite englobante alignee sur les axes, aabb).

Definition at line 489 of file mesh.cpp.

490{
491 if(m_positions.size() < 1)
492 return;
493
494 pmin= Point(m_positions[0]);
495 pmax= pmin;
496
497 for(unsigned i= 1; i < m_positions.size(); i++)
498 {
499 vec3 p= m_positions[i];
500 pmin= Point( std::min(pmin.x, p.x), std::min(pmin.y, p.y), std::min(pmin.z, p.z) );
501 pmax= Point( std::max(pmax.x, p.x), std::max(pmax.y, p.y), std::max(pmax.z, p.z) );
502 }
503}

◆ default_color() [1/2]

Color Mesh::default_color ( ) const
inline

renvoie la couleur par defaut du mesh, utilisee si les sommets n'ont pas de couleur associee.

Definition at line 293 of file mesh.h.

293{ return m_color; }

◆ default_color() [2/2]

Mesh & Mesh::default_color ( const Color & color)

modifie la couleur par defaut, utilisee si les sommets n'ont pas de couleur associee.

Definition at line 60 of file mesh.cpp.

61{
62 m_color= color;
63 return *this;
64}

◆ vertex_count()

int Mesh::vertex_count ( ) const
inline

renvoie le nombre de sommets.

Definition at line 300 of file mesh.h.

300{ return (int) m_positions.size(); }

◆ index_count()

int Mesh::index_count ( ) const
inline

renvoie le nombre d'indices de sommets.

Definition at line 302 of file mesh.h.

302{ return (int) m_indices.size(); }

◆ vertex_buffer()

const float * Mesh::vertex_buffer ( ) const
inline

renvoie l'adresse de la position du premier sommet. permet de construire les vertex buffers openGL. par convention, la position est un vec3, 3 GL_FLOAT.

Definition at line 305 of file mesh.h.

305{ return &m_positions.front().x; }

◆ vertex_buffer_size()

std::size_t Mesh::vertex_buffer_size ( ) const
inline

renvoie la longueur (en octets) du vertex buffer.

Definition at line 307 of file mesh.h.

307{ return m_positions.size() * sizeof(vec3); }

◆ normal_buffer()

const float * Mesh::normal_buffer ( ) const
inline

renvoie l'adresse de la normale du premier sommet. par convention, la normale est un vec3, 3 GL_FLOAT.

Definition at line 310 of file mesh.h.

310{ return &m_normals.front().x; }

◆ normal_buffer_size()

std::size_t Mesh::normal_buffer_size ( ) const
inline

renvoie la longueur (en octets) du normal buffer.

Definition at line 312 of file mesh.h.

312{ return m_normals.size() * sizeof(vec3); }

◆ texcoord_buffer()

const float * Mesh::texcoord_buffer ( ) const
inline

renvoie l'adresse des coordonnees de textures du premier sommet. par convention, c'est un vec2, 2 GL_FLOAT.

Definition at line 315 of file mesh.h.

315{ return &m_texcoords.front().x; }

◆ texcoord_buffer_size()

std::size_t Mesh::texcoord_buffer_size ( ) const
inline

renvoie la taille (en octets) du texcoord buffer.

Definition at line 317 of file mesh.h.

317{ return m_texcoords.size() * sizeof(vec2); }

◆ color_buffer()

const float * Mesh::color_buffer ( ) const
inline

renvoie l'adresse de la couleur du premier sommet. par convention, la couleur est un vec4, 4 GL_FLOAT.

Definition at line 320 of file mesh.h.

320{ return &m_colors.front().x; }

◆ color_buffer_size()

std::size_t Mesh::color_buffer_size ( ) const
inline

renvoie la taille (en octets) du color buffer.

Definition at line 322 of file mesh.h.

322{ return m_colors.size() * sizeof(vec4); }

◆ index_buffer()

const void * Mesh::index_buffer ( ) const
inline

renvoie l'adresse du premier indice du premier triangle. par convention c'est un uint, 1, GL_UNSIGNED_INT.

Definition at line 325 of file mesh.h.

325{ return &m_indices.front(); }

◆ index_buffer_size()

std::size_t Mesh::index_buffer_size ( ) const
inline

renvoie la taille (en octets) de l'index buffer.

Definition at line 327 of file mesh.h.

327{ return m_indices.size() * sizeof(unsigned int); }

◆ positions()

const std::vector< vec3 > & Mesh::positions ( ) const
inline

Definition at line 330 of file mesh.h.

330{ return m_positions; }

◆ texcoords()

const std::vector< vec2 > & Mesh::texcoords ( ) const
inline

Definition at line 331 of file mesh.h.

331{ return m_texcoords; }

◆ normals()

const std::vector< vec3 > & Mesh::normals ( ) const
inline

Definition at line 332 of file mesh.h.

332{ return m_normals; }

◆ colors()

const std::vector< vec4 > & Mesh::colors ( ) const
inline

Definition at line 333 of file mesh.h.

333{ return m_colors; }

◆ indices()

const std::vector< unsigned int > & Mesh::indices ( ) const
inline

Definition at line 334 of file mesh.h.

334{ return m_indices; }

◆ has_position()

bool Mesh::has_position ( ) const
inline

verifie que les attributs sont decrits de maniere coherente.

Definition at line 337 of file mesh.h.

337{ return !m_positions.empty(); }

◆ has_texcoord()

bool Mesh::has_texcoord ( ) const
inline

Definition at line 338 of file mesh.h.

338{ return m_texcoords.size() == m_positions.size(); }

◆ has_normal()

bool Mesh::has_normal ( ) const
inline

Definition at line 339 of file mesh.h.

339{ return m_normals.size() == m_positions.size(); }

◆ has_color()

bool Mesh::has_color ( ) const
inline

Definition at line 340 of file mesh.h.

340{ return m_colors.size() == m_positions.size(); }

◆ has_material_index()

bool Mesh::has_material_index ( ) const
inline

Definition at line 341 of file mesh.h.

341{ return int(m_triangle_materials.size()) == triangle_count(); }

◆ primitives()

GLenum Mesh::primitives ( ) const
inline

renvoie le type de primitives.

Definition at line 345 of file mesh.h.

345{ return m_primitives; }

◆ create_buffers() [1/3]

GLuint Mesh::create_buffers ( )

construit les buffers et le vertex array object necessaires pour dessiner l'objet avec openGL. utilitaire. detruit par release( ). ou release_buffers( ).

Definition at line 606 of file mesh.cpp.

607{
608 return create_buffers( has_texcoord(), has_normal(), has_color(), has_material_index() );
609}
GLuint create_buffers()
construit les buffers et le vertex array object necessaires pour dessiner l'objet avec openGL....
Definition mesh.cpp:606

◆ create_buffers() [2/3]

GLuint Mesh::create_buffers ( const bool use_texcoord,
const bool use_normal,
const bool use_color,
const bool use_material_index )

construit les buffers et le vertex array object necessaires pour dessiner l'objet avec openGL. utilitaire. detruit par release( ). ou release_buffers( ).

Definition at line 563 of file mesh.cpp.

564{
565 if(m_vao)
566 return m_vao; // c'est deja fait...
567
568 // configuration du format de sommet
569 glGenVertexArrays(1, &m_vao);
570 glBindVertexArray(m_vao);
571
572 // determine la taille du buffer pour stocker tous les attributs et les indices
573 m_vertex_buffer_size= vertex_buffer_size();
574 if(use_texcoord && has_texcoord())
575 m_vertex_buffer_size+= texcoord_buffer_size();
576 if(use_normal && has_normal())
577 m_vertex_buffer_size+= normal_buffer_size();
578 if(use_color && has_color())
579 m_vertex_buffer_size+= color_buffer_size();
580 if(use_material_index && has_material_index())
581 m_vertex_buffer_size+= m_positions.size() * sizeof(unsigned char);
582
583 if(m_vertex_buffer_size == 0)
584 return 0;
585
586 // alloue le buffer
587 glGenBuffers(1, &m_buffer);
588 glBindBuffer(GL_ARRAY_BUFFER, m_buffer);
589 glBufferData(GL_ARRAY_BUFFER, m_vertex_buffer_size, nullptr, GL_STATIC_DRAW);
590
591 // index buffer
592 m_index_buffer_size= index_buffer_size();
593 if(m_index_buffer_size)
594 {
595 glGenBuffers(1, &m_index_buffer);
596 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_index_buffer);
597 glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_index_buffer_size, index_buffer(), GL_STATIC_DRAW);
598 }
599
600 // transfere les donnees dans les buffers
601 update_buffers(use_texcoord, use_normal, use_color, use_material_index);
602
603 return m_vao;
604}
std::size_t texcoord_buffer_size() const
renvoie la taille (en octets) du texcoord buffer.
Definition mesh.h:317
std::size_t index_buffer_size() const
renvoie la taille (en octets) de l'index buffer.
Definition mesh.h:327
std::size_t vertex_buffer_size() const
renvoie la longueur (en octets) du vertex buffer.
Definition mesh.h:307
const void * index_buffer() const
renvoie l'adresse du premier indice du premier triangle. par convention c'est un uint,...
Definition mesh.h:325
std::size_t normal_buffer_size() const
renvoie la longueur (en octets) du normal buffer.
Definition mesh.h:312
std::size_t color_buffer_size() const
renvoie la taille (en octets) du color buffer.
Definition mesh.h:322

◆ create_buffers() [3/3]

GLuint Mesh::create_buffers ( const unsigned flags)

idem mais utilise une combinaison des flags USE_TEXCOORD, USE_NORMAL...

Definition at line 611 of file mesh.cpp.

612{
613#ifndef GK_RELEASE
614 if((flags & USE_TEXCOORD) && !has_texcoord()) { printf("[oops] create_buffers: no texcoord array...\n"); return 0; }
615 if((flags & USE_NORMAL) && !has_normal()) { printf("[oops] create_buffers: no normal array...\n"); return 0; }
616 if((flags & USE_COLOR) && !has_color()) { printf("[oops] create_buffers: no color array...\n"); return 0; }
617 if((flags & USE_MATERIAL_INDEX) && !has_material_index()) { printf("[oops] create_buffers: no material index array...\n"); return 0; }
618#endif
619
620 return create_buffers( flags & USE_TEXCOORD, flags & USE_NORMAL, flags & USE_COLOR, flags & USE_MATERIAL_INDEX );
621}
@ USE_COLOR
inclut l'attribut couleur dans les buffers.
Definition mesh.h:115
@ USE_TEXCOORD
inclut l'attribut coordonnees de texture dans les buffers.
Definition mesh.h:113
@ USE_MATERIAL_INDEX
inclut l'attribut indice de matiere dans les buffers.
Definition mesh.h:116
@ USE_NORMAL
inclut l'attribut normale dans les buffers.
Definition mesh.h:114

◆ draw() [1/2]

void Mesh::draw ( const GLuint program)

dessine l'objet avec un shader program.

Definition at line 757 of file mesh.cpp.

758{
759 if(m_indices.size())
760 draw(0, int(m_indices.size()), program);
761 else
762 draw(0, int(m_positions.size()), program);
763}
void draw(const GLuint program)
dessine l'objet avec un shader program.
Definition mesh.cpp:757

◆ draw() [2/2]

void Mesh::draw ( const int first,
const int n,
const GLuint program )

dessine une partie de l'objet avec un shader program.

Definition at line 765 of file mesh.cpp.

766{
767 if(program == 0)
768 {
769 printf("[oops] no program... can't draw !!\n");
770 return;
771 }
772
773 // transfere toutes les donnees disponibles (et correctement definies)
774 // le meme mesh peut etre dessine avec plusieurs shaders utilisant des attributs differents...
775 if(m_vao == 0)
776 create_buffers(has_texcoord(), has_normal(), has_color(), has_material_index());
777 assert(m_vao != 0);
778
779 if(m_update_buffers)
780 update_buffers(has_texcoord(), has_normal(), has_color(), has_material_index());
781
782 glBindVertexArray(m_vao);
783
784 #ifndef GK_RELEASE
785 {
786 char label[2048]= { 0 };
787 #ifdef GL_VERSION_4_3
788 {
789 char tmp[1024];
790 glGetObjectLabel(GL_PROGRAM, program, sizeof(tmp), nullptr, tmp);
791 sprintf(label, "program( %u '%s' )", program, tmp);
792 }
793 #else
794 sprintf(label, "program( %u )", program);
795 #endif
796
797 // verifie que le program est selectionne
798 GLuint current;
799 glGetIntegerv(GL_CURRENT_PROGRAM, (GLint *) &current);
800 if(current != program)
801 printf("[oops] %s: not active... undefined draw !!\n", label);
802
803 // verifie que les attributs necessaires a l'execution du shader sont presents dans le mesh...
804 // etape 1 : recuperer le nombre d'attributs
805 GLint n= 0;
806 glGetProgramiv(program, GL_ACTIVE_ATTRIBUTES, &n);
807
808 // etape 2 : recuperer les infos de chaque attribut
809 char name[1024];
810 for(int index= 0; index < n; index++)
811 {
812 GLint glsl_size;
813 GLenum glsl_type;
814 glGetActiveAttrib(program, index, sizeof(name), nullptr, &glsl_size, &glsl_type, name);
815
816 GLint location= glGetAttribLocation(program, name);
817 if(location == 0) // attribut position necessaire a l'execution du shader
818 {
819 if(!has_position())
820 printf("[oops] position attribute '%s' in %s: no data... undefined draw !!\n", name, label);
821 if(glsl_size != 1 || glsl_type != GL_FLOAT_VEC3)
822 printf("[oops] position attribute '%s' is not declared as a vec3 in %s... undefined draw !!\n", name, label);
823 }
824 else if(location == 1) // attribut texcoord necessaire
825 {
826 if(!has_texcoord())
827 printf("[oops] texcoord attribute '%s' in %s: no data... undefined draw !!\n", name, label);
828 if(glsl_size != 1 || glsl_type != GL_FLOAT_VEC2)
829 printf("[oops] texcoord attribute '%s' is not declared as a vec2 in %s... undefined draw !!\n", name, label);
830 }
831 else if(location == 2) // attribut normal necessaire
832 {
833 if(!has_normal())
834 printf("[oops] normal attribute '%s' in %s: no data... undefined draw !!\n", name, label);
835 if(glsl_size != 1 || glsl_type != GL_FLOAT_VEC3)
836 printf("[oops] attribute '%s' is not declared as a vec3 in %s... undefined draw !!\n", name, label);
837 }
838 else if(location == 3) // attribut color necessaire
839 {
840 if(!has_color())
841 printf("[oops] color attribute '%s' in %s: no data... undefined draw !!\n", name, label);
842 if(glsl_size != 1 || glsl_type != GL_FLOAT_VEC4)
843 printf("[oops] attribute '%s' is not declared as a vec4 in %s... undefined draw !!\n", name, label);
844 }
845 else if(location == 4) // attribut material_index necessaire
846 {
847 if(!has_material_index())
848 printf("[oops] material_index attribute '%s' in %s: no data... undefined draw !!\n", name, label);
849 if(glsl_size != 1 || glsl_type != GL_UNSIGNED_INT)
850 printf("[oops] attribute '%s' is not declared as a uint in %s... undefined draw !!\n", name, label);
851 }
852 }
853 }
854 #endif
855
856 if(m_indices.size() > 0)
857 glDrawElements(m_primitives, count, GL_UNSIGNED_INT, (void *) (first * sizeof(unsigned)));
858 else
859 glDrawArrays(m_primitives, first, count);
860}
bool has_position() const
verifie que les attributs sont decrits de maniere coherente.
Definition mesh.h:337

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