OpenGL ES SDK for Android ARM Developer Center
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
model3d.h
Go to the documentation of this file.
1 /* Copyright (c) 2017, ARM Limited and Contributors
2  *
3  * SPDX-License-Identifier: MIT
4  *
5  * Permission is hereby granted, free of charge,
6  * to any person obtaining a copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
9  * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
14  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19  */
20 
21 #ifndef __MODEL3D_H_INCLUDED__
22 #define __MODEL3D_H_INCLUDED__
23 
24 #include <string>
25 #include <vector>
26 
27 namespace Model3D
28 {
43  bool load_file(const std::string& a_path, char **a_buffer, int &a_bytes_read, const bool binary = true);
44 
55  class Material
56  {
57  public:
61  Material();
62 
66  ~Material();
67 
68  float *m_ambient;
69  float *m_diffuse;
70  float *m_specular;
71  float *m_emmision;
72  float *m_shine;
73  float *m_transparency;
74  };
75 
76 
84  class Keyframe
85  {
86  public:
90  Keyframe();
91 
95  ~Keyframe();
96 
97  float *m_time;
98  float *m_transforms;
99  };
100 
118  class Model3D
119  {
120  public:
121 
122  friend class Model3DClientGL;
123 
127  Model3D();
128 
133  ~Model3D();
134 
143  bool load(const std::string &a_path);
144 
149  unsigned int get_indices_count() const;
150 
155  unsigned int get_keyframes_count() const;
156 
161  float* get_positions() const;
162 
167  float* get_normals() const;
168 
173  float* get_texture_coordinates0() const;
174 
179  float* get_tangents() const;
180 
185  unsigned int* get_indices() const;
186 
187 
188  protected:
194 
195  unsigned int *m_vertices_count;
196  unsigned int *m_indices_count;
197  unsigned int *m_bones_count;
198  unsigned int *m_keyframes_count;
199  unsigned int *m_materials_count;
200 
201  float *m_positions;
203  float *m_normals;
204  float *m_tangents;
205  float *m_weights;
206  unsigned int *m_bone_ids;
208 
209  unsigned int *m_indices;
210 
212 
216 
219  };
220 }
221 
222 #endif // __MODEL3D_H_INCLUDED__
char * m_animation_buffer
All the animation data is loaded in this buffer.
Definition: model3d.h:215
unsigned int * m_vertices_count
Total number of vertices in the model.
Definition: model3d.h:195
char * m_tangent_buffer
All the tangent data is loaded in this buffer.
Definition: model3d.h:214
unsigned int * m_materials_count
Total number of materials in the model.
Definition: model3d.h:199
float * m_weights
List of 4D Weights in the model.
Definition: model3d.h:205
float * m_transforms
Transformations for all the bones in the current keyframe.
Definition: model3d.h:98
bool m_has_texture_coordinates0
True if the model has texture coordinates 0.
Definition: model3d.h:193
float * m_bounding_box_minimum
Bounding box minimum of the model.
Definition: model3d.h:217
float * m_ambient
4D Ambient color of the material
Definition: model3d.h:68
bool m_has_normals
True if the model has normals.
Definition: model3d.h:192
float * m_normals
List of 3D Normals in the model.
Definition: model3d.h:203
Material ** m_materials
List of all the materials in the model.
Definition: model3d.h:207
GLsizei GLsizei GLenum void * binary
Definition: gl2ext.h:396
unsigned int * m_keyframes_count
Total number of keyframes in the model.
Definition: model3d.h:198
float * m_transparency
Transparency of the material.
Definition: model3d.h:73
float * m_bounding_box_maximum
Bounding box maximum of the model.
Definition: model3d.h:218
bool m_has_indices
True if the model has indexed data.
Definition: model3d.h:191
bool load_file(const std::string &a_path, char **a_buffer, int &a_bytes_read, const bool binary)
Definition: model3d.cpp:33
Keyframe ** m_keyframes
List of all keyframes for all bones.
Definition: model3d.h:211
unsigned int * m_bone_ids
List of 4D Bone Ids in the model.
Definition: model3d.h:206
float * m_tangents
List of 3D Tangents in the model.
Definition: model3d.h:204
bool m_has_materials
True if the model has one or more materials.
Definition: model3d.h:190
unsigned int * m_indices
List of indices in the model.
Definition: model3d.h:209
float * m_shine
Shine exponent of the material.
Definition: model3d.h:72
bool m_has_animation
True if the model has animation data.
Definition: model3d.h:189
unsigned int * m_indices_count
Total number of indices in the model.
Definition: model3d.h:196
float * m_diffuse
4D Diffuse color of the material
Definition: model3d.h:69
float * m_positions
List of 3D Vertex Positions in the model.
Definition: model3d.h:201
char * m_geometry_buffer
All the geometry data is loaded in this buffer.
Definition: model3d.h:213
float * m_specular
4D Specular color of the material
Definition: model3d.h:70
float * m_time
Keyframe time in seconds for the all the bones.
Definition: model3d.h:97
float * m_emmision
4D Emissive color of the material
Definition: model3d.h:71
float * m_texture_coordinates0
List of 3D Texture Coordinates in the model.
Definition: model3d.h:202
unsigned int * m_bones_count
Total number of bones in the model.
Definition: model3d.h:197