| [10439] | 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_entity.h" | 
|---|
 | 26 | #include "debug.h" | 
|---|
 | 27 |  | 
|---|
 | 28 | #include "track/track.h" | 
|---|
 | 29 |  | 
|---|
 | 30 |  | 
|---|
 | 31 |  | 
|---|
 | 32 |  | 
|---|
 | 33 | #include "state.h" | 
|---|
 | 34 |  | 
|---|
 | 35 |  | 
|---|
 | 36 |  | 
|---|
 | 37 |  | 
|---|
 | 38 | ObjectListDefinition(TestEntity); | 
|---|
 | 39 | CREATE_FACTORY(TestEntity); | 
|---|
 | 40 |  | 
|---|
 | 41 | #include "script_class.h" | 
|---|
 | 42 | CREATE_SCRIPTABLE_CLASS(TestEntity, | 
|---|
 | 43 |                         addMethod("getAbsCoorX", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorX)) | 
|---|
 | 44 |                         ->addMethod("getAbsCoorY", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorY)) | 
|---|
 | 45 |                         ->addMethod("getAbsCoorZ", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorZ)) | 
|---|
 | 46 |                         ->addMethod("setAbsCoor", Executor3<PNode, lua_State*,float,float,float>(&PNode::setAbsCoor)) | 
|---|
 | 47 |                         ->addMethod("setAbsDir", Executor4<PNode, lua_State*,float,float,float,float>(&PNode::setAbsDir)) | 
|---|
 | 48 |                        ); | 
|---|
 | 49 |  | 
|---|
 | 50 |  | 
|---|
 | 51 | /** | 
|---|
 | 52 |  * | 
|---|
 | 53 |  */ | 
|---|
 | 54 | TestEntity::TestEntity () | 
|---|
 | 55 | { | 
|---|
 | 56 |   this->init(); | 
|---|
 | 57 | } | 
|---|
 | 58 |  | 
|---|
 | 59 |  | 
|---|
 | 60 | /** | 
|---|
 | 61 |  * | 
|---|
 | 62 |  */ | 
|---|
 | 63 | TestEntity::TestEntity(const TiXmlElement* root) | 
|---|
 | 64 | { | 
|---|
 | 65 |   if( root != NULL) | 
|---|
 | 66 |     this->loadParams(root); | 
|---|
 | 67 |  | 
|---|
 | 68 |   this->init(); | 
|---|
 | 69 | } | 
|---|
 | 70 |  | 
|---|
 | 71 |  | 
|---|
 | 72 | /** | 
|---|
 | 73 |  * | 
|---|
 | 74 |  */ | 
|---|
 | 75 | TestEntity::~TestEntity () | 
|---|
 | 76 | {} | 
|---|
 | 77 |  | 
|---|
 | 78 |  | 
|---|
 | 79 | /** | 
|---|
 | 80 |  * | 
|---|
 | 81 |  */ | 
|---|
 | 82 | void TestEntity::init() | 
|---|
 | 83 | { | 
|---|
 | 84 |   this->registerObject(this, TestEntity::_objectList); | 
|---|
 | 85 |   this->toList(OM_GROUP_00); | 
|---|
 | 86 |  | 
|---|
 | 87 |  //add to track | 
|---|
 | 88 |   if(this->entityTrack) | 
|---|
 | 89 |     this->setParent(this->entityTrack->getTrackNode()); | 
|---|
 | 90 |  | 
|---|
 | 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 |  */ | 
|---|
 | 98 | void TestEntity::loadParams(const TiXmlElement* root) | 
|---|
 | 99 | { | 
|---|
 | 100 |   WorldEntity::loadParams(root); | 
|---|
 | 101 | } | 
|---|
 | 102 |  | 
|---|
 | 103 | void TestEntity::draw() const | 
|---|
 | 104 | { | 
|---|
 | 105 | //   if(!mediaLoaded) | 
|---|
 | 106 | //     false; | 
|---|
 | 107 |  | 
|---|
 | 108 |   glPushAttrib(GL_ENABLE_BIT); | 
|---|
 | 109 |   glDisable(GL_LIGHTING); | 
|---|
 | 110 | //   glDisable(GL_BLEND); | 
|---|
 | 111 | //  | 
|---|
 | 112 | //   glEnable(GL_TEXTURE_2D); | 
|---|
 | 113 | //   glBindTexture(GL_TEXTURE_2D, media_container->getFrameTexture(counter)); | 
|---|
 | 114 |  | 
|---|
 | 115 |   glPushMatrix(); | 
|---|
 | 116 |  /* glTranslatef (this->getAbsCoor ().x, | 
|---|
 | 117 |                 this->getAbsCoor ().y, | 
|---|
 | 118 |                 this->getAbsCoor ().z); | 
|---|
 | 119 |   glRotatef(axis, 0.0f, 1.0f, 0.0f);*/ | 
|---|
 | 120 | //PRINTF(0)("axis: %f\n", axis); | 
|---|
 | 121 |  | 
|---|
 | 122 |   glColor3f(1.0, 0, 0); | 
|---|
 | 123 |  | 
|---|
 | 124 |   glBegin(GL_QUADS); | 
|---|
 | 125 |     glVertex3f( 0.0f, -100.0f, 0.0f); | 
|---|
 | 126 | //     glTexCoord2f(1.0f, 1.0f); | 
|---|
 | 127 |     glVertex3f( 0.0f,  -100.0f , 2000.0f); | 
|---|
 | 128 | //     glTexCoord2f(0.0f, 1.0f); | 
|---|
 | 129 |     glVertex3f( 10000.0f,  -100.0f , 2000.0f ); | 
|---|
 | 130 | //     glTexCoord2f(0.0f, 0.0f); | 
|---|
 | 131 |     glVertex3f( 10000.0f, -100.0f, 0.0f ); | 
|---|
 | 132 | //     glTexCoord2f(1.0f, 0.0f); | 
|---|
 | 133 |      | 
|---|
 | 134 |   glEnd(); | 
|---|
 | 135 |  | 
|---|
 | 136 |   glPopMatrix(); | 
|---|
 | 137 |   glPopAttrib(); | 
|---|
 | 138 |  | 
|---|
 | 139 |  | 
|---|
 | 140 | if( this->entityTrack != NULL) | 
|---|
 | 141 |     this->entityTrack->drawGraph(); | 
|---|
 | 142 |  | 
|---|
 | 143 | } | 
|---|
 | 144 |  | 
|---|
 | 145 | /** | 
|---|
 | 146 |  * | 
|---|
 | 147 |  */ | 
|---|
 | 148 | void TestEntity::tick (float time) | 
|---|
 | 149 | { | 
|---|
 | 150 |  if(this->entityTrack) | 
|---|
 | 151 |     this->entityTrack->tick(time); | 
|---|
 | 152 |  | 
|---|
 | 153 |  | 
|---|
 | 154 | } | 
|---|
 | 155 |  | 
|---|
 | 156 |  | 
|---|
 | 157 |  | 
|---|
 | 158 |  | 
|---|
 | 159 |  | 
|---|
 | 160 |  | 
|---|