[7504] | 1 | /* |
---|
[8495] | 2 | orxonox - the future of 3D-vertical-scrollers |
---|
[7504] | 3 | |
---|
[9935] | 4 | Copyright (C) 2006 orx |
---|
[7504] | 5 | |
---|
[8495] | 6 | This program is free software; you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 9 | any later version. |
---|
[7504] | 10 | |
---|
| 11 | ### File Specific: |
---|
[9935] | 12 | main-programmer: hdavid |
---|
[7504] | 13 | */ |
---|
| 14 | |
---|
| 15 | #include "volfog_effect.h" |
---|
| 16 | |
---|
| 17 | #include "util/loading/load_param.h" |
---|
| 18 | #include "util/loading/factory.h" |
---|
| 19 | |
---|
[7760] | 20 | #include "p_node.h" |
---|
| 21 | #include "state.h" |
---|
[9936] | 22 | #include "shell_command.h" |
---|
[7760] | 23 | |
---|
[8495] | 24 | #include "glincl.h" |
---|
[9727] | 25 | #include "debug.h" |
---|
[7504] | 26 | |
---|
[9937] | 27 | |
---|
[9938] | 28 | |
---|
[7759] | 29 | #define GLX_GLXEXT_PROTOTYPES |
---|
| 30 | |
---|
[9716] | 31 | #include "class_id_DEPRECATED.h" |
---|
[9715] | 32 | ObjectListDefinitionID(VolFogEffect, CL_VOLFOG_EFFECT); |
---|
[9709] | 33 | CREATE_FACTORY(VolFogEffect); |
---|
[7504] | 34 | |
---|
[9936] | 35 | SHELL_COMMAND(activate, VolFogEffect, activateFog); |
---|
| 36 | SHELL_COMMAND(deactivate, VolFogEffect, deactivateFog); |
---|
[9935] | 37 | |
---|
| 38 | |
---|
[8495] | 39 | VolFogEffect::VolFogEffect(const TiXmlElement* root) { |
---|
[9686] | 40 | this->registerObject(this, VolFogEffect::_objectList); |
---|
[7504] | 41 | |
---|
[9936] | 42 | if (root != NULL) |
---|
| 43 | this->loadParams(root); |
---|
[7532] | 44 | |
---|
[9936] | 45 | // Initialize Effect |
---|
| 46 | this->init(); |
---|
[7546] | 47 | |
---|
[9936] | 48 | // Activate Effect |
---|
| 49 | if(fogActivate) |
---|
| 50 | this->activate(); |
---|
[7504] | 51 | } |
---|
| 52 | |
---|
| 53 | |
---|
[8495] | 54 | VolFogEffect::~VolFogEffect() { |
---|
[9936] | 55 | if(fogActivate) |
---|
[8495] | 56 | this->deactivate(); |
---|
[7504] | 57 | } |
---|
| 58 | |
---|
[8495] | 59 | void VolFogEffect::loadParams(const TiXmlElement* root) { |
---|
[9936] | 60 | WeatherEffect::loadParams(root); |
---|
[7504] | 61 | } |
---|
| 62 | |
---|
[8495] | 63 | void VolFogEffect::init() { |
---|
[9936] | 64 | PRINTF(0)("Initalize VolFogEffect\n"); |
---|
[7504] | 65 | |
---|
[9938] | 66 | fogActivate = false; |
---|
[7546] | 67 | } |
---|
| 68 | |
---|
| 69 | |
---|
[8495] | 70 | void VolFogEffect::activate() { |
---|
[9936] | 71 | PRINTF(0)("Activating VolFogEffect\n"); |
---|
| 72 | |
---|
| 73 | // Test whether the extension exists |
---|
| 74 | if (!glewIsSupported("GL_EXT_fog_coord")) |
---|
| 75 | { |
---|
| 76 | PRINTF(0)("Can't activate volumetric fog, GL_EXT_fog_coord extension is misssing\n"); |
---|
| 77 | return; |
---|
| 78 | } |
---|
[9937] | 79 | |
---|
[9936] | 80 | fogActivate = true; |
---|
[7504] | 81 | } |
---|
| 82 | |
---|
[8495] | 83 | void VolFogEffect::deactivate() { |
---|
[9936] | 84 | PRINTF(0)("Deactivating VolFogEffect\n"); |
---|
| 85 | |
---|
| 86 | fogActivate = false; |
---|
[7504] | 87 | } |
---|
| 88 | |
---|
[7520] | 89 | |
---|
[7516] | 90 | /** |
---|
[9935] | 91 | * draws the effect |
---|
[7652] | 92 | */ |
---|
[8495] | 93 | void VolFogEffect::draw() const { |
---|
[7760] | 94 | |
---|
[9936] | 95 | if(!fogActivate) |
---|
| 96 | return; |
---|
[7557] | 97 | } |
---|
[7546] | 98 | |
---|
| 99 | |
---|
[7516] | 100 | /** |
---|
[7652] | 101 | * ticks the effect if there is any time dependancy |
---|
| 102 | */ |
---|
[8495] | 103 | void VolFogEffect::tick(float dt) {} |
---|