Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10341 was 10341, checked in by gfilip, 17 years ago

blackscreen light

File size: 2.9 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=1;
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
91void blackscreen::draw() const
92{
93  glPushAttrib(GL_ENABLE_BIT);
94  glDisable(GL_LIGHTING);
95  glPushMatrix();
96  glEnable(GL_BLEND);   // Turn Blending On
97
98this->material->setTransparency(i);
99this->material->select();
100
101  glBegin(GL_QUADS);
102  glVertex3f(State::getCameraNode()->getAbsCoorX()+3,State::getCameraNode()->getAbsCoorY() -100.0f,
103             State::getCameraNode()->getAbsCoorZ()-100.0f);
104  glVertex3f(State::getCameraNode()->getAbsCoorX()+3, State::getCameraNode()->getAbsCoorY()-100.0f,
105             State::getCameraNode()->getAbsCoorZ()+100.0f);
106  glVertex3f(State::getCameraNode()->getAbsCoorX()+3, State::getCameraNode()->getAbsCoorY() +100.0f,
107             State::getCameraNode()->getAbsCoorZ()+100.0f);
108  glVertex3f(State::getCameraNode()->getAbsCoorX()+3, State::getCameraNode()->getAbsCoorY()+100.0f,
109             State::getCameraNode()->getAbsCoorZ()-100.0f);
110
111  glEnd();
112
113  glPopMatrix();
114  glPopAttrib();
115}
116
117/**
118 *
119 */
120void blackscreen::tick (float time)
121{
122if (state == true)
123  fadeOut();
124else
125  fadeIn();
126}
127
128void blackscreen::fadeIn()
129{
130  if (i>0)
131    i=i-0.005*fadeSpeed;
132}
133
134void blackscreen::fadeOut()
135{
136  if (i<=1)
137    i=i+0.005*fadeSpeed;
138}
139
140void  blackscreen::toggleFade ()
141{
142
143    this->state= !this->state;
144}
145
146void blackscreen::changeFadeSpeed(float newSpeed)
147{
148  fadeSpeed=newSpeed;
149}
150
151bool blackscreen::isBlack()
152{
153if (i==1)
154  return 1;
155else
156  return 0;
157}
158
159bool blackscreen::isTrans()
160{
161  if (i==0)
162    return 1;
163  else
164    return 0;
165}
Note: See TracBrowser for help on using the repository browser.