Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10367 was 10352, checked in by gfilip, 19 years ago

finito

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