| 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: | 
|---|
| 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 |  | 
|---|
| 22 |  | 
|---|
| 23 | #include "test_entity.h" | 
|---|
| 24 | #include "debug.h" | 
|---|
| 25 |  | 
|---|
| 26 |  | 
|---|
| 27 | #include "material.h" | 
|---|
| 28 |  | 
|---|
| 29 | #include "state.h" | 
|---|
| 30 |  | 
|---|
| 31 |  | 
|---|
| 32 |  | 
|---|
| 33 | #include "class_id_DEPRECATED.h" | 
|---|
| 34 | ObjectListDefinition(TestEntity); | 
|---|
| 35 | CREATE_FACTORY(TestEntity); | 
|---|
| 36 |  | 
|---|
| 37 | float i=0; | 
|---|
| 38 | bool state=1; | 
|---|
| 39 |  | 
|---|
| 40 | /** | 
|---|
| 41 |  * | 
|---|
| 42 |  */ | 
|---|
| 43 | TestEntity::TestEntity () | 
|---|
| 44 | { | 
|---|
| 45 |   this->init(); | 
|---|
| 46 | } | 
|---|
| 47 |  | 
|---|
| 48 |  | 
|---|
| 49 | /** | 
|---|
| 50 |  * | 
|---|
| 51 |  */ | 
|---|
| 52 | TestEntity::TestEntity(const TiXmlElement* root) | 
|---|
| 53 | { | 
|---|
| 54 |   this->init(); | 
|---|
| 55 |  | 
|---|
| 56 |   if( root != NULL) | 
|---|
| 57 |     this->loadParams(root); | 
|---|
| 58 | } | 
|---|
| 59 |  | 
|---|
| 60 |  | 
|---|
| 61 | /** | 
|---|
| 62 |  * | 
|---|
| 63 |  */ | 
|---|
| 64 | TestEntity::~TestEntity () | 
|---|
| 65 | {} | 
|---|
| 66 |  | 
|---|
| 67 |  | 
|---|
| 68 | /** | 
|---|
| 69 |  * | 
|---|
| 70 |  */ | 
|---|
| 71 | void TestEntity::init() | 
|---|
| 72 | { | 
|---|
| 73 |   this->registerObject(this, TestEntity::_objectList); | 
|---|
| 74 |   this->toList(OM_GROUP_00); | 
|---|
| 75 |  | 
|---|
| 76 |   this->material = new Material(); | 
|---|
| 77 |   this->material->setIllum(3); | 
|---|
| 78 |   this->material->setDiffuse(1.0,1.0,1.0); | 
|---|
| 79 |   this->material->setSpecular(0.0,0.0,0.0); | 
|---|
| 80 |   this->material->setAmbient(1.0, 1.0, 1.0); | 
|---|
| 81 |   this->material->setDiffuseMap("maps/TE2.tga"); | 
|---|
| 82 | } | 
|---|
| 83 |  | 
|---|
| 84 |  | 
|---|
| 85 | /** | 
|---|
| 86 |  * loads the Settings of a MD2Creature from an XML-element. | 
|---|
| 87 |  * @param root the XML-element to load the MD2Creature's properties from | 
|---|
| 88 |  */ | 
|---|
| 89 | void TestEntity::loadParams(const TiXmlElement* root) | 
|---|
| 90 | { | 
|---|
| 91 |   WorldEntity::loadParams(root); | 
|---|
| 92 | } | 
|---|
| 93 |  | 
|---|
| 94 | void TestEntity::draw() const | 
|---|
| 95 | { | 
|---|
| 96 | //   if(!mediaLoaded) | 
|---|
| 97 | //     false; | 
|---|
| 98 |  | 
|---|
| 99 |   glPushAttrib(GL_ENABLE_BIT); | 
|---|
| 100 |   glDisable(GL_LIGHTING); | 
|---|
| 101 | //   glDisable(GL_BLEND); | 
|---|
| 102 | // | 
|---|
| 103 | //   glEnable(GL_TEXTURE_2D); | 
|---|
| 104 | //   glBindTexture(GL_TEXTURE_2D, media_container->getFrameTexture(counter)); | 
|---|
| 105 |  | 
|---|
| 106 |   glPushMatrix(); | 
|---|
| 107 |  /* glTranslatef (this->getAbsCoor ().x, | 
|---|
| 108 |                 this->getAbsCoor ().y, | 
|---|
| 109 |                 this->getAbsCoor ().z); | 
|---|
| 110 |   glRotatef(axis, 0.0f, 1.0f, 0.0f);*/ | 
|---|
| 111 | //PRINTF(0)("axis: %f\n", axis); | 
|---|
| 112 | glEnable(GL_BLEND);     // Turn Blending On | 
|---|
| 113 |  | 
|---|
| 114 |  | 
|---|
| 115 |  | 
|---|
| 116 | glColor4f(0, 0, 0, i); | 
|---|
| 117 |  | 
|---|
| 118 |   glBegin(GL_QUADS); | 
|---|
| 119 |     glVertex3f(-1.0f, -100.0f, -100.0f); | 
|---|
| 120 | //     glTexCoord2f(1.0f, 1.0f); | 
|---|
| 121 |     glVertex3f(-1.0f, -100.0f, 100.0f); | 
|---|
| 122 | //     glTexCoord2f(0.0f, 1.0f); | 
|---|
| 123 |     glVertex3f(-1.0f, 100.0f, 100.0f); | 
|---|
| 124 | //     glTexCoord2f(0.0f, 0.0f); | 
|---|
| 125 |     glVertex3f(-1.0f, 100.0f, -100.0f); | 
|---|
| 126 | //     glTexCoord2f(1.0f, 0.0f); | 
|---|
| 127 |  | 
|---|
| 128 |   glEnd(); | 
|---|
| 129 |  | 
|---|
| 130 |   glPopMatrix(); | 
|---|
| 131 |   glPopAttrib(); | 
|---|
| 132 | } | 
|---|
| 133 |  | 
|---|
| 134 | /** | 
|---|
| 135 |  * | 
|---|
| 136 |  */ | 
|---|
| 137 | void TestEntity::tick (float time) | 
|---|
| 138 | { | 
|---|
| 139 |   if (state==0 && i==1) | 
|---|
| 140 |     i=0; | 
|---|
| 141 |   if (state==1 && i<=1) | 
|---|
| 142 |     i=i+0.005; | 
|---|
| 143 | } | 
|---|
| 144 |  | 
|---|
| 145 |  | 
|---|
| 146 | void  TestEntity::changeState (bool sta) | 
|---|
| 147 | { | 
|---|
| 148 |   state=sta; | 
|---|
| 149 | } | 
|---|