Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10414 was 10404, checked in by patrick, 18 years ago

correct fading

File size: 3.1 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"
[10404]25// #include "camera.h"
26#include "primitive_model.h"
[10218]27
[10342]28ObjectListDefinition(BlackScreen);
29CREATE_FACTORY(BlackScreen);
[10207]30
31
[10212]32
[10207]33/**
34 *
35 */
[10342]36BlackScreen::BlackScreen()
[10207]37{
38  this->init();
[10215]39
[10218]40
[10207]41}
42
43
44/**
45 *
46 */
[10342]47BlackScreen::BlackScreen(const TiXmlElement* root)
[10207]48{
49  this->init();
50
51  if( root != NULL)
52    this->loadParams(root);
[10254]53
[10207]54}
55
56
57/**
58 *
59 */
[10342]60BlackScreen::~BlackScreen()
[10207]61{}
62
63
64/**
65 *
66 */
[10342]67void BlackScreen::init()
[10207]68{
[10342]69  this->registerObject(this, BlackScreen::_objectList);
[10207]70  this->toList(OM_GROUP_00);
71
72  this->material = new Material();
[10341]73  this->material->setDiffuse(0,0,0);
[10339]74  this->material->setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
[10220]75
[10404]76  PrimitiveModel* model = new PrimitiveModel(PRIM_SPHERE, 6., 10);
77  this->setModel(model);
[10403]78
[10342]79  i=0;
[10254]80  state=0;
81  fadeSpeed=1;
82
[10207]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 */
[10342]90void BlackScreen::loadParams(const TiXmlElement* root)
[10207]91{
92  WorldEntity::loadParams(root);
93}
94
[10343]95
96
97
[10342]98void BlackScreen::draw() const
[10207]99{
100  glPushAttrib(GL_ENABLE_BIT);
101  glDisable(GL_LIGHTING);
[10342]102  glEnable(GL_BLEND);   // Turn Blending On
[10207]103
[10404]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 );
[10352]112
[10403]113  this->material->select();
[10338]114
[10207]115
[10403]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
[10218]127  glPopMatrix();
128  glPopAttrib();
[10207]129}
130
131/**
132 *
133 */
[10342]134void BlackScreen::tick (float time)
[10207]135{
[10330]136if (state == true)
[10254]137  fadeOut();
138else
[10330]139  fadeIn();
[10403]140
141  this->material->setTransparency(i);
[10404]142//   Camera* cam = State::getCamera();
143//   if( cam != NULL)
144//     this->setParent(cam);
[10207]145}
146
[10342]147void BlackScreen::fadeIn()
[10254]148{
149  if (i>0)
150    i=i-0.005*fadeSpeed;
[10348]151  else
152    this->toList(OM_DEAD);
[10254]153}
[10207]154
[10342]155void BlackScreen::fadeOut()
[10207]156{
[10254]157  if (i<=1)
158    i=i+0.005*fadeSpeed;
[10207]159}
[10254]160
[10342]161void  BlackScreen::toggleFade ()
[10254]162{
[10348]163    this->state= !this->state;
[10330]164
[10348]165    if(state)
166    {
167      this->toList(OM_COMMON);
168    }
[10254]169}
170
[10342]171void BlackScreen::changeFadeSpeed(float newSpeed)
[10254]172{
173  fadeSpeed=newSpeed;
174}
175
[10342]176bool BlackScreen::isBlack()
[10338]177{
178if (i==1)
179  return 1;
180else
181  return 0;
182}
183
[10342]184bool BlackScreen::isTrans()
[10338]185{
186  if (i==0)
187    return 1;
188  else
189    return 0;
[10341]190}
Note: See TracBrowser for help on using the repository browser.