[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 | |
---|
| 38 | #include "class_id_DEPRECATED.h" |
---|
| 39 | ObjectListDefinition(TestEntity2); |
---|
| 40 | CREATE_FACTORY(TestEntity2); |
---|
| 41 | |
---|
| 42 | |
---|
| 43 | |
---|
| 44 | /** |
---|
| 45 | * |
---|
| 46 | */ |
---|
| 47 | TestEntity2::TestEntity2() |
---|
| 48 | { |
---|
| 49 | this->init(); |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | |
---|
| 53 | /** |
---|
| 54 | * |
---|
| 55 | */ |
---|
| 56 | TestEntity2::TestEntity2(const TiXmlElement* root) |
---|
| 57 | { |
---|
| 58 | this->init(); |
---|
| 59 | |
---|
| 60 | if( root != NULL) |
---|
| 61 | this->loadParams(root); |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | |
---|
| 65 | /** |
---|
| 66 | * |
---|
| 67 | */ |
---|
| 68 | TestEntity2::~TestEntity2 () |
---|
| 69 | {} |
---|
| 70 | |
---|
| 71 | |
---|
| 72 | /** |
---|
| 73 | * |
---|
| 74 | */ |
---|
| 75 | void 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); |
---|
| 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 | |
---|
[9978] | 86 | //this->material->setDiffuseMap("maps/torp2.png"); |
---|
[9969] | 87 | } |
---|
| 88 | |
---|
| 89 | |
---|
| 90 | /** |
---|
| 91 | * loads the Settings of a MD2Creature from an XML-element. |
---|
| 92 | * @param root the XML-element to load the MD2Creature's properties from |
---|
| 93 | */ |
---|
| 94 | void TestEntity2::loadParams(const TiXmlElement* root) |
---|
| 95 | { |
---|
| 96 | WorldEntity::loadParams(root); |
---|
| 97 | } |
---|
| 98 | |
---|
| 99 | void TestEntity2::draw() const |
---|
| 100 | { |
---|
| 101 | |
---|
[9979] | 102 | glPushAttrib(GL_ENABLE_BIT); |
---|
| 103 | glDisable(GL_LIGHTING); |
---|
[9969] | 104 | |
---|
[9974] | 105 | glPushMatrix(); |
---|
[9969] | 106 | glMatrixMode(GL_MODELVIEW); |
---|
| 107 | |
---|
[9974] | 108 | |
---|
[9969] | 109 | /* translate */ |
---|
| 110 | glTranslatef (this->getAbsCoor ().x, |
---|
| 111 | this->getAbsCoor ().y, |
---|
| 112 | this->getAbsCoor ().z); |
---|
| 113 | Vector tmpRot = this->getAbsDir().getSpacialAxis(); |
---|
| 114 | glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z ); |
---|
| 115 | |
---|
| 116 | //PRINTF(0)("axis: %f\n", axis); |
---|
[9979] | 117 | |
---|
| 118 | |
---|
[9978] | 119 | glDisable(GL_TEXTURE_2D); |
---|
[9974] | 120 | this->material->select(); |
---|
[9969] | 121 | |
---|
[9974] | 122 | glColor3f(0.0, 1.0, 0.0); |
---|
[9978] | 123 | glBindTexture( GL_TEXTURE_2D, 1 ); |
---|
| 124 | glBegin(GL_QUADS); // +X |
---|
| 125 | glTexCoord2f (0.0, 0.0); |
---|
| 126 | glVertex3f( 0.0f, -0.5f, -0.5f); |
---|
| 127 | glNormal3f(1.0, 0.0, 0.0); |
---|
[9974] | 128 | |
---|
[9978] | 129 | glTexCoord2f (1.0, 0.0); |
---|
| 130 | glVertex3f( 0.0f, -0.5f , 0.5f); |
---|
| 131 | glNormal3f(1.0, 0.0, 0.0); |
---|
[9977] | 132 | |
---|
[9978] | 133 | glTexCoord2f (1.0, 1.0); |
---|
| 134 | glVertex3f( 0.0, 0.5f , 0.5f ); |
---|
[9974] | 135 | glNormal3f(1.0, 0.0, 0.0); |
---|
[9977] | 136 | |
---|
[9978] | 137 | |
---|
| 138 | glTexCoord2f (0.0, 1.0); |
---|
| 139 | glVertex3f( 0.0, 0.5f, -0.5f ); |
---|
[9974] | 140 | glNormal3f(1.0, 0.0, 0.0); |
---|
[9978] | 141 | glEnd(); |
---|
[9969] | 142 | |
---|
[9978] | 143 | glBegin(GL_QUADS); // +Y |
---|
| 144 | glTexCoord2f (0.0, 0.0); |
---|
| 145 | glVertex3f(-0.5f, 0.0f, -0.5f); |
---|
| 146 | glNormal3f(0.0, 1.0, 0.0); |
---|
[9977] | 147 | |
---|
[9978] | 148 | glTexCoord2f (1.0, 0.0); |
---|
| 149 | glVertex3f(-0.5f, 0.0f , 0.5f); |
---|
| 150 | glNormal3f(0.0, 1.0, 0.0); |
---|
[9977] | 151 | |
---|
[9978] | 152 | glTexCoord2f (1.0, 1.0); |
---|
| 153 | glVertex3f( 0.5f, 0.0f , 0.5f ); |
---|
| 154 | glNormal3f(0.0, 1.0, 0.0); |
---|
[9969] | 155 | |
---|
[9978] | 156 | glTexCoord2f (0.0, 1.0); |
---|
| 157 | glVertex3f( 0.5f, 0.0f, -0.5f ); |
---|
| 158 | glNormal3f(0.0, 1.0, 0.0); |
---|
| 159 | glEnd(); |
---|
[9977] | 160 | |
---|
[9978] | 161 | glBegin(GL_QUADS);// +Z |
---|
| 162 | glTexCoord2f (0.0, 0.0); |
---|
| 163 | glVertex3f(-0.5f, -0.5f, 0.0f); |
---|
| 164 | glNormal3f(0.0, 0.0, 1.0); |
---|
[9977] | 165 | |
---|
[9978] | 166 | glTexCoord2f (1.0, 0.0); |
---|
| 167 | glVertex3f(-0.5f, 0.5f , 0.0f); |
---|
| 168 | glNormal3f(0.0, 0.0, 1.0); |
---|
[9969] | 169 | |
---|
[9978] | 170 | glTexCoord2f (1.0, 1.0); |
---|
| 171 | glVertex3f( 0.5f, 0.5f , 0.0f ); |
---|
| 172 | glNormal3f(0.0, 0.0, 1.0); |
---|
[9977] | 173 | |
---|
[9978] | 174 | glTexCoord2f (0.0, 1.0); |
---|
| 175 | glVertex3f( 0.5f, -0.5f, 0.0f ); |
---|
| 176 | glNormal3f(0.0, 0.0, 1.0); |
---|
| 177 | glEnd(); |
---|
[9974] | 178 | |
---|
[9978] | 179 | glBegin(GL_QUADS); |
---|
| 180 | glTexCoord2f (0.0, 0.0); |
---|
| 181 | glVertex3f( 0.0f, -0.5f, -0.5f); |
---|
| 182 | glNormal3f(-1.0, 0.0, 0.0); |
---|
| 183 | |
---|
| 184 | glTexCoord2f (1.0, 0.0); |
---|
| 185 | glVertex3f( 0.0f, 0.5f , -0.5f); |
---|
| 186 | glNormal3f(-1.0, 0.0, 0.0); |
---|
| 187 | |
---|
| 188 | glTexCoord2f (1.0, 1.0); |
---|
| 189 | glVertex3f( 0.0, 0.5f , 0.5f ); |
---|
| 190 | glNormal3f(-1.0, 0.0, 0.0); |
---|
| 191 | |
---|
| 192 | glTexCoord2f (0.0, 1.0); |
---|
| 193 | glVertex3f( 0.0, -0.5f, 0.5f ); |
---|
| 194 | glNormal3f(-1.0, 0.0, 0.0); |
---|
[9969] | 195 | glEnd(); |
---|
| 196 | |
---|
[9978] | 197 | glBegin(GL_QUADS); |
---|
| 198 | glTexCoord2f (0.0, 0.0); |
---|
| 199 | glVertex3f(-0.5f, 0.0f, -0.5f); |
---|
| 200 | glNormal3f(0.0, -1.0, 0.0); |
---|
| 201 | |
---|
| 202 | glTexCoord2f (1.0, 0.0); |
---|
| 203 | glVertex3f(0.5f, 0.0f , -0.5f); |
---|
| 204 | glNormal3f(0.0, -1.0, 0.0); |
---|
| 205 | |
---|
| 206 | glTexCoord2f (1.0, 1.0); |
---|
| 207 | glVertex3f( 0.5f, 0.0f , 0.5f ); |
---|
| 208 | glNormal3f(0.0, -1.0, 0.0); |
---|
| 209 | |
---|
| 210 | glTexCoord2f (0.0, 1.0); |
---|
| 211 | glVertex3f( -0.5f, 0.0f, 0.5f ); |
---|
| 212 | glNormal3f(0.0, -1.0, 0.0); |
---|
| 213 | glEnd(); |
---|
| 214 | |
---|
| 215 | glBegin(GL_QUADS); |
---|
| 216 | glTexCoord2f (0.0, 0.0); |
---|
| 217 | glVertex3f(-0.5f, -0.5f, 0.0f); |
---|
| 218 | glNormal3f(0.0, 0.0, -1.0); |
---|
| 219 | |
---|
| 220 | glTexCoord2f (1.0, 0.0); |
---|
| 221 | glVertex3f(0.5f, -0.5f , 0.0f); |
---|
| 222 | glNormal3f(0.0, 0.0, -1.0); |
---|
| 223 | |
---|
| 224 | glTexCoord2f (1.0, 1.0); |
---|
| 225 | glVertex3f( 0.5f, 0.5f , 0.0f ); |
---|
| 226 | glNormal3f(0.0, 0.0, -1.0); |
---|
| 227 | |
---|
| 228 | glTexCoord2f (0.0, 1.0); |
---|
| 229 | glVertex3f( -0.5f, 0.5f, 0.0f ); |
---|
| 230 | glNormal3f(0.0, 0.0, -1.0); |
---|
| 231 | glEnd(); |
---|
| 232 | |
---|
[9969] | 233 | glPopMatrix(); |
---|
[9979] | 234 | glPopAttrib(); |
---|
[9969] | 235 | } |
---|
| 236 | |
---|
| 237 | /** |
---|
| 238 | * |
---|
| 239 | */ |
---|
| 240 | void TestEntity2::tick (float time) |
---|
| 241 | { |
---|
| 242 | Player* p = State::getPlayer(); |
---|
| 243 | Playable* pl = p->getPlayable(); |
---|
| 244 | |
---|
| 245 | this->setParent(pl); |
---|
| 246 | } |
---|
| 247 | |
---|
| 248 | |
---|
| 249 | |
---|
| 250 | |
---|
| 251 | |
---|
| 252 | |
---|