Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10399 was 10379, checked in by patrick, 19 years ago

merged branche camera to trunk. resolved many conflicts as in the other projects too

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