[7379] | 1 | /* |
---|
| 2 | orxonox - the future of 3D-vertical-scrollers |
---|
| 3 | |
---|
| 4 | Copyright (C) 2004 orx |
---|
| 5 | |
---|
| 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. |
---|
| 10 | |
---|
| 11 | ### File Specific: |
---|
| 12 | main-programmer: Andreas Maechler, David Hasenfratz |
---|
| 13 | co-programmer: ... |
---|
| 14 | */ |
---|
| 15 | |
---|
| 16 | #include "atmospheric_engine.h" |
---|
| 17 | |
---|
| 18 | #include "util/loading/resource_manager.h" |
---|
| 19 | |
---|
[9760] | 20 | #include "weather_effects/fog_effect.h" |
---|
[7379] | 21 | |
---|
[9727] | 22 | #include "util/loading/load_param_xml.h" |
---|
[7379] | 23 | #include "util/loading/factory.h" |
---|
| 24 | |
---|
[9715] | 25 | ObjectListDefinition(AtmosphericEngine); |
---|
[7379] | 26 | |
---|
| 27 | /** |
---|
| 28 | * @param root The XML-element to load the AtmosphericEngine from |
---|
| 29 | */ |
---|
[9685] | 30 | AtmosphericEngine::AtmosphericEngine() |
---|
| 31 | { |
---|
| 32 | this->registerObject(this, AtmosphericEngine::_objectList); |
---|
[7379] | 33 | } |
---|
| 34 | |
---|
| 35 | /** |
---|
| 36 | * The Pointer to this AtmosphericEngine |
---|
| 37 | */ |
---|
| 38 | AtmosphericEngine* AtmosphericEngine::singletonRef = NULL; |
---|
| 39 | |
---|
| 40 | |
---|
| 41 | /** |
---|
| 42 | * destroys a AtmosphericEngine |
---|
| 43 | */ |
---|
[9685] | 44 | AtmosphericEngine::~AtmosphericEngine() |
---|
| 45 | { |
---|
| 46 | AtmosphericEngine::singletonRef = NULL; |
---|
[7503] | 47 | |
---|
[9685] | 48 | while(!WeatherEffect::objectList().empty()) |
---|
| 49 | delete WeatherEffect::objectList().front(); |
---|
[7379] | 50 | } |
---|
| 51 | |
---|
| 52 | /** |
---|
| 53 | * @param root The XML-element to load the AtmosphericEngine from |
---|
| 54 | */ |
---|
[9685] | 55 | void AtmosphericEngine::loadParams(const TiXmlElement* root) |
---|
| 56 | { |
---|
| 57 | LoadParamXML(root, "WeatherEffect", this, AtmosphericEngine, loadWeatherEffect); |
---|
| 58 | LoadParamXML(root, "SunEffect", this, AtmosphericEngine, loadSunEffect); |
---|
[7379] | 59 | } |
---|
| 60 | |
---|
| 61 | /** |
---|
| 62 | * @param root The XML-element to load WeatherEffects from |
---|
| 63 | */ |
---|
[9685] | 64 | void AtmosphericEngine::loadWeatherEffect(const TiXmlElement* root) |
---|
| 65 | { |
---|
| 66 | LOAD_PARAM_START_CYCLE(root, element); |
---|
| 67 | { |
---|
| 68 | PRINTF(4)("element is: %s\n", element->Value()); |
---|
| 69 | // Factory::fabricate(element); |
---|
[7532] | 70 | |
---|
[9685] | 71 | BaseObject* bo = Factory::fabricate(element); |
---|
| 72 | if( bo == NULL) |
---|
| 73 | PRINTF(0)(" Could not create Element %s\n", element->Value()); |
---|
| 74 | } |
---|
| 75 | LOAD_PARAM_END_CYCLE(element); |
---|
[7379] | 76 | } |
---|
| 77 | |
---|
| 78 | /** |
---|
| 79 | * @param root The XML-element to load SunEffects from |
---|
| 80 | */ |
---|
[9685] | 81 | void AtmosphericEngine::loadSunEffect(const TiXmlElement* root) |
---|
| 82 | { |
---|
| 83 | LOAD_PARAM_START_CYCLE(root, element); |
---|
| 84 | { |
---|
| 85 | PRINTF(4)("element is: %s\n", element->Value()); |
---|
| 86 | } |
---|
| 87 | LOAD_PARAM_END_CYCLE(element); |
---|
[7379] | 88 | } |
---|
| 89 | |
---|
| 90 | |
---|
| 91 | /** |
---|
| 92 | * draws the effect, if needed |
---|
| 93 | */ |
---|
[9685] | 94 | void AtmosphericEngine::draw() const |
---|
| 95 | { |
---|
[9715] | 96 | for (ObjectList<WeatherEffect>::const_iterator it = WeatherEffect::objectList().begin(); |
---|
[9685] | 97 | it != WeatherEffect::objectList().end(); |
---|
| 98 | ++it) |
---|
| 99 | (*it)->draw(); |
---|
[7514] | 100 | } |
---|
[7379] | 101 | |
---|
| 102 | |
---|
[7514] | 103 | |
---|
[7379] | 104 | /** |
---|
| 105 | * ticks the effect if there is any time dependancy |
---|
| 106 | */ |
---|
[9685] | 107 | void AtmosphericEngine::tick(float dt) |
---|
| 108 | { |
---|
[7514] | 109 | |
---|
[9715] | 110 | for (ObjectList<WeatherEffect>::const_iterator it = WeatherEffect::objectList().begin(); |
---|
[9685] | 111 | it != WeatherEffect::objectList().end(); |
---|
| 112 | ++it) |
---|
| 113 | (*it)->tick(dt); |
---|
[7514] | 114 | } |
---|