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 __VR3SCENE_H__
00022 #define __VR3SCENE_H__
00023
00024
00025 #include <VR3Camera.h>
00026 #include <VR3light.h>
00027 #include <VR3FBO.h>
00028 #include <VR3Background.h>
00029
00031
00037 struct VR3SceneShaderParams {
00039 GLfloat projmat[16];
00041 GLfloat viewmat[16];
00043
00044 GLfloat projviewmat[16];
00045
00047 GLfloat orthoprojmat[16];
00049
00051 GLfloat camerapos[3];
00053 GLint numactivelights;
00055 GLfloat lightambient[VR3SC_NUM_LIGHTS*3];
00057 GLfloat lightdiffuse[VR3SC_NUM_LIGHTS*3];
00059 GLfloat lightspecular[VR3SC_NUM_LIGHTS*3];
00061 GLfloat lightpos[VR3SC_NUM_LIGHTS*3];
00062 };
00063
00065
00092 class VR3Scene {
00093
00095 static VR3Scene* ms_activescene;
00096
00098 bool m_beginendblock;
00100 long m_time;
00102 long m_starttime;
00104 long m_framecounter;
00106 int m_polycounter;
00107
00109
00110
00112 VR3Camera m_cameras[VR3SC_NUM_CAMERAS];
00114 VR3Camera* m_current_camera;
00116 VR3Light m_lights[VR3SC_NUM_LIGHTS];
00118
00119 bool m_face_culling;
00121 bool m_vf_culling;
00123 VR3Background m_background;
00125 int m_polygons;
00126
00128
00137
00139
00146 GLint m_env_mode;
00148 VR3Texture* m_env_specular;
00150 VR3Texture* m_env_diffuse;
00151
00153
00155
00156
00158 GLsizei m_totdrawregion[2];
00160 GLint m_minframetime;
00162 GLfloat m_framerate;
00163
00165
00167 VR3SceneShaderParams m_shadparams;
00168
00170 VR3Scene(const VR3Scene&);
00172 VR3Scene& operator = (const VR3Scene&);
00173
00175
00176
00178
00191 void RealBegin( GLsizei width, GLsizei height,
00192 VR3Camera* cam, int flags );
00193
00195
00196
00197
00199
00200
00202
00206 void UpdateLightParams();
00207
00209
00217 void UpdateMatrices(GLsizei width, GLsizei height);
00218
00219 public:
00220
00222
00233 void StoreUniforms(GLsizei width, GLsizei height);
00234
00236
00237
00238
00240
00245 static VR3Scene* GetActiveScene() { return ms_activescene; }
00246
00247
00248
00250
00251
00253
00261 VR3Scene( GLsizei width, GLsizei height, GLfloat fovy,
00262 GLfloat znear = VR3SC_DEF_ZNEAR,
00263 GLfloat zfar = VR3SC_DEF_ZFAR );
00264
00266
00267 ~VR3Scene();
00268
00270
00271
00272
00274
00275
00277
00281 void SetClearColor(GLfloat r, GLfloat g, GLfloat b);
00282
00284
00287 void SetClearColor(const GLfloat* color);
00288
00290
00294 VR3Camera* GetCurrentCamera() { return m_current_camera; }
00295
00297
00301 void SetActiveCamera(int id);
00302
00304
00309 void SetLightPosition(int id, GLfloat x, GLfloat y, GLfloat z);
00310
00312
00316 void SetLightPosition(int id, const GLfloat *v);
00317
00319
00325 void GetLightPosition(int id, GLfloat *p);
00326
00328
00339 void SetLightColor( int id, int color,
00340 GLfloat r, GLfloat g, GLfloat b );
00341
00343
00354 void GetLightColor( int id, int color, GLfloat* c);
00355
00357
00363 GLint GetActiveLights(bool* fa);
00364
00366
00380 void SetBackground(const char* file_name, bool fl_skybox = false)
00381 { m_background.SetBackground(file_name, fl_skybox); }
00382
00384
00389 VR3Texture* GetBackground()
00390 { return m_background.GetBackground(); }
00391
00393
00410 void EnvironmentMapping(const char* diff_file, const char* spec_file);
00411
00413
00424 VR3Texture* GetEnvMap(GLint map);
00425
00427
00431 GLint GetEnvMappingMode()
00432 { return m_env_mode; }
00433
00435
00446 void SetFrameRate(GLfloat fps);
00447
00449
00457 GLfloat GetFrameRate() { return m_framerate; }
00458
00460
00479 GLint GetNumPolys() { return m_polygons; }
00480
00482
00490 void AddPolys(GLint polys) { m_polycounter += polys; }
00491
00493
00497 bool HasBegun() { return m_beginendblock; }
00499
00500
00501
00503
00504
00506
00516 void Enable(int feature, int optional_param = 0);
00517
00519
00530 void Disable(int feature, int optional_param = 0);
00531
00533
00545 bool IsEnabled(int feature, int optional_param = 0);
00546
00548
00554 bool CheckVFCulling()
00555 { return m_vf_culling; }
00556
00558
00559
00560
00562
00563
00565
00573 void UpdateDrawRegion(GLsizei w, GLsizei h);
00574
00576
00577
00578
00580
00581
00583
00586 const VR3SceneShaderParams* FetchParameters()
00587 { return &m_shadparams; }
00588
00590
00591
00592
00594
00595
00597
00612 void Begin( VR3Camera* cam = 0, int flags = 0 );
00613
00615
00632 void BeginAbs( GLint x, GLint y, GLsizei w, GLsizei h,
00633 VR3Camera* cam = 0, int flags = 0 );
00634
00636
00653 void BeginRel( GLfloat x, GLfloat y, GLfloat w, GLfloat h,
00654 VR3Camera* cam = 0, int flags = 0 );
00655
00657
00670 void BeginFBO( VR3FBO* fbo, VR3Camera* cam = 0, int flags = 0 );
00671
00673
00675 void End();
00676
00678
00679 };
00680
00681 #endif