Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00020
00021 #ifndef __VR3MESH_H__
00022 #define __VR3MESH_H__
00023
00024 #include <VR3Material.h>
00025 #include <string>
00026
00028
00059 class VR3Mesh {
00061 friend class VR3MeshManager;
00063 friend class VR3PhysicsSimulator;
00065 friend class VR3Obj;
00066
00068
00075 struct UniformCache {
00077 GLfloat transfmat[16];
00079 GLfloat invmodelmat[16];
00081 GLfloat eyeposobj[3];
00083 GLfloat shamodelview[VR3SDOW_NUM_SOURCES*16];
00085 GLfloat lightposobj[VR3SC_NUM_LIGHTS*3];
00086 } m_unicache;
00087
00088
00090
00093 struct Subset {
00094
00096 bool ishidden;
00097
00099
00100
00102 bool fl_difftex;
00104 bool fl_lightmap;
00106 bool fl_normmap;
00108 bool fl_dispmap;
00109
00111
00113
00114
00116 GLuint shader_program;
00118 const GLint* unilocs;
00119
00121
00124 typedef void (VR3Mesh::*f_loaduniforms) (const Subset* sub);
00125
00127
00131 f_loaduniforms loadunifunc;
00132
00134
00136
00137
00139 GLint tri_count;
00141 GLint first;
00143 GLint* ptex_indices;
00145 GLint* stex_indices;
00147 GLint* ntex_indices;
00149 GLint* dtex_indices;
00150
00152
00154
00155
00157 VR3Material* material;
00158
00160
00162
00163
00165 GLuint VAO;
00167 GLuint VBOs[VR3MESH_MAX_VER_ATTRIBS];
00168
00170
00172 Subset();
00174 ~Subset();
00175
00176 };
00177
00179 Subset* m_subsets;
00181 int m_subset_count;
00182
00184
00188 int m_all_light_mapped;
00189
00191
00192
00194 GLint m_vertex_count;
00196 GLfloat* m_vertices;
00197
00199 GLint m_tex_coord_count;
00201 GLfloat* m_tex_coords;
00202
00204 GLint m_tri_count;
00206 GLint* m_ver_indices;
00207
00209 bool m_smgroups_enabled;
00211 GLint m_smgroup_count;
00213
00214 GLint* m_smgroups;
00215
00217
00219
00220
00222 GLfloat m_BI;
00224 GLfloat m_SC;
00226 GLint m_TF;
00227
00229
00231
00232
00234 GLfloat m_bounding_box[6];
00236
00245 GLfloat m_bbox_vertices[8][3];
00246
00248
00250
00251
00253 std::string m_meshfile;
00255 std::string m_name;
00257 int m_ID;
00258
00260
00262 VR3Mesh(const VR3Mesh&);
00264 VR3Mesh& operator = (const VR3Mesh&);
00265
00266
00267
00269
00270
00272
00277 void PrepareVerticesVBOs();
00278
00280
00285 void PrepareNormalsVBOs();
00286
00288
00294 void PrepareDiffuseTexCoordVBOs();
00295
00297
00303 void PrepareLightMapCoordVBOs();
00304
00306
00312 void PrepareNormalMapCoordVBOs();
00313
00315
00321 void PrepareDisplacementMapCoordVBOs();
00322
00324
00325
00326
00328
00345
00347 void LoadUniformsSubsetFFFF(const Subset* sub);
00349 void LoadUniformsSubsetTFFF(const Subset* sub);
00351 void LoadUniformsSubsetFTFF(const Subset* sub);
00353 void LoadUniformsSubsetTTFF(const Subset* sub);
00355 void LoadUniformsSubsetFFTF(const Subset* sub);
00357 void LoadUniformsSubsetTFTF(const Subset* sub);
00359 void LoadUniformsSubsetFFTT(const Subset* sub);
00361 void LoadUniformsSubsetFTFT(const Subset* sub);
00363 void LoadUniformsSubsetTFTT(const Subset* sub);
00365 void LoadUniformsSubsetTTFT(const Subset* sub);
00366
00368
00370
00388 void LoadUniformsStdMesh( const GLfloat* modelmat, const GLint* unilocs,
00389 int flags, bool lightmap );
00390
00392
00405 void ComputeUniformsStdMesh(const GLfloat* modelmat, int flags);
00406
00407
00408
00410
00411
00413
00426 void LoadUniformsExtMesh(const GLfloat* modelmat, const GLint* unilocs);
00427
00429
00442 void LoadUniformsExtSubset(const Subset* sub, const GLint* unilocs);
00443
00445
00446
00447
00449
00450
00452
00459 void LoadUniformsShadowMap(const GLfloat* modelmat);
00460
00462
00463
00464
00466
00467
00469
00486 bool VisibilityTest(const GLfloat* modelmat, int flags);
00487
00489
00490
00491
00493
00494
00496
00508 void Draw(const GLfloat* modelmat, int flags);
00509
00511
00512
00513
00515
00516
00518
00523 ~VR3Mesh();
00524
00526
00527
00528
00530
00531
00533
00543 void LoadUniformLoader(Subset* sub);
00544
00546
00547 public:
00548
00549
00550
00552
00553
00555
00568 VR3Mesh(const char* file_name, const char* mesh_name = 0, int objID = -1);
00569
00571
00572
00573
00575
00576
00578
00587 void Destroy();
00588
00590
00591
00592
00594
00595
00597
00603 void Draw(int flags = 0);
00604
00606
00607
00608
00610
00611
00613
00617 void Hide(int id);
00618
00620
00621 void HideAll();
00622
00624
00628 void Unhide (int id);
00629
00631
00632 void UnhideAll();
00633
00635
00641 bool IsHidden(int id);
00642
00644
00657 VR3Material* GetSubsetMaterial(int id);
00658
00660
00673 void ForceSubsetMaterial(VR3Material* material, int id);
00674
00676
00684 VR3Material* GetMaterial();
00685
00687
00698 void ForceMaterial(VR3Material* material);
00699
00701
00706 int GetID()
00707 { return m_ID; }
00708
00710
00718 const char* GetName()
00719 { return m_name.c_str(); }
00720
00722
00730 const char* GetFileName()
00731 { return m_meshfile.c_str(); }
00732
00734
00735 };
00736
00737 #endif