Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/playability/src/world_entities/test_entity2.cc @ 10003

Last change on this file since 10003 was 10003, checked in by nicolasc, 17 years ago

hbolt rotates

File size: 5.1 KB
Line 
1
2
3/*
4   orxonox - the future of 3D-vertical-scrollers
5
6   Copyright (C) 2004 orx
7
8   This program is free software; you can redistribute it and/or modify
9   it under the terms of the GNU General Public License as published by
10   the Free Software Foundation; either version 2, or (at your option)
11   any later version.
12
13   ### File Specific
14   main-programmer:
15   co-programmer:
16*/
17#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
18
19
20#include "executor/executor.h"
21#include "util/loading/factory.h"
22#include "util/loading/load_param.h"
23
24
25#include "test_entity2.h"
26#include "debug.h"
27
28#include "state.h"
29#include "player.h"
30#include "playable.h"
31#include "material.h"
32
33
34#include "state.h"
35
36
37
38#include "class_id_DEPRECATED.h"
39ObjectListDefinition(TestEntity2);
40CREATE_FACTORY(TestEntity2);
41
42
43
44/**
45 *
46 */
47TestEntity2::TestEntity2()
48{
49  this->init();
50}
51
52
53/**
54 *
55 */
56TestEntity2::TestEntity2(const TiXmlElement* root)
57{
58  this->init();
59
60  if( root != NULL)
61    this->loadParams(root);
62}
63
64
65/**
66 *
67 */
68TestEntity2::~TestEntity2 ()
69{}
70
71
72/**
73 *
74 */
75void TestEntity2::init()
76{
77  this->registerObject(this, TestEntity2::_objectList);
78  this->toList(OM_GROUP_00);
79
80  this->material = new Material();
81  this->material->setIllum(3);
82  this->material->setDiffuse(0.0,0.0,0.0);
83  this->material->setSpecular(0.0,0.0,0.0);
84  this->material->setAmbient(1.0, 0.0, 1.0);
85
86  this->angle = 0;
87  this->rotationSpeed = 3;
88
89  this->material->setDiffuseMap("maps/torp2.png");
90}
91
92
93/**
94 * loads the Settings of a MD2Creature from an XML-element.
95 * @param root the XML-element to load the MD2Creature's properties from
96 */
97void TestEntity2::loadParams(const TiXmlElement* root)
98{
99  WorldEntity::loadParams(root);
100}
101
102
103void TestEntity2::updateAngle()
104{
105  this->angle = this->angle + this->rotationSpeed;
106}
107
108void TestEntity2::draw() const
109{
110
111    glPushAttrib(GL_ENABLE_BIT);
112    glDisable(GL_LIGHTING);
113
114    glPushMatrix();
115    glMatrixMode(GL_MODELVIEW);
116
117
118    /* translate */
119    glTranslatef (this->getAbsCoor ().x,
120                  this->getAbsCoor ().y,
121                  this->getAbsCoor ().z);
122    Vector tmpRot = this->getAbsDir().getSpacialAxis();
123    glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
124    glRotatef(this->angle, 0.0, 0.0, -1.0);
125//PRINTF(0)("axis: %f\n", axis);
126
127
128    glEnable(GL_TEXTURE_2D);
129    this->material->select();
130
131  glColor3f(0.0, 1.0, 0.0);
132
133  glBindTexture( GL_TEXTURE_2D, 0 );
134
135  glBegin(GL_QUADS); // +X
136    glTexCoord2f (0.0, 0.0);
137    glVertex3f( 0.0f, -0.5f, -0.5f);
138    glNormal3f(1.0, 0.0, 0.0);
139
140    glTexCoord2f (1.0, 0.0);
141    glVertex3f( 0.0f, -0.5f , 0.5f);
142    glNormal3f(1.0, 0.0, 0.0);
143
144    glTexCoord2f (1.0, 1.0);
145    glVertex3f( 0.0, 0.5f , 0.5f );
146    glNormal3f(1.0, 0.0, 0.0);
147
148
149    glTexCoord2f (0.0, 1.0);
150    glVertex3f( 0.0, 0.5f, -0.5f );
151    glNormal3f(1.0, 0.0, 0.0);
152  glEnd();
153
154  glBegin(GL_QUADS); // +Y
155    glTexCoord2f (0.0, 0.0);
156    glVertex3f(-0.5f, 0.0f, -0.5f);
157    glNormal3f(0.0, 1.0, 0.0);
158
159    glTexCoord2f (1.0, 0.0);
160    glVertex3f(-0.5f, 0.0f , 0.5f);
161    glNormal3f(0.0, 1.0, 0.0);
162
163    glTexCoord2f (1.0, 1.0);
164    glVertex3f( 0.5f, 0.0f , 0.5f );
165    glNormal3f(0.0, 1.0, 0.0);
166
167    glTexCoord2f (0.0, 1.0);
168    glVertex3f( 0.5f, 0.0f, -0.5f );
169    glNormal3f(0.0, 1.0, 0.0);
170  glEnd();
171
172  glBegin(GL_QUADS);// +Z
173    glTexCoord2f (0.0, 0.0);
174    glVertex3f(-0.5f, -0.5f, 0.0f);
175    glNormal3f(0.0, 0.0, 1.0);
176
177    glTexCoord2f (1.0, 0.0);
178    glVertex3f(-0.5f, 0.5f , 0.0f);
179    glNormal3f(0.0, 0.0, 1.0);
180
181    glTexCoord2f (1.0, 1.0);
182    glVertex3f( 0.5f, 0.5f , 0.0f );
183    glNormal3f(0.0, 0.0, 1.0);
184
185    glTexCoord2f (0.0, 1.0);
186    glVertex3f( 0.5f, -0.5f, 0.0f );
187    glNormal3f(0.0, 0.0, 1.0);
188  glEnd();
189
190  glBegin(GL_QUADS);
191    glTexCoord2f (0.0, 0.0);
192    glVertex3f( 0.0f, -0.5f, -0.5f);
193    glNormal3f(-1.0, 0.0, 0.0);
194
195    glTexCoord2f (1.0, 0.0);
196    glVertex3f( 0.0f, 0.5f , -0.5f);
197    glNormal3f(-1.0, 0.0, 0.0);
198
199    glTexCoord2f (1.0, 1.0);
200    glVertex3f( 0.0, 0.5f , 0.5f );
201    glNormal3f(-1.0, 0.0, 0.0);
202
203    glTexCoord2f (0.0, 1.0);
204    glVertex3f( 0.0, -0.5f, 0.5f );
205    glNormal3f(-1.0, 0.0, 0.0);
206  glEnd();
207
208  glBegin(GL_QUADS);
209    glTexCoord2f (0.0, 0.0);
210    glVertex3f(-0.5f, 0.0f, -0.5f);
211    glNormal3f(0.0, -1.0, 0.0);
212
213    glTexCoord2f (1.0, 0.0);
214    glVertex3f(0.5f, 0.0f , -0.5f);
215    glNormal3f(0.0, -1.0, 0.0);
216
217    glTexCoord2f (1.0, 1.0);
218    glVertex3f( 0.5f, 0.0f , 0.5f );
219    glNormal3f(0.0, -1.0, 0.0);
220
221    glTexCoord2f (0.0, 1.0);
222    glVertex3f( -0.5f, 0.0f, 0.5f );
223    glNormal3f(0.0, -1.0, 0.0);
224  glEnd();
225
226  glBegin(GL_QUADS);
227    glTexCoord2f (0.0, 0.0);
228    glVertex3f(-0.5f, -0.5f, 0.0f);
229    glNormal3f(0.0, 0.0, -1.0);
230
231    glTexCoord2f (1.0, 0.0);
232    glVertex3f(0.5f, -0.5f , 0.0f);
233    glNormal3f(0.0, 0.0, -1.0);
234
235    glTexCoord2f (1.0, 1.0);
236    glVertex3f( 0.5f, 0.5f , 0.0f );
237    glNormal3f(0.0, 0.0, -1.0);
238
239    glTexCoord2f (0.0, 1.0);
240    glVertex3f( -0.5f, 0.5f, 0.0f );
241    glNormal3f(0.0, 0.0, -1.0);
242  glEnd();
243
244  glPopMatrix();
245  glPopAttrib();
246}
247
248/**
249 *
250 */
251void TestEntity2::tick (float time)
252{
253  Player* p = State::getPlayer();
254  Playable* pl = p->getPlayable();
255
256  this->setParent(pl);
257
258  this->updateAngle();
259}
260
261
262
263
264
265
Note: See TracBrowser for help on using the repository browser.