Changeset 2816 in orxonox.OLD for orxonox/trunk/src
- Timestamp:
- Nov 11, 2004, 10:32:34 PM (20 years ago)
- Location:
- orxonox/trunk/src
- Files:
-
- 2 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/Makefile.am
r2811 r2816 6 6 7 7 bin_PROGRAMS=orxonox 8 orxonox_SOURCES=orxonox.cc world.cc player.cc data_tank.cc world_entity.cc vector.cc camera.cc collision.cc command_node.cc ini_parser.cc keynames.cc track.cc base_entity.cc game_loader.cc campaign.cc story_entity.cc object.cc array.cc material.cc9 8 10 noinst_HEADERS=ability.h data_tank.h npc.h stdincl.h ai.h environment.h orxonox.h synchronisable.h base_entity.h error.h player.h track.h camera.h ini_parser.h power_up.h vector.h collision.h keynames.h proto_class.h world.h command_node.h list.h shoot_laser.h world_entity.h coordinates.h message_structures.h shoot_rocket.h object.h array.h material.h 9 orxonox_SOURCES=orxonox.cc world.cc player.cc data_tank.cc world_entity.cc vector.cc camera.cc collision.cc command_node.cc ini_parser.cc keynames.cc track.cc base_entity.cc game_loader.cc campaign.cc story_entity.cc object.cc environment.cc array.cc material.cc list.cc 10 noinst_HEADERS=ability.h data_tank.h npc.h stdincl.h ai.h environment.h orxonox.h synchronisable.h base_entity.h error.h player.h track.h camera.h ini_parser.h power_up.h vector.h collision.h keynames.h proto_class.h world.h command_node.h list.h shoot_laser.h world_entity.h coordinates.h message_structures.h shoot_rocket.h object.h array.h material.h list_template.h 11 11 12 12 13 -
orxonox/trunk/src/Makefile.in
r2811 r2816 58 58 track.$(OBJEXT) base_entity.$(OBJEXT) game_loader.$(OBJEXT) \ 59 59 campaign.$(OBJEXT) story_entity.$(OBJEXT) object.$(OBJEXT) \ 60 array.$(OBJEXT) material.$(OBJEXT) 60 environment.$(OBJEXT) array.$(OBJEXT) material.$(OBJEXT) \ 61 list.$(OBJEXT) 61 62 orxonox_OBJECTS = $(am_orxonox_OBJECTS) 62 63 orxonox_LDADD = $(LDADD) … … 69 70 @AMDEP_TRUE@ ./$(DEPDIR)/command_node.Po \ 70 71 @AMDEP_TRUE@ ./$(DEPDIR)/data_tank.Po \ 72 @AMDEP_TRUE@ ./$(DEPDIR)/environment.Po \ 71 73 @AMDEP_TRUE@ ./$(DEPDIR)/game_loader.Po \ 72 74 @AMDEP_TRUE@ ./$(DEPDIR)/ini_parser.Po ./$(DEPDIR)/keynames.Po \ 73 @AMDEP_TRUE@ ./$(DEPDIR)/ material.Po ./$(DEPDIR)/object.Po \74 @AMDEP_TRUE@ ./$(DEPDIR)/o rxonox.Po ./$(DEPDIR)/player.Po \75 @AMDEP_TRUE@ ./$(DEPDIR)/ story_entity.Po ./$(DEPDIR)/track.Po \76 @AMDEP_TRUE@ ./$(DEPDIR)/ vector.Po ./$(DEPDIR)/world.Po \77 @AMDEP_TRUE@ ./$(DEPDIR)/world _entity.Po75 @AMDEP_TRUE@ ./$(DEPDIR)/list.Po ./$(DEPDIR)/material.Po \ 76 @AMDEP_TRUE@ ./$(DEPDIR)/object.Po ./$(DEPDIR)/orxonox.Po \ 77 @AMDEP_TRUE@ ./$(DEPDIR)/player.Po ./$(DEPDIR)/story_entity.Po \ 78 @AMDEP_TRUE@ ./$(DEPDIR)/track.Po ./$(DEPDIR)/vector.Po \ 79 @AMDEP_TRUE@ ./$(DEPDIR)/world.Po ./$(DEPDIR)/world_entity.Po 78 80 CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ 79 81 $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) … … 165 167 AM_CXXFLAGS = "-I/usr/X11R6/include" 166 168 AM_LDFLAGS = "-L/usr/Mesa-6.0.1/lib -L/usr/X11R6/lib -lXt -lX11" $(MWINDOWS) 167 orxonox_SOURCES = orxonox.cc world.cc player.cc data_tank.cc world_entity.cc vector.cc camera.cc collision.cc command_node.cc ini_parser.cc keynames.cc track.cc base_entity.cc game_loader.cc campaign.cc story_entity.cc object.cc array.cc material.cc168 noinst_HEADERS = ability.h data_tank.h npc.h stdincl.h ai.h environment.h orxonox.h synchronisable.h base_entity.h error.h player.h track.h camera.h ini_parser.h power_up.h vector.h collision.h keynames.h proto_class.h world.h command_node.h list.h shoot_laser.h world_entity.h coordinates.h message_structures.h shoot_rocket.h object.h array.h material.h 169 orxonox_SOURCES = orxonox.cc world.cc player.cc data_tank.cc world_entity.cc vector.cc camera.cc collision.cc command_node.cc ini_parser.cc keynames.cc track.cc base_entity.cc game_loader.cc campaign.cc story_entity.cc object.cc environment.cc array.cc material.cc list.cc 170 noinst_HEADERS = ability.h data_tank.h npc.h stdincl.h ai.h environment.h orxonox.h synchronisable.h base_entity.h error.h player.h track.h camera.h ini_parser.h power_up.h vector.h collision.h keynames.h proto_class.h world.h command_node.h list.h shoot_laser.h world_entity.h coordinates.h message_structures.h shoot_rocket.h object.h array.h material.h list_template.h 169 171 all: all-am 170 172 … … 240 242 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/command_node.Po@am__quote@ 241 243 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/data_tank.Po@am__quote@ 244 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/environment.Po@am__quote@ 242 245 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/game_loader.Po@am__quote@ 243 246 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ini_parser.Po@am__quote@ 244 247 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/keynames.Po@am__quote@ 248 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/list.Po@am__quote@ 245 249 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/material.Po@am__quote@ 246 250 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/object.Po@am__quote@ -
orxonox/trunk/src/campaign.cc
r2636 r2816 27 27 Campaign::Campaign () 28 28 { 29 this->entities = new List <StoryEntity>();29 this->entities = new ListTemplate<StoryEntity>(); 30 30 this->isInit = false; 31 31 } … … 144 144 StoryEntity* Campaign::getStoryEntity(Uint32 storyID) 145 145 { 146 List <StoryEntity>* l;146 ListTemplate<StoryEntity>* l; 147 147 StoryEntity* entity; 148 148 l = this->entities->get_next(); -
orxonox/trunk/src/campaign.h
r2636 r2816 33 33 34 34 private: 35 List <StoryEntity>* entities;35 ListTemplate<StoryEntity>* entities; 36 36 bool running; 37 37 -
orxonox/trunk/src/command_node.cc
r2636 r2816 11 11 ### File Specific: 12 12 main-programmer: Christian Meyer 13 co-programmer: ...13 co-programmer: Patrick Boenzli 14 14 */ 15 15 … … 33 33 CommandNode::CommandNode (int ID) 34 34 { 35 bound = new List <WorldEntity>();35 bound = new List(); 36 36 aliases = NULL; 37 37 netID = ID; … … 48 48 bLocalInput = true; 49 49 netID = 0; 50 bound = new List <WorldEntity>();50 bound = new List(); 51 51 load_bindings (filename); 52 52 } … … 59 59 if( aliases != NULL) free (aliases); 60 60 if( bound != NULL) delete bound; 61 } 62 63 64 void CommandNode::reset() 65 { 66 this->bound->clear(); 61 67 } 62 68 … … 123 129 void CommandNode::bind (WorldEntity* entity) 124 130 { 125 bound->add (entity , LIST_ADD_NEXT, true);131 bound->add (entity); 126 132 } 127 133 … … 132 138 void CommandNode::unbind (WorldEntity* entity) 133 139 { 134 bound->remove (entity , LIST_FIND_FW);140 bound->remove (entity); 135 141 } 136 142 … … 214 220 } 215 221 222 216 223 void CommandNode::process_network () 217 224 { … … 219 226 } 220 227 228 221 229 void CommandNode::relay (Command* cmd) 222 230 { 223 //printf("CommandNode|relay()\n");224 List<WorldEntity>* plist = bound;225 231 226 232 Orxonox *orx = Orxonox::getInstance(); … … 231 237 if( bLocalInput) send_over_network (cmd); 232 238 233 while( (plist = plist->get_next()) != NULL) 234 { 235 plist->get_object()->command (cmd); 236 } 237 } 239 WorldEntity* entity = bound->enumerate(); 240 while( entity != NULL) 241 { 242 entity->command (cmd); 243 entity = bound->nextElement(); 244 } 245 } 246 238 247 239 248 /** -
orxonox/trunk/src/command_node.h
r2190 r2816 19 19 //! Key aliasing structure 20 20 /** 21 22 21 This structure contains the key aliasing information, e.g. the command strings that 22 have been bound to the keys. 23 23 */ 24 24 typedef struct 25 25 { 26 27 26 char keys[N_STD_KEYS][CMD_LENGHT]; 27 char buttons[N_BUTTONS][CMD_LENGHT]; 28 28 } KeyBindings; 29 29 30 30 //! Command Node 31 31 /** 32 33 34 35 36 32 This class gathers all incoming SDL_Events and processes them. Keyboard, mouse and joystick input is 33 captured and translated into command messages which are passed down to the bound WorldEntities (via WorldEntity::command()). 34 Other SDL_Events are passed to Orxonox::event_handler() to deal with them. If the CommandNode has been created 35 with bLocalInput set to false, it will query the network class for incoming commands that match his netID and pass 36 them on to it's WorldEntities. 37 37 */ 38 38 class CommandNode { 39 39 private: 40 bool bLocalInput; //!< Identifies the CommandNode that processes local input 41 int netID; //!< Unique identifier that is used to determine between remote CommandNodes 42 KeyBindings* aliases; 43 List<WorldEntity>* bound; //!< List of WorldEntites that recieve commands from this CommandNode 44 Sint32 coord[2]; 45 46 void relay (Command* cmd); 47 int* name_to_index (char* name); 48 void process_local (); 49 void process_network (); 50 void send_over_network (Command* cmd); 51 40 bool bLocalInput; //!< Identifies the CommandNode that processes local input 41 int netID; //!< Unique identifier that is used to determine between remote CommandNodes 42 KeyBindings* aliases; 43 List* bound; //!< List of WorldEntites that recieve commands from this CommandNode 44 Sint32 coord[2]; 45 46 47 void relay (Command* cmd); 48 int* name_to_index (char* name); 49 void process_local (); 50 void process_network (); 51 void send_over_network (Command* cmd); 52 52 53 public: 53 54 CommandNode (int ID); 54 55 CommandNode (char* filename); 55 56 ~CommandNode (); 56 57 58 void reset(); 57 59 void load_bindings (char* filename); 58 60 void bind (WorldEntity* entity); -
orxonox/trunk/src/environment.cc
r2036 r2816 16 16 */ 17 17 18 #include <iostream>19 #include <GL/glut.h>20 #include <stdlib.h>21 22 #include "data_tank.h"23 18 24 19 #include "environment.h" 20 #include "stdincl.h" 21 #include "world_entity.h" 22 #include "vector.h" 25 23 26 24 using namespace std; … … 30 28 #define LEVEL_LENGTH 500 31 29 32 Environment::Environment () 33 : WorldEntity() 30 Environment::Environment () : WorldEntity() 34 31 { 35 32 … … 60 57 Environment::~Environment () {} 61 58 59 void Environment::tick (float time) {} 62 60 61 void Environment::hit (WorldEntity* weapon, Vector loc) {} 62 63 void Environment::destroy () {} 64 65 void Environment::collide (WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags) {} 66 67 void Environment::draw () 68 { 69 printf("Environment::draw()"); 70 71 glMatrixMode(GL_MODELVIEW); 72 glLoadIdentity(); 73 float matrix[4][4]; 74 75 glTranslatef(get_placement()->r.x,get_placement()->r.y,get_placement()->r.z); 76 get_placement()->w.matrix (matrix); 77 glMultMatrixf ((float*)matrix); 78 79 glBegin(GL_TRIANGLES); 80 glColor3f(1,1,1); 81 glVertex3f(0,0,0.5); 82 glVertex3f(-0.5,0,-1); 83 glVertex3f(0.5,0,-1); 84 85 glVertex3f(0,0,0.5); 86 glVertex3f(0,0.5,-1); 87 glVertex3f(0,-0.5,-1); 88 glEnd(); 89 90 glBegin(GL_QUADS); 91 glColor3f(0,0,1); 92 glVertex3f(0.5,0.5,-1); 93 glVertex3f(0.5,-0.5,-1); 94 glVertex3f(-0.5,-0.5,-1); 95 glVertex3f(-0.5,0.5,-1); 96 glEnd(); 97 } 98 99 /* 63 100 void Environment::paint() 64 101 { 65 /*102 66 103 glPushMatrix(); 67 104 //glScalef(0.5, 0.5, 1.0); … … 95 132 96 133 glPopMatrix(); 97 */134 98 135 } 99 136 … … 103 140 } 104 141 142 */ -
orxonox/trunk/src/environment.h
r2036 r2816 1 2 3 4 1 #ifndef ENVIRONEMENT_H 5 2 #define ENVIRONEMENT_H 6 3 7 8 4 #include "world_entity.h" 9 5 10 class Environment : public WorldEntity { 6 7 class Environment : public WorldEntity 8 { 9 friend class World; 11 10 12 11 private: … … 21 20 ~Environment (); 22 21 23 void paint(void); 24 void drawEnvironment(void); 25 void setEnvPosition(void); 26 void getEnvPosition(void); 22 23 virtual void tick (float time); 24 virtual void hit (WorldEntity* weapon, Vector loc); 25 virtual void destroy (); 26 virtual void collide (WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags); 27 virtual void draw (); 27 28 28 29 }; -
orxonox/trunk/src/list.h
r2636 r2816 1 /*2 orxonox - the future of 3D-vertical-scrollers3 4 Copyright (C) 2004 orx5 6 This program is free software; you can redistribute it and/or modify7 it under the terms of the GNU General Public License as published by8 the Free Software Foundation; either version 2, or (at your option)9 any later version.10 11 ### File Specific:12 main-programmer: Christian Meyer13 14 ADDONS/FIXES:15 16 Patrick Boenzli : Implemented getSize() function17 */18 19 20 /*!21 \file list.h22 \brief Contains a template for a doubly linked list23 */24 1 25 2 #ifndef LIST_H 26 3 #define LIST_H 27 4 28 #include "std lib.h"5 #include "stdincl.h" 29 6 30 7 //! An enum to list all the modes available when adding an object to a List 31 enum ADDMODE {LIST_ADD_NEXT, LIST_ADD_PREV,LIST_ADD_FIRST, LIST_ADD_LAST};8 //enum ADDMODE {LIST_ADD_FIRST, LIST_ADD_LAST}; 32 9 //! An enum to list the two searching directions available when removing an object from a List 33 enum FINDMODE {LIST_FIND_BW, LIST_FIND_FW};10 //enum FINDMODE {LIST_FIND_BW, LIST_FIND_FW}; 34 11 35 //! A generic doubly linked list 36 template<class T> class List 37 { 38 T* object; 39 List<T>* next; 40 List<T>* prev; 41 bool bReference; 42 int size; 43 12 13 14 class WorldEntity; 15 16 class List { 17 44 18 public: 45 List ( T* obj, List<T>* n, List<T>* p, bool bRef);19 List (); 46 20 ~List (); 47 48 int add (T* obj, ADDMODE mode, bool bRef); 49 T* get_object(); 50 List<T>* get_next (); 51 List<T>* get_previous (); 52 List<T>* get_last (); 53 List<T>* get_first (); 54 void set_next (List<T>* ptr); 55 void set_prev (List<T>* ptr); 56 int remove (T* obj, FINDMODE mode); 21 22 void add(WorldEntity* entity); 23 void remove(WorldEntity* entity); 24 void clear(); 25 WorldEntity* firstElement(); 26 bool isEmpty(); 57 27 int getSize(); 28 WorldEntity* enumerate(); 29 WorldEntity* nextElement(); 30 WorldEntity* toArray(); 31 void debug(); 32 33 private: 34 struct listElement 35 { 36 listElement* prev; 37 WorldEntity* curr; 38 listElement* next; 39 }; 40 Uint32 size; 41 listElement* first; 42 listElement* last; 43 listElement* currentEl; 44 45 58 46 }; 59 47 48 class Iterator 49 { 60 50 61 /** 62 \brief Standard constructor 63 64 Call this without any parameters to generate a new List which can be filled with content. 65 DO NOT create a List element that contains an object on your own, you'll lose the data 66 contained in that object and will have trouble removing the list from your memory. 67 */ 68 template<class T> 69 List<T>::List (T* obj = NULL, List<T>* n = NULL, List<T>* p = NULL, bool bRef = false) 70 { 71 object = obj; 72 next = n; 73 prev = p; 74 bReference = bRef; 75 if(obj != NULL) 76 ++size; 77 } 51 public: 52 bool hasNext(); 53 WorldEntity* next(); 78 54 79 /** 80 \brief Standard destructor 81 82 Call this on the initially generated base List element to remove the whole List from the memory. 83 You can safely do this to any List element you want without messing up the rest of the List, but keep in mind 84 that the contained object will be deleted as well when bRef had been set to false. 85 */ 86 template<class T> 87 List<T>::~List () 88 { 89 if (object == NULL) // deleted foot node => disband the list 90 { 91 while( next != NULL) 92 { 93 delete next; 94 } 95 while( prev != NULL) 96 { 97 delete prev; 98 } 99 } 100 else 101 { 102 if (prev != NULL) prev->set_next (next); 103 if (next != NULL) next->set_prev (prev); 104 if (!bReference) delete object; 105 } 106 } 107 108 /** 109 \brief Add an object to the List 110 \param obj: A pointer to an allocated object 111 \param mode: A Value of ADDMODE (default: LIST_ADD_NEXT) 112 \param bRef: Sets whether the element is serving as a storage point or a simple listing (default: false) 113 \return 0 if the operation succeded, -1 if the element could not be added 114 115 This adds a new List element to the chain. The mode parameter can be used to specify 116 the location where the element should be added. LIST_ADD_NEXT will add the new element directly 117 after the base element. LIST_ADD_PREV will add the new element directly before the base element. 118 LIST_ADD_FIRST will add the element at the beginning of the List whereas LIST_ADD_LAST will add 119 it to the end of the chain. If the bRef parameter is set to true, the object pointer will not be deleted 120 when the element containing that object is deleted, thus the List can be used for temporary listings as 121 well as permanent data storage. 122 */ 123 template<class T> 124 int List<T>::add (T* obj, ADDMODE mode = LIST_ADD_NEXT, bool bRef = false) 125 { 126 List<T>* p; 127 if( obj == NULL) return -1; 128 switch (mode) 129 { 130 case LIST_ADD_NEXT: 131 p = new List<T>( obj, next, this, bRef); 132 if( next != NULL) next->set_prev (p); 133 next = p; 134 break; 135 case LIST_ADD_PREV: 136 p = new List<T>( obj, this, prev, bRef); 137 if( prev != NULL) prev->set_next (p); 138 prev = p; 139 break; 140 case LIST_ADD_FIRST: 141 if (prev == NULL) prev = new List<T> (obj, this, NULL, bRef); 142 else return prev->add (obj, mode, bRef); 143 break; 144 case LIST_ADD_LAST: 145 if (next == NULL) next = new List<T> (obj, NULL, this, bRef); 146 else return next->add (obj, mode, bRef); 147 break; 148 default: 149 return -1; 150 break; 151 } 152 ++size; 153 return 0; 154 } 55 private: 155 56 156 /** 157 \brief Get the next element of the List 158 \return The List element after the current List element 159 */ 160 template<class T> 161 List<T>* List<T>::get_next () 162 { 163 return next; 164 } 165 166 /** 167 \brief Get the previous element of the List 168 \return The List element before the current List element 169 */ 170 template<class T> 171 List<T>* List<T>::get_previous () 172 { 173 return prev; 174 } 175 176 /** 177 \brief Get the last element of the List 178 \return The last List element 179 */ 180 template<class T> 181 List<T>* List<T>::get_last () 182 { 183 if (next == NULL) return this; 184 else return next->get_last(); 185 } 186 187 /** 188 \brief Get the first element of the List 189 \return The first List element 190 */ 191 template<class T> 192 List<T>* List<T>::get_first () 193 { 194 if (prev == NULL) return this; 195 else return prev->get_first(); 196 } 197 198 /** 199 \brief Removes a certain element from the List 200 \param obj: A pointer to the object that should be removed 201 \param mode: A value of FINDMODE 202 \return 0 if the element was found and removed, -1 if the element was not found 203 204 This searches the part of the List specified with mode for the object in question. 205 When the object is found it is deleted and the List element is removed from the chain. 206 If mode is LIST_FIND_FW all elements AFTER the base element are searched, if mode is 207 LIST_FIND_BW all elements BEFORE the base element are searched. Note that the object 208 contained within the List element is NOT deleted when bRef was set to true. 209 */ 210 template<class T> 211 int List<T>::remove (T* obj, FINDMODE mode = LIST_FIND_FW) 212 { 213 if (obj == NULL) return -1; 214 else 215 { 216 switch (mode) 217 { 218 case LIST_FIND_BW: 219 if (prev == NULL) return -1; 220 else 221 { 222 if( prev->get_object() == obj) 223 { 224 delete prev; 225 } 226 else 227 { 228 return prev->remove( obj, mode); 229 } 230 } 231 break; 232 case LIST_FIND_FW: 233 if (next == NULL) return -1; 234 else 235 { 236 if( next->get_object() == obj) 237 { 238 delete next; 239 } 240 else 241 { 242 return next->remove( obj, mode); 243 } 244 } 245 break; 246 default: 247 return -1; 248 } 249 } 250 --size; 251 return 0; 252 } 253 254 /** 255 \brief Set the next element of a List element 256 \param ptr: A pointer to the new next element 257 258 Sets the next element of a List element... Better not touch this, it can really mess up a List. 259 */ 260 template<class T> 261 void List<T>::set_next (List<T>* ptr) 262 { 263 next = ptr; 264 } 265 266 /** 267 \brief Set the prev element of a List element 268 \param ptr: A pointer to the new previous element 269 270 Sets the previous element of a List element... Better not touch this, it can really mess up a List. 271 */ 272 template<class T> 273 void List<T>::set_prev (List<T>* ptr) 274 { 275 prev = ptr; 276 } 277 278 /** 279 \brief Get the pointer to the object the element is containing 280 \return The contained object (will be NULL if called on the base element). 281 */ 282 template<class T> 283 T* List<T>::get_object() 284 { 285 return object; 286 } 287 288 289 /** 290 \brief Returns the current size of the List 291 \return Size of List 292 */ 293 template<class T> 294 int List<T>::getSize() 295 { 296 return this->size; 297 } 57 }; 298 58 299 59 #endif 300 -
orxonox/trunk/src/player.cc
r2811 r2816 61 61 void Player::post_spawn () 62 62 { 63 64 65 66 67 68 63 travel_speed = 15.0; 64 velocity = Vector(); 65 bUp = bDown = bLeft = bRight = bAscend = bDescend = false; 66 bFire = false; 67 acceleration = 10.0; 68 set_collision (new CollisionCluster (1.0, Vector(0,0,0))); 69 69 } 70 70 … … 112 112 // glCallList (objectList); 113 113 114 114 115 115 116 //printf("Player@%f/%f/%f\n", get_placement()->r.x, get_placement()->r.y, get_placement()->r.z); -
orxonox/trunk/src/stdincl.h
r2636 r2816 15 15 #include "coordinates.h" 16 16 #include "list.h" 17 #include "list_template.h" 17 18 #include "error.h" 18 19 #include "message_structures.h" -
orxonox/trunk/src/vector.cc
r2551 r2816 33 33 { 34 34 Vector r; 35 35 36 36 r.x = x + v.x; 37 37 r.y = y + v.y; -
orxonox/trunk/src/world.cc
r2811 r2816 22 22 #include "command_node.h" 23 23 #include "camera.h" 24 #include "environment.h" 24 25 25 26 using namespace std; … … 35 36 this->worldName = name; 36 37 this->debugWorldNr = -1; 37 this->entities = new List <WorldEntity>();38 this->entities = new List(); 38 39 } 39 40 … … 42 43 this->debugWorldNr = worldID; 43 44 this->worldName = NULL; 44 this->entities = new List <WorldEntity>();45 this->entities = new List(); 45 46 } 46 47 … … 74 75 this->bQuitCurrentGame = true; 75 76 this->localCamera->setWorld(NULL); 77 this->entities->clear(); 78 Orxonox::getInstance()->get_localinput()->reset(); 76 79 this->~World(); 77 80 } … … 105 108 106 109 // create the tracks 107 this->tracklen = 6;108 this->track = new Track[ 6];110 this->tracklen = 2; 111 this->track = new Track[2]; 109 112 for( int i = 0; i < this->tracklen; i++) 110 113 { … … 113 116 114 117 // create a player 115 //WorldEntity* myPlayer = (WorldEntity*) this->spawn<Player>();116 118 WorldEntity* myPlayer = new Player(); 117 119 this->spawn(myPlayer); … … 125 127 this->localCamera = new Camera(this); 126 128 this->getCamera()->bind (myPlayer); 129 130 Placement* plc = new Placement; 131 plc->r = Vector(100, 10, 10); 132 plc->w = Quaternion(); 133 WorldEntity* env = new Environment(); 134 this->spawn(env, plc); 135 136 this->entities->debug(); 127 137 break; 128 138 } … … 260 270 void World::collide () 261 271 { 262 List<WorldEntity> *a, *b; 272 /* 273 List *a, *b; 263 274 WorldEntity *aobj, *bobj; 264 265 a = entities ->get_next();275 276 a = entities; 266 277 267 278 while( a != NULL) 268 279 { 269 aobj = a-> get_object();280 aobj = a->nextElement(); 270 281 if( aobj->bCollide && aobj->collisioncluster != NULL) 271 282 { 272 b = a-> get_next();283 b = a->nextElement(); 273 284 while( b != NULL ) 274 285 { 275 bobj = b-> get_object();286 bobj = b->nextElement(); 276 287 if( bobj->bCollide && bobj->collisioncluster != NULL ) 277 288 { … … 285 296 } 286 297 } 287 b = b-> get_next();298 b = b->nextElement(); 288 299 } 289 300 } 290 a = a->get_next(); 291 } 301 a = a->enumerate(); 302 } 303 */ 292 304 } 293 305 … … 300 312 301 313 // draw entities 302 List <WorldEntity>*l;314 List *l; 303 315 WorldEntity* entity; 304 316 305 l = entities->get_next(); 306 while( l != NULL ) 317 l = entities; 318 entity = l->enumerate(); 319 while( entity != NULL ) 307 320 { 308 entity = l->get_object();309 321 if( entity->bDraw ) entity->draw(); 310 l = l->get_next();322 entity = l->nextElement(); 311 323 } 312 324 … … 328 340 void World::update () 329 341 { 330 List<WorldEntity> *l;342 //List<WorldEntity> *l; 331 343 WorldEntity* entity; 332 344 Location* loc; … … 334 346 Uint32 t; 335 347 336 l = entities->get_next(); 337 while( l != NULL ) 348 // l = entities->enumerate(); 349 entity = this->entities->enumerate(); 350 while( entity != NULL ) 338 351 { 339 entity = l->get_object(); 352 340 353 341 354 if( !entity->isFree() ) … … 375 388 } 376 389 377 l = l->get_next();390 entity = entities->nextElement(); 378 391 } 379 392 … … 386 399 void World::time_slice (Uint32 deltaT) 387 400 { 388 List<WorldEntity> *l;401 //List<WorldEntity> *l; 389 402 WorldEntity* entity; 390 403 float seconds = deltaT; … … 392 405 seconds /= 1000; 393 406 394 l = entities->get_next();395 while( l!= NULL)407 entity = entities->enumerate(); 408 while( entity != NULL) 396 409 { 397 entity = l->get_object();398 410 entity->tick (seconds); 399 l = l->get_next();400 } 401 411 entity = entities->nextElement(); 412 } 413 402 414 for( int i = 0; i < tracklen; i++) track[i].tick (seconds); 403 415 } … … 436 448 void World::debug() 437 449 { 438 List<WorldEntity> *l;450 //List<WorldEntity> *l; 439 451 WorldEntity* entity; 440 452 441 453 printf("counting all entities\n"); 442 l = entities->get_next(); 443 while( l != NULL ) 454 printf("World::debug() - enumerate()\n"); 455 entity = entities->enumerate(); 456 while( entity != NULL ) 444 457 { 445 entity = l->get_object();446 458 if( entity->bDraw ) printf("got an entity\n"); 447 l = l->get_next();459 entity = entities->nextElement(); 448 460 } 449 461 } … … 470 482 // Draw 471 483 display(); 484 485 for(int i = 0; i < 1000000; i++){} 486 472 487 } 473 488 printf("World|Exiting the main loop\n"); … … 502 517 { 503 518 Uint32 dt = currentFrame - this->lastFrame; 504 /*519 505 520 if(dt > 0) 506 521 { … … 510 525 else 511 526 { 512 printf("fps = 1000 \n");513 } 514 */527 printf("fps = 1000 but 0ms!\n"); 528 } 529 515 530 this->time_slice (dt); 516 531 this->update (); … … 570 585 Location* loc = NULL; 571 586 WorldEntity* owner; 572 //T* entity = new T(); 573 entities->add (entity, LIST_ADD_NEXT); 574 //if( loc == NULL) 575 //{ 576 zeroloc.dist = 0; 577 zeroloc.part = 0; 578 zeroloc.pos = Vector(); 579 zeroloc.rot = Quaternion(); 580 loc = &zeroloc; 581 //} 587 588 entities->add (entity); 589 zeroloc.dist = 0; 590 zeroloc.part = 0; 591 zeroloc.pos = Vector(); 592 zeroloc.rot = Quaternion(); 593 loc = &zeroloc; 582 594 entity->init (loc, owner); 583 595 if (entity->bFree) … … 586 598 } 587 599 entity->post_spawn (); 600 } 601 602 603 void World::spawn(WorldEntity* entity, Location* loc) 604 { 605 Location zeroLoc; 606 WorldEntity* owner; 607 this->entities->add (entity); 608 if( loc == NULL) 609 { 610 zeroLoc.dist = 0; 611 zeroLoc.part = 0; 612 zeroLoc.pos = Vector(); 613 zeroLoc.rot = Quaternion(); 614 loc = &zeroLoc; 615 } 616 entity->init (loc, owner); 617 if (entity->bFree) 618 { 619 this->track[loc->part].map_coords( loc, entity->get_placement()); 620 } 621 entity->post_spawn (); 588 622 //return entity; 589 623 } 624 625 626 void World::spawn(WorldEntity* entity, Placement* plc) 627 { 628 Placement zeroPlc; 629 WorldEntity* owner; 630 if( plc == NULL) 631 { 632 zeroPlc.r = Vector(); 633 zeroPlc.w = Quaternion(); 634 plc = &zeroPlc; 635 } 636 this->entities->add (entity); 637 entity->init (plc, owner); 638 entity->post_spawn (); 639 //return entity; 640 } -
orxonox/trunk/src/world.h
r2731 r2816 49 49 bool system_command (Command* cmd); 50 50 Camera* getCamera(); 51 //private:52 51 53 52 void spawn(WorldEntity* entity); 53 void spawn(WorldEntity* entity, Location* loc); 54 void spawn(WorldEntity* entity, Placement* plc); 54 55 55 List <WorldEntity>* entities;56 List* entities; 56 57 57 58 // base level data
Note: See TracChangeset
for help on using the changeset viewer.