Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

blackscreen orientation

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