| 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: Claudio Botta | 
|---|
| 13 |    co-programmer: ... | 
|---|
| 14 | */ | 
|---|
| 15 |  | 
|---|
| 16 | #include "bsp_entity.h" | 
|---|
| 17 | #include "util/loading/resource_manager.h" | 
|---|
| 18 |  | 
|---|
| 19 | CREATE_FACTORY(BspEntity, CL_BSP_ENTITY); | 
|---|
| 20 |  | 
|---|
| 21 |  | 
|---|
| 22 | /** | 
|---|
| 23 |  * constructs and loads a BspEntity from a XML-element | 
|---|
| 24 |  * @param root the XML-element to load from | 
|---|
| 25 |  */ | 
|---|
| 26 | BspEntity::BspEntity(const TiXmlElement* root) | 
|---|
| 27 | { | 
|---|
| 28 |   this->init(); | 
|---|
| 29 |  | 
|---|
| 30 |   if (root != NULL) | 
|---|
| 31 |     this->loadParams(root); | 
|---|
| 32 | } | 
|---|
| 33 |  | 
|---|
| 34 |  | 
|---|
| 35 | /** | 
|---|
| 36 |  * standard deconstructor | 
|---|
| 37 |  */ | 
|---|
| 38 | BspEntity::~BspEntity () | 
|---|
| 39 | { | 
|---|
| 40 |   if( this->bspManager) | 
|---|
| 41 |     delete this->bspManager; | 
|---|
| 42 | } | 
|---|
| 43 |  | 
|---|
| 44 |  | 
|---|
| 45 | /** | 
|---|
| 46 |  * initializes the BspEntity | 
|---|
| 47 |  * @todo change this to what you wish | 
|---|
| 48 |  */ | 
|---|
| 49 | void BspEntity::init() | 
|---|
| 50 | { | 
|---|
| 51 |   this->setClassID(CL_BSP_ENTITY, "BspEntity"); | 
|---|
| 52 |  | 
|---|
| 53 |   this->bspManager = new BspManager(this); | 
|---|
| 54 |   this->toList(OM_ENVIRON); | 
|---|
| 55 |  | 
|---|
| 56 |   /** | 
|---|
| 57 |    * @todo: Write CL_BSP_ENTITY INTO THE src/defs/class_id.h (your own definition) | 
|---|
| 58 |    */ | 
|---|
| 59 | } | 
|---|
| 60 |  | 
|---|
| 61 |  | 
|---|
| 62 | void BspEntity::setName(const std::string& name) | 
|---|
| 63 | { | 
|---|
| 64 |   PRINTF(0)("+++++++++++ LOADING NAME %s\n", name.c_str()); | 
|---|
| 65 |  | 
|---|
| 66 |   this->bspManager->load(name.c_str(), 0.1f); | 
|---|
| 67 | } | 
|---|
| 68 |  | 
|---|
| 69 |  | 
|---|
| 70 | /** | 
|---|
| 71 |  * loads a BspEntity from a XML-element | 
|---|
| 72 |  * @param root the XML-element to load from | 
|---|
| 73 |  * @todo make the class Loadable | 
|---|
| 74 |  */ | 
|---|
| 75 | void BspEntity::loadParams(const TiXmlElement* root) | 
|---|
| 76 | { | 
|---|
| 77 |   // all the clases this Entity is directly derived from must be called in this way, to load all settings. | 
|---|
| 78 |  // WorldEntity::loadParam(root); | 
|---|
| 79 |  | 
|---|
| 80 |   LoadParam(root, "Name", this, BspEntity, setName) | 
|---|
| 81 |       .describe("Sets the of the BSP file."); | 
|---|
| 82 |  | 
|---|
| 83 | /*  LoadParam(root, "Scale", this, BSpEntity, setScale) | 
|---|
| 84 |       .describe("Sets the scale factore of the bsp level."); | 
|---|
| 85 | */ | 
|---|
| 86 |  | 
|---|
| 87 |   /** | 
|---|
| 88 |    * @todo: make the class Loadable | 
|---|
| 89 |    */ | 
|---|
| 90 | } | 
|---|
| 91 |  | 
|---|
| 92 |  | 
|---|
| 93 | /** | 
|---|
| 94 |  * advances the BspEntity about time seconds | 
|---|
| 95 |  * @param time the Time to step | 
|---|
| 96 |  */ | 
|---|
| 97 | void BspEntity::tick(float time) | 
|---|
| 98 | { | 
|---|
| 99 |   this->bspManager->tick(time); | 
|---|
| 100 | } | 
|---|
| 101 |  | 
|---|
| 102 |  | 
|---|
| 103 | /** | 
|---|
| 104 |  * draws this worldEntity | 
|---|
| 105 |  */ | 
|---|
| 106 | void BspEntity::draw () const | 
|---|
| 107 | { | 
|---|
| 108 |   this->bspManager->draw(); | 
|---|
| 109 | } | 
|---|
| 110 |  | 
|---|
| 111 |  | 
|---|
| 112 | /** | 
|---|
| 113 |  * | 
|---|
| 114 |  * | 
|---|
| 115 |  */ | 
|---|
| 116 | void BspEntity::collidesWith (WorldEntity* entity, const Vector& location) | 
|---|
| 117 | { | 
|---|
| 118 |  | 
|---|
| 119 | } | 
|---|