Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/test_entity2.cc @ 10431

Last change on this file since 10431 was 10420, checked in by patrick, 18 years ago

maps ⇒ textures

File size: 5.2 KB
RevLine 
[9969]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"
[9974]31#include "material.h"
[9969]32
33
34#include "state.h"
35
36
37
[10366]38
[9969]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);
[9974]79
80  this->material = new Material();
81  this->material->setIllum(3);
[10005]82  this->material->setDiffuse(1.0,1.0,1.0);
[9974]83  this->material->setSpecular(0.0,0.0,0.0);
[10005]84  this->material->setAmbient(1.0, 1.0, 1.0);
[9974]85
[9989]86  this->angle = 0;
[9991]87  this->rotationSpeed = 3;
[9989]88
[10420]89  this->material->setDiffuseMap("textures/TE2.tga");
[10035]90
[9969]91}
92
93
94/**
95 * loads the Settings of a MD2Creature from an XML-element.
96 * @param root the XML-element to load the MD2Creature's properties from
97 */
98void TestEntity2::loadParams(const TiXmlElement* root)
99{
100  WorldEntity::loadParams(root);
101}
102
[9989]103
104void TestEntity2::updateAngle()
105{
106  this->angle = this->angle + this->rotationSpeed;
107}
108
[9969]109void TestEntity2::draw() const
110{
111
[10005]112  glPushAttrib(GL_ENABLE_BIT);
113  glDisable(GL_LIGHTING);
[9969]114
[10005]115  glPushMatrix();
116  glMatrixMode(GL_MODELVIEW);
[9969]117
[9974]118
[9969]119    /* translate */
[10005]120  glTranslatef (this->getAbsCoor ().x,
[9969]121                  this->getAbsCoor ().y,
122                  this->getAbsCoor ().z);
[10005]123  Vector tmpRot = this->getAbsDir().getSpacialAxis();
124  glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
125  glRotatef(this->angle, 1.0, 1.0, 1.0);
[9969]126//PRINTF(0)("axis: %f\n", axis);
[9979]127
128
[10035]129  glEnable(GL_BLEND);
130  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
131  glShadeModel(GL_FLAT);
132  glClearColor(0.0, 0.0, 0.0, 0.0);
133
[10005]134  glEnable(GL_TEXTURE_2D);
135  this->material->select();
[9969]136
[10005]137  glColor3f(1.0, 1.0, 1.0);
[10003]138
[9978]139  glBegin(GL_QUADS); // +X
140    glTexCoord2f (0.0, 0.0);
141    glVertex3f( 0.0f, -0.5f, -0.5f);
[10005]142//     glNormal3f(1.0, 0.0, 0.0);
[9974]143
[9978]144    glTexCoord2f (1.0, 0.0);
145    glVertex3f( 0.0f, -0.5f , 0.5f);
[10005]146//     glNormal3f(1.0, 0.0, 0.0);
[9977]147
[9978]148    glTexCoord2f (1.0, 1.0);
149    glVertex3f( 0.0, 0.5f , 0.5f );
[10005]150//     glNormal3f(1.0, 0.0, 0.0);
[9977]151
[9978]152
153    glTexCoord2f (0.0, 1.0);
154    glVertex3f( 0.0, 0.5f, -0.5f );
[10005]155//     glNormal3f(1.0, 0.0, 0.0);
[9978]156  glEnd();
[9969]157
[9978]158  glBegin(GL_QUADS); // +Y
159    glTexCoord2f (0.0, 0.0);
160    glVertex3f(-0.5f, 0.0f, -0.5f);
[10005]161//     glNormal3f(0.0, 1.0, 0.0);
[9977]162
[9978]163    glTexCoord2f (1.0, 0.0);
164    glVertex3f(-0.5f, 0.0f , 0.5f);
[10005]165//     glNormal3f(0.0, 1.0, 0.0);
[9977]166
[9978]167    glTexCoord2f (1.0, 1.0);
168    glVertex3f( 0.5f, 0.0f , 0.5f );
[10005]169//     glNormal3f(0.0, 1.0, 0.0);
[9969]170
[9978]171    glTexCoord2f (0.0, 1.0);
172    glVertex3f( 0.5f, 0.0f, -0.5f );
[10005]173//     glNormal3f(0.0, 1.0, 0.0);
[9978]174  glEnd();
[9977]175
[9978]176  glBegin(GL_QUADS);// +Z
177    glTexCoord2f (0.0, 0.0);
178    glVertex3f(-0.5f, -0.5f, 0.0f);
[10005]179//     glNormal3f(0.0, 0.0, 1.0);
[9977]180
[9978]181    glTexCoord2f (1.0, 0.0);
182    glVertex3f(-0.5f, 0.5f , 0.0f);
[10005]183//     glNormal3f(0.0, 0.0, 1.0);
[9969]184
[9978]185    glTexCoord2f (1.0, 1.0);
186    glVertex3f( 0.5f, 0.5f , 0.0f );
[10005]187//     glNormal3f(0.0, 0.0, 1.0);
[9977]188
[9978]189    glTexCoord2f (0.0, 1.0);
190    glVertex3f( 0.5f, -0.5f, 0.0f );
[10005]191//     glNormal3f(0.0, 0.0, 1.0);
[9978]192  glEnd();
[9974]193
[10035]194/*
[10005]195  glBegin(GL_QUADS);// -X
[9978]196    glTexCoord2f (0.0, 0.0);
197    glVertex3f( 0.0f, -0.5f, -0.5f);
[10005]198//     glNormal3f(-1.0, 0.0, 0.0);
[9978]199
200    glTexCoord2f (1.0, 0.0);
201    glVertex3f( 0.0f, 0.5f , -0.5f);
[10005]202//     glNormal3f(-1.0, 0.0, 0.0);
[9978]203
204    glTexCoord2f (1.0, 1.0);
205    glVertex3f( 0.0, 0.5f , 0.5f );
[10005]206//     glNormal3f(-1.0, 0.0, 0.0);
[9978]207
208    glTexCoord2f (0.0, 1.0);
209    glVertex3f( 0.0, -0.5f, 0.5f );
[10005]210//     glNormal3f(-1.0, 0.0, 0.0);
[9969]211  glEnd();
212
[10005]213  glBegin(GL_QUADS);// -Y
[9978]214    glTexCoord2f (0.0, 0.0);
215    glVertex3f(-0.5f, 0.0f, -0.5f);
[10005]216//     glNormal3f(0.0, -1.0, 0.0);
[9978]217
218    glTexCoord2f (1.0, 0.0);
219    glVertex3f(0.5f, 0.0f , -0.5f);
[10005]220//     glNormal3f(0.0, -1.0, 0.0);
[9978]221
222    glTexCoord2f (1.0, 1.0);
223    glVertex3f( 0.5f, 0.0f , 0.5f );
[10005]224//     glNormal3f(0.0, -1.0, 0.0);
[9978]225
226    glTexCoord2f (0.0, 1.0);
227    glVertex3f( -0.5f, 0.0f, 0.5f );
[10005]228//     glNormal3f(0.0, -1.0, 0.0);
[9978]229  glEnd();
230
[10005]231  glBegin(GL_QUADS);// -Z
[9978]232    glTexCoord2f (0.0, 0.0);
233    glVertex3f(-0.5f, -0.5f, 0.0f);
[10005]234//     glNormal3f(0.0, 0.0, -1.0);
[9978]235
236    glTexCoord2f (1.0, 0.0);
237    glVertex3f(0.5f, -0.5f , 0.0f);
[10005]238//     glNormal3f(0.0, 0.0, -1.0);
[9978]239
240    glTexCoord2f (1.0, 1.0);
241    glVertex3f( 0.5f, 0.5f , 0.0f );
[10005]242//     glNormal3f(0.0, 0.0, -1.0);
[9978]243
244    glTexCoord2f (0.0, 1.0);
245    glVertex3f( -0.5f, 0.5f, 0.0f );
[10005]246//     glNormal3f(0.0, 0.0, -1.0);
[10035]247  glEnd();*/
[9978]248
[9969]249  glPopMatrix();
[9979]250  glPopAttrib();
[9969]251}
252
253/**
254 *
255 */
256void TestEntity2::tick (float time)
257{
258  Player* p = State::getPlayer();
259  Playable* pl = p->getPlayable();
260
261  this->setParent(pl);
[9987]262
[9989]263  this->updateAngle();
[9969]264}
265
266
267
268
269
270
Note: See TracBrowser for help on using the repository browser.