| 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: Patrick Boenzli | 
|---|
| 13 |    co-programmer: | 
|---|
| 14 | */ | 
|---|
| 15 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY | 
|---|
| 16 |  | 
|---|
| 17 |  | 
|---|
| 18 | #include "collision_test_entity.h" | 
|---|
| 19 |  | 
|---|
| 20 | #include "resource_manager.h" | 
|---|
| 21 |  | 
|---|
| 22 | #include "vector.h" | 
|---|
| 23 | #include "objModel.h" | 
|---|
| 24 | #include "obb_tree.h" | 
|---|
| 25 | #include "factory.h" | 
|---|
| 26 |  | 
|---|
| 27 | using namespace std; | 
|---|
| 28 | CREATE_FACTORY(CollisionTestEntity); | 
|---|
| 29 |  | 
|---|
| 30 | /** | 
|---|
| 31 |  *  creates an environment | 
|---|
| 32 | */ | 
|---|
| 33 | CollisionTestEntity::CollisionTestEntity () : WorldEntity() | 
|---|
| 34 | { | 
|---|
| 35 |   this->init(); | 
|---|
| 36 |   this->loadModel("models/ships/reaplow.obj"); | 
|---|
| 37 |   //  this->loadModel("models/ships/figther.obj"); | 
|---|
| 38 |  | 
|---|
| 39 |   this->buildObbTree(10); | 
|---|
| 40 | } | 
|---|
| 41 |  | 
|---|
| 42 | /** | 
|---|
| 43 |  * create an environment out of a XML-element | 
|---|
| 44 |  * @param root the XML-element to load the CollisionTestEntity from | 
|---|
| 45 |  */ | 
|---|
| 46 | CollisionTestEntity::CollisionTestEntity(const TiXmlElement* root) | 
|---|
| 47 | { | 
|---|
| 48 |   this->init(); | 
|---|
| 49 |   if (root != NULL) | 
|---|
| 50 |     this->loadParams(root); | 
|---|
| 51 | } | 
|---|
| 52 |  | 
|---|
| 53 | /** | 
|---|
| 54 |  *  deletes an environment | 
|---|
| 55 | */ | 
|---|
| 56 | CollisionTestEntity::~CollisionTestEntity () | 
|---|
| 57 | {} | 
|---|
| 58 |  | 
|---|
| 59 | /** | 
|---|
| 60 |  * initialize an CollisionTestEntity | 
|---|
| 61 |  */ | 
|---|
| 62 | void CollisionTestEntity::init() | 
|---|
| 63 | { | 
|---|
| 64 |   this->setClassID(CL_ENVIRONMENT, "CollisionTestEntity"); | 
|---|
| 65 | } | 
|---|
| 66 |  | 
|---|
| 67 | /** | 
|---|
| 68 |  * loads the Settings of an CollisionTestEntity from an XML-element. | 
|---|
| 69 |  * @param root the XML-element to load the ELements properties from | 
|---|
| 70 |  */ | 
|---|
| 71 | void CollisionTestEntity::loadParams(const TiXmlElement* root) | 
|---|
| 72 | { | 
|---|
| 73 |   static_cast<WorldEntity*>(this)->loadParams(root); | 
|---|
| 74 | } | 
|---|
| 75 |  | 
|---|
| 76 |  | 
|---|
| 77 | /** | 
|---|
| 78 |  *  ticks the environment | 
|---|
| 79 |  * @param time the time about which to tick | 
|---|
| 80 | */ | 
|---|
| 81 | void CollisionTestEntity::tick (float time) {} | 
|---|
| 82 |  | 
|---|
| 83 |  | 
|---|
| 84 | /** | 
|---|
| 85 |  *  draws the CollisionTestEntity | 
|---|
| 86 | */ | 
|---|
| 87 | void CollisionTestEntity::draw () | 
|---|
| 88 | { | 
|---|
| 89 |   glMatrixMode(GL_MODELVIEW); | 
|---|
| 90 |   glPushMatrix(); | 
|---|
| 91 |   float matrix[4][4]; | 
|---|
| 92 |  | 
|---|
| 93 |   glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z); | 
|---|
| 94 |   //rotate | 
|---|
| 95 |   this->getAbsDir().matrix (matrix); | 
|---|
| 96 |   glMultMatrixf((float*)matrix); | 
|---|
| 97 |  | 
|---|
| 98 |   this->model->draw(); | 
|---|
| 99 |  | 
|---|
| 100 |   glPopMatrix(); | 
|---|
| 101 | } | 
|---|
| 102 |  | 
|---|