[10207] | 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: Filip Gospodinov |
---|
| 13 | co-programmer: |
---|
| 14 | */ |
---|
| 15 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY |
---|
| 16 | |
---|
| 17 | |
---|
| 18 | #include "executor/executor.h" |
---|
| 19 | #include "util/loading/factory.h" |
---|
| 20 | #include "util/loading/load_param.h" |
---|
| 21 | #include "blackscreen.h" |
---|
| 22 | #include "debug.h" |
---|
| 23 | #include "material.h" |
---|
| 24 | #include "state.h" |
---|
[10210] | 25 | #include "class_id_DEPRECATED.h" |
---|
[10218] | 26 | |
---|
[10342] | 27 | ObjectListDefinition(BlackScreen); |
---|
| 28 | CREATE_FACTORY(BlackScreen); |
---|
[10207] | 29 | |
---|
| 30 | |
---|
[10212] | 31 | |
---|
[10207] | 32 | /** |
---|
| 33 | * |
---|
| 34 | */ |
---|
[10342] | 35 | BlackScreen::BlackScreen() |
---|
[10207] | 36 | { |
---|
| 37 | this->init(); |
---|
[10215] | 38 | |
---|
[10218] | 39 | |
---|
[10207] | 40 | } |
---|
| 41 | |
---|
| 42 | |
---|
| 43 | /** |
---|
| 44 | * |
---|
| 45 | */ |
---|
[10342] | 46 | BlackScreen::BlackScreen(const TiXmlElement* root) |
---|
[10207] | 47 | { |
---|
| 48 | this->init(); |
---|
| 49 | |
---|
| 50 | if( root != NULL) |
---|
| 51 | this->loadParams(root); |
---|
[10254] | 52 | |
---|
[10207] | 53 | } |
---|
| 54 | |
---|
| 55 | |
---|
| 56 | /** |
---|
| 57 | * |
---|
| 58 | */ |
---|
[10342] | 59 | BlackScreen::~BlackScreen() |
---|
[10207] | 60 | {} |
---|
| 61 | |
---|
| 62 | |
---|
| 63 | /** |
---|
| 64 | * |
---|
| 65 | */ |
---|
[10342] | 66 | void BlackScreen::init() |
---|
[10207] | 67 | { |
---|
[10342] | 68 | this->registerObject(this, BlackScreen::_objectList); |
---|
[10207] | 69 | this->toList(OM_GROUP_00); |
---|
| 70 | |
---|
| 71 | this->material = new Material(); |
---|
[10341] | 72 | this->material->setDiffuse(0,0,0); |
---|
[10339] | 73 | this->material->setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
---|
[10220] | 74 | |
---|
[10342] | 75 | i=0; |
---|
[10254] | 76 | state=0; |
---|
| 77 | fadeSpeed=1; |
---|
| 78 | |
---|
[10207] | 79 | } |
---|
| 80 | |
---|
| 81 | |
---|
| 82 | /** |
---|
| 83 | * loads the Settings of a MD2Creature from an XML-element. |
---|
| 84 | * @param root the XML-element to load the MD2Creature's properties from |
---|
| 85 | */ |
---|
[10342] | 86 | void BlackScreen::loadParams(const TiXmlElement* root) |
---|
[10207] | 87 | { |
---|
| 88 | WorldEntity::loadParams(root); |
---|
| 89 | } |
---|
| 90 | |
---|
[10342] | 91 | void BlackScreen::draw() const |
---|
[10207] | 92 | { |
---|
| 93 | glPushAttrib(GL_ENABLE_BIT); |
---|
| 94 | glDisable(GL_LIGHTING); |
---|
| 95 | glPushMatrix(); |
---|
[10342] | 96 | glEnable(GL_BLEND); // Turn Blending On |
---|
[10207] | 97 | |
---|
[10338] | 98 | this->material->setTransparency(i); |
---|
[10330] | 99 | this->material->select(); |
---|
[10338] | 100 | |
---|
[10207] | 101 | glBegin(GL_QUADS); |
---|
[10220] | 102 | glVertex3f(State::getCameraNode()->getAbsCoorX()+3,State::getCameraNode()->getAbsCoorY() -100.0f, |
---|
[10218] | 103 | State::getCameraNode()->getAbsCoorZ()-100.0f); |
---|
[10220] | 104 | glVertex3f(State::getCameraNode()->getAbsCoorX()+3, State::getCameraNode()->getAbsCoorY()-100.0f, |
---|
[10218] | 105 | State::getCameraNode()->getAbsCoorZ()+100.0f); |
---|
[10220] | 106 | glVertex3f(State::getCameraNode()->getAbsCoorX()+3, State::getCameraNode()->getAbsCoorY() +100.0f, |
---|
[10218] | 107 | State::getCameraNode()->getAbsCoorZ()+100.0f); |
---|
[10220] | 108 | glVertex3f(State::getCameraNode()->getAbsCoorX()+3, State::getCameraNode()->getAbsCoorY()+100.0f, |
---|
[10218] | 109 | State::getCameraNode()->getAbsCoorZ()-100.0f); |
---|
[10207] | 110 | |
---|
| 111 | glEnd(); |
---|
| 112 | |
---|
[10218] | 113 | glPopMatrix(); |
---|
| 114 | glPopAttrib(); |
---|
[10207] | 115 | } |
---|
| 116 | |
---|
| 117 | /** |
---|
| 118 | * |
---|
| 119 | */ |
---|
[10342] | 120 | void BlackScreen::tick (float time) |
---|
[10207] | 121 | { |
---|
[10330] | 122 | if (state == true) |
---|
[10254] | 123 | fadeOut(); |
---|
| 124 | else |
---|
[10330] | 125 | fadeIn(); |
---|
[10207] | 126 | } |
---|
| 127 | |
---|
[10342] | 128 | void BlackScreen::fadeIn() |
---|
[10254] | 129 | { |
---|
| 130 | if (i>0) |
---|
| 131 | i=i-0.005*fadeSpeed; |
---|
| 132 | } |
---|
[10207] | 133 | |
---|
[10342] | 134 | void BlackScreen::fadeOut() |
---|
[10207] | 135 | { |
---|
[10254] | 136 | if (i<=1) |
---|
| 137 | i=i+0.005*fadeSpeed; |
---|
[10207] | 138 | } |
---|
[10254] | 139 | |
---|
[10342] | 140 | void BlackScreen::toggleFade () |
---|
[10254] | 141 | { |
---|
[10330] | 142 | |
---|
| 143 | this->state= !this->state; |
---|
[10254] | 144 | } |
---|
| 145 | |
---|
[10342] | 146 | void BlackScreen::changeFadeSpeed(float newSpeed) |
---|
[10254] | 147 | { |
---|
| 148 | fadeSpeed=newSpeed; |
---|
| 149 | } |
---|
| 150 | |
---|
[10342] | 151 | bool BlackScreen::isBlack() |
---|
[10338] | 152 | { |
---|
| 153 | if (i==1) |
---|
| 154 | return 1; |
---|
| 155 | else |
---|
| 156 | return 0; |
---|
| 157 | } |
---|
| 158 | |
---|
[10342] | 159 | bool BlackScreen::isTrans() |
---|
[10338] | 160 | { |
---|
| 161 | if (i==0) |
---|
| 162 | return 1; |
---|
| 163 | else |
---|
| 164 | return 0; |
---|
[10341] | 165 | } |
---|