Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

blackscreen works

File size: 3.7 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->setDiffuseMap("maps/black.png");
73 // this->material->setIllum(3);
74 // this->material->setTransparency(0.6);
75  //this->material->setDiffuse(0,0,0);
76  this->material->setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
77 // this->material->setSpecular(0.0,0.0,0.0);
78 // this->material->setAmbient(1, 1, 1);
79
80  i=1;
81  state=0;
82  fadeSpeed=1;
83
84}
85
86
87/**
88 * loads the Settings of a MD2Creature from an XML-element.
89 * @param root the XML-element to load the MD2Creature's properties from
90 */
91void blackscreen::loadParams(const TiXmlElement* root)
92{
93  WorldEntity::loadParams(root);
94}
95
96void blackscreen::draw() const
97{
98//   if(!mediaLoaded)
99//     false;
100
101  glPushAttrib(GL_ENABLE_BIT);
102  glDisable(GL_LIGHTING);
103//   glDisable(GL_BLEND);
104//
105//   glEnable(GL_TEXTURE_2D);
106//   glBindTexture(GL_TEXTURE_2D, media_container->getFrameTexture(counter));
107
108  glPushMatrix();
109 /* glTranslatef (this->getAbsCoor ().x,
110                this->getAbsCoor ().y,
111                this->getAbsCoor ().z);
112  glRotatef(axis, 0.0f, 1.0f, 0.0f);*/
113//PRINTF(0)("axis: %f\n", axis);
114glEnable(GL_BLEND);     // Turn Blending On
115//lDisable(GL_ALPHA_TEST);
116
117//
118//  Coord schould depend on CameraTarget
119//
120//
121//
122
123//glColor4f(0, 0, 0, i);
124
125this->material->setTransparency(i);
126this->material->select();
127
128  glBegin(GL_QUADS);
129  glVertex3f(State::getCameraNode()->getAbsCoorX()+3,State::getCameraNode()->getAbsCoorY() -100.0f,
130             State::getCameraNode()->getAbsCoorZ()-100.0f);
131  glVertex3f(State::getCameraNode()->getAbsCoorX()+3, State::getCameraNode()->getAbsCoorY()-100.0f,
132             State::getCameraNode()->getAbsCoorZ()+100.0f);
133  glVertex3f(State::getCameraNode()->getAbsCoorX()+3, State::getCameraNode()->getAbsCoorY() +100.0f,
134             State::getCameraNode()->getAbsCoorZ()+100.0f);
135  glVertex3f(State::getCameraNode()->getAbsCoorX()+3, State::getCameraNode()->getAbsCoorY()+100.0f,
136             State::getCameraNode()->getAbsCoorZ()-100.0f);
137
138
139/* glBegin(GL_QUADS);
140glVertex3f(0,-100.0f,-100.0f);
141glVertex3f(0,-100.0f,+100.0f);
142glVertex3f(0,+100.0f,+100.0f);
143glVertex3f(0,+100.0f,-100.0f);
144*/
145
146
147  glEnd();
148
149  glPopMatrix();
150  glPopAttrib();
151}
152
153/**
154 *
155 */
156void blackscreen::tick (float time)
157{
158if (state == true)
159  fadeOut();
160else
161  fadeIn();
162}
163
164void blackscreen::fadeIn()
165{
166  if (i>0)
167    i=i-0.005*fadeSpeed;
168}
169
170void blackscreen::fadeOut()
171{
172  if (i<=1)
173    i=i+0.005*fadeSpeed;
174}
175
176void  blackscreen::toggleFade ()
177{
178
179    this->state= !this->state;
180}
181
182void blackscreen::changeFadeSpeed(float newSpeed)
183{
184  fadeSpeed=newSpeed;
185}
186
187bool blackscreen::isBlack()
188{
189if (i==1)
190  return 1;
191else
192  return 0;
193}
194
195bool blackscreen::isTrans()
196{
197  if (i==0)
198    return 1;
199  else
200    return 0;
201}
Note: See TracBrowser for help on using the repository browser.