Changeset 2141 in orxonox.OLD for orxonox/branches/chris
- Timestamp:
- Jul 14, 2004, 3:31:42 PM (20 years ago)
- Location:
- orxonox/branches/chris/src
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/chris/src/command_node.cc
r2115 r2141 26 26 using namespace std; 27 27 28 28 /** 29 \brief constructs a CommandNode to handle remote input 30 \param ID: unique denumerator to identify the node in the network 31 */ 29 32 CommandNode::CommandNode (int ID) 30 33 { … … 35 38 } 36 39 40 /** 41 \brief constructs a CommandNode to handle local input 42 \param filename: The path and name of the file to load the key bindings from 43 */ 37 44 CommandNode::CommandNode (char* filename = DEFAULT_KEYBIND_FILE) 38 45 { … … 43 50 } 44 51 52 /** 53 \brief removes the CommandNode from memory 54 */ 45 55 CommandNode::~CommandNode () 46 56 { … … 49 59 } 50 60 61 /** 62 \brief loads new key bindings from a file 63 \param filename: The path and name of the file to load the bindings from 64 */ 51 65 void CommandNode::load_bindings (char* filename) 52 66 { … … 101 115 } 102 116 117 /** 118 \brief binds a WorldEntity to the CommandNode 119 \param entity: Pointer to the entity to bind 120 */ 103 121 void CommandNode::bind (WorldEntity* entity) 104 122 { … … 106 124 } 107 125 126 /** 127 \brief removes an entity from the list of the CommandNode 128 \param entity: Pointer to the entity to relese 129 */ 108 130 void CommandNode::unbind (WorldEntity* entity) 109 131 { … … 129 151 } 130 152 153 /** 154 \brief tells the CommandNode to run through all pending events and relay them accordingly 155 */ 131 156 void CommandNode::process () 132 157 { 133 perror("CommandNode|process()");134 158 if( bLocalInput) process_local (); 135 159 else process_network (); … … 208 232 } 209 233 234 /** 235 \brief sets the network identifier of the CommandNode 236 \param ID: the new ID to use 237 */ 210 238 void CommandNode::set_netID (int ID) 211 239 { 240 netID = ID; 212 241 } 213 242 -
orxonox/branches/chris/src/command_node.h
r2105 r2141 34 34 Other SDL_Events are passed to Orxonox::event_handler() to deal with them. If the CommandNode has been created 35 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 his WorldEntities.36 them on to it's WorldEntities. 37 37 */ 38 38 class CommandNode { -
orxonox/branches/chris/src/ini_parser.cc
r2066 r2141 19 19 using namespace std; 20 20 21 /** 22 \brief constructs an IniParser using a file 23 \param filename: the path and name of the file to parse 24 */ 21 25 IniParser::IniParser (char* filename) 22 26 { … … 26 30 } 27 31 32 /** 33 \brief removes the IniParser from memory 34 */ 28 35 IniParser::~IniParser () 29 36 { … … 31 38 } 32 39 40 /** 41 \brief opens another file to parse 42 \param filename: path and name of the new file to parse 43 \return zero on success or -1 if an error occured; 44 */ 33 45 int IniParser::open_file( char* filename) 34 46 { … … 44 56 } 45 57 58 /** 59 \brief set the parsing cursor to the specified section 60 \param section: the name of the section to set the cursor to 61 \return zero on success or -1 if the section could not be found 62 */ 46 63 int IniParser::get_section( char* section) 47 64 { … … 77 94 } 78 95 96 /** 97 \brief gets the next VarName=VarValue pair from the parsing stream 98 \param name: a pointer to a buffer to store the name of the entry 99 \param value: a pointer to a buffer to store the value of the entry 100 \return zero if the buffers have been filled with data or -1 if there are no entries left in the current section 101 */ 79 102 int IniParser::next_var( char* name, char* value) 80 103 { … … 111 134 } 112 135 136 /** 137 \brief directly acesses an entry in a section 138 \param name: the name of the entry to find 139 \param section: the section where the entry is to be found 140 \param defvalue: what should be returned in case the entry cannot be found 141 \return a pointer to a buffer conatining the value of the specified entry. This buffer will contain the data specified in defvalue in case the entry wasn't found 142 143 The returned pointer points to an internal buffer, so do not free it on your own. Do not give a NULL pointer to defvalue, this will certainly 144 lead to unwanted behaviour. 145 */ 113 146 char* IniParser::get_var( char* name, char* section, char* defvalue = "") 114 147 { -
orxonox/branches/chris/src/ini_parser.h
r2066 r2141 15 15 #define PARSELINELENGHT 512 16 16 17 //! ini-file parser 18 /** 19 This class can be used to load an initializer file and parse it's contents for variablename=value pairs. 20 */ 17 21 class IniParser { 18 22 private: -
orxonox/branches/chris/src/keynames.h
r2066 r2141 12 12 #include <SDL/SDL.h> 13 13 14 /** 15 \brief converts a button name string to a integer representing the corresponding SDL mouse button identifier 16 \param name: the name of the mouse button 17 \return an int containing the SDL identifier of the mouse button or -1 if the button name is not valid 18 */ 14 19 int buttonname_to_SDLB( char* name); 20 21 /** 22 \brief converst a SDL mouse button identifier to a name string 23 \param button: an SDL mouse button identifier 24 \return a pointer to a string containing the name of the mouse button 25 */ 15 26 char* SDLB_to_buttonname( int button); 27 28 /** 29 \brief converts a key name string to a integer representing the corresponding SDLK sym 30 \param name: the name of the key 31 \return the SDLK sym of the named key or -1 if the key name is not valid 32 */ 16 33 int keyname_to_SDLK( char* name); 34 35 /** 36 \brief converts an SDLK sym to a name string 37 \param key: the SDLK sym 38 \return a pointer to a string containig the name of the key 39 */ 17 40 char* SDLK_to_keyname( int key); 18 41 -
orxonox/branches/chris/src/message_structures.h
r2066 r2141 1 /*! 2 \file message_structures.h 3 \brief contains defintitons of messages that can be passed between classes 4 */ 1 5 2 6 #ifndef _MESSAGESTRUCTURES_H … … 5 9 #define CMD_LENGHT 16 6 10 7 // structure that contains commands 11 //! structure that contains a command message 8 12 typedef struct 9 13 { 10 char cmd[CMD_LENGHT]; 11 bool bUp; 14 char cmd[CMD_LENGHT]; //!< the command delivered 15 bool bUp; //!< false = command was activated / true = command was deactivated 16 17 //! if cmd is "cursor" the coordinates of the mouse cursor are stored here 18 //!@{ 12 19 Uint16 x, y; 13 Sint16 xrel, yrel; 20 //!@} 21 22 //! if cmd is "cursor" the relative motion of the mouse cursor is stored here 23 //!@{ 24 Sint16 xrel, yrel; 25 //!@} 14 26 } Command; 15 27 -
orxonox/branches/chris/src/orxonox.cc
r2115 r2141 32 32 using namespace std; 33 33 34 /** 35 \brief create a new Orxonox 36 */ 34 37 Orxonox::Orxonox () 35 38 { … … 37 40 } 38 41 39 40 42 /** 43 \brief remove Orxonox from memory 44 */ 41 45 Orxonox::~Orxonox () 42 46 { … … 59 63 } 60 64 65 /** 66 \brief this finds the config file 67 68 Since the config file varies from user to user and since one may want to specify different config files 69 for certain occasions or platforms this function finds the right config file for every occasion and stores 70 it's path and name into configfilename 71 */ 61 72 void Orxonox::get_config_file (int argc, char** argv) 62 73 { … … 75 86 } 76 87 88 /** 89 \brief initialize Orxonox with command line 90 */ 77 91 int Orxonox::init (int argc, char** argv) 78 92 { … … 107 121 } 108 122 123 /** 124 \brief initializes SDL and OpenGL 125 */ 109 126 int Orxonox::init_video () 110 127 { … … 148 165 } 149 166 167 /** 168 \brief initializes the sound engine 169 */ 150 170 int Orxonox::init_sound () 151 171 { … … 154 174 } 155 175 176 /** 177 \brief initializes input functions 178 */ 156 179 int Orxonox::init_input () 157 180 { … … 162 185 } 163 186 164 187 /** 188 \brief initializes network system 189 */ 165 190 int Orxonox::init_networking () 166 191 { … … 169 194 } 170 195 196 /** 197 \brief initializes and loads resource files 198 */ 171 199 int Orxonox::init_resources () 172 200 { … … 175 203 } 176 204 205 /** 206 \brief initializes the world 207 */ 177 208 int Orxonox::init_world () 178 209 { … … 185 216 } 186 217 218 /** 219 \brief exits Orxonox 220 */ 187 221 void Orxonox::quitGame() 188 222 { 189 223 bQuitOrxonox = true; 190 224 } 225 226 /** 227 \brief this runs all of Orxonox 228 */ 191 229 void Orxonox::mainLoop() 192 230 { … … 211 249 } 212 250 251 /** 252 \brief handles sprecial events from localinput 253 \param event: an event not handled by the CommandNode 254 */ 213 255 void Orxonox::event_handler (SDL_Event* event) 214 256 { … … 216 258 } 217 259 260 /** 261 \brief synchronize local data with remote data 262 */ 218 263 void Orxonox::synchronize () 219 264 { … … 222 267 } 223 268 269 /** 270 \brief run all input processing 271 */ 224 272 void Orxonox::handle_input () 225 273 { … … 229 277 } 230 278 279 /** 280 \brief advance the timeline 281 */ 231 282 void Orxonox::time_slice () 232 283 { … … 241 292 } 242 293 294 /** 295 \brief compute collision detection 296 */ 243 297 void Orxonox::collision () 244 298 { … … 246 300 } 247 301 302 /** 303 \brief handle keyboard commands that are not meant for WorldEntities 304 \param cmd: the command to handle 305 \return true if the command was handled by the system or false if it may be passed to the WorldEntities 306 */ 248 307 bool Orxonox::system_command (Command* cmd) 249 308 { 250 if( !strcmp( cmd->cmd, "quit") && !cmd->bUp)309 if( !strcmp( cmd->cmd, "quit")) 251 310 { 252 bQuitOrxonox = true;311 if( !cmd->bUp) bQuitOrxonox = true; 253 312 return true; 254 313 } … … 256 315 } 257 316 317 /** 318 \brief render the current frame 319 */ 258 320 void Orxonox::display () 259 321 { … … 269 331 } 270 332 333 /** 334 \brief retrieve a pointer to the local Camera 335 \return a pointer to localcamera 336 */ 271 337 Camera* Orxonox::get_camera () 272 338 { … … 274 340 } 275 341 342 /** 343 \brief retrieve a pointer to the local CommandNode 344 \return a pointer to localinput 345 */ 276 346 CommandNode* Orxonox::get_localinput () 277 347 { … … 279 349 } 280 350 351 /** 352 \brief retrieve a pointer to the local World 353 \return a pointer to world 354 */ 281 355 World* Orxonox::get_world () 282 356 { … … 296 370 297 371 (*orx).mainLoop(); 372 373 delete orx; 298 374 299 375 return 0; -
orxonox/branches/chris/src/orxonox.h
r2105 r2141 1 /*! 2 \file orxonox.h 3 \brief Orxonox core functions 4 */ 1 5 2 6 #ifndef ORXONOX_H … … 13 17 class Camera; 14 18 19 //! Orxonox core singleton class 20 /** 21 */ 15 22 class Orxonox { 16 23 -
orxonox/branches/chris/src/player.h
r2101 r2141 1 /*! 2 \file player.h 3 \brief Implements a basic controllable WorldEntity 4 */ 1 5 2 6 #ifndef PLAYER_H … … 5 9 #include "world_entity.h" 6 10 11 //! Basic controllable WorldEntity 7 12 class Player : public WorldEntity 8 13 { -
orxonox/branches/chris/src/track.cc
r2115 r2141 20 20 using namespace std; 21 21 22 /** 23 \brief creates a null Track part 24 */ 22 25 Track::Track () 23 26 { … … 28 31 } 29 32 33 /** 34 \brief creates a functional base Track part 35 \param number: the ID if this Track part 36 \param next: the ID of the next Track part 37 \param start: pointer to an anchor point (Vector) representing the offset of this part 38 \param finish: pointer to an anchor point (Vector) representing the end of this part 39 */ 30 40 Track::Track (Uint32 number, Uint32 next, Vector* start, Vector* finish) 31 41 { … … 36 46 } 37 47 48 /** 49 \brief removes the Track part from memory 50 */ 38 51 Track::~Track () 39 52 { 40 53 } 41 54 55 /** 56 \brief calculate a camera Placement from a "look at"-Location 57 \param lookat: the Location the camera should be centered on 58 \param camplc: pointer to a buffer where the new camera Placement should be put into 59 60 Theoretically you can place the camera wherever you want, but for the sake of common sense I suggest that you at least 61 try to keep the thing that should be looked at inside camera boundaries. 62 */ 42 63 void Track::map_camera (Location* lookat, Placement* camplc) 43 64 { 44 printf("Track|Mapping camera: %d (%f)\n", lookat->part, lookat->dist);45 65 Line trace(*offset, *end - *offset); 46 66 float l = trace.len (); … … 48 68 // camplc->r = *offset + Vector(0,0,0.5); 49 69 // camplc->w = Quaternion (trace.a, Vector(0,0,1)); 50 70 float r = (lookat->dist)*PI / l; 51 71 camplc->r = trace.r + (trace.a * ((lookat->dist-10.0) / l)) + Vector(0,0,5.0); 52 camplc->w = Quaternion(Vector(0,0,0) - ((trace.r + (trace.a * ((lookat->dist) / l)) - camplc->r)), Vector(0, 0,1));72 camplc->w = Quaternion(Vector(0,0,0) - ((trace.r + (trace.a * ((lookat->dist) / l)) - camplc->r)), Vector(0,sin(r),cos(r))); 53 73 54 74 } 55 75 76 /** 77 \brief calculate a Placement from a given Location 78 \param loc: the Location the entity is in 79 \param plc: a pointer to a buffer where the corresponding Placement should be put into 80 81 There are no limitations to how you transform a Location into a Placement, but for the sake of placement compatibility between 82 track parts you should make sure that the resulting Placement at dist == 0 is equal to the offset Vector and the Placement at 83 dist == len() is equal to the end Vector. Elseway there will be ugly artifacts when transfering between track parts. 84 */ 56 85 bool Track::map_coords (Location* loc, Placement* plc) 57 86 { 58 printf("Track|Mapping coords: %d (%f)\n", loc->part, loc->dist);59 87 Line trace(*offset, *end - *offset); 60 88 float l = trace.len (); … … 75 103 } 76 104 105 /** 106 \brief this is called when a WorldEntity enters a Track part 107 \param entity: pointer to the WorldEntity in question 108 109 You can do stuff like add or remove effects, do some coordinate finetuning or whatever in here. 110 */ 77 111 void Track::post_enter (WorldEntity* entity) 78 112 { 79 113 } 80 114 115 /** 116 \brief this is called when a WorldEntity leaves a Track part 117 \param entity: pointer to the WorldEntity in question 118 119 You can do stuff like add or remove effects, do some coordinate finetuning or whatever in here. 120 */ 81 121 void Track::post_leave (WorldEntity* entity) 82 122 { 83 123 } 84 124 125 /** 126 \brief this is called every frame 127 \param deltaT: amount of time passed since the last frame in seconds 128 129 Do time based or polling scripts here. 130 */ 85 131 void Track::tick (float deltaT) 86 132 { -
orxonox/branches/chris/src/track.h
r2101 r2141 1 /*! 2 \file track.h 3 \brief Basic level architecture 4 */ 1 5 2 6 #ifndef TRACK_H … … 5 9 #include "stdincl.h" 6 10 11 //! The Red Line through a level 12 /** 13 Handles level boundaries, bound movement mapping, camera placement and scripting. 14 To create special levels with special camera movement, rules or whatever, derive from this base class. 15 */ 7 16 class Track 8 17 { -
orxonox/branches/chris/src/vector.cc
r2112 r2141 181 181 } 182 182 183 /** 184 \brief creates a multiplicational identity Quaternion 185 */ 183 186 Quaternion::Quaternion () 184 187 { … … 187 190 } 188 191 192 /** 193 \brief turns a rotation along an axis into a Quaternion 194 \param angle: the amount of radians to rotate 195 \param axis: the axis to rotate around 196 */ 189 197 Quaternion::Quaternion (float angle, const Vector& axis) 190 198 { … … 193 201 } 194 202 203 /** 204 \brief calculates a look_at rotation 205 \param dir: the direction you want to look 206 \param up: specify what direction up should be 207 208 Mathematically this determines the rotation a (0,0,1)-Vector has to undergo to point the same way as dir. 209 If you want to use this with cameras, you'll have to reverse the dir Vector (Vector(0,0,0) - your viewing direction) 210 or you'll point the wrong way. You can use this for meshes as well (then you do not have to reverse the vector), but keep in mind that if you do that, the model's front 211 has to point in +z direction, and left and right should be -x or +x respectively or the mesh wont rotate correctly. 212 */ 195 213 Quaternion::Quaternion (const Vector& dir, const Vector& up) 196 214 { … … 222 240 } 223 241 242 /** 243 \brief calculates a rotation from euler angles 244 \param roll: the roll in radians 245 \param pitch: the pitch in radians 246 \param yaw: the yaw in radians 247 248 I DO HONESTLY NOT EXACTLY KNOW WHICH ANGLE REPRESENTS WHICH ROTATION. And I do not know in what order they are applied, 249 I just copy-pasted the code. 250 */ 224 251 Quaternion::Quaternion (float roll, float pitch, float yaw) 225 252 { … … 244 271 } 245 272 273 /** 274 \brief rotates one Quaternion by another 275 \param q: another Quaternion to rotate this by 276 \return a quaternion that represents the first one rotated by the second one (WARUNING: this operation is not commutative! e.g. (A*B) != (B*A)) 277 */ 246 278 Quaternion Quaternion::operator*(const Quaternion& q) const 247 279 { … … 266 298 } 267 299 300 /** 301 \brief add two Quaternions 302 \param q: another Quaternion 303 \return the sum of both Quaternions 304 */ 268 305 Quaternion Quaternion::operator+(const Quaternion& q) const 269 306 { … … 274 311 } 275 312 313 /** 314 \brief subtract two Quaternions 315 \param q: another Quaternion 316 \return the difference of both Quaternions 317 */ 276 318 Quaternion Quaternion::operator- (const Quaternion& q) const 277 319 { … … 282 324 } 283 325 326 /** 327 \brief rotate a Vector by a Quaternion 328 \param v: the Vector 329 \return a new Vector representing v rotated by the Quaternion 330 */ 284 331 Vector Quaternion::apply (Vector& v) const 285 332 { … … 291 338 } 292 339 340 /** 341 \brief multiply a Quaternion with a real value 342 \param f: a real value 343 \return a new Quaternion containing the product 344 */ 293 345 Quaternion Quaternion::operator*(const float& f) const 294 346 { … … 299 351 } 300 352 353 /** 354 \brief divide a Quaternion by a real value 355 \param f: a real value 356 \return a new Quaternion containing the quotient 357 */ 301 358 Quaternion Quaternion::operator/(const float& f) const 302 359 { … … 308 365 } 309 366 367 /** 368 \brief calculate the conjugate value of the Quaternion 369 \return the conjugate Quaternion 370 */ 310 371 Quaternion Quaternion::conjugate() const 311 372 { … … 315 376 } 316 377 378 /** 379 \brief calculate the norm of the Quaternion 380 \return the norm of The Quaternion 381 */ 317 382 float Quaternion::norm() const 318 383 { … … 320 385 } 321 386 387 /** 388 \brief calculate the inverse value of the Quaternion 389 \return the inverse Quaternion 390 391 Note that this is equal to conjugate() if the Quaternion's norm is 1 392 */ 322 393 Quaternion Quaternion::inverse() const 323 394 { … … 330 401 } 331 402 403 /** 404 \brief convert the Quaternion to a 4x4 rotational glMatrix 405 \param m: a buffer to store the Matrix in 406 */ 332 407 void Quaternion::matrix (float m[4][4]) const 333 408 { … … 355 430 } 356 431 432 /** 433 \brief convert a rotational 4x4 glMatrix into a Quaternion 434 \param m: a 4x4 matrix in glMatrix order 435 */ 357 436 Quaternion::Quaternion (float m[4][4]) 358 437 { -
orxonox/branches/chris/src/vector.h
r2112 r2141 12 12 #define PI 3.14159265359f 13 13 14 //! 3D Vector 15 /** 16 Class to handle 3D Vectors 17 */ 14 18 class Vector { 15 19 … … 43 47 { 44 48 public: 45 Vector v; 46 float w; 49 Vector v; //!< Imaginary Vector 50 float w; //!< Real part of the number 47 51 48 52 Quaternion (); -
orxonox/branches/chris/src/world.cc
r2115 r2141 27 27 28 28 /** 29 \brief Create a new World29 \brief create a new World 30 30 31 31 This creates a new empty world! … … 36 36 } 37 37 38 38 /** 39 \brief remove the World from memory 40 */ 39 41 World::~World () 40 42 { … … 43 45 } 44 46 47 /** 48 \brief checks for collisions 49 50 This method runs through all WorldEntities known to the world and checks for collisions between them. 51 In case of collisions the collide() method of the corresponding entities is called. 52 */ 45 53 void World::collide () 46 54 { … … 75 83 } 76 84 85 /** 86 \brief runs through all entities calling their draw() methods 87 */ 77 88 void World::draw () 78 89 { … … 140 151 } 141 152 153 /** 154 \brief updates Placements and notifies entities when they left the world 155 156 This runs trough all WorldEntities and maps Locations to Placements if they are bound, checks 157 whether they left the level boundaries and calls appropriate functions. 158 */ 142 159 void World::update () 143 160 { … … 190 207 } 191 208 209 /** 210 \brief relays the passed time since the last frame to entities and Track parts 211 \param deltaT: the time passed since the last frame in milliseconds 212 */ 192 213 void World::time_slice (Uint32 deltaT) 193 214 { … … 209 230 } 210 231 232 /** 233 \brief removes level data from memory 234 */ 211 235 void World::unload() 212 236 { … … 215 239 } 216 240 241 /** 242 \brief loads a simple level for testing purposes 243 */ 217 244 void World::load_debug_level() 218 245 { … … 245 272 } 246 273 274 /** 275 \brief calls the correct mapping function to convert a given "look at"-Location to a Camera Placement 276 */ 247 277 void World::calc_camera_pos (Location* loc, Placement* plc) 248 278 { -
orxonox/branches/chris/src/world.h
r2112 r2141 1 /*! 2 \file world.h 3 \brief Holds and manages all game data 4 */ 1 5 2 6 #ifndef WORLD_H … … 8 12 class WorldEntity; 9 13 14 //! The game environment 10 15 class World { 11 16 … … 40 45 }; 41 46 47 /** 48 \brief spawn a new WorldEntity at a Location 49 \param loc: the Location where the Entity should be spawned 50 \param owner: a pointer to the parent of the Entity 51 \return a pointer to the new WorldEntity or NULL if there was an error 52 53 You can use this function to spawn any derivation of WorldEntity you want, just specify the desired 54 class within the template specification brackets. Do not attempt to spawn any classes that have NOT been 55 derived from WorldEntity, you won't even be able to compile the code. Note that this version of spawn() 56 works with both free and bound WorldEntities. 57 */ 42 58 template<typename T> T* World::spawn(Location* loc = NULL, WorldEntity* owner = NULL) 43 59 { … … 62 78 } 63 79 80 /** 81 \brief spawn a new WorldEntity at a Placement 82 \param lplc: the placement where the Entity should be spawned 83 \param owner: a pointer to the parent of the Entity 84 \return a pointer to the new WorldEntity or NULL if there was an error 85 86 You can use this function to spawn any FREE derivation of WorldEntity you want, just specify the desired 87 class within the template specification brackets. Do not attempt to spawn any classes that have NOT been 88 derived from WorldEntity, you won't even be able to compile the code. Note that this version of spawn() 89 works with free WorldEntities only, you will provoke an error message if you try to spawn a bound Entity with 90 a Placement. 91 */ 64 92 template<typename T> T* World::spawn(Placement* plc, WorldEntity* owner = NULL) 65 93 { -
orxonox/branches/chris/src/world_entity.cc
r2112 r2141 24 24 using namespace std; 25 25 26 27 26 /** 28 \brief 29 \param v: 30 \return 31 */ 32 33 /** 34 \brief Constructor 35 36 This Constructor initializises the all WorldEntities. Everything, that is a part of the game-world is a child of WorldEntity. This class implements empty functions for all sort of operation a WorldEntity has to or can implement. 37 This is some sort of standard interface to all WorldEntities... 27 \brief standard constructor 28 29 Every derived contructor HAS to call the previous one supplying the isFree parameter. This is necessary to distunguish 30 between free and bound entities. The difference between them is simply the fact that the movement of a free entity is 31 not bound to the track of a world. Use this to implement projectile or effect classes that do not have to travel along the track. 32 To specify an entity to be free or bound set the default parameter in the declaration of the constructor. 33 Theoretically you should never have to call the constructor of an Entity directly, for it is called by the spawn() function of the World 34 class. So if you want to create a new entity at any time, call World::spawn(). It will handle everything that is necessary. 38 35 */ 39 36 WorldEntity::WorldEntity (bool isFree) : bFree(isFree) … … 43 40 } 44 41 45 WorldEntity::~WorldEntity () {} 42 /** 43 \brief standard destructor 44 */ 45 WorldEntity::~WorldEntity () 46 { 47 if( collisioncluster != NULL) delete collisioncluster; 48 } 46 49 50 /** 51 \brief get the Location of the WorldEntity 52 \return a pointer to location 53 */ 47 54 Location* WorldEntity::get_location () 48 55 { … … 50 57 } 51 58 59 /** 60 \brief get the Placement of the WorldEntity 61 \return a pointer to placement 62 */ 52 63 Placement* WorldEntity::get_placement () 53 64 { … … 55 66 } 56 67 68 /** 69 \brief query whether the WorldEntity in question is free 70 \return true if the WorldEntity is free or false if it isn't 71 */ 57 72 bool WorldEntity::isFree () 58 73 { … … 60 75 } 61 76 77 /** 78 \brief set the WorldEntity's collision hull 79 \param newhull: a pointer to a completely assembled CollisionCluster 80 81 Any previously assigned collision hull will be deleted on reassignment 82 */ 62 83 void WorldEntity::set_collision (CollisionCluster* newhull) 63 84 { … … 68 89 69 90 /** 70 \brief this method is called every tick 71 \param time: the time since start of the world 72 73 This function is called before every repaint of the world, to update every time dependent variable of the entity. If the entity moves, it has to calculate the new position every tick here in this function. Do not use this for animations. 91 \brief this method is called every frame 92 \param time: the time in seconds that has passed since the last tick 93 94 Handle all stuff that should update with time inside this method (movement, animation, etc.) 74 95 */ 75 96 void WorldEntity::tick(float time) 76 {} 97 { 98 } 77 99 78 100 /** 79 \brief the entity is paintedto the screen with this function101 \brief the entity is drawn onto the screen with this function 80 102 81 103 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. … … 83 105 void WorldEntity::draw() 84 106 { 85 printf("WorldEntity|draw()\n");86 107 } 87 108 88 /* virtual void WorldEntity::actionEvent(Event* event); */89 109 /** 90 \brief this function is called, when two entities collide 91 \param we: the world entity, with whom it collides 92 \param loc: place where the collision happens 110 \brief this function is called, when two entities collide 111 \param other: the world entity with whom it collides 112 \param ownhitflags: flags to the CollisionCluster subsections that registered an impact 113 \param otherhitflags: flags to the CollisionCluster subsections of the other entity that registered an impact 114 115 Implement behaviour like damage application or other miscellaneous collision stuff in this function 93 116 */ 94 117 void WorldEntity::collide(WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags) {} … … 104 127 105 128 /** 106 \brief this function is called , ifthe entity is to be destroied129 \brief this function is called when the entity is to be destroied 107 130 108 131 This can be called, if eg. something realy bad happens :) … … 110 133 void WorldEntity::destroy() {} 111 134 135 136 /** 137 \brief basic initialisation for bound Entities 138 */ 112 139 void WorldEntity::init( Location* spawnloc, WorldEntity* spawnowner) 113 140 { … … 116 143 } 117 144 145 /** 146 \brief basic initialisation for free Entities 147 */ 118 148 void WorldEntity::init( Placement* spawnplc, WorldEntity* spawnowner) 119 149 { … … 122 152 } 123 153 154 /** 155 \brief this is called immediately after the Entity has been constructed and initialized 156 157 Put any initialisation code that requires knowledge of location (placement if the Entity is free) and owner of the entity here. 158 DO NOT place such code in the constructor, those variables are set AFTER the entity is constucted. 159 */ 124 160 void WorldEntity::post_spawn () 125 161 { 126 162 } 127 163 164 /** 165 \brief this handles incoming command messages 166 \param cmd: a pointer to the incoming Command structure 167 168 Put all code that handles Command messages here, this will mainly be called by the assigned CommandNode but can also be used 169 to send commands from one WorldEntity to another. 170 */ 128 171 void WorldEntity::command (Command* cmd) 129 172 { 130 173 } 131 174 175 /** 176 \brief this is called by the local Camera to determine the point it should look at on the WorldEntity 177 \param locbuf: a pointer to the buffer to fill with a location to look at 178 179 You may put any Location you want into locbuf, the Camera will determine via the corresponding Track how 180 to look at the location you return with this. 181 */ 132 182 void WorldEntity::get_lookat (Location* locbuf) 133 183 { 134 184 } 135 185 186 /** 187 \brief this method is called by the world if the WorldEntity leaves valid gamespace 188 189 For free entities this means it left the Track boundaries. With bound entities it means its Location adresses a 190 place that is not in the world anymore. In both cases you might have to take extreme measures (a.k.a. call destroy). 191 */ 136 192 void WorldEntity::left_world () 137 193 { -
orxonox/branches/chris/src/world_entity.h
r2101 r2141 1 /*! 2 \file world_entity.h 3 \brief Definition of the basic WorldEntity 4 */ 1 5 2 6 #ifndef WORLD_ENTITY_H … … 7 11 class CollisionCluster; 8 12 13 //! Basic class from which all interactive stuff in the world is derived from 9 14 class WorldEntity 10 15 {
Note: See TracChangeset
for help on using the changeset viewer.