| 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/fighter.obj"); | 
|---|
| 37 |  | 
|---|
| 38 |   this->buildObbTree(10); | 
|---|
| 39 | } | 
|---|
| 40 |  | 
|---|
| 41 | /** | 
|---|
| 42 |  * create an environment out of a XML-element | 
|---|
| 43 |  * @param root the XML-element to load the CollisionTestEntity from | 
|---|
| 44 |  */ | 
|---|
| 45 | CollisionTestEntity::CollisionTestEntity(const TiXmlElement* root) | 
|---|
| 46 | { | 
|---|
| 47 |   this->init(); | 
|---|
| 48 |   if (root != NULL) | 
|---|
| 49 |     this->loadParams(root); | 
|---|
| 50 | } | 
|---|
| 51 |  | 
|---|
| 52 | /** | 
|---|
| 53 |  *  deletes an environment | 
|---|
| 54 | */ | 
|---|
| 55 | CollisionTestEntity::~CollisionTestEntity () | 
|---|
| 56 | {} | 
|---|
| 57 |  | 
|---|
| 58 | /** | 
|---|
| 59 |  * initialize an CollisionTestEntity | 
|---|
| 60 |  */ | 
|---|
| 61 | void CollisionTestEntity::init() | 
|---|
| 62 | { | 
|---|
| 63 |   this->setClassID(CL_ENVIRONMENT, "CollisionTestEntity"); | 
|---|
| 64 | } | 
|---|
| 65 |  | 
|---|
| 66 | /** | 
|---|
| 67 |  * loads the Settings of an CollisionTestEntity from an XML-element. | 
|---|
| 68 |  * @param root the XML-element to load the ELements properties from | 
|---|
| 69 |  */ | 
|---|
| 70 | void CollisionTestEntity::loadParams(const TiXmlElement* root) | 
|---|
| 71 | { | 
|---|
| 72 |   static_cast<WorldEntity*>(this)->loadParams(root); | 
|---|
| 73 | } | 
|---|
| 74 |  | 
|---|
| 75 |  | 
|---|
| 76 | /** | 
|---|
| 77 |  *  ticks the environment | 
|---|
| 78 |  * @param time the time about which to tick | 
|---|
| 79 | */ | 
|---|
| 80 | void CollisionTestEntity::tick (float time) {} | 
|---|
| 81 |  | 
|---|
| 82 |  | 
|---|
| 83 | /** | 
|---|
| 84 |  *  draws the CollisionTestEntity | 
|---|
| 85 | */ | 
|---|
| 86 | void CollisionTestEntity::draw () | 
|---|
| 87 | { | 
|---|
| 88 |   glMatrixMode(GL_MODELVIEW); | 
|---|
| 89 |   glPushMatrix(); | 
|---|
| 90 |   float matrix[4][4]; | 
|---|
| 91 |  | 
|---|
| 92 |   glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z); | 
|---|
| 93 |   //rotate | 
|---|
| 94 |   this->getAbsDir().matrix (matrix); | 
|---|
| 95 |   glMultMatrixf((float*)matrix); | 
|---|
| 96 |  | 
|---|
| 97 |   this->model->draw(); | 
|---|
| 98 |  | 
|---|
| 99 |   glPopMatrix(); | 
|---|
| 100 | } | 
|---|
| 101 |  | 
|---|