[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 | |
---|
[10207] | 27 | ObjectListDefinition(blackscreen); |
---|
| 28 | CREATE_FACTORY(blackscreen); |
---|
| 29 | |
---|
| 30 | |
---|
[10212] | 31 | |
---|
[10207] | 32 | /** |
---|
| 33 | * |
---|
| 34 | */ |
---|
[10330] | 35 | blackscreen::blackscreen() |
---|
[10207] | 36 | { |
---|
| 37 | this->init(); |
---|
[10215] | 38 | |
---|
[10218] | 39 | |
---|
[10207] | 40 | } |
---|
| 41 | |
---|
| 42 | |
---|
| 43 | /** |
---|
| 44 | * |
---|
| 45 | */ |
---|
| 46 | blackscreen::blackscreen(const TiXmlElement* root) |
---|
| 47 | { |
---|
| 48 | this->init(); |
---|
| 49 | |
---|
| 50 | if( root != NULL) |
---|
| 51 | this->loadParams(root); |
---|
[10254] | 52 | |
---|
[10207] | 53 | } |
---|
| 54 | |
---|
| 55 | |
---|
| 56 | /** |
---|
| 57 | * |
---|
| 58 | */ |
---|
[10330] | 59 | blackscreen::~blackscreen() |
---|
[10207] | 60 | {} |
---|
| 61 | |
---|
| 62 | |
---|
| 63 | /** |
---|
| 64 | * |
---|
| 65 | */ |
---|
| 66 | void blackscreen::init() |
---|
| 67 | { |
---|
| 68 | this->registerObject(this, blackscreen::_objectList); |
---|
| 69 | this->toList(OM_GROUP_00); |
---|
| 70 | |
---|
| 71 | this->material = new Material(); |
---|
[10330] | 72 | // this->material->setIllum(3); |
---|
| 73 | // this->material->setDiffuse(0,0,0); |
---|
[10207] | 74 | this->material->setSpecular(0.0,0.0,0.0); |
---|
[10330] | 75 | // this->material->setAmbient(0, 0, 0); |
---|
[10220] | 76 | |
---|
[10330] | 77 | i=1; |
---|
[10254] | 78 | state=0; |
---|
| 79 | fadeSpeed=1; |
---|
| 80 | |
---|
[10207] | 81 | } |
---|
| 82 | |
---|
| 83 | |
---|
| 84 | /** |
---|
| 85 | * loads the Settings of a MD2Creature from an XML-element. |
---|
| 86 | * @param root the XML-element to load the MD2Creature's properties from |
---|
| 87 | */ |
---|
| 88 | void blackscreen::loadParams(const TiXmlElement* root) |
---|
| 89 | { |
---|
| 90 | WorldEntity::loadParams(root); |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | void blackscreen::draw() const |
---|
| 94 | { |
---|
| 95 | // if(!mediaLoaded) |
---|
| 96 | // false; |
---|
| 97 | |
---|
| 98 | glPushAttrib(GL_ENABLE_BIT); |
---|
| 99 | glDisable(GL_LIGHTING); |
---|
| 100 | // glDisable(GL_BLEND); |
---|
| 101 | // |
---|
| 102 | // glEnable(GL_TEXTURE_2D); |
---|
| 103 | // glBindTexture(GL_TEXTURE_2D, media_container->getFrameTexture(counter)); |
---|
| 104 | |
---|
| 105 | glPushMatrix(); |
---|
| 106 | /* glTranslatef (this->getAbsCoor ().x, |
---|
| 107 | this->getAbsCoor ().y, |
---|
| 108 | this->getAbsCoor ().z); |
---|
| 109 | glRotatef(axis, 0.0f, 1.0f, 0.0f);*/ |
---|
| 110 | //PRINTF(0)("axis: %f\n", axis); |
---|
| 111 | glEnable(GL_BLEND); // Turn Blending On |
---|
| 112 | |
---|
[10236] | 113 | // |
---|
| 114 | // Coord schould depend on CameraTarget |
---|
| 115 | // |
---|
| 116 | // |
---|
| 117 | // |
---|
[10207] | 118 | |
---|
| 119 | glColor4f(0, 0, 0, i); |
---|
[10330] | 120 | this->material->select(); |
---|
| 121 | this->material->setTransparency(i); |
---|
[10207] | 122 | glBegin(GL_QUADS); |
---|
[10220] | 123 | glVertex3f(State::getCameraNode()->getAbsCoorX()+3,State::getCameraNode()->getAbsCoorY() -100.0f, |
---|
[10218] | 124 | State::getCameraNode()->getAbsCoorZ()-100.0f); |
---|
[10220] | 125 | glVertex3f(State::getCameraNode()->getAbsCoorX()+3, State::getCameraNode()->getAbsCoorY()-100.0f, |
---|
[10218] | 126 | State::getCameraNode()->getAbsCoorZ()+100.0f); |
---|
[10220] | 127 | glVertex3f(State::getCameraNode()->getAbsCoorX()+3, State::getCameraNode()->getAbsCoorY() +100.0f, |
---|
[10218] | 128 | State::getCameraNode()->getAbsCoorZ()+100.0f); |
---|
[10220] | 129 | glVertex3f(State::getCameraNode()->getAbsCoorX()+3, State::getCameraNode()->getAbsCoorY()+100.0f, |
---|
[10218] | 130 | State::getCameraNode()->getAbsCoorZ()-100.0f); |
---|
[10207] | 131 | |
---|
[10330] | 132 | |
---|
| 133 | /* glBegin(GL_QUADS); |
---|
[10238] | 134 | glVertex3f(0,-100.0f,-100.0f); |
---|
| 135 | glVertex3f(0,-100.0f,+100.0f); |
---|
| 136 | glVertex3f(0,+100.0f,+100.0f); |
---|
| 137 | glVertex3f(0,+100.0f,-100.0f); |
---|
[10330] | 138 | */ |
---|
[10207] | 139 | |
---|
[10238] | 140 | |
---|
[10207] | 141 | glEnd(); |
---|
| 142 | |
---|
[10218] | 143 | glPopMatrix(); |
---|
| 144 | glPopAttrib(); |
---|
[10207] | 145 | } |
---|
| 146 | |
---|
| 147 | /** |
---|
| 148 | * |
---|
| 149 | */ |
---|
| 150 | void blackscreen::tick (float time) |
---|
| 151 | { |
---|
[10330] | 152 | if (state == true) |
---|
[10254] | 153 | fadeOut(); |
---|
| 154 | else |
---|
[10330] | 155 | fadeIn(); |
---|
[10207] | 156 | } |
---|
| 157 | |
---|
[10254] | 158 | void blackscreen::fadeIn() |
---|
| 159 | { |
---|
| 160 | if (i>0) |
---|
| 161 | i=i-0.005*fadeSpeed; |
---|
| 162 | } |
---|
[10207] | 163 | |
---|
[10254] | 164 | void blackscreen::fadeOut() |
---|
[10207] | 165 | { |
---|
[10254] | 166 | if (i<=1) |
---|
| 167 | i=i+0.005*fadeSpeed; |
---|
[10207] | 168 | } |
---|
[10254] | 169 | |
---|
| 170 | void blackscreen::toggleFade () |
---|
| 171 | { |
---|
[10330] | 172 | |
---|
| 173 | this->state= !this->state; |
---|
[10254] | 174 | } |
---|
| 175 | |
---|
| 176 | void blackscreen::changeFadeSpeed(float newSpeed) |
---|
| 177 | { |
---|
| 178 | fadeSpeed=newSpeed; |
---|
| 179 | } |
---|
| 180 | |
---|