#include <World.h>
Inheritance diagram for pge::World:
Public Member Functions | |
World (void) | |
Constructor. | |
virtual | ~World (void) |
Destructor. | |
bool | init (void) |
void | render (void) |
Called when the object should render itself. | |
void | timer (unsigned int delay) |
Called when the timer event comes. | |
void | action (InputSystem::InputAction type, int param0, int param1) |
Camera * | getCamera (void) |
Frustum * | getFrustum (void) |
GPUProgram * | getLightProgram (void) |
void | setSky (ISky *sky) |
void | addRenderableObject (IRenderableObject *object, bool disableBloom=false) |
void | clearRenderableObjects () |
void | addLight (Light *light) |
int | getLightNum (void) |
Light * | getLightAt (int index) |
Private Attributes | |
std::vector< IRenderableObject * > | m_objects |
std::vector< IRenderableObject * > | m_objectsWithoutBloom |
std::vector< Light * > | m_lights |
Camera * | m_camera |
Frustum * | m_frustum |
ISky * | m_sky |
GPUProgram * | m_globalLightProgram |
BloomEffect * | m_bloomEffect |
|
Constructor.
Definition at line 26 of file World.cpp. References m_bloomEffect, m_camera, m_frustum, m_globalLightProgram, and m_sky.
00026 { 00027 m_camera = new Camera(); 00028 m_frustum = new Frustum(); 00029 00030 m_globalLightProgram = new GPUProgram("../data/shader/light_vs.txt", "../data/shader/light_fs.txt"); 00031 00032 m_bloomEffect = new BloomEffect(); 00033 00034 m_sky = NULL; 00035 } |
|
Destructor.
Definition at line 43 of file World.cpp. References m_bloomEffect, m_frustum, m_globalLightProgram, m_lights, m_objects, m_objectsWithoutBloom, and m_sky.
00043 { 00044 std::vector<IRenderableObject*>::iterator it; 00045 std::vector<Light*>::iterator lightIt; 00046 00047 00048 // Delete objects. 00049 for(it = m_objects.begin(); it != m_objects.end(); it++) { 00050 if(*it != NULL) { 00051 delete *it; 00052 } 00053 } 00054 // Delete objects without bloom. 00055 for(it = m_objectsWithoutBloom.begin(); it != m_objectsWithoutBloom.end(); it++) { 00056 if(*it != NULL) { 00057 delete *it; 00058 } 00059 } 00060 00061 // Delete lights. 00062 for(lightIt = m_lights.begin(); lightIt != m_lights.end(); lightIt++) { 00063 if(*lightIt != NULL) { 00064 delete *lightIt; 00065 } 00066 } 00067 00068 // Delete frustum. 00069 if(m_frustum != NULL) { 00070 delete m_frustum; 00071 m_frustum = NULL; 00072 } 00073 00074 // Delete bloom effect. 00075 if(m_bloomEffect != NULL) { 00076 delete m_bloomEffect; 00077 m_bloomEffect = NULL; 00078 } 00079 00080 // Delete global light program. 00081 if(m_globalLightProgram != NULL) { 00082 delete m_globalLightProgram; 00083 m_globalLightProgram = NULL; 00084 } 00085 00086 // Delete sky. 00087 if(m_sky != NULL) { 00088 delete m_sky; 00089 m_sky = NULL; 00090 } 00091 } |
|
Definition at line 213 of file World.cpp. References pge::Camera::backward(), pge::Camera::down(), pge::Camera::forward(), m_camera, pge::Camera::slideLeft(), pge::Camera::slideRight(), pge::Camera::turnDown(), pge::Camera::turnLeft(), pge::Camera::turnRight(), pge::Camera::turnUp(), and pge::Camera::up(). Referenced by pge::CoreEngine::action().
00213 { 00214 switch(type) { 00215 case InputSystem::Forward: 00216 m_camera->forward(); 00217 break; 00218 case InputSystem::Backward: 00219 m_camera->backward(); 00220 break; 00221 case InputSystem::Up: 00222 m_camera->up(); 00223 break; 00224 case InputSystem::Down: 00225 m_camera->down(); 00226 break; 00227 case InputSystem::SlideLeft: 00228 m_camera->slideLeft(); 00229 break; 00230 case InputSystem::SlideRight: 00231 m_camera->slideRight(); 00232 break; 00233 case InputSystem::TurnLeft: 00234 m_camera->turnLeft(param0); 00235 break; 00236 case InputSystem::TurnRight: 00237 m_camera->turnRight(param0); 00238 break; 00239 case InputSystem::TurnUp: 00240 m_camera->turnUp(param0); 00241 break; 00242 case InputSystem::TurnDown: 00243 m_camera->turnDown(param0); 00244 break; 00245 default: 00246 break; 00247 } 00248 } |
Here is the call graph for this function:
|
Definition at line 327 of file World.cpp. References m_lights. Referenced by pge::sgfmeshmodelfactory::createSGFMeshModelWithLights(), and pge::EffectTest::initLights().
00327 { 00328 m_lights.push_back(light); 00329 } |
|
Definition at line 300 of file World.cpp. References pge::IRenderableObject::init(), m_objects, and m_objectsWithoutBloom. Referenced by addModels(), and main().
00300 { 00301 00302 object->init(); 00303 00304 if(disableBloom) { 00305 m_objectsWithoutBloom.push_back(object); 00306 } else { 00307 m_objects.push_back(object); 00308 } 00309 } |
Here is the call graph for this function:
|
Definition at line 317 of file World.cpp. References m_objects.
00317 { 00318 m_objects.clear(); 00319 } |
|
Definition at line 256 of file World.cpp. References m_camera.
00256 { 00257 return m_camera; 00258 } |
|
Definition at line 266 of file World.cpp. References m_frustum.
00266 { 00267 return m_frustum; 00268 } |
|
Definition at line 347 of file World.cpp. References m_lights. Referenced by pge::SingleTexturedMesh::getSurroundingLights().
00347 { 00348 return m_lights.at(index); 00349 } |
|
Definition at line 337 of file World.cpp. References m_lights.
00337 { 00338 return (int)m_lights.size(); 00339 } |
|
Definition at line 276 of file World.cpp. References m_globalLightProgram.
00276 { 00277 return m_globalLightProgram; 00278 } |
|
Implements pge::IRenderableObject. Definition at line 99 of file World.cpp. Referenced by pge::CoreEngine::init().
00099 { 00100 return true; 00101 } |
|
Called when the object should render itself.
Implements pge::IRenderableObject. Definition at line 109 of file World.cpp. References pge::Camera::applyCameraRotation(), pge::Camera::applyCameraView(), pge::BloomEffect::getTextureSize(), m_bloomEffect, m_camera, m_frustum, m_objects, m_objectsWithoutBloom, m_sky, pge::BloomEffect::prepareRendering(), pge::BloomEffect::render(), pge::IRenderableObject::render(), and pge::Frustum::update(). Referenced by pge::CoreEngine::render().
00109 { 00110 // 00111 // Variables 00112 // 00113 std::vector<IRenderableObject*>::iterator it; 00114 00115 00117 // 3D Mode for world and object rendering! 00119 renderer::enter3DMode(); 00120 00121 m_camera->applyCameraView(); 00122 00123 // After setting the camera, apply view frustum. 00124 m_frustum->update(); 00125 00126 // Prepare bloom effect here. Therefore render all objects that want bloom rendering. 00127 glViewport(0, 0, m_bloomEffect->getTextureSize(), m_bloomEffect->getTextureSize()); 00128 for(it = m_objects.begin(); it != m_objects.end(); it++) { 00129 IRenderableObject *object = *it; 00130 object->render(); 00131 } 00132 m_bloomEffect->prepareRendering(); 00133 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00134 glViewport(0, 0, CoreEngine::getInstance()->getResolutionWidth(), CoreEngine::getInstance()->getResolutionHeight()); 00135 00136 // Now render all objects with bloom and all objects without bloom for final rendered image. 00137 renderer::pushMatrix(); 00138 // Apply the camera view 00139 m_camera->applyCameraRotation(); 00140 // If a sky is set ... 00141 if(m_sky != NULL) { 00142 // ... render sky at first with deactivated z-buffer, so its always seen 00143 // but all other objects will be in front of the sky. 00144 glDisable(GL_DEPTH_TEST); 00145 m_sky->render(); 00146 glEnable(GL_DEPTH_TEST); 00147 } 00148 renderer::popMatrix(); 00149 00150 m_camera->applyCameraView(); 00151 for(it = m_objectsWithoutBloom.begin(); it != m_objectsWithoutBloom.end(); it++) { 00152 IRenderableObject *object = *it; 00153 object->render(); 00154 } 00155 for(it = m_objects.begin(); it != m_objects.end(); it++) { 00156 IRenderableObject *object = *it; 00157 object->render(); 00158 } 00159 00161 // 2D Mode for GUI rendering! 00163 renderer::enter2DMode(0.0f, (float)CoreEngine::getInstance()->getResolutionWidth(), 0.0f, (float)CoreEngine::getInstance()->getResolutionHeight(), -1.0f, 1.0f); 00164 00165 // Apply the bloom image to the scene. 00166 m_bloomEffect->render(); 00167 00168 // Finally render the GUI stuff. 00169 gui::SceneAnalyseGUI::getInstance()->render(); 00170 } |
Here is the call graph for this function:
|
Definition at line 286 of file World.cpp. References m_sky. Referenced by main().
|
|
Called when the timer event comes.
Implements pge::IRenderableObject. Definition at line 178 of file World.cpp. References m_camera, m_objects, m_objectsWithoutBloom, m_sky, pge::Camera::timer(), and pge::IRenderableObject::timer(). Referenced by pge::CoreEngine::timer().
00178 { 00179 // 00180 // Variables 00181 // 00182 std::vector<IRenderableObject*>::iterator it; 00183 00184 00185 for(it = m_objects.begin(); it != m_objects.end(); it++) { 00186 IRenderableObject *object = *it; 00187 object->timer(delay); 00188 } 00189 for(it = m_objectsWithoutBloom.begin(); it != m_objectsWithoutBloom.end(); it++) { 00190 IRenderableObject *object = *it; 00191 object->timer(delay); 00192 } 00193 00194 if(m_camera != NULL) { 00195 m_camera->timer(delay); 00196 } 00197 00198 DayNightCycle::getInstance()->update(delay); 00199 00200 if(m_sky != NULL) { 00201 m_sky->timer(delay); 00202 } 00203 00204 gui::SceneAnalyseGUI::getInstance()->timer(delay); 00205 } |
Here is the call graph for this function:
|
|
|
Definition at line 84 of file World.h. Referenced by action(), getCamera(), render(), timer(), and World(). |
|
Definition at line 85 of file World.h. Referenced by getFrustum(), render(), World(), and ~World(). |
|
Definition at line 89 of file World.h. Referenced by getLightProgram(), World(), and ~World(). |
|
Definition at line 82 of file World.h. Referenced by addLight(), getLightAt(), getLightNum(), and ~World(). |
|
Definition at line 79 of file World.h. Referenced by addRenderableObject(), clearRenderableObjects(), render(), timer(), and ~World(). |
|
Definition at line 80 of file World.h. Referenced by addRenderableObject(), render(), timer(), and ~World(). |
|
Definition at line 87 of file World.h. Referenced by render(), setSky(), timer(), World(), and ~World(). |