/* 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_WEAPON #include "lightning_bolt.h" #include "factory.h" #include "material.h" using namespace std; CREATE_FACTORY(LightningBolt, CL_LIGHTNING_BOLT); /** * standard constructor */ LightningBolt::LightningBolt (const TiXmlElement* root) { this->setClassID(CL_LIGHTNING_BOLT, "LightningBolt"); this->toList(OM_COMMON); this->bRender = false; this->time = 0.0; this->flashFrequency = 0.6f; this->flashConstTime = 0.1f; this->material = new Material(); this->material->setDiffuseMap("maps/lightning_bolt.png"); this->offset = Vector(-1440.00, 100.00, 280.00); this->setAbsCoor(offset); this->width = 100.0f; this->height = 300.0f; } /** * standard deconstructor */ LightningBolt::~LightningBolt () { } void LightningBolt::activate() { } void LightningBolt::deactivate() { } /** * signal tick, time dependent things will be handled here * @param time since last tick */ void LightningBolt::tick (float dt) { this->time += dt; PRINTF(0)("time: %f, bRender: %i\n", this->time, this->bRender); if( this->time > this->flashFrequency) { this->bRender = true; this->time = 0.0f; } else if( this->bRender && this->time > this->flashConstTime) { this->bRender = false; this->time = 0.0; } else { } } void LightningBolt::draw() const { if( this->bRender) { PRINTF(0)("draw\n"); glPushMatrix(); glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z); // glRotatef(axis, 0.0f, 1.0f, 0.0f); // glPushAttrib(GL_ENABLE_BIT); // glDisable(GL_LIGHTING); // glDisable(GL_BLEND); this->material->select(); glBegin(GL_QUADS); glTexCoord2f(1.0f, 1.0f); glVertex3f(-width/2, -height/2, 0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f( width/2, -height/2, 0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f( width/2, height/2, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(-width/2, height/2, 0.0f); glEnd(); // glPopAttrib(); glPopMatrix(); } }