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, 19 years ago

blackscreen works

File size: 3.7 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
[10207]27ObjectListDefinition(blackscreen);
28CREATE_FACTORY(blackscreen);
29
30
[10212]31
[10207]32/**
33 *
34 */
[10330]35blackscreen::blackscreen()
[10207]36{
37  this->init();
[10215]38
[10218]39
[10207]40}
41
42
43/**
44 *
45 */
46blackscreen::blackscreen(const TiXmlElement* root)
47{
48  this->init();
49
50  if( root != NULL)
51    this->loadParams(root);
[10254]52
[10207]53}
54
55
56/**
57 *
58 */
[10330]59blackscreen::~blackscreen()
[10207]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();
[10339]72  this->material->setDiffuseMap("maps/black.png");
[10330]73 // this->material->setIllum(3);
[10338]74 // this->material->setTransparency(0.6);
75  //this->material->setDiffuse(0,0,0);
[10339]76  this->material->setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
[10338]77 // this->material->setSpecular(0.0,0.0,0.0);
78 // this->material->setAmbient(1, 1, 1);
[10220]79
[10330]80  i=1;
[10254]81  state=0;
82  fadeSpeed=1;
83
[10207]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
[10339]115//lDisable(GL_ALPHA_TEST);
[10207]116
[10236]117//
118//  Coord schould depend on CameraTarget
119//
120//
121//
[10207]122
[10338]123//glColor4f(0, 0, 0, i);
124
125this->material->setTransparency(i);
[10330]126this->material->select();
[10338]127
[10207]128  glBegin(GL_QUADS);
[10220]129  glVertex3f(State::getCameraNode()->getAbsCoorX()+3,State::getCameraNode()->getAbsCoorY() -100.0f,
[10218]130             State::getCameraNode()->getAbsCoorZ()-100.0f);
[10220]131  glVertex3f(State::getCameraNode()->getAbsCoorX()+3, State::getCameraNode()->getAbsCoorY()-100.0f,
[10218]132             State::getCameraNode()->getAbsCoorZ()+100.0f);
[10220]133  glVertex3f(State::getCameraNode()->getAbsCoorX()+3, State::getCameraNode()->getAbsCoorY() +100.0f,
[10218]134             State::getCameraNode()->getAbsCoorZ()+100.0f);
[10220]135  glVertex3f(State::getCameraNode()->getAbsCoorX()+3, State::getCameraNode()->getAbsCoorY()+100.0f,
[10218]136             State::getCameraNode()->getAbsCoorZ()-100.0f);
[10207]137
[10330]138
139/* glBegin(GL_QUADS);
[10238]140glVertex3f(0,-100.0f,-100.0f);
141glVertex3f(0,-100.0f,+100.0f);
142glVertex3f(0,+100.0f,+100.0f);
143glVertex3f(0,+100.0f,-100.0f);
[10330]144*/
[10207]145
[10238]146
[10207]147  glEnd();
148
[10218]149  glPopMatrix();
150  glPopAttrib();
[10207]151}
152
153/**
154 *
155 */
156void blackscreen::tick (float time)
157{
[10330]158if (state == true)
[10254]159  fadeOut();
160else
[10330]161  fadeIn();
[10207]162}
163
[10254]164void blackscreen::fadeIn()
165{
166  if (i>0)
167    i=i-0.005*fadeSpeed;
168}
[10207]169
[10254]170void blackscreen::fadeOut()
[10207]171{
[10254]172  if (i<=1)
173    i=i+0.005*fadeSpeed;
[10207]174}
[10254]175
176void  blackscreen::toggleFade ()
177{
[10330]178
179    this->state= !this->state;
[10254]180}
181
182void blackscreen::changeFadeSpeed(float newSpeed)
183{
184  fadeSpeed=newSpeed;
185}
186
[10338]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.