Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/blackscreen.cc @ 10533

Last change on this file since 10533 was 10453, checked in by patrick, 18 years ago

scrolling screen prototype

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