[7111] | 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: Patrick Boenzli |
---|
| 13 | */ |
---|
| 14 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON |
---|
| 15 | |
---|
| 16 | |
---|
| 17 | #include "lightning_bolt.h" |
---|
| 18 | |
---|
| 19 | #include "factory.h" |
---|
| 20 | #include "material.h" |
---|
| 21 | |
---|
| 22 | using namespace std; |
---|
| 23 | |
---|
| 24 | CREATE_FACTORY(LightningBolt, CL_LIGHTNING_BOLT); |
---|
| 25 | |
---|
| 26 | |
---|
| 27 | /** |
---|
| 28 | * standard constructor |
---|
| 29 | */ |
---|
| 30 | LightningBolt::LightningBolt (const TiXmlElement* root) |
---|
| 31 | { |
---|
| 32 | this->setClassID(CL_LIGHTNING_BOLT, "LightningBolt"); |
---|
| 33 | |
---|
| 34 | this->toList(OM_COMMON); |
---|
| 35 | |
---|
| 36 | this->bRender = false; |
---|
| 37 | this->time = 0.0; |
---|
| 38 | this->flashFrequency = 0.6f; |
---|
| 39 | this->flashConstTime = 0.1f; |
---|
| 40 | |
---|
| 41 | this->material = new Material(); |
---|
| 42 | this->material->setDiffuseMap("maps/lightning_bolt.png"); |
---|
| 43 | this->offset = Vector(-1440.00, 100.00, 280.00); |
---|
| 44 | |
---|
| 45 | this->setAbsCoor(offset); |
---|
| 46 | this->width = 100.0f; |
---|
| 47 | this->height = 300.0f; |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | |
---|
| 51 | /** |
---|
| 52 | * standard deconstructor |
---|
| 53 | */ |
---|
| 54 | LightningBolt::~LightningBolt () |
---|
| 55 | { |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | void LightningBolt::activate() |
---|
| 59 | { |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | |
---|
| 63 | void LightningBolt::deactivate() |
---|
| 64 | { |
---|
| 65 | |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | |
---|
| 69 | /** |
---|
| 70 | * signal tick, time dependent things will be handled here |
---|
| 71 | * @param time since last tick |
---|
| 72 | */ |
---|
| 73 | void LightningBolt::tick (float dt) |
---|
| 74 | { |
---|
| 75 | |
---|
| 76 | |
---|
| 77 | |
---|
| 78 | |
---|
| 79 | this->time += dt; |
---|
| 80 | PRINTF(0)("time: %f, bRender: %i\n", this->time, this->bRender); |
---|
| 81 | |
---|
| 82 | if( this->time > this->flashFrequency) |
---|
| 83 | { |
---|
| 84 | this->bRender = true; |
---|
| 85 | this->time = 0.0f; |
---|
| 86 | } |
---|
| 87 | else if( this->bRender && this->time > this->flashConstTime) |
---|
| 88 | { |
---|
| 89 | this->bRender = false; |
---|
| 90 | this->time = 0.0; |
---|
| 91 | } |
---|
| 92 | else |
---|
| 93 | { |
---|
| 94 | |
---|
| 95 | } |
---|
| 96 | } |
---|
| 97 | |
---|
| 98 | |
---|
| 99 | void LightningBolt::draw() const |
---|
| 100 | { |
---|
| 101 | if( this->bRender) |
---|
| 102 | { |
---|
| 103 | PRINTF(0)("draw\n"); |
---|
| 104 | |
---|
| 105 | glPushMatrix(); |
---|
| 106 | glTranslatef (this->getAbsCoor ().x, |
---|
| 107 | this->getAbsCoor ().y, |
---|
| 108 | this->getAbsCoor ().z); |
---|
| 109 | |
---|
| 110 | // glRotatef(axis, 0.0f, 1.0f, 0.0f); |
---|
| 111 | |
---|
| 112 | // glPushAttrib(GL_ENABLE_BIT); |
---|
| 113 | // glDisable(GL_LIGHTING); |
---|
| 114 | // glDisable(GL_BLEND); |
---|
| 115 | |
---|
| 116 | this->material->select(); |
---|
| 117 | |
---|
| 118 | glBegin(GL_QUADS); |
---|
| 119 | glTexCoord2f(1.0f, 1.0f); glVertex3f(-width/2, -height/2, 0.0f); |
---|
| 120 | glTexCoord2f(0.0f, 1.0f); glVertex3f( width/2, -height/2, 0.0f); |
---|
| 121 | glTexCoord2f(0.0f, 0.0f); glVertex3f( width/2, height/2, 0.0f); |
---|
| 122 | glTexCoord2f(1.0f, 0.0f); glVertex3f(-width/2, height/2, 0.0f); |
---|
| 123 | glEnd(); |
---|
| 124 | |
---|
| 125 | // glPopAttrib(); |
---|
| 126 | |
---|
| 127 | glPopMatrix(); |
---|
| 128 | } |
---|
| 129 | } |
---|
| 130 | |
---|
| 131 | |
---|