Changeset 2822 in orxonox.OLD for orxonox/trunk
- Timestamp:
- Nov 12, 2004, 1:33:25 AM (20 years ago)
- Location:
- orxonox/trunk/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/array.h
r2811 r2822 6 6 #include <GL/gl.h> 7 7 #include <GL/glu.h> 8 #include <fstream .h>8 #include <fstream> 9 9 class Array 10 10 { -
orxonox/trunk/src/list.h
r2816 r2822 57 57 }; 58 58 59 60 template<class T> class tList 61 { 62 private: 63 struct listElement 64 { 65 listElement* prev; 66 T* curr; 67 listElement* next; 68 }; 69 70 Uint32 size; 71 listElement* first; 72 listElement* last; 73 listElement* currentEl; 74 75 public: 76 tList (); 77 ~tList (); 78 79 80 void add(WorldEntity* entity); 81 void remove(WorldEntity* entity); 82 void clear(); 83 T* firstElement(); 84 bool isEmpty(); 85 int getSize(); 86 T* enumerate(); 87 T* nextElement(); 88 T* toArray(); 89 void debug(); 90 }; 91 92 93 template<class T> 94 tList<T>::tList () 95 { 96 this->first = NULL; 97 this->last = NULL; 98 this->size = 0; 99 } 100 101 template<class T> 102 tList<T>::~tList () 103 {} 104 105 template<class T> 106 void tList<T>::add(WorldEntity* entity) 107 { 108 printf("tList<T>::add() \n"); 109 listElement* el = new listElement; 110 el->prev = this->last; 111 el->curr = entity; 112 el->next = NULL; 113 114 this->last = el; 115 116 if(this->size == 0) this->first = el; 117 else el->prev->next = el; 118 this->size++; 119 } 120 121 122 template<class T> 123 void tList<T>::remove(WorldEntity* entity) 124 { 125 this->currentEl = this->first; 126 listElement* te; 127 while( this->currentEl != NULL) 128 { 129 if( this->currentEl->curr == entity) 130 { 131 printf("tList<T>::remove() - object found\n"); 132 133 if( this->currentEl->prev == NULL ) this->first = this->currentEl->next; 134 else this->currentEl->prev->next = this->currentEl->next; 135 136 if( this->currentEl->next == NULL) this->last = this->currentEl->prev; 137 else this->currentEl->next->prev = this->currentEl->prev; 138 139 te = this->currentEl->next; 140 delete this->currentEl; 141 this->currentEl = te; 142 return; 143 } 144 this->currentEl = this->currentEl->next; 145 } 146 } 147 148 149 template<class T> 150 void tList<T>::clear() 151 { 152 printf("tList<T>::clear() - clearing all world objects, releasing mem\n"); 153 this->currentEl = this->first; 154 while(this->currentEl != NULL) 155 { 156 listElement* le = this->currentEl->next; 157 delete this->currentEl->curr; 158 delete this->currentEl; 159 this->currentEl = le; 160 } 161 this->first = NULL; 162 this->last = NULL; 163 this->size = 0; 164 } 165 166 167 template<class T> 168 T* tList<T>::firstElement() 169 { 170 return this->first->curr; 171 } 172 173 174 template<class T> 175 bool tList<T>::isEmpty() 176 { 177 return (this->size==0)?true:false; 178 } 179 180 181 template<class T> 182 int tList<T>::getSize() 183 { 184 return this->size; 185 } 186 187 188 template<class T> 189 T* tList<T>::enumerate() 190 { 191 if(this->size == 0) return NULL; 192 this->currentEl = this->first; 193 return this->currentEl->curr; 194 } 195 196 197 template<class T> 198 T* tList<T>::nextElement() 199 { 200 if(this->size == 0) return NULL; 201 this->currentEl = this->currentEl->next; 202 if(this->currentEl == NULL) return NULL; 203 return this->currentEl->curr; 204 } 205 206 207 template<class T> 208 T* tList<T>::toArray() 209 {} 210 59 211 #endif -
orxonox/trunk/src/material.h
r2811 r2822 7 7 #include <GL/glu.h> 8 8 #include <stdlib.h> 9 #include <fstream .h>9 #include <fstream> 10 10 11 11 class Material -
orxonox/trunk/src/object.h
r2811 r2822 8 8 #include "material.h" 9 9 #include <fstream.h> 10 10 11 11 12 class Object -
orxonox/trunk/src/world.cc
r2819 r2822 36 36 this->worldName = name; 37 37 this->debugWorldNr = -1; 38 this->entities = new List();38 this->entities = new tList<WorldEntity>(); 39 39 } 40 40 … … 43 43 this->debugWorldNr = worldID; 44 44 this->worldName = NULL; 45 this->entities = new List();45 this->entities = new tList<WorldEntity>(); 46 46 } 47 47 … … 134 134 this->spawn(env, plc); 135 135 136 this->entities->debug();137 136 break; 138 137 } … … 331 330 332 331 // draw entities 333 List *l;334 332 WorldEntity* entity; 335 333 336 l = entities; 337 entity = l->enumerate(); 334 entity = this->entities->enumerate(); 338 335 while( entity != NULL ) 339 336 { 340 entity->draw();341 entity = l->nextElement();337 if( entity->bDraw ) entity->draw(); 338 entity = this->entities->nextElement(); 342 339 } 343 340 … … 502 499 display(); 503 500 504 for(int i = 0; i < 1000000; i++){}501 //for(int i = 0; i < 1000000; i++){} 505 502 506 503 } -
orxonox/trunk/src/world.h
r2816 r2822 54 54 void spawn(WorldEntity* entity, Placement* plc); 55 55 56 List* entities;56 tList<WorldEntity>* entities; 57 57 58 58 // base level data -
orxonox/trunk/src/world_entity.cc
r2190 r2822 36 36 WorldEntity::WorldEntity (bool isFree) : bFree(isFree) 37 37 { 38 collisioncluster = NULL; 39 owner = NULL; 38 this->bDraw = true; 39 collisioncluster = NULL; 40 owner = NULL; 40 41 } 41 42 … … 45 46 WorldEntity::~WorldEntity () 46 47 { 47 48 if( collisioncluster != NULL) delete collisioncluster; 48 49 } 49 50 50 51 /** 51 52 52 \brief get the Location of the WorldEntity 53 \return a pointer to location 53 54 */ 54 55 Location* WorldEntity::get_location () 55 56 { 56 57 return &loc; 57 58 } 58 59 59 60 /** 60 61 61 \brief get the Placement of the WorldEntity 62 \return a pointer to placement 62 63 */ 63 64 Placement* WorldEntity::get_placement () 64 65 { 65 66 return &place; 66 67 } 67 68 68 69 /** 69 70 70 \brief query whether the WorldEntity in question is free 71 \return true if the WorldEntity is free or false if it isn't 71 72 */ 72 73 bool WorldEntity::isFree () … … 76 77 77 78 /** 78 79 80 81 79 \brief set the WorldEntity's collision hull 80 \param newhull: a pointer to a completely assembled CollisionCluster 81 82 Any previously assigned collision hull will be deleted on reassignment 82 83 */ 83 84 void WorldEntity::set_collision (CollisionCluster* newhull) 84 85 { 85 86 87 86 if( newhull == NULL) return; 87 if( collisioncluster != NULL) delete collisioncluster; 88 collisioncluster = newhull; 88 89 } 89 90 90 91 /** 91 92 93 94 92 \brief this method is called every frame 93 \param time: the time in seconds that has passed since the last tick 94 95 Handle all stuff that should update with time inside this method (movement, animation, etc.) 95 96 */ 96 97 void WorldEntity::tick(float time) … … 100 101 /** 101 102 \brief the entity is drawn onto the screen with this function 102 103 103 104 This is a central function of an entity: call it to let the entity painted to the screen. Just override this function with whatever you want to be drawn. 104 105 */ … … 108 109 109 110 /** 110 111 112 113 111 \brief this function is called, when two entities collide 112 \param other: the world entity with whom it collides 113 \param ownhitflags: flags to the CollisionCluster subsections that registered an impact 114 \param otherhitflags: flags to the CollisionCluster subsections of the other entity that registered an impact 114 115 115 116 Implement behaviour like damage application or other miscellaneous collision stuff in this function 116 117 */ 117 118 void WorldEntity::collide(WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags) {} … … 135 136 136 137 /** 137 138 \brief basic initialisation for bound Entities 138 139 */ 139 140 void WorldEntity::init( Location* spawnloc, WorldEntity* spawnowner) 140 141 { 141 142 142 loc = *spawnloc; 143 owner = spawnowner; 143 144 } 144 145 145 146 /** 146 147 \brief basic initialisation for free Entities 147 148 */ 148 149 void WorldEntity::init( Placement* spawnplc, WorldEntity* spawnowner) 149 150 { 150 151 151 place = *spawnplc; 152 owner = spawnowner; 152 153 } 153 154 154 155 /** 155 156 157 158 156 \brief this is called immediately after the Entity has been constructed and initialized 157 158 Put any initialisation code that requires knowledge of location (placement if the Entity is free) and owner of the entity here. 159 DO NOT place such code in the constructor, those variables are set AFTER the entity is constucted. 159 160 */ 160 161 void WorldEntity::post_spawn () … … 163 164 164 165 /** 165 166 167 168 169 166 \brief this handles incoming command messages 167 \param cmd: a pointer to the incoming Command structure 168 169 Put all code that handles Command messages here, this will mainly be called by the assigned CommandNode but can also be used 170 to send commands from one WorldEntity to another. 170 171 */ 171 172 void WorldEntity::command (Command* cmd) … … 174 175 175 176 /** 176 177 177 \brief this is called by the local Camera to determine the point it should look at on the WorldEntity 178 \param locbuf: a pointer to the buffer to fill with a location to look at 178 179 179 180 180 You may put any Location you want into locbuf, the Camera will determine via the corresponding Track how 181 to look at the location you return with this. 181 182 */ 182 183 void WorldEntity::get_lookat (Location* locbuf) … … 185 186 186 187 /** 187 188 189 190 188 \brief this method is called by the world if the WorldEntity leaves valid gamespace 189 190 For free entities this means it left the Track boundaries. With bound entities it means its Location adresses a 191 place that is not in the world anymore. In both cases you might have to take extreme measures (a.k.a. call destroy). 191 192 */ 192 193 void WorldEntity::left_world ()
Note: See TracChangeset
for help on using the changeset viewer.