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