Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/camera/src/world_entities/blackscreen.cc @ 10367

Last change on this file since 10367 was 10352, checked in by gfilip, 19 years ago

finito

File size: 2.8 KB
Line 
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"
25#include "class_id_DEPRECATED.h"
26
27ObjectListDefinition(BlackScreen);
28CREATE_FACTORY(BlackScreen);
29
30
31
32/**
33 *
34 */
35BlackScreen::BlackScreen()
36{
37  this->init();
38
39
40}
41
42
43/**
44 *
45 */
46BlackScreen::BlackScreen(const TiXmlElement* root)
47{
48  this->init();
49
50  if( root != NULL)
51    this->loadParams(root);
52
53}
54
55
56/**
57 *
58 */
59BlackScreen::~BlackScreen()
60{}
61
62
63/**
64 *
65 */
66void BlackScreen::init()
67{
68  this->registerObject(this, BlackScreen::_objectList);
69  this->toList(OM_GROUP_00);
70
71  this->material = new Material();
72  this->material->setDiffuse(0,0,0);
73  this->material->setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
74
75  i=0;
76  state=0;
77  fadeSpeed=1;
78
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 */
86void BlackScreen::loadParams(const TiXmlElement* root)
87{
88  WorldEntity::loadParams(root);
89}
90
91
92
93
94void BlackScreen::draw() const
95{
96  glPushAttrib(GL_ENABLE_BIT);
97  glDisable(GL_LIGHTING);
98  glEnable(GL_BLEND);   // Turn Blending On
99
100  glMatrixMode(GL_MODELVIEW);
101  glPushMatrix();
102  /* translate */
103  glTranslatef (this->getAbsCoor ().x,
104                this->getAbsCoor ().y,
105                this->getAbsCoor ().z);
106  Vector tmpRot = this->getAbsDir().getSpacialAxis();
107  glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
108
109this->material->setTransparency(i);
110this->material->select();
111
112  glBegin(GL_QUADS);
113  glVertex3f(0.,-100.0f,-100.0f);
114  glVertex3f(0., -100.0f,100.0f);
115  glVertex3f(0., 100.0f,100.0f);
116  glVertex3f(0., 100.0f,-100.0f);
117
118  glEnd();
119
120  glPopMatrix();
121  glPopAttrib();
122}
123
124/**
125 *
126 */
127void BlackScreen::tick (float time)
128{
129if (state == true)
130  fadeOut();
131else
132  fadeIn();
133}
134
135void BlackScreen::fadeIn()
136{
137  if (i>0)
138    i=i-0.005*fadeSpeed;
139  else
140    this->toList(OM_DEAD);
141}
142
143void BlackScreen::fadeOut()
144{
145  if (i<=1)
146    i=i+0.005*fadeSpeed;
147}
148
149void  BlackScreen::toggleFade ()
150{
151    this->state= !this->state;
152
153    if(state)
154    {
155      this->toList(OM_COMMON);
156    }
157}
158
159void BlackScreen::changeFadeSpeed(float newSpeed)
160{
161  fadeSpeed=newSpeed;
162}
163
164bool BlackScreen::isBlack()
165{
166if (i==1)
167  return 1;
168else
169  return 0;
170}
171
172bool BlackScreen::isTrans()
173{
174  if (i==0)
175    return 1;
176  else
177    return 0;
178}
Note: See TracBrowser for help on using the repository browser.