Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/network/src/lib/graphics/effects/lense_flare.cc @ 6785

Last change on this file since 6785 was 6785, checked in by patrick, 18 years ago

network: lense flare work

File size: 2.7 KB
Line 
1
2
3/*
4   orxonox - the future of 3D-vertical-scrollers
5
6   Copyright (C) 2004 orx
7
8   This program is free software; you can redistribute it and/or modify
9   it under the terms of the GNU General Public License as published by
10   the Free Software Foundation; either version 2, or (at your option)
11   any later version.
12
13### File Specific:
14   main-programmer: Patrick Boenzli
15*/
16
17#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GRAPHICS
18
19#include "lense_flare.h"
20
21#include "load_param.h"
22#include "factory.h"
23
24#include "glincl.h"
25#include "texture.h"
26
27#include "render2D/billboard.h"
28
29using namespace std;
30
31CREATE_FACTORY(LenseFlare, CL_LENSE_FLARE);
32
33
34
35/**
36 *  default constructor
37 * @param root The XML-element to load the LenseFlare from
38 */
39 LenseFlare::LenseFlare(const TiXmlElement* root)
40{
41  if (root != NULL)
42    this->loadParams(root);
43
44  this->flareVector = new Vector();
45  this->screenCenter = new Vector();
46}
47
48
49/**
50 *  destroys a LenseFlare
51 */
52LenseFlare::~LenseFlare()
53{
54  std::vector<Billboard*>::iterator it;
55  for( it = flares.begin(); it != flares.end(); it++)
56    delete (*it);
57
58  delete this-flareVector;
59  delete this->screenCenter;
60}
61
62
63/**
64 * @param root The XML-element to load the LenseFlare from
65 */
66void LenseFlare::loadParams(const TiXmlElement* root)
67{
68  GraphicsEffect::loadParams(root);
69
70    LoadParam(root, "add-flare-texture", this, LenseFlare, addFlare)
71        .describe("adds a lensflare texture to the engine");
72}
73
74
75/**
76 * initializes the fog effect
77 */
78bool LenseFlare::init()
79{}
80
81
82/**
83 * activates the fog effect
84 */
85bool LenseFlare::activate()
86{
87  this->bActivated = true;
88}
89
90
91/**
92 * deactivates the fog effect
93 */
94bool LenseFlare::deactivate()
95{
96  this->bActivated = false;
97}
98
99
100/**
101 * converts a gl mode char to a GLint
102 * @param mode the mode character
103 */
104GLint LenseFlare::charToFogMode(const char* mode)
105{}
106
107
108/**
109 * adds a texture flare
110 * @param textureName the name of the flare texture
111 *
112 *  1st: Texture of the Sun/Light source itself
113 *  2nd: Texture of the fist halo
114 *  3rd: Texture of small burst
115 *  4th: Texture of the second halo
116 *  5th: Texutre of the second burst
117 *  6th: Texture of the third halo
118 *  7th: Texture of the third burst
119 */
120void LenseFlare::addFlare(const char* textureName)
121{
122  Billboard* bb = new Billboard(NULL);
123  bb->setTexture(textureName);
124  this->flares.push_back(bb);
125
126  // the first flare belongs to the light source
127  if( this->flares.size() == 1 && this->lightSource != NULL)
128  {
129    bb->setBindNode(this->lightSource);
130  }
131}
132
133
134
135/**
136 * tick the effect
137 */
138void LenseFlare::tick(float dt)
139{
140
141}
142
143
144/**
145 * draws the LenseFlares
146 */
147void LenseFlare::draw() const
148{
149  if( !this->bActivated)
150    return;
151
152  for( it = flares.begin(); it != flares.end(); it++)
153    (*it)->draw();
154}
Note: See TracBrowser for help on using the repository browser.