gKit2 light
mesh_buffer.h
Go to the documentation of this file.
1 
3 #ifndef _MESH_BUFFER_H
4 #define _MESH_BUFFER_H
5 
6 #include "mesh_data.h"
7 
8 
10 struct MeshGroup
11 {
12  int material;
13  int first;
14  int count;
15 
16  MeshGroup( const int _id= -1, const int _first= 0 ) : material(_id), first(_first), count(0) {}
17 };
18 
19 
21 struct MeshBuffer
22 {
23  std::vector<vec3> positions;
24  std::vector<vec2> texcoords;
25  std::vector<vec3> normals;
26 
27  std::vector<int> material_indices;
28  std::vector<int> indices;
29 
30  std::vector<MaterialData> materials;
31  std::vector<MeshGroup> material_groups;
32 
33  const void *vertex_buffer( ) const { return positions.data(); }
34  size_t vertex_buffer_size( ) const { return positions.size() * sizeof(vec3); }
35 
36  const void *texcoord_buffer( ) const { return texcoords.data(); }
37  size_t texcoord_buffer_size( ) const { return texcoords.size() * sizeof(vec2); }
38 
39  const void *normal_buffer( ) const { return normals.data(); }
40  size_t normal_buffer_size( ) const { return normals.size() * sizeof(vec3); }
41 
42  const void *index_buffer( ) const { return indices.data(); }
43  size_t index_buffer_size( ) const { return indices.size() * sizeof(int); }
44  const void *index_buffer_offset( const int first ) const { return (const void *) (first * sizeof(int)); }
45 
46  const void *material_buffer( ) const { return material_indices.data(); }
47  size_t material_buffer_size( ) const { return material_indices.size() * sizeof(int); }
48 };
49 
50 
52 MeshBuffer buffers( const MeshData& data );
53 
54 
55 #endif
MeshBuffer buffers(const MeshData &data)
construction a partir des donnees d'un maillage.
Definition: mesh_buffer.cpp:48
representation des donnees d'un fichier wavefront .obj
representation d'un objet.
Definition: mesh_buffer.h:22
std::vector< vec3 > positions
attribut position
Definition: mesh_buffer.h:23
std::vector< MeshGroup > material_groups
sequence de triangles groupes par matiere
Definition: mesh_buffer.h:31
std::vector< MaterialData > materials
ensemble de matieres
Definition: mesh_buffer.h:30
std::vector< int > indices
indices des sommets des triangles
Definition: mesh_buffer.h:28
std::vector< int > material_indices
indice de la matiere des triangles
Definition: mesh_buffer.h:27
std::vector< vec2 > texcoords
attribut coordonnees de texture
Definition: mesh_buffer.h:24
std::vector< vec3 > normals
attribut normale
Definition: mesh_buffer.h:25
representation d'une sequence de triangles associes a la meme matiere
Definition: mesh_buffer.h:11
int first
indice des premiers sommets
Definition: mesh_buffer.h:13
int material
indice de la matiere
Definition: mesh_buffer.h:12
int count
nombre d'indices
Definition: mesh_buffer.h:14
vecteur generique, utilitaire.
Definition: vec.h:131
vecteur generique, utilitaire.
Definition: vec.h:146