/* orxonox - the future of 3D-vertical-scrollers Copyright (C) 2004 orx This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. ### File Specific: main-programmer: Patrick Boenzli */ #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GRAPHICS #include "lense_flare.h" #include "load_param.h" #include "factory.h" #include "glincl.h" #include "texture.h" #include "light.h" #include "render2D/billboard.h" using namespace std; CREATE_FACTORY(LenseFlare, CL_LENSE_FLARE); /** * default constructor * @param root The XML-element to load the LenseFlare from */ LenseFlare::LenseFlare(const TiXmlElement* root) { if (root != NULL) this->loadParams(root); } /** * destroys a LenseFlare */ LenseFlare::~LenseFlare() { std::vector::iterator it; for( it = flares.begin(); it != flares.end(); it++) delete (*it); } /** * @param root The XML-element to load the LenseFlare from */ void LenseFlare::loadParams(const TiXmlElement* root) { GraphicsEffect::loadParams(root); LoadParam(root, "add-flare-texture", this, LenseFlare, addFlare) .describe("adds a lensflare texture to the engine"); } /** * initializes the fog effect */ bool LenseFlare::init() {} /** * activates the fog effect */ bool LenseFlare::activate() { this->bActivated = true; } /** * deactivates the fog effect */ bool LenseFlare::deactivate() { this->bActivated = false; } /** * converts a gl mode char to a GLint * @param mode the mode character */ GLint LenseFlare::charToFogMode(const char* mode) {} /** * adds a texture flare * @param textureName the name of the flare texture * * 1st: Texture of the Sun/Light source itself * 2nd: Texture of the fist halo * 3rd: Texture of small burst * 4th: Texture of the second halo * 5th: Texutre of the second burst * 6th: Texture of the third halo * 7th: Texture of the third burst */ void LenseFlare::addFlare(const char* textureName) { Billboard* bb = new Billboard(NULL); bb->setTexture(textureName); this->flares.push_back(bb); // the first flare belongs to the light source if( this->flares.size() == 1 && this->lightSource != NULL) { bb->setBindNode(static_cast(this->lightSource)); } } /** * tick the effect */ void LenseFlare::tick(float dt) { } /** * draws the LenseFlares */ void LenseFlare::draw() const { if( !this->bActivated) return; std::vector::const_iterator it; for( it = flares.begin(); it != flares.end(); it++) (*it)->draw(); }