Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/scrolling_screen.cc @ 10455

Last change on this file since 10455 was 10455, checked in by patrick, 17 years ago

scroller und debug

File size: 3.4 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#include "scrolling_screen.h"
18
19#include "util/loading/factory.h"
20#include "util/loading/load_param.h"
21
22#include "debug.h"
23#include "material.h"
24#include "state.h"
25// #include "camera.h"
26
27ObjectListDefinition(ScrollingScreen);
28CREATE_FACTORY(ScrollingScreen);
29
30
31
32/**
33 *
34 */
35ScrollingScreen::ScrollingScreen()
36{
37  this->init();
38}
39
40
41/**
42 *
43 */
44ScrollingScreen::ScrollingScreen(const TiXmlElement* root)
45{
46  this->init();
47
48  if( root != NULL)
49    this->loadParams(root);
50}
51
52
53/**
54 *
55 */
56ScrollingScreen::~ScrollingScreen()
57{}
58
59
60/**
61 *
62 */
63void ScrollingScreen::init()
64{
65  this->registerObject(this, ScrollingScreen::_objectList);
66  this->toList(OM_COMMON);
67
68  this->material = new Material();
69  this->material->setDiffuse(0,0,0);
70  this->material->setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
71
72  this->isTransparent = false;
73  this->transparency = 1.0;
74}
75
76
77/**
78 * loads the Settings of a MD2Creature from an XML-element.
79 * @param root the XML-element to load the MD2Creature's properties from
80 */
81void ScrollingScreen::loadParams(const TiXmlElement* root)
82{
83  WorldEntity::loadParams(root);
84
85  LoadParam(root, "setSpeed", this, ScrollingScreen, setSpeed);
86
87  LoadParam(root, "setHeight", this, ScrollingScreen, setViewHeight);
88
89  LoadParam(root, "setSize", this, ScrollingScreen, setSize);
90
91  LoadParam(root, "texture", this, ScrollingScreen, setTexture);
92}
93
94
95
96
97/**
98 * sets the texture
99 * @param texture name of tex
100 */
101void ScrollingScreen::setTexture(const std::string& texture)
102{
103  this->material->setDiffuseMap( texture);
104}
105
106
107
108
109void ScrollingScreen::draw() const
110{
111  glPushAttrib(GL_ENABLE_BIT);
112  glDisable(GL_LIGHTING);
113  glEnable(GL_BLEND);   // Turn Blending On
114
115  glMatrixMode(GL_MODELVIEW);
116  glPushMatrix();
117  /* translate */
118  glTranslatef (this->getAbsCoor ().x,
119                this->getAbsCoor ().y,
120                this->getAbsCoor ().z);
121  Vector tmpRot = this->getAbsDir().getSpacialAxis();
122  glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
123
124  this->material->select();
125
126  glBegin(GL_QUADS);
127
128  glTexCoord2f(0., 0.);
129  glVertex3f(0., -this->xSize*0.5, -this->ySize*0.5);
130
131  glTexCoord2f(0., 1.);
132  glVertex3f(0., -this->xSize*0.5, this->ySize*0.5);
133
134  glTexCoord2f(1., 1.);
135  glVertex3f(0., this->xSize*0.5, this->ySize*0.5);
136
137  glTexCoord2f(1., 0.);
138  glVertex3f(0., this->xSize*0.5, -this->ySize*0.5);
139
140  glEnd();
141
142  glPopMatrix();
143  glPopAttrib();
144}
145
146/**
147 *
148 */
149void ScrollingScreen::tick (float time)
150{
151  if( State::getCameraNode() != NULL && State::getCameraTargetNode() != NULL)
152  {
153    PNode* cam = State::getCameraNode();
154    PNode* tar = State::getCameraTargetNode();
155
156    Vector dir = tar->getAbsCoor() - cam->getAbsCoor();
157    dir.normalize();
158
159    float offset = 4.;
160
161    this->setAbsCoor( cam->getAbsCoor() + dir * offset);
162
163
164
165
166//     if( this->getParent() != cam)
167//     {
168//       this->setParent( cam);
169//       this->setRelCoor( 4.0, 0., 0.);
170//       this->setRelDir();
171//     }
172
173  }
174}
175
176void ScrollingScreen::fadeIn(float speed)
177{
178
179}
180
181void ScrollingScreen::fadeOut(float speed)
182{
183
184}
Note: See TracBrowser for help on using the repository browser.