Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/graphics/effects/atmospheric_engine.cc @ 8261

Last change on this file since 8261 was 8190, checked in by patrick, 19 years ago

trunk: merged the cr branche to trunk

File size: 3.1 KB
RevLine 
[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
20#include "effects/fog_effect.h"
21
22#include "util/loading/load_param.h"
23#include "util/loading/factory.h"
24#include "class_list.h"
25
26
27using namespace std;
28
29/**
30 * @param root The XML-element to load the AtmosphericEngine from
31 */
32AtmosphericEngine::AtmosphericEngine()
33{
[7416]34  this->setClassID(CL_ATMOSPHERIC_ENGINE, "AtmosphericEngine");
[7379]35}
36
37/**
38 *  The Pointer to this AtmosphericEngine
39*/
40AtmosphericEngine* AtmosphericEngine::singletonRef = NULL;
41
42
43/**
44 *  destroys a AtmosphericEngine
45 */
46AtmosphericEngine::~AtmosphericEngine()
47{
48  AtmosphericEngine::singletonRef = NULL;
[7503]49
[7514]50  const std::list<BaseObject*>* weatherEffects = ClassList::getList( CL_WEATHER_EFFECT);
[7503]51
[7514]52  if (weatherEffects != NULL)
[7503]53  {
[7514]54      while(!weatherEffects->empty())
55        delete weatherEffects->front();
[7503]56  }
[7379]57}
58
59/**
60 * @param root The XML-element to load the AtmosphericEngine from
61 */
62void AtmosphericEngine::loadParams(const TiXmlElement* root)
63{
[7381]64  LoadParamXML(root, "WeatherEffect", this, AtmosphericEngine, loadWeatherEffect);
65  LoadParamXML(root, "SunEffect", this, AtmosphericEngine, loadSunEffect);
[7379]66}
67
68/**
69 * @param root The XML-element to load WeatherEffects from
70 */
[7381]71void AtmosphericEngine::loadWeatherEffect(const TiXmlElement* root)
[7379]72{
73  LOAD_PARAM_START_CYCLE(root, element);
74  {
75    PRINTF(4)("element is: %s\n", element->Value());
[7560]76    // Factory::fabricate(element);
[7532]77
[7519]78    BaseObject* bo = Factory::fabricate(element);
79    if( bo == NULL)
80      PRINTF(0)(" Could not create Element %s\n", element->Value());
[7379]81  }
82  LOAD_PARAM_END_CYCLE(element);
83}
84
85/**
86 * @param root The XML-element to load SunEffects from
87 */
[7381]88void AtmosphericEngine::loadSunEffect(const TiXmlElement* root)
[7379]89{
90  LOAD_PARAM_START_CYCLE(root, element);
91  {
92    PRINTF(4)("element is: %s\n", element->Value());
93  }
94  LOAD_PARAM_END_CYCLE(element);
95}
96
97
98/**
99 * draws the effect, if needed
100 */
101void AtmosphericEngine::draw() const
[7514]102{
103  const std::list<BaseObject*>* weatherEffects = ClassList::getList( CL_WEATHER_EFFECT);
[7379]104
[7514]105  // draw the weather effects
106  if (weatherEffects != NULL)
107  {
108    std::list<BaseObject*>::const_iterator it;
109    for (it = weatherEffects->begin(); it != weatherEffects->end(); it++)
110      dynamic_cast<WeatherEffect*>(*it)->draw();
111  }
112}
[7379]113
114
[7514]115
[7379]116/**
117 * ticks the effect if there is any time dependancy
118 */
119void AtmosphericEngine::tick(float dt)
[7514]120{
121  const std::list<BaseObject*>* weatherEffects = ClassList::getList( CL_WEATHER_EFFECT);
122
123  // tick the weather effects
124  if (weatherEffects != NULL)
125  {
126    std::list<BaseObject*>::const_iterator it;
127    for (it = weatherEffects->begin(); it != weatherEffects->end(); it++)
[7836]128    {
[8190]129/*      printf("%s::%s \n", (*it)->getClassName(), (*it)->getName());*/
[7514]130      dynamic_cast<WeatherEffect*>(*it)->tick(dt);
[7836]131    }
[7514]132  }
133}
Note: See TracBrowser for help on using the repository browser.