Changeset 5968 in orxonox.OLD for branches/network/src
- Timestamp:
- Dec 7, 2005, 4:16:51 PM (19 years ago)
- Location:
- branches/network/src
- Files:
-
- 3 deleted
- 66 edited
- 22 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/Makefile.am
r5830 r5968 21 21 lib/collision_detection/libORXcd.a \ 22 22 lib/graphics/spatial_separation/libORXquadtree.a \ 23 lib/tinyxml/libtinyxml.a \ 23 lib/parser/tinyxml/libtinyxml.a \ 24 lib/parser/ini_parser/libIniParser.a \ 24 25 lib/gui/gl_gui/libORXglgui.a \ 25 26 lib/shell/libORXshell.a \ … … 37 38 lib/particles/libORXparticles.a \ 38 39 lib/graphics/spatial_separation/libORXquadtree.a \ 39 lib/tinyxml/libtinyxml.a \ 40 lib/parser/tinyxml/libtinyxml.a \ 41 lib/parser/ini_parser/libIniParser.a \ 40 42 lib/gui/gl_gui/libORXglgui.a \ 41 43 lib/shell/libORXshell.a \ … … 49 51 world_entities/world_entity.cc \ 50 52 world_entities/camera.cc \ 53 world_entities/playable.cc \ 51 54 world_entities/player.cc \ 52 55 world_entities/npcs/npc.cc \ … … 78 81 world_entities/power_ups/turret_power_up.cc \ 79 82 world_entities/power_ups/laser_power_up.cc \ 83 world_entities/space_ships/space_ship.cc \ 80 84 subprojects/benchmark.cc 81 85 … … 89 93 world_entities/world_entity.h \ 90 94 world_entities/camera.h \ 95 world_entities/playable.h \ 91 96 world_entities/player.h \ 92 97 world_entities/npcs/npc.h \ -
branches/network/src/defs/class_id.h
r5822 r5968 57 57 // superclasses 58 58 CL_MASK_SUPER_CLASS = 0xff000000, 59 CL_BASE_OBJECT = 0x ff000000,59 CL_BASE_OBJECT = 0x00000000, 60 60 61 61 CL_PARENT_NODE = 0x01000000, … … 69 69 CL_ELEMENT_2D = 0x10000000, 70 70 71 CL_SYNCHRONIZEABLE 71 CL_SYNCHRONIZEABLE = 0x20000000, 72 72 73 73 CL_WORLD_ENTITY = 0x40000000, 74 74 75 75 // subsuper-classes derivations taken : 1, 2, 5, a, b, c. << THIS IS A LIST OF ALL THE DCL_MASK_SUBSUPERCLASS_ID's taken 76 76 // subsuper-classes 77 77 CL_MASK_SUBSUPER_CLASS = 0x00fff000, 78 CL_MASK_SUBSUPER_CLASS_ID = 0x00f00000, 79 CL_MASK_SUBSUPER_CLASS_ID2 = 0x000ff000, 80 CL_PLAYER = 0x00101000, 81 CL_NPC = 0x00102000, 82 CL_POWER_UP = 0x00104000, 83 CL_FIELD = 0x00108000, 84 CL_PROJECTILE = 0x00110000, 85 CL_WEAPON = 0x00120000, 86 87 // subsuper-classes derivations taken : 1, 5, a, b, c. << THIS IS A LIST OF ALL THE DCL_MASK_SUBSUPERCLASS_ID's taken 78 CL_MASK_SUBSUPER_CLASS_IDA = 0x00f00000, 79 CL_MASK_SUBSUPER_CLASS_IDB = 0x000ff000, 80 // SUPER-PNodes 81 CL_FIELD = 0x00101000, 82 // SUPER-WorldEntities 83 CL_PLAYABLE = 0x00201000, 84 CL_PLAYER = 0x00202000, 85 CL_NPC = 0x00204000, 86 CL_PROJECTILE = 0x00208000, 87 CL_WEAPON = 0x00210000, 88 CL_POWER_UP = 0x00220000, 89 90 // SUPER-Modeling 91 CL_TEXTURE = 0x00c01000, 92 CL_MODEL = 0x00c02000, 93 94 95 // subsuper-classes derivations taken : 1, 2, 5, a, b, c. << THIS IS A LIST OF ALL THE DCL_MASK_SUBSUPERCLASS_ID's taken 88 96 89 97 // lowest level classes … … 120 128 121 129 130 122 131 // StoryEntities (range from 0x00000100 to 0x000001ff) 123 132 CL_CAMPAIGN = 0x00000101, … … 135 144 CL_TERRAIN = 0x00000207, 136 145 CL_TEST_ENTITY = 0x00000209, 146 CL_SPACE_SHIP = 0x0000020a, 137 147 138 148 CL_TURRET_POWER_UP = 0x00000211, … … 177 187 178 188 // graphical stuff (range from 0x00000800 to 0x000009ff) 179 CL_TEXTURE = 0x00c01000, 189 CL_FONT = 0x00c02802, 190 191 180 192 CL_TEXT = 0x00b01801, 181 CL_FONT = 0x00c02802,182 193 CL_MATERIAL = 0x00000804, 183 CL_ MODEL = 0x00000805, //!< @todo make this a SUBCLASS maybe184 CL_OBJMODEL = 0x0000080 6,185 CL_PROMITIVE_MODEL = 0x0000080 7,186 CL_MD2Model = 0x0000080 8,187 CL_LIGHT = 0x0000080 9,188 CL_PARTICLE_EMITTER = 0x0000080 a,189 CL_PARTICLE_SYSTEM = 0x0000080 b,194 CL_TEXTURE_SEQUENCE = 0x00c04805, 195 CL_OBJMODEL = 0x00000807, 196 CL_PROMITIVE_MODEL = 0x00000808, 197 CL_MD2Model = 0x00000809, 198 CL_LIGHT = 0x0000080a, 199 CL_PARTICLE_EMITTER = 0x0000080b, 200 CL_PARTICLE_SYSTEM = 0x0000080c, 190 201 CL_ENVIRONMENT = 0x00000810, 191 202 CL_SHADER = 0x00000811, -
branches/network/src/defs/debug.h
r5833 r5968 27 27 28 28 #include "confincl.h" 29 #include "shell_buffer.h" 29 #ifndef NO_SHELL 30 #include "shell_buffer.h" 31 #endif /* NO_SHELL */ 30 32 31 33 #include <stdio.h> … … 78 80 #define DEBUG_MODULE_SPATIAL_SEPARATION 2 79 81 #define DEBUG_MODULE_GUI 2 82 #define DEBUG_MODULE_SOUND 2 80 83 81 84 // MISC -
branches/network/src/defs/globals.h
r5829 r5968 45 45 #define CONFIG_NAME_DATADIR "DataDir" 46 46 #define CONFIG_NAME_AUTO_UPDATE "Auto-Update" 47 47 48 #define CONFIG_NAME_FULLSCREEN "Fullscreen-mode" 48 49 #define CONFIG_NAME_RESOLUTION "Resolution" … … 57 58 #define CONFIG_NAME_ANTI_ALIASING "Anti-Aliasing" 58 59 #define CONFIG_NAME_FILTER_METHOD "Filtering-Method" 60 59 61 #define CONFIG_NAME_DISABLE_AUDIO "Disable-Audio" 62 #define CONFIG_NAME_AUDIO_CHANNELS "Audio-Channels" 60 63 #define CONFIG_NAME_MUSIC_VOLUME "Music-Volume" 61 64 #define CONFIG_NAME_EFFECTS_VOLUME "Effects-Volume" 65 62 66 #define CONFIG_NAME_SAVE_SETTINGS "Save-Settings" 63 67 #define CONFIG_NAME_VERBOSE_MODE "Verbose-Mode" -
branches/network/src/lib/Makefile.am
r5822 r5968 15 15 network/libORXnet.a \ 16 16 graphics/spatial_separation/libORXquadtree.a \ 17 tinyxml/libtinyxml.a \ 17 parser/tinyxml/libtinyxml.a \ 18 parser/ini_parser/libIniParser.a \ 18 19 shell/libORXshell.a 19 20 … … 29 30 network/libORXnet.a \ 30 31 graphics/spatial_separation/libORXquadtree.a \ 31 tinyxml/libtinyxml.a \32 32 shell/libORXshell.a \ 33 33 $(GTK2_LIBS) $(GTHREAD_LIBS) $(CURL_LIBS) … … 37 37 lang/base_object.cc \ 38 38 lang/class_list.cc \ 39 util/ini_parser.cc \40 39 util/substring.cc \ 41 40 util/color.cc \ … … 53 52 graphics/render2D/render_2d.h \ 54 53 lang/class_list.h \ 55 util/ini_parser.h \56 54 util/substring.h \ 57 55 util/array.h \ … … 75 73 collision_detection \ 76 74 network \ 77 tinyxml\75 parser \ 78 76 shell \ 79 77 gui \ -
branches/network/src/lib/collision_detection/cd_engine.cc
r5134 r5968 24 24 #include "world_entity.h" 25 25 #include "terrain.h" 26 #include "player.h"26 // #include "player.h" 27 27 28 28 #include "spatial_separation.h" … … 119 119 Quadtree* q = this->terrain->ssp->getQuadtree(); 120 120 121 QuadtreeNode* n = q->getQuadtreeFromPosition(this->player->getAbsCoor());121 // QuadtreeNode* n = q->getQuadtreeFromPosition(this->player->getAbsCoor()); 122 122 } 123 123 //sTriangleExt* tri = q->getTriangleFromPosition(this->player->getAbsCoor()); -
branches/network/src/lib/collision_detection/cd_engine.h
r5039 r5968 17 17 class OBBTree; 18 18 class Terrain; 19 class Player;19 //class Player; 20 20 21 21 … … 51 51 inline void setEntityList(tList<WorldEntity>* entityList) { this->entityList = entityList; } 52 52 inline void setTerrain(Terrain* terrain) { this->terrain = terrain; } 53 inline void setPlayer(Player* player) { this->player = player; } /* only for debug purposes \todo: delete*/53 // inline void setPlayer(Player* player) { this->player = player; } /* only for debug purposes \todo: delete*/ 54 54 55 55 void drawBV(int depth, int drawMode) const; … … 79 79 80 80 Terrain* terrain; //!< this it a ref to the terrain, serving as a ground for all WE 81 Player* player;81 // Player* player; 82 82 }; 83 83 -
branches/network/src/lib/coord/p_node.cc
r5819 r5968 428 428 429 429 this->bias = bias; 430 this->bRelDirChanged = true; 430 431 } 431 432 … … 836 837 glEnd(); 837 838 } 839 838 840 /* if we want to draw the children too */ 839 841 if (depth == 0) /* -> all of them */ -
branches/network/src/lib/coord/p_node.h
r5770 r5968 76 76 inline const Vector& getRelCoor () const { return this->prevRelCoordinate; }; 77 77 /** @returns the Relative Coordinate Destination */ 78 inline const Vector& getRelCoorSoft2D() const { return (this->toCoordinate)? *this->toCoordinate:this->relCoordinate; };78 inline const Vector& getRelCoorSoft2D() const { return (this->toCoordinate)? *this->toCoordinate : this->relCoordinate; }; 79 79 void setAbsCoor (const Vector& absCoord); 80 80 void setAbsCoor (float x, float y, float z); … … 93 93 inline const Quaternion& getRelDir () const { return this->prevRelDirection; }; 94 94 /** @returns the Relative Directional Destination */ 95 inline const Quaternion& getRelDirSoft2D() const { return (this->toDirection)? *this->toDirection:this->relDirection; };95 inline const Quaternion& getRelDirSoft2D() const { return (this->toDirection)? *this->toDirection : this->relDirection; }; 96 96 /** @returns a Vector pointing into the relative Direction */ 97 97 inline Vector getRelDirV() const { return this->prevRelDirection.apply(Vector(0,1,0)); }; … … 100 100 void setAbsDirSoft(const Quaternion& absDirSoft, float bias = 1.0); 101 101 void setAbsDirSoft(float x, float y, float z, float bias = 1.0); 102 void shiftDir (const Quaternion& shift); 102 103 /** @returns the absolute Direction */ 103 104 inline const Quaternion& getAbsDir () const { return this->absDirection; }; 104 105 /** @returns a Vector pointing into the absolute Direction */ 105 106 inline Vector getAbsDirV() const { return this->absDirection.apply(Vector(0,1,0)); }; 106 void shiftDir (const Quaternion& shift); 107 /** @returns A Vector pointing into the forward direction (X) of the Node */ 108 inline Vector getAbsDirX() const { return this->absDirection.apply(Vector(1,0,0)); }; 109 /** @returns A Vector pointing into the upward direction (Y) of the Node */ 110 inline Vector getAbsDirY() const { return this->absDirection.apply(Vector(0,1,0)); }; 111 /** @returns A Vector pointing into the right direction (Z) of the Node */ 112 inline Vector getAbsDirZ() const { return this->absDirection.apply(Vector(0,0,1)); }; 107 113 108 114 /** @returns the Speed of the Node */ -
branches/network/src/lib/event/key_mapper.cc
r5474 r5968 21 21 #include "key_mapper.h" 22 22 23 #include "event_def.h" 24 23 25 #include "globals.h" 24 #include " ini_parser.h"26 #include "parser/ini_parser/ini_parser.h" 25 27 #include "key_names.h" 26 28 #include "debug.h" 29 27 30 28 31 using namespace std; … … 129 132 int* index; 130 133 131 iniParser-> getFirstVar();134 iniParser->firstVar(); 132 135 while(iniParser->getCurrentName()) 133 136 { … … 148 151 } 149 152 150 iniParser-> getFirstVar();153 iniParser->firstVar(); 151 154 while(iniParser->getCurrentName()) 152 155 { … … 191 194 { 192 195 if( index[0] == 0) 193 196 { 194 197 *map[i].pValue = index[1]; 195 198 PRINTF(4)("Mapping %s to '%s' (id %i)\n", name, SDLKToKeyname(index[1]), index[1]); 196 199 break; 197 198 else { 200 } 201 else { 199 202 *map[i].pValue = index[1]; 200 203 PRINTF(4)("Mapping %s to '%s' (id %i)\n", name, SDLBToButtonname(index[1]), index[1]); 201 204 break; 202 205 } 203 206 } 204 207 } -
branches/network/src/lib/event/key_mapper.h
r5819 r5968 10 10 11 11 #include "base_object.h" 12 #include "event_def.h"12 //#include "event_def.h" 13 13 14 14 class IniParser; … … 66 66 67 67 private: 68 Sint32coord[2]; //!< temp place to save variables in nameToIndex() function68 int coord[2]; //!< temp place to save variables in nameToIndex() function 69 69 }; 70 70 -
branches/network/src/lib/graphics/graphics_engine.cc
r5819 r5968 26 26 #include "debug.h" 27 27 28 #include " ini_parser.h"28 #include "parser/ini_parser/ini_parser.h" 29 29 #include "substring.h" 30 30 #include "text.h" 31 31 32 32 #include "globals.h" 33 #include "texture.h" 33 34 34 35 #ifdef __WIN32__ 35 36 #include "class_list.h" 36 #include "texture.h"37 37 #include "list.h" 38 38 #include "model.h" … … 131 131 const char* textures = iniParser->getVar(CONFIG_NAME_TEXTURES, CONFIG_SECTION_VIDEO_ADVANCED, "0"); 132 132 if (strchr(textures, '1') || !strcasecmp(textures, "true")) 133 this->texturesEnabled = true;133 Texture::setTextureEnableState( true); 134 134 else 135 this->texturesEnabled = false;135 Texture::setTextureEnableState(false); 136 136 137 137 // searching for a usefull resolution … … 365 365 366 366 /** 367 * if Textures should be enabled368 */369 bool GraphicsEngine::texturesEnabled = true;370 371 /**372 367 * 373 368 * @param show if The mouse-cursor should be visible -
branches/network/src/lib/graphics/graphics_engine.h
r5366 r5968 83 83 84 84 public: 85 static bool texturesEnabled; //!< if textures should be enabled (globally)86 87 85 88 86 private: -
branches/network/src/lib/graphics/importer/Makefile.am
r5463 r5968 9 9 md2Model.cc \ 10 10 material.cc \ 11 texture.cc 11 texture.cc \ 12 texture_sequence.cc 12 13 13 14 … … 20 21 material.h \ 21 22 texture.h \ 23 texture_sequence.h \ 22 24 anorms.h \ 23 25 anormtab.h -
branches/network/src/lib/graphics/importer/material.h
r5405 r5968 51 51 static void addTexturePath(const char* pathName); 52 52 53 private:54 int illumModel; //!< The IlluminationModel is either flat or smooth.55 float diffuse [4]; //!< The diffuse color of the Material.56 float ambient [4]; //!< The ambient color of the Material.57 float specular [4]; //!< The specular color of the Material.58 float shininess; //!< The shininess of the Material.59 float transparency; //!< The transperency of the Material.53 private: 54 int illumModel; //!< The IlluminationModel is either flat or smooth. 55 float diffuse [4]; //!< The diffuse color of the Material. 56 float ambient [4]; //!< The ambient color of the Material. 57 float specular [4]; //!< The specular color of the Material. 58 float shininess; //!< The shininess of the Material. 59 float transparency; //!< The transperency of the Material. 60 60 public: 61 Texture* diffuseTexture; //!< The diffuse texture of the Material.62 Texture* ambientTexture; //!< The ambient texture of the Material.63 Texture* specularTexture; //!< The specular texture of the Material.61 Texture* diffuseTexture; //!< The diffuse texture of the Material. 62 Texture* ambientTexture; //!< The ambient texture of the Material. 63 Texture* specularTexture; //!< The specular texture of the Material. 64 64 }; 65 65 #endif -
branches/network/src/lib/graphics/importer/texture.cc
r5790 r5968 19 19 20 20 #include "debug.h" 21 #include "graphics_engine.h" 22 21 22 // INCLUDING SDL_Image 23 23 #ifdef HAVE_SDL_IMAGE_H 24 24 #include <SDL_image.h> … … 45 45 } 46 46 47 47 48 /** 48 49 * Destructor of a Texture … … 65 66 bool Texture::loadImage(const char* imageName) 66 67 { 67 if ( GraphicsEngine::texturesEnabled)68 if (Texture::texturesEnabled) 68 69 { 69 70 if (this->image != NULL) … … 80 81 { 81 82 SDL_Surface* tmpSurf; 82 if (this->texture )83 if (this->texture != 0 && glIsTexture(this->texture)) 83 84 glDeleteTextures(1, &this->texture); 84 85 // load the new Image to memory … … 87 88 { 88 89 PRINTF(4)("loading Image %s\n", imageName); 89 if (this->prepareSurface(tmpSurf)) 90 loadTexToGL(); 90 bool hasAlpha; 91 SDL_Surface* newSurf = this->prepareSurface(tmpSurf, hasAlpha); 92 if (newSurf != NULL) 93 { 94 this->setSurface(newSurf); 95 this->setAlpha(hasAlpha); 96 this->setTexture(Texture::loadTexToGL(newSurf)); 97 } 98 91 99 SDL_FreeSurface(tmpSurf); 92 100 return true; … … 108 116 } 109 117 118 119 /** 120 * rebuilds the texture. 121 * reloads the Texture from Memory to OpenGL. 122 */ 110 123 bool Texture::rebuild() 111 124 { 112 125 if (this->texture != 0) 113 126 { 114 glDeleteTextures(1,&this->texture); 115 this->texture = 0; 127 if (glIsTexture(this->texture)) 128 glDeleteTextures(1,&this->texture); 129 this->setTexture(0); 116 130 } 117 131 … … 119 133 { 120 134 PRINTF(3)("Reloading Texture of %s '%s'\n", this->getClassName(), this->getName()); 121 this-> loadTexToGL();135 this->setTexture(loadTexToGL(this->image)); 122 136 } 123 124 } 125 137 } 138 139 140 /** 141 * set the surface this Texture handles 142 * @param newSurface the new Surface to set as the image for this Texture. 143 * 144 * This deletes the old version of the stored Texture, 145 * and sets the newly given Surface as current. 146 */ 147 bool Texture::setSurface(SDL_Surface* newSurface) 148 { 149 if (this->image != NULL) 150 SDL_FreeSurface(this->image); 151 152 this->image = newSurface; 153 154 return (this->image != NULL); 155 } 156 157 158 bool Texture::texturesEnabled = true; 159 160 /** 161 * enables, disables textures 162 * @param texturesEnabled true if the textures should be enabled 163 */ 164 void Texture::setTextureEnableState(bool texturesEnabled) 165 { 166 Texture::texturesEnabled = texturesEnabled; 167 } 168 169 170 ////////////////////////////////////// 171 // UTILITY FUNCTIONALITY OF TEXTURE // 172 ////////////////////////////////////// 126 173 /** 127 174 * converts surface to a new SDL_Surface, that is loadable by openGL 128 175 * @param surface the Surface to convert 176 * @param hasAlpha if the newly created Surface has an alpha channel, true is returned otherwise false. 129 177 * @returns a !!new!! Surface, that is loadable by openGL. 130 178 */ 131 bool Texture::prepareSurface(SDL_Surface* surface)179 SDL_Surface* Texture::prepareSurface(SDL_Surface* surface, bool& hasAlpha) 132 180 { 133 181 PRINTF(4)("Loading texture to OpenGL-Environment.\n"); 134 182 135 SDL_Surface* putSurface;183 SDL_Surface* retSurface; 136 184 SDL_Rect area; 137 185 Uint32 saved_flags; 138 186 Uint8 saved_alpha; 139 187 140 putSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, 141 surface->w, surface->h, 142 32, 188 hasAlpha = false; 189 retSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, 190 surface->w, surface->h, 191 32, 143 192 #if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */ 144 193 0x000000FF, … … 147 196 0xFF000000 148 197 #else 149 0xFF000000,198 0xFF000000, 150 199 0x00FF0000, 151 200 0x0000FF00, 152 201 0x000000FF 153 202 #endif 154 );155 if ( putSurface == NULL )203 ); 204 if ( retSurface == NULL ) 156 205 { 157 this->setSurface(NULL); 158 return false; 206 return NULL; 159 207 } 160 208 … … 171 219 area.w = surface->w; 172 220 area.h = surface->h; 173 SDL_BlitSurface(surface, &area, putSurface, &area);221 SDL_BlitSurface(surface, &area, retSurface, &area); 174 222 175 223 /* Restore the alpha blending attributes */ … … 177 225 { 178 226 SDL_SetAlpha(surface, saved_flags | SDL_OPENGL, saved_alpha); 179 this->bAlpha = true; 180 } 181 182 return (this->setSurface(putSurface)); 183 } 184 185 bool Texture::setSurface(SDL_Surface* newSurface) 186 { 187 if (this->image != NULL) 188 SDL_FreeSurface(this->image); 189 190 this->image = newSurface; 191 192 return (this->image != NULL); 227 hasAlpha = true; 228 } 229 230 return (retSurface); 193 231 } 194 232 … … 199 237 * @returns The ID of the texture. 200 238 */ 201 GLuint Texture::loadTexToGL () 202 { 203 if (this->texture != 0 && glIsTexture(this->texture)) 204 glDeleteTextures(1, &this->texture); 205 this->texture = 0; 206 207 if (this->image == NULL) 239 GLuint Texture::loadTexToGL (const SDL_Surface* surface) 240 { 241 // if (this->texture != 0 && glIsTexture(this->texture)) 242 // glDeleteTextures(1, &this->texture); 243 // this->texture = 0; 244 245 GLuint texture; 246 247 if (surface == NULL) 208 248 return 0; 209 249 210 250 /* Create an OpenGL texture for the image */ 211 glGenTextures(1, &t his->texture);212 glBindTexture(GL_TEXTURE_2D, t his->texture);251 glGenTextures(1, &texture); 252 glBindTexture(GL_TEXTURE_2D, texture); 213 253 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 214 254 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); … … 217 257 0, 218 258 GL_RGBA, 219 this->image->w, this->image->h,259 surface->w, surface->h, 220 260 0, 221 261 GL_RGBA, 222 262 GL_UNSIGNED_BYTE, 223 this->image->pixels);263 surface->pixels); 224 264 // build the MipMaps 225 265 gluBuild2DMipmaps(GL_TEXTURE_2D, 226 266 GL_RGBA, 227 this->image->w,228 this->image->h,267 surface->w, 268 surface->h, 229 269 GL_RGBA, 230 270 GL_UNSIGNED_BYTE, 231 this->image->pixels);271 surface->pixels); 232 272 glBindTexture(GL_TEXTURE_2D, 0); 233 return t his->texture;234 } 273 return texture; 274 } -
branches/network/src/lib/graphics/importer/texture.h
r5768 r5968 14 14 struct SDL_Surface; 15 15 16 //! an enumerator for different procedural texture-types17 typedef enum TEXTURE_TYPE { TEXTURE_RADIAL_ALIAS,18 TEXTURE_NOISE };19 20 16 //! A Class, that reads in Textures from different fileformats. 21 17 class Texture : public BaseObject … … 27 23 28 24 bool loadImage(const char* imageName); 29 bool rebuild();25 virtual bool rebuild(); 30 26 31 27 /** @returns The textureID of this texture. */ … … 33 29 /** @returns true if texture has alpha, false otherwise */ 34 30 inline bool hasAlpha() const {return bAlpha;} 31 /** @returns the stored image of this Texture */ 32 const SDL_Surface* const getStoredImage() const { return this->image; }; 33 34 35 36 static void setTextureEnableState(bool texturesEnabled); 37 /** @returns true if Textures are enabled */ 38 inline static bool getTextureEnableState() { return Texture::texturesEnabled; }; 39 40 // Utility functionality: 41 static SDL_Surface* prepareSurface(SDL_Surface* input, bool& hasAlpha); 42 static GLuint loadTexToGL (const SDL_Surface* surface); 35 43 36 44 protected: 37 bool prepareSurface(SDL_Surface* input); 45 38 46 bool setSurface(SDL_Surface* newSurface); 47 bool setAlpha(bool hasAlpha) { this->bAlpha = hasAlpha; }; 48 bool setTexture(GLuint texture) { this->texture = texture; }; 39 49 40 GLuint loadTexToGL ();41 50 42 51 private: 43 GLuint texture; //!< The Texture-ID of opengl from this Texture. 44 bool bAlpha; //!< if the texture has an alpha channel. 45 SDL_Surface* image; //!< The SDL_Surfce that stores the Texture on it. 52 GLuint texture; //!< The Texture-ID of opengl from this Texture. 53 bool bAlpha; //!< if the texture has an alpha channel. 54 SDL_Surface* image; //!< The SDL_Surfce that stores the Texture on it. 55 56 static bool texturesEnabled; //!< If the Textures are enabled. 46 57 }; 47 58 -
branches/network/src/lib/graphics/light.cc
r5750 r5968 22 22 #include "glincl.h" 23 23 #include "vector.h" 24 #include " tinyxml.h"24 #include "parser/tinyxml/tinyxml.h" 25 25 #include "load_param.h" 26 26 #include "factory.h" -
branches/network/src/lib/graphics/render2D/element_2d.cc
r5783 r5968 23 23 #include "graphics_engine.h" 24 24 #include "load_param.h" 25 #include " tinyxml.h"25 #include "parser/tinyxml/tinyxml.h" 26 26 #include "class_list.h" 27 27 -
branches/network/src/lib/graphics/text_engine/font.cc
r5768 r5968 181 181 this->fontTTF = NULL; 182 182 } 183 if (this->prepareSurface(surface)) 184 this->loadTexToGL( ); 183 bool hasAlpha; 184 SDL_Surface* newSurf = this->prepareSurface(surface, hasAlpha); 185 if (newSurf != NULL) 186 { 187 this->setSurface(newSurf); 188 this->setAlpha(hasAlpha); 189 this->setTexture(Texture::loadTexToGL(newSurf)); 190 } 185 191 186 192 // initializing the Glyphs. … … 491 497 492 498 if (this->setSurface(tmpSurf)) 493 loadTexToGL();499 (this->setTexture(Texture::loadTexToGL(tmpSurf))); 494 500 } 495 501 -
branches/network/src/lib/graphics/text_engine/text_engine.cc
r5780 r5968 64 64 { 65 65 // first remove all the remaining Texts (if any). 66 std::list<BaseObject*>* textList = ClassList::getList(CL_TEXT);66 const std::list<BaseObject*>* textList = ClassList::getList(CL_TEXT); 67 67 if (textList != NULL) 68 68 { … … 71 71 } 72 72 // delete all remaining fonts (There should not be Anything to do here) 73 std::list<BaseObject*>* fontList = ClassList::getList(CL_FONT);73 const std::list<BaseObject*>* fontList = ClassList::getList(CL_FONT); 74 74 if (fontList != NULL) 75 75 { … … 124 124 void TextEngine::debug() const 125 125 { 126 list<BaseObject*>* textList = ClassList::getList(CL_TEXT);126 const list<BaseObject*>* textList = ClassList::getList(CL_TEXT); 127 127 if (textList != NULL) 128 128 { … … 132 132 PRINT(0)("Reference: %p; Text Counts: %d\n", this, textList->size()); 133 133 134 list<BaseObject*>:: iterator text;134 list<BaseObject*>::const_iterator text; 135 135 for ( text = textList->begin(); text != textList->end(); text++) 136 136 dynamic_cast<Text*>(*text)->debug(); -
branches/network/src/lib/gui/gtk_gui/gui_audio.cc
r5298 r5968 42 42 { 43 43 CheckButton* enableSound; //!< A Ckeckbutton for enabling Sound. 44 Slider* audioChannels; //!< A Slider for the count of audio-channels. 44 45 Slider* musicVolume; //!< A Slider for music volume. 45 46 Slider* effectsVolume; //!< A Slider for effects volume. … … 51 52 enableSound->saveability(); 52 53 audioBox->fill(enableSound); 54 55 Label* audioChannelsLabel = new Label(CONFIG_NAME_AUDIO_CHANNELS); 56 audioBox->fill(audioChannelsLabel); 57 audioChannels = new Slider(CONFIG_NAME_AUDIO_CHANNELS, 0, 32); 58 audioChannels->setFlagName("channels", "c", 32); 59 audioChannels->setDescription("Sets the count of channels in the game"); 60 audioChannels->saveability(); 61 audioBox->fill (audioChannels); 62 63 53 64 Label* musicVolumeLabel = new Label(CONFIG_NAME_MUSIC_VOLUME); 54 65 audioBox->fill(musicVolumeLabel); … … 58 69 musicVolume->saveability(); 59 70 audioBox->fill (musicVolume); 71 60 72 Label* effectsVolumeLabel = new Label (CONFIG_NAME_EFFECTS_VOLUME); 61 73 audioBox->fill (effectsVolumeLabel); -
branches/network/src/lib/gui/gtk_gui/gui_exec.cc
r5241 r5968 27 27 28 28 #include "resource_manager.h" 29 #include " ini_parser.h"29 #include "parser/ini_parser/ini_parser.h" 30 30 31 31 #include <string.h> … … 254 254 255 255 /** 256 * Reads in Configuration Data.256 * @brief Reads in Configuration Data. 257 257 * @param widget from which Widget on should be saved. 258 258 */ … … 265 265 return; 266 266 267 iniParser. getFirstSection();267 iniParser.firstSection(); 268 268 Widget* groupWidget = widget; 269 269 const char* groupName; … … 272 272 while (groupName = iniParser.getCurrentSection()) 273 273 { 274 printf("GROUP:::%s\n", groupName); 274 275 if((groupWidget = locateGroup(widget, groupName, 1))==NULL) 275 {276 277 278 279 }276 { 277 PRINTF(2)("!!There is no group called %s in this GUI.\n First best Widget will get the Infos assigned.\n Config-File will be updated in next Save\n", groupName); 278 groupWidget = widget; 279 continue; 280 } 280 281 else 281 PRINT(0)("Group %s located.\n", static_cast<Packer*>(groupWidget)->groupName); 282 283 iniParser.getFirstVar(); 284 while(iniParser.getCurrentName()) 285 { 286 varInfo.variableName = iniParser.getCurrentName(); 282 PRINT(4)("Group %s located.\n", static_cast<Packer*>(groupWidget)->groupName); 283 284 const char* entryName; 285 iniParser.firstVar(); 286 while(entryName = iniParser.getCurrentName()) 287 { 288 PRINTF(4)("ENTRY:::%s = %s\n", entryName, iniParser.getCurrentValue()); 289 varInfo.variableName = entryName; 287 290 varInfo.variableValue = iniParser.getCurrentValue(); 288 291 groupWidget->walkThrough(this->readFileText, &varInfo, 0); … … 303 306 { 304 307 VarInfo* info =(VarInfo*)varInfo; 308 if (info == NULL || info->variableName == NULL) 309 return; 310 305 311 if(widget->title && !strcmp(widget->title, info->variableName)) 306 312 { 307 313 PRINT(5)("Located Option %s.\n", widget->title); 308 314 if(widget->optionType > GUI_NOTHING) 309 static_cast<Option*>(widget)->load(info->variableValue); 315 if (info->variableValue != NULL) 316 static_cast<Option*>(widget)->load(info->variableValue); 310 317 } 311 318 } … … 323 330 { 324 331 Widget* tmp; 332 if (widget == NULL || groupName == NULL) 333 return NULL; 325 334 326 335 if(widget->optionType < GUI_NOTHING) 327 336 { 328 if(static_cast<Packer*>(widget)->getGroupName() &&337 if(static_cast<Packer*>(widget)->getGroupName() != NULL && 329 338 !strcmp(groupName, static_cast<Packer*>(widget)->getGroupName())) 330 { 331 return widget; 332 } 339 return widget; 333 340 else 334 341 { 335 if((tmp = locateGroup(static_cast<Packer*>(widget)->down, groupName, depth+1)) != NULL) 342 if((tmp = locateGroup(static_cast<Packer*>(widget)->down, 343 groupName, depth+1)) != NULL) 336 344 return tmp; 337 345 } -
branches/network/src/lib/gui/gtk_gui/gui_keys.cc
r5766 r5968 119 119 pKeysBox->fill(addKey(CONFIG_NAME_PLAYER_LEFT, "LEFT")); 120 120 pKeysBox->fill(addKey(CONFIG_NAME_PLAYER_RIGHT, "RIGHT")); 121 pKeysBox->fill(addKey(CONFIG_NAME_PLAYER_FIRE, " MOUSE_LEFT"));121 pKeysBox->fill(addKey(CONFIG_NAME_PLAYER_FIRE, "BUTTON_LEFT")); 122 122 pKeysBox->fill(addKey(CONFIG_NAME_PLAYER_NEXT_WEAPON, "m")); 123 123 pKeysBox->fill(addKey(CONFIG_NAME_PLAYER_PREV_WEAPON, "n")); -
branches/network/src/lib/lang/base_object.cc
r5791 r5968 112 112 else if (classID & CL_MASK_SUBSUPER_CLASS) 113 113 { 114 if (likely(((this->classID & CL_MASK_SUBSUPER_CLASS_ID ) == (this->classID & CL_MASK_SUBSUPER_CLASS_ID)) &&115 this->classID & classID & CL_MASK_SUBSUPER_CLASS_ID 2))114 if (likely(((this->classID & CL_MASK_SUBSUPER_CLASS_IDA) == (this->classID & CL_MASK_SUBSUPER_CLASS_IDA)) && 115 this->classID & classID & CL_MASK_SUBSUPER_CLASS_IDB)) 116 116 return true; 117 117 } -
branches/network/src/lib/lang/class_list.cc
r5822 r5968 133 133 * @return the List accessed by classID, or NULL if not found 134 134 */ 135 std::list<BaseObject*>* ClassList::getList(ClassID classID)135 const std::list<BaseObject*>* ClassList::getList(ClassID classID) 136 136 { 137 137 ClassList* fl; … … 156 156 * @return the List accessed by classID, or NULL if not found 157 157 */ 158 std::list<BaseObject*>* ClassList::getList(const char* className)158 const std::list<BaseObject*>* ClassList::getList(const char* className) 159 159 { 160 160 ClassList* fl; -
branches/network/src/lib/lang/class_list.h
r5821 r5968 40 40 static void removeFromClassList(BaseObject* objectPointer); 41 41 42 static std::list<BaseObject*>*getList(ClassID classID = CL_NULL);// { return (ClassList* fl = ClassList::getClassList(classID) != NULL)? &(fl->objectList) : NULL; };43 static std::list<BaseObject*>*getList(const char* className); // { return (ClassList* fl = ClassList::getClassList(className) != NULL)? &(fl->objectList) : NULL; };42 static const std::list<BaseObject*>* getList(ClassID classID = CL_NULL);// { return (ClassList* fl = ClassList::getClassList(classID) != NULL)? &(fl->objectList) : NULL; }; 43 static const std::list<BaseObject*>* getList(const char* className); // { return (ClassList* fl = ClassList::getClassList(className) != NULL)? &(fl->objectList) : NULL; }; 44 44 static const std::list<const char*>* getClassNames(); 45 45 static BaseObject* getObject(const char* name, ClassID classID = CL_NULL); 46 46 static bool exists(const BaseObject* object, ClassID classID = CL_NULL); 47 48 void sendBack(std::list<BaseObject*>::const_iterator it); 47 49 48 50 static void whatIs(const BaseObject* object); … … 51 53 static long StringToID(const char* className); 52 54 static void debug(unsigned int debugLevel = 0, long classID = CL_NULL); 53 static void debugS(const char* className = 0x0, unsigned int debugLevel = 0);55 static void debugS(const char* className = NULL, unsigned int debugLevel = 0); 54 56 55 57 inline bool operator==(ClassID classID) { return (this->classID == classID); }; -
branches/network/src/lib/network/network_manager.cc
r5829 r5968 156 156 { 157 157 if (this->netStreamList != NULL || (this->netStreamList = ClassList::getList(CL_NETWORK_STREAM)) != NULL) 158 { 159 // tIterator<BaseObject>* iterator = this->netStreamList->getIterator(); 160 // NetworkStream* stream = (NetworkStream*)(iterator->firstElement()); 161 // while( stream) 162 // { 163 // if(stream->isActive()) 164 // stream->processData(); 165 // stream = (NetworkStream*)(iterator->nextElement()); 166 // } 167 // delete iterator; 168 std::list<BaseObject*>::iterator stream; 158 { 159 std::list<BaseObject*>::const_iterator stream; 169 160 for (stream = this->netStreamList->begin(); stream != this->netStreamList->end(); ++stream) 170 161 if( static_cast<NetworkStream*>(*stream)->isActive()) -
branches/network/src/lib/network/network_manager.h
r5829 r5968 42 42 void shutdownConnection(); 43 43 44 44 45 void connectSynchronizeable(Synchronizeable& sync); 45 46 46 void synchronize(); 47 47 48 48 49 private: … … 51 52 52 53 private: 53 std::list<BaseObject*>* netStreamList; // list with refs to all network streams54 std::list<BaseObject*>* syncList; // list of synchronizeables54 const std::list<BaseObject*>* netStreamList; // list with refs to all network streams 55 const std::list<BaseObject*>* syncList; // list of synchronizeables 55 56 static NetworkManager* singletonRef; //!< Pointer to the only instance of this Class 56 57 NetworkStream* tmpStream; //!< FIXME: this is only for testing purposes -
branches/network/src/lib/particles/particle_engine.h
r5447 r5968 12 12 #include "particle_emitter.h" 13 13 14 #include " tinyxml.h"14 #include "parser/tinyxml/tinyxml.h" 15 15 16 16 // FORWARD DECLARATION -
branches/network/src/lib/particles/particle_system.cc
r5750 r5968 30 30 #include "shell_command.h" 31 31 32 #include " tinyxml.h"32 #include "parser/tinyxml/tinyxml.h" 33 33 34 34 CREATE_FACTORY(ParticleSystem, CL_PARTICLE_SYSTEM); -
branches/network/src/lib/physics/physics_engine.cc
r5779 r5968 20 20 #include "class_list.h" 21 21 #include "list.h" 22 #include " tinyxml.h"22 #include "parser/tinyxml/tinyxml.h" 23 23 #include "factory.h" 24 24 #include "load_param.h" -
branches/network/src/lib/shell/shell_command.cc
r5791 r5968 159 159 long classID = CL_NULL; //< the classID retrieved from the Class. 160 160 ShellCommandClass* commandClass = NULL; //< the command class this command applies to. 161 std::list<BaseObject*>* objectList = NULL; //< the list of Objects stored in classID161 const std::list<BaseObject*>* objectList = NULL; //< the list of Objects stored in classID 162 162 BaseObject* objectPointer = NULL; //< a pointer to th Object to Execute the command on 163 163 bool emptyComplete = false; //< if the completion input is empty string. e.g "" -
branches/network/src/lib/shell/shell_completion.cc
r5791 r5968 58 58 59 59 long classID; //< the classID retrieved from the Class. 60 std::list<BaseObject*>* objectList; //< the list of Objects stored in classID60 const std::list<BaseObject*>* objectList; //< the list of Objects stored in classID 61 61 bool emptyComplete = false; //< if the completion input is empty string. e.g "" 62 62 long completeType = SHELLC_NONE; //< the Type we'd like to complete. -
branches/network/src/lib/sound/sound_buffer.cc
r5422 r5968 20 20 #include "sound_engine.h" 21 21 22 23 22 using namespace std; 24 25 23 26 24 ////////////////// … … 36 34 this->setName(fileName); 37 35 38 SoundEngine::getInstance()->addBuffer(this);39 40 36 ALenum format; 41 37 ALvoid* data; … … 47 43 alGenBuffers(1, &this->bufferID); 48 44 if ((result = alGetError()) != AL_NO_ERROR) 49 SoundEngine::PrintALErrorString(result);45 PRINTF(2)("%s\n", SoundEngine::getALErrorString(result)); 50 46 51 47 // read in the wav data … … 59 55 #endif 60 56 if ((result = alGetError()) != AL_NO_ERROR) 61 SoundEngine::PrintALErrorString(result);57 PRINTF(2)("%s\n", SoundEngine::getALErrorString(result)); 62 58 63 59 // send the loaded wav data to the buffer 64 60 alBufferData(this->bufferID, format, data, this->size, freq); 65 61 if ((result = alGetError()) != AL_NO_ERROR) 66 SoundEngine::PrintALErrorString(result);62 PRINTF(2)("%s\n", SoundEngine::getALErrorString(result)); 67 63 68 64 // remove the wav data (redundant) 69 65 alutUnloadWAV(format, data, this->size, freq); 70 66 if ((result = alGetError()) != AL_NO_ERROR) 71 SoundEngine::PrintALErrorString(result);67 PRINTF(2)("%s\n", SoundEngine::getALErrorString(result)); 72 68 } 73 69 -
branches/network/src/lib/sound/sound_engine.cc
r5832 r5968 27 27 #include "resource_manager.h" 28 28 #include "debug.h" 29 #include " ini_parser.h"29 #include "parser/ini_parser/ini_parser.h" 30 30 #include "globals.h" 31 31 … … 47 47 this->bufferList = NULL; 48 48 this->sourceList = NULL; 49 50 this->device = NULL; 51 this->context = NULL; 52 53 this->maxSourceCount = 32; 49 54 } 50 55 … … 64 69 while (this->sourceList->size() > 0) 65 70 delete dynamic_cast<SoundSource*>(this->sourceList->front()); 71 } 72 73 while(!this->ALSources.empty()) 74 { 75 alDeleteSources(1, &this->ALSources.top()); 76 this->ALSources.pop(); 66 77 } 67 78 … … 86 97 void SoundEngine::loadSettings(IniParser* iniParser) 87 98 { 99 const char* channels = iniParser->getVar(CONFIG_NAME_AUDIO_CHANNELS, CONFIG_SECTION_AUDIO, "32"); 100 this->maxSourceCount = atoi(channels); 88 101 const char* musicVolume = iniParser->getVar(CONFIG_NAME_MUSIC_VOLUME, CONFIG_SECTION_AUDIO, "80"); 89 102 this->musicVolume = atof(musicVolume)/100.0; … … 118 131 119 132 120 /** 121 * adds a SoundBuffer to the bufferList of the SoundEngine 122 * @param buffer The buffer to add to the bufferList 123 */ 124 void SoundEngine::addBuffer(SoundBuffer* buffer) 125 { 126 if (unlikely(this->bufferList == NULL)) 127 this->bufferList = ClassList::getList(CL_SOUND_BUFFER); 128 } 129 130 /** 131 * removes a SoundBuffer from the bufferList of the SoundEngine 132 * @param buffer The buffer to delete from the SoundEngine 133 */ 134 void SoundEngine::removeBuffer(SoundBuffer* buffer) 135 { 136 // look if there are any sources that have the buffer still loaded 137 if (this->sourceList != NULL) 138 { 139 list<BaseObject*>::iterator source; 140 for (source = this->sourceList->begin(); source != this->sourceList->end(); source++) 141 { 142 if (buffer == static_cast<SoundSource*>(*source)->getBuffer()) 143 delete (*source); 133 void SoundEngine::popALSource(ALuint& source) 134 { 135 if (source != 0) 136 return; 137 else 138 { 139 140 /// @TODO try to create more sources if needed 141 if (!this->ALSources.empty()) 142 { 143 144 source = this->ALSources.top(); 145 printf("test: : %d\n", source); 146 this->ALSources.pop(); 144 147 } 145 148 } 146 149 } 147 150 148 /**149 * adds a SoundSource to the sourceList of the SoundEngine150 * @param source The source to add to the sourceList151 */152 void SoundEngine::addSource(SoundSource* source)153 {154 this->sourceList = ClassList::getList(CL_SOUND_SOURCE);155 }156 151 157 152 /** … … 180 175 181 176 // updating all the Sources positions 182 if (likely(this->sourceList != NULL ))183 { 184 list<BaseObject*>:: iterator sourceIT;177 if (likely(this->sourceList != NULL || (this->sourceList = ClassList::getList(CL_SOUND_SOURCE)) != NULL)) 178 { 179 list<BaseObject*>::const_iterator sourceIT; 185 180 SoundSource* source; 186 181 for (sourceIT = this->sourceList->begin(); sourceIT != this->sourceList->end(); sourceIT++) 187 182 { 188 183 source = static_cast<SoundSource*>(*sourceIT); 189 if ( likely(source->getNode() != NULL))184 if (source->isPlaying()) 190 185 { 191 alSource3f(source->getID(), AL_POSITION, 192 source->getNode()->getAbsCoor().x, 193 source->getNode()->getAbsCoor().y, 194 source->getNode()->getAbsCoor().z); 195 alSource3f(source->getID(), AL_VELOCITY, 196 source->getNode()->getVelocity().x, 197 source->getNode()->getVelocity().y, 198 source->getNode()->getVelocity().z); 186 int play; 187 alGetSourcei(source->getID(), AL_SOURCE_STATE, &play); 188 if(play == AL_PLAYING) 189 { 190 if (likely(source->getNode() != NULL)) 191 { 192 alSource3f(source->getID(), AL_POSITION, 193 source->getNode()->getAbsCoor().x, 194 source->getNode()->getAbsCoor().y, 195 source->getNode()->getAbsCoor().z); 196 alSource3f(source->getID(), AL_VELOCITY, 197 source->getNode()->getVelocity().x, 198 source->getNode()->getVelocity().y, 199 source->getNode()->getVelocity().z); 200 } 201 202 } 203 else 204 { 205 source->stop(); 206 } 199 207 } 200 208 } … … 282 290 // INITIALIZING THE DEVICE: 283 291 284 ALchar deviceName[] = 292 #ifdef AL_VERSION_1_1 293 ALubyte deviceName[] = 294 #else 295 ALCchar deviceName[] = 296 #endif 297 285 298 #ifdef __WIN32__ 286 " native";299 "Direct3D"; 287 300 #else 288 "'( ( devices '( native artsnull ) ) )";301 "'( ( devices '( native null ) ) )"; 289 302 #endif 290 303 // … … 297 310 298 311 if ((result = alGetError()) != AL_NO_ERROR) 299 SoundEngine::PrintALErrorString(result);312 PRINTF(2)("%s\n", SoundEngine::getALErrorString(result)); 300 313 301 314 this->setDopplerValues(SOUND_DOPPLER_FACTOR, SOUND_DOPPLER_VELOCITY); 315 } 316 317 318 /** 319 * Allocates openAL sources 320 * @param count how many sources to allocate 321 * @returns true on success, false if at least one source could not be allocated 322 */ 323 bool SoundEngine::allocateSources(unsigned int count) 324 { 325 ALenum result; 326 // Setting default values. 327 for (unsigned int i = 0; i < count; i++) 328 { 329 ALuint source; 330 331 alGenSources(1, &source); 332 if ((result = alGetError()) != AL_NO_ERROR) 333 PRINTF(1)("Error Generating Sources: '%s'\n", SoundEngine::getALErrorString(result)); 334 335 alSourcef (source, AL_PITCH, 1.0 ); 336 alSourcef (source, AL_GAIN, this->getEffectsVolume() ); 337 alSourcei (source, AL_LOOPING, AL_FALSE ); 338 this->ALSources.push(source); 339 } 340 return true; 302 341 } 303 342 … … 306 345 * @param err The error found 307 346 */ 308 void SoundEngine::PrintALErrorString(ALenum err)347 const char* SoundEngine::getALErrorString(ALenum err) 309 348 { 310 349 switch(err) 311 350 { 312 351 case AL_NO_ERROR: 313 PRINTF(4)("AL_NO_ERROR\n"); 314 break; 315 352 return ("AL_NO_ERROR"); 316 353 case AL_INVALID_NAME: 317 PRINTF(2)("AL_INVALID_NAME\n"); 318 break; 319 354 return ("AL_INVALID_NAME"); 320 355 case AL_INVALID_ENUM: 321 PRINTF(2)("AL_INVALID_ENUM\n"); 322 break; 323 356 return ("AL_INVALID_ENUM"); 324 357 case AL_INVALID_VALUE: 325 PRINTF(2)("AL_INVALID_VALUE\n"); 326 break; 327 358 return ("AL_INVALID_VALUE"); 328 359 case AL_INVALID_OPERATION: 329 PRINTF(2)("AL_INVALID_OPERATION\n"); 330 break; 331 360 return ("AL_INVALID_OPERATION"); 332 361 case AL_OUT_OF_MEMORY: 333 PRINTF(2)("AL_OUT_OF_MEMORY\n"); 334 break; 362 return ("AL_OUT_OF_MEMORY"); 335 363 }; 336 364 } … … 338 366 void SoundEngine::listDevices() 339 367 { 340 341 368 printf("%s\n",(const char*)alcGetString(NULL, ALC_DEVICE_SPECIFIER)); 342 369 } -
branches/network/src/lib/sound/sound_engine.h
r5819 r5968 14 14 15 15 #include <list> 16 #include <stack> 16 17 17 18 #define SOUND_DOPPLER_FACTOR 0.001 //!< A factor for the audible doppler effect … … 22 23 class IniParser; 23 24 25 24 26 //! A class that handles audio via the openAudioLibrary 25 27 class SoundEngine : public BaseObject { 26 27 28 public: 28 29 virtual ~SoundEngine(); … … 47 48 48 49 // administrative 49 void addBuffer(SoundBuffer* buffer); 50 void removeBuffer(SoundBuffer* buffer); 51 void addSource(SoundSource* source); 50 void popALSource(ALuint& source); 51 void pushALSource(ALuint& source) { if (source != 0) this->ALSources.push(source); }; 52 52 53 53 void flushUnusedBuffers(); 54 54 void flushAllBuffers(); 55 55 void flushAllSources(); 56 56 57 bool initAudio(); 58 bool allocateSources(unsigned int count); 57 59 58 60 // error handling: 59 static void PrintALErrorString(ALenum err); 60 // static void PrintALCErrorString(ALenum err); 61 61 static const char* getALErrorString(ALenum err); 62 62 63 63 private: 64 64 SoundEngine(); 65 65 66 void listDevices(); 66 67 67 68 private: 68 static SoundEngine* singletonRef; //!< Reference to this class69 static SoundEngine* singletonRef; //!< Reference to this class 69 70 70 ALCdevice* device; //!< the used audio-device.71 ALCcontext* context; //!< the context, currently in use.71 ALCdevice* device; //!< the used audio-device. 72 ALCcontext* context; //!< the context, currently in use. 72 73 73 float musicVolume; //!< the maximum volume of the music in % (0f,1f]74 float effectsVolume; //!< the maximum volume of sound-effects in % (0f,1f]75 PNode* listener; //!< The listener of the Scene74 float musicVolume; //!< the maximum volume of the music in % (0f,1f] 75 float effectsVolume; //!< the maximum volume of sound-effects in % (0f,1f] 76 PNode* listener; //!< The listener of the Scene 76 77 77 std::list<BaseObject*>* bufferList; //!< A list of buffers78 std::list<BaseObject*>* sourceList; //!< A list for all the sources in the scene.78 const std::list<BaseObject*>* bufferList; //!< A list of buffers 79 const std::list<BaseObject*>* sourceList; //!< A list for all the sources in the scene. 79 80 80 81 unsigned int maxSourceCount; //!< How many Sources is the Maximum 82 std::stack<ALuint> ALSources; //!< A list of real openAL-Sources, the engine allocates, and stores for reuse. 81 83 }; 82 84 -
branches/network/src/lib/sound/sound_source.cc
r5386 r5968 18 18 #include "sound_source.h" 19 19 #include "sound_engine.h" 20 20 21 #include "alincl.h" 21 22 #include "compiler.h" … … 33 34 34 35 // adding the Source to the SourcesList of the SoundEngine 35 SoundEngine::getInstance()->addSource(this);36 37 36 this->buffer = buffer; 38 37 this->sourceNode = sourceNode; 39 38 40 alGenSources(1, &this->sourceID); 41 if ((result = alGetError()) != AL_NO_ERROR) 42 SoundEngine::PrintALErrorString(result); 43 if (this->buffer != NULL) 44 alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID()); 45 alSourcef (this->sourceID, AL_PITCH, 1.0 ); 46 alSourcef (this->sourceID, AL_GAIN, SoundEngine::getInstance()->getEffectsVolume() ); 47 alSourcei (sourceID, AL_LOOPING, AL_FALSE ); 39 this->sourceID = 0; 40 this->bPlay = false; 48 41 } 49 42 … … 53 46 SoundSource::~SoundSource() 54 47 { 55 //SoundEngine::getInstance()->removeSource(this); 56 alDeleteSources(1, &this->sourceID); 48 SoundEngine::getInstance()->pushALSource(this->sourceID); 57 49 } 58 50 … … 62 54 void SoundSource::play() 63 55 { 56 if (this->sourceID == 0) 57 SoundEngine::getInstance()->popALSource(this->sourceID); 64 58 alSourcePlay(this->sourceID); 59 this->bPlay = true; 65 60 } 66 61 … … 71 66 void SoundSource::play(const SoundBuffer* buffer) 72 67 { 68 if (unlikely(this->sourceID == 0)) 69 SoundEngine::getInstance()->popALSource(this->sourceID); 70 71 printf("%d\n",sourceID); 73 72 alSourceStop(this->sourceID); 74 73 alSourcei (this->sourceID, AL_BUFFER, buffer->getID()); … … 77 76 if (unlikely(this->buffer != NULL)) 78 77 alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID()); 78 this->bPlay = true; 79 79 } 80 80 … … 84 84 void SoundSource::stop() 85 85 { 86 this->bPlay = false; 86 87 alSourceStop(this->sourceID); 88 SoundEngine::getInstance()->pushALSource(this->sourceID); 87 89 } 88 90 -
branches/network/src/lib/sound/sound_source.h
r5386 r5968 31 31 /** @returns The ID of this Source */ 32 32 inline ALuint getID() const { return this->sourceID; } 33 /** @returns true, if the Source is Playing */ 34 inline bool isPlaying() const { return this->bPlay; }; 33 35 /** @returns the SoundBuffer of this Source */ 34 36 inline const SoundBuffer* getBuffer() const { return this->buffer; } … … 39 41 40 42 private: 43 bool bPlay; //!< If the Source is Playing. 41 44 ALuint sourceID; //!< The ID of the Source 42 45 const SoundBuffer* buffer; //!< The buffer to play in this source. -
branches/network/src/lib/util/executor/executor_specials.h
r5754 r5968 10 10 11 11 #include "compiler.h" 12 #include " tinyxml.h"12 #include "parser/tinyxml/tinyxml.h" 13 13 // FORWARD DECLARATION 14 14 -
branches/network/src/lib/util/list.h
r5403 r5968 4 4 */ 5 5 6 #ifndef _ LIST_H7 #define _ LIST_H6 #ifndef _T_LIST_H 7 #define _T_LIST_H 8 8 9 9 #include "compiler.h" … … 645 645 } 646 646 647 #endif /* _ LIST_H */647 #endif /* _T_LIST_H */ -
branches/network/src/orxonox.cc
r5829 r5968 33 33 34 34 #include "world.h" 35 #include " ini_parser.h"35 #include "parser/ini_parser/ini_parser.h" 36 36 #include "game_loader.h" 37 37 … … 250 250 // SDL_InitSubSystem(SDL_INIT_AUDIO); 251 251 SoundEngine::getInstance()->initAudio(); 252 SoundEngine::getInstance()->allocateSources(1); 252 253 253 254 SoundEngine::getInstance()->loadSettings(this->iniParser); -
branches/network/src/story_entities/world.cc
r5829 r5968 26 26 #include "null_parent.h" 27 27 #include "pilot_node.h" 28 #include "track_node.h"29 28 #include "world_entity.h" 30 29 #include "player.h" … … 40 39 #include "shell.h" 41 40 42 #include "track_manager.h"43 41 #include "garbage_collector.h" 44 42 #include "fast_factory.h" … … 63 61 #include "weapons/projectile.h" 64 62 #include "event_handler.h" 65 66 63 #include "sound_engine.h" 67 64 #include "ogg_player.h" … … 74 71 75 72 #include "network_manager.h" 73 #include "playable.h" 74 76 75 77 76 SHELL_COMMAND(speed, World, setSpeed); … … 124 123 PRINTF(3)("World::~World() - deleting current world\n"); 125 124 125 126 126 // here everything that is alocated by the World is deleted 127 127 delete this->entities; 128 128 State::setWorldEntityList(NULL); 129 129 130 delete this->localPlayer; 130 131 131 132 // delete all the initialized Engines. 132 133 FastFactory::flushAll(true); 133 134 delete LightManager::getInstance(); 134 delete TrackManager::getInstance();135 135 delete ParticleEngine::getInstance(); 136 136 delete AnimationPlayer::getInstance(); … … 144 144 // erease everything that is left. 145 145 delete NullParent::getInstance(); 146 146 147 Shader::suspendShader(); 147 148 … … 174 175 this->shell = NULL; 175 176 this->entities = NULL; 177 this->localPlayer = NULL; 178 this->localCamera = NULL; 176 179 177 180 this->showPNodes = false; … … 215 218 216 219 AnimationPlayer::getInstance(); // initializes the animationPlayer 220 ParticleEngine::getInstance(); 217 221 PhysicsEngine::getInstance(); 218 222 … … 244 248 } 245 249 246 TiXmlDocument* XMLDoc = new TiXmlDocument( path);250 TiXmlDocument* XMLDoc = new TiXmlDocument( getPath()); 247 251 // load the campaign document 248 252 if( !XMLDoc->LoadFile()) 249 253 { 250 254 // report an error 251 PRINTF(1)("loading XML File: %s @ % d:%d\n", XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());255 PRINTF(1)("loading XML File: %s @ %s:l%d:c%d\n", XMLDoc->ErrorDesc(), this->getPath(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol()); 252 256 delete XMLDoc; 253 257 return (ErrorMessage){213,"XML File parsing error","World::load()"}; … … 315 319 while( element != NULL) 316 320 { 317 WorldEntity* created = dynamic_cast<WorldEntity*>( loader->fabricate( element)); 318 if( created != NULL) this->spawn( created); 319 // if we load a 'Player' we use it as localPlayer 320 //todo do this more elegant 321 if( element->Value() != NULL && !strcmp( element->Value(), "Player")) 321 BaseObject* created = (loader->fabricate(element)); 322 if( created != NULL ) 322 323 { 323 localPlayer = (Player*) created; 324 CDEngine::getInstance()->setPlayer(localPlayer); 324 if(created->isA(CL_WORLD_ENTITY)) 325 this->spawn(dynamic_cast<WorldEntity*>(created)); 326 printf("Created a %s: %s\n", created->getClassName(), created->getName()); 325 327 NetworkManager::getInstance()->connectSynchronizeable(*(Synchronizeable*)this->localPlayer); 326 328 } 327 if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox")) sky = (SkyBox*) created; 329 330 // if we load a 'Player' we use it as localPlayer 331 332 333 //todo do this more elegant 334 if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox")) 335 sky = dynamic_cast<SkyBox*>(created); 328 336 if( element->Value() != NULL && !strcmp( element->Value(), "Terrain")) 329 337 { 330 terrain = (Terrain*) created;338 terrain = dynamic_cast<Terrain*>(created); 331 339 CDEngine::getInstance()->setTerrain(terrain); 332 340 } … … 343 351 LoadParamXML(root, "LightManager", LightManager::getInstance(), LightManager, loadParams); 344 352 345 LoadParamXML(root, "ParticleEngine", ParticleEngine::getInstance(), ParticleEngine, loadParams); 346 LoadParamXML(root, "PhysicsEngine", PhysicsEngine::getInstance(), PhysicsEngine, loadParams); 347 348 // find Track 349 element = root->FirstChildElement( "Track"); 350 if( element == NULL) 351 { 352 PRINTF(0)("World is missing a 'Track'\n"); 353 } 354 else 355 { 356 //load track 357 PRINTF(4)("Loading Track\n"); 358 359 TrackManager::getInstance()->loadParams( element); 360 TrackManager::getInstance()->finalize(); 361 } 353 LoadParamXML(root, "ParticleEngine", ParticleEngine::getInstance(), ParticleEngine, loadParams); 354 // LoadParamXML(root, "PhysicsEngine", PhysicsEngine::getInstance(), PhysicsEngine, loadParams); 362 355 363 356 // free the XML data … … 366 359 /* GENERIC LOADING PROCESS FINISHED */ 367 360 368 // bind input 369 EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, KeyMapper::PEV_UP); 370 EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, KeyMapper::PEV_DOWN); 371 EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, KeyMapper::PEV_LEFT); 372 EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, KeyMapper::PEV_RIGHT); 373 EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, KeyMapper::PEV_FIRE1); 374 EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, KeyMapper::PEV_NEXT_WEAPON); 375 EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, KeyMapper::PEV_PREVIOUS_WEAPON); 376 EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, SDLK_PAGEUP); 377 EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, SDLK_PAGEDOWN); 361 362 // Create a Player 363 this->localPlayer = new Player(); 364 365 Playable* playable; 366 const list<BaseObject*>* playableList = ClassList::getList(CL_PLAYABLE); 367 if (playableList != NULL) 368 { 369 playable = dynamic_cast<Playable*>(playableList->front()); 370 this->localPlayer->setControllable(playable); 371 } 378 372 379 373 // bind camera 380 //this->localCamera->bind (localPlayer); 381 // this->localPlayer->addChild (this->localCamera); 382 383 384 // TrackManager::getInstance()->setBindSlave(env); 385 PNode* tn = TrackManager::getInstance()->getTrackNode(); 386 tn->addChild(this->localPlayer); 387 388 //localCamera->setParent(TrackNode::getInstance()); 389 tn->addChild(this->localCamera); 390 localCamera->lookAt(tn); 374 playable->addChild (this->localCamera); 375 376 // //localCamera->setParent(TrackNode::getInstance()); 377 // tn->addChild(this->localCamera); 391 378 localCamera->setClipRegion(1, 10000.0); 392 this->localPlayer->setParentMode(PNODE_ALL); 393 TrackManager::getInstance()->condition(1, LEFTRIGHT, this->localPlayer); 394 379 localCamera->lookAt(playable); 380 // this->localPlayer->setParentMode(PNODE_ALL); 395 381 if (sky != NULL) 396 382 { … … 403 389 glNewList (objectList, GL_COMPILE); 404 390 405 //TrackManager::getInstance()->drawGraph(.01);406 //TrackManager::getInstance()->debug(2);407 391 glEndList(); 408 392 … … 415 399 //////////// 416 400 417 Gravity* test = new Gravity();418 419 // SYSTEM TRAILING THE PLAYER420 // Creating a Test Particle System421 422 //new PhysicsConnection(system, gravity);423 // new PhysicsConnection(this->localPlayer, gravity);424 401 425 402 // TestEntity* testEntity = new TestEntity(); … … 427 404 // testEntity->setRelDir(Quaternion(M_PI, Vector(0, 1, 0))); 428 405 // this->spawn(testEntity); 429 430 // TestEntity* testEntity2 = new TestEntity();431 // testEntity2->setAnim(STAND);432 // testEntity2->setRelCoor(Vector(2400.0, 10.0, -30.0));433 // testEntity2->setRelDir(Quaternion(M_PI, Vector(0, 1, 0)));434 // //testEntity2->setParent(this->localPlayer);435 // this->spawn(testEntity2);436 //437 // TestEntity* testEntity3 = new TestEntity();438 // testEntity3->setAnim(BOOM);439 // testEntity3->setRelCoor(Vector(2450.0, 10.0, -40.0));440 // testEntity3->setRelDir(Quaternion(M_PI, Vector(0, 1, 0)));441 // this->spawn(testEntity3);442 //443 // TestEntity* testEntity4 = new TestEntity();444 // testEntity4->setAnim(FLIP);445 // testEntity4->setRelCoor(Vector(2500.0, 10.0, -22.0));446 // testEntity4->setRelDir(Quaternion(M_PI, Vector(0, 1, 0)));447 // this->spawn(testEntity4);448 //449 // TestEntity* testEntity5 = new TestEntity();450 // testEntity5->setAnim(WAVE);451 // testEntity5->setRelCoor(Vector(2420.0, 10.0, -50.0));452 // testEntity5->setRelDir(Quaternion(M_PI, Vector(0, 1, 0)));453 // this->spawn(testEntity5);454 //455 // TestEntity* testEntity6 = new TestEntity();456 // testEntity6->setAnim(WAVE);457 // testEntity6->setRelCoor(Vector(2420.0, 10.0, -20.0));458 // testEntity6->setRelDir(Quaternion(M_PI, Vector(0, 1, 0)));459 // this->spawn(testEntity6);460 //461 // TestEntity* testEntity7 = new TestEntity();462 // testEntity7->setAnim(WAVE);463 // testEntity7->setRelCoor(Vector(2500.0, 10.0, -50.0));464 // testEntity7->setRelDir(Quaternion(M_PI, Vector(0, 1, 0)));465 // this->spawn(testEntity7);466 467 468 469 // PhysicsEngine::getInstance()->debug();470 471 472 406 473 407 for(int i = 0; i < 100; i++) … … 479 413 tmp->setAbsCoor(((float)rand()/RAND_MAX) * 5000, 50/*+ (float)rand()/RAND_MAX*20*/, ((float)rand()/RAND_MAX -.5) *30); 480 414 this->spawn(tmp); 481 482 483 415 } 484 485 486 487 // ClassList::debug();488 416 489 417 this->music = NULL;//(OggPlayer*)ResourceManager::getInstance()->load("sound/00-luke_grey_-_hypermode.ogg", OGG, RP_LEVEL); … … 501 429 this->glmis->step(); 502 430 // stuff beyond this point remains to be loaded properly 503 504 // initializing the TrackManager505 TrackManager::getInstance()->addPointV(Vector(150, -35, 5));506 TrackManager::getInstance()->addPointV(Vector(200,-35, 5));507 TrackManager::getInstance()->addPointV(Vector(250, -35, 5));508 TrackManager::getInstance()->addPointV(Vector(320,-33,-.55));509 TrackManager::getInstance()->setDuration(1);510 TrackManager::getInstance()->setSavePoint();511 512 TrackManager::getInstance()->addPointV(Vector(410, 0, 0));513 TrackManager::getInstance()->addPointV(Vector(510, 20, -10));514 TrackManager::getInstance()->addPointV(Vector(550, 20, -10));515 TrackManager::getInstance()->addPointV(Vector(570, 20, -10));516 TrackManager::getInstance()->setDuration(2);517 518 TrackManager::getInstance()->forkS("testFork1,testFork2");519 TrackManager::getInstance()->workOnS("testFork1");520 TrackManager::getInstance()->addPointV(Vector(640, 25, -30));521 TrackManager::getInstance()->addPointV(Vector(700, 40, -120));522 TrackManager::getInstance()->addPointV(Vector(800, 50, -150));523 TrackManager::getInstance()->addPointV(Vector(900, 60, -100));524 TrackManager::getInstance()->addPointV(Vector(900, 60, -70));525 TrackManager::getInstance()->addPointV(Vector(990, 65, -15));526 TrackManager::getInstance()->addPointV(Vector(1050, 65, -10));527 TrackManager::getInstance()->addPointV(Vector(1100, 65, -20));528 TrackManager::getInstance()->setDuration(4);529 530 TrackManager::getInstance()->workOnS("testFork2");531 TrackManager::getInstance()->addPointV(Vector(640, 25, 20));532 TrackManager::getInstance()->addPointV(Vector(670, 50, 120));533 TrackManager::getInstance()->addPointV(Vector(700, 70, 80));534 TrackManager::getInstance()->addPointV(Vector(800, 70, 65));535 TrackManager::getInstance()->addPointV(Vector(850, 65, 65));536 TrackManager::getInstance()->addPointV(Vector(920, 35, 40));537 TrackManager::getInstance()->addPointV(Vector(945, 40, 40));538 TrackManager::getInstance()->addPointV(Vector(970, 24, 40));539 TrackManager::getInstance()->addPointV(Vector(1000, 40, -7));540 541 TrackManager::getInstance()->setDuration(4);542 543 544 TrackManager::getInstance()->joinS("testFork1,testFork2");545 546 TrackManager::getInstance()->addPointV(Vector(1200, 60, -50));547 TrackManager::getInstance()->addPointV(Vector(1300, 50, -50));548 TrackManager::getInstance()->addPointV(Vector(1400, 40, -50));549 TrackManager::getInstance()->addPointV(Vector(1500, 40, -60));550 TrackManager::getInstance()->addPointV(Vector(1600, 35, -55));551 TrackManager::getInstance()->addPointV(Vector(1700, 45, -40));552 TrackManager::getInstance()->addPointV(Vector(1750, 60, -40));553 TrackManager::getInstance()->addPointV(Vector(1770, 80, -40));554 TrackManager::getInstance()->addPointV(Vector(1800, 100, -40));555 TrackManager::getInstance()->setDuration(10);556 557 TrackManager::getInstance()->finalize();558 559 431 560 432 // LIGHT initialisation … … 574 446 { 575 447 LightManager::getInstance()->getLight()->setAbsCoor(-5.0, 10.0, -40.0); 576 577 578 this->localPlayer = new Player ();579 this->localPlayer->setName ("player");580 this->spawn (this->localPlayer);581 this->localPlayer->setRelCoor(Vector(5,0,0));582 448 /*monitor progress*/ 583 449 this->glmis->step(); 584 585 586 EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, KeyMapper::PEV_FIRE1);587 EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, KeyMapper::PEV_NEXT_WEAPON);588 EventHandler::getInstance()->subscribe(this->localPlayer, ES_GAME, KeyMapper::PEV_PREVIOUS_WEAPON);589 590 /*591 Field* testField = new Gravity();592 testField->setMagnitude(10);593 new PhysicsConnection(this->localPlayer, testField);594 */595 450 596 451 // bind camera … … 617 472 this->glmis->step(); 618 473 619 this->pilotNode = new PilotNode();620 this->spawn(this->pilotNode);621 this->pilotNode->setAbsCoor(Vector(150, -35, 5));622 this->pilotNode->addChild(this->localPlayer);623 this->pilotNode->addChild(this->localCamera);624 this->localCamera->lookAt(this->localPlayer);625 626 EventHandler::getInstance()->subscribe(this->pilotNode, ES_GAME, KeyMapper::PEV_UP);627 EventHandler::getInstance()->subscribe(this->pilotNode, ES_GAME, KeyMapper::PEV_DOWN);628 EventHandler::getInstance()->subscribe(this->pilotNode, ES_GAME, KeyMapper::PEV_LEFT);629 EventHandler::getInstance()->subscribe(this->pilotNode, ES_GAME, KeyMapper::PEV_RIGHT);630 EventHandler::getInstance()->subscribe(this->pilotNode, ES_GAME, EV_MOUSE_MOTION);631 632 /*633 PNode* tn = TrackManager::getInstance()->getTrackNode();634 tn->addChild(this->localPlayer);635 this->localCamera->lookAt(tn);636 637 tn->addChild(this->localCamera);638 this->localPlayer->setParentMode(PNODE_ALL);639 TrackManager::getInstance()->condition(2, LEFTRIGHT, this->localPlayer);640 */641 474 this->glmis->step(); 642 475 break; … … 666 499 { 667 500 this->bPause = false; 668 this->pilotNode = NULL;669 501 670 502 /* update the object position before game start - so there are no wrong coordinates used in the first processing */ … … 842 674 void World::handleInput () 843 675 { 844 // localinput845 //CommandNode* cn = Orxonox::getInstance()->getLocalInput();846 //cn->process();847 848 676 EventHandler::getInstance()->process(); 849 677 … … 897 725 898 726 /* update tick the rest */ 899 TrackManager::getInstance()->tick(this->dtS);900 727 this->localCamera->tick(this->dtS); 901 728 // tick the engines -
branches/network/src/story_entities/world.h
r5429 r5968 16 16 class Camera; 17 17 class Player; 18 class PNode;19 18 class GLMenuImageScreen; 20 19 class Terrain; … … 22 21 class Text; 23 22 class TiXmlElement; 24 class PilotNode;25 23 26 24 class Shell; … … 121 119 tList<WorldEntity>* entities; //!< A template List of all entities. Every moving thing should be included here, and world automatically updates them. 122 120 Player* localPlayer; //!< The Player, you fly through the level. 123 PilotNode* pilotNode; //!< THe pilot node to fly with the mouse124 125 126 121 }; 127 122 -
branches/network/src/subprojects/framework.cc
r5819 r5968 24 24 #include "resource_manager.h" 25 25 #include "camera.h" 26 #include " ini_parser.h"26 #include "parser/ini_parser/ini_parser.h" 27 27 #include "globals.h" 28 28 -
branches/network/src/subprojects/importer/Makefile.am
r5750 r5968 6 6 importer_LDFLAGS = $(MWINDOWS) 7 7 8 bin_PROGRAMS = importer 8 bin_PROGRAMS = importer \ 9 multitex 9 10 10 11 importer_LDADD = $(MAINSRCDIR)/lib/event/libORXevent.a \ … … 32 33 $(MAINSRCDIR)/lib/util/color.cc \ 33 34 $(MAINSRCDIR)/lib/util/multi_type.cc \ 35 $(MAINSRCDIR)/lib/util/executor/executor.cc \ 34 36 $(MAINSRCDIR)/util/loading/factory.cc 37 38 39 multitex_LDADD = $(MAINSRCDIR)/lib/event/libORXevent.a \ 40 $(MAINSRCDIR)/lib/tinyxml/libtinyxml.a \ 41 $(MAINSRCDIR)/lib/graphics/libORXgraphics.a \ 42 $(MAINSRCDIR)/lib/shell/libORXshell.a \ 43 $(MAINSRCDIR)/lib/sound/libORXsound.a \ 44 $(MAINSRCDIR)/lib/graphics/importer/libORXimporter.a 45 46 multitex_SOURCES= ../framework.cc \ 47 multitex.cc \ 48 $(MAINSRCDIR)/util/state.cc \ 49 $(MAINSRCDIR)/world_entities/camera.cc \ 50 $(MAINSRCDIR)/lib/lang/base_object.cc \ 51 $(MAINSRCDIR)/lib/lang/class_list.cc \ 52 $(MAINSRCDIR)/lib/math/vector.cc \ 53 $(MAINSRCDIR)/util/loading/resource_manager.cc \ 54 $(MAINSRCDIR)/lib/util/ini_parser.cc \ 55 $(MAINSRCDIR)/lib/coord/p_node.cc \ 56 $(MAINSRCDIR)/lib/coord/null_parent.cc \ 57 $(MAINSRCDIR)/util/loading/load_param.cc \ 58 $(MAINSRCDIR)/util/loading/load_param_description.cc \ 59 $(MAINSRCDIR)/lib/util/helper_functions.cc \ 60 $(MAINSRCDIR)/lib/util/substring.cc \ 61 $(MAINSRCDIR)/lib/util/color.cc \ 62 $(MAINSRCDIR)/lib/util/multi_type.cc \ 63 $(MAINSRCDIR)/lib/util/executor/executor.cc \ 64 $(MAINSRCDIR)/util/loading/factory.cc -
branches/network/src/util/loading/factory.h
r5750 r5968 25 25 class BaseObject; 26 26 27 #include " tinyxml.h"27 #include "parser/tinyxml/tinyxml.h" 28 28 #include "base_object.h" 29 29 #include "debug.h" -
branches/network/src/util/loading/resource_manager.cc
r5483 r5968 33 33 #endif /* NO_TEXT */ 34 34 #ifndef NO_AUDIO 35 #include "sound_ engine.h"35 #include "sound_buffer.h" 36 36 #include "ogg_player.h" 37 37 #endif /* NO_AUDIO */ -
branches/network/src/util/object_manager.cc
r5795 r5968 62 62 list<BaseObject*>::const_iterator node; 63 63 for (node = objectList->begin(); node != objectList->end(); node++) 64 {65 printf("1:::%s\n", (*node)->getName());66 64 if ((dynamic_cast<PNode*>(*node)->getAbsCoor() - center.getAbsCoor()).len() < radius) 67 {68 65 newList->push_back(dynamic_cast<WorldEntity*>(*node)); 69 printf("%s\n",(*node)->getName());70 }71 }72 66 return newList; 73 67 } -
branches/network/src/util/track/track_manager.cc
r5767 r5968 28 28 29 29 30 #include " tinyxml.h"30 #include "parser/tinyxml/tinyxml.h" 31 31 #include "substring.h" 32 32 -
branches/network/src/world_entities/Makefile.am
r5750 r5968 7 7 world_entity.cc \ 8 8 camera.cc \ 9 player.cc \ 9 playable.cc \ 10 player.cc \ 10 11 npc.cc \ 11 12 npc2.cc \ … … 17 18 character_attributes.cc \ 18 19 test_entity.cc \ 20 space_ships/space_ship.cc \ 19 21 weapons/weapon_manager.cc \ 20 22 weapons/weapon.cc \ … … 35 37 world_entity.h \ 36 38 camera.h \ 37 player.h \ 39 playable.h \ 40 player.h \ 38 41 npc.h \ 39 42 npc2.h \ … … 45 48 character_attributes.h \ 46 49 test_entity.h \ 50 space_ships/space_ship.h \ 47 51 weapons/weapon_manager.h \ 48 52 weapons/weapon.h \ -
branches/network/src/world_entities/player.cc
r5833 r5968 10 10 11 11 ### File Specific: 12 main-programmer: Patrick Boenzli13 co-programmer: Christian Meyer12 main-programmer: Silvan Nellen 13 co-programmer: Benjamin Knecht 14 14 */ 15 15 16 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY17 18 19 #include "executor/executor.h"20 16 #include "player.h" 21 22 #include "track_manager.h" 23 #include "objModel.h" 24 #include "resource_manager.h" 25 #include "factory.h" 26 27 #include "weapons/weapon_manager.h" 28 #include "weapons/test_gun.h" 29 #include "weapons/turret.h" 30 #include "weapons/cannon.h" 31 32 #include "list.h" 17 #include "playable.h" 33 18 34 19 #include "event_handler.h" 35 20 36 #include "event.h"37 38 21 using namespace std; 39 40 CREATE_FACTORY(Player, CL_PLAYER);41 42 43 44 #define UP 045 #define DOWN 146 #define RIGHT 247 #define LEFT 348 #define TIME 449 22 50 23 51 24 /** 52 25 * creates a new Player 53 * @param isFree if the player is free54 26 */ 55 27 Player::Player() … … 58 30 } 59 31 60 /**61 * loads a Players information from a specified file.62 * @param fileName the name of the File to load the player from (absolute path)63 */64 Player::Player(const char* fileName)65 {66 this->init();67 TiXmlDocument doc(fileName);68 69 if(!doc.LoadFile())70 {71 PRINTF(2)("Loading file %s failed for player.\n", fileName);72 return;73 }74 75 this->loadParams(doc.RootElement());76 }77 78 /**79 * creates a new Player from Xml Data80 * @param root the xml element containing player data81 82 @todo add more parameters to load83 */84 Player::Player(const TiXmlElement* root)85 {86 this->init();87 if (root != NULL)88 this->loadParams(root);89 90 //weapons:91 Weapon* wpRight = new TestGun(0);92 wpRight->setName("testGun Right");93 Weapon* wpLeft = new TestGun(1);94 wpLeft->setName("testGun Left");95 Weapon* cannon = dynamic_cast<Weapon*>(Factory::getFirst()->fabricate(CL_CANNON));96 97 cannon->setName("BFG");98 99 this->weaponMan->addWeapon(wpLeft, 1, 0);100 this->weaponMan->addWeapon(wpRight,1 ,1);101 this->weaponMan->addWeapon(cannon, 0, 6);102 103 //this->weaponMan->addWeapon(turret, 3, 0);104 105 this->weaponMan->changeWeaponConfig(1);106 }107 32 108 33 /** … … 111 36 Player::~Player () 112 37 { 113 /* do not delete the weapons, they are contained in the pnode tree114 and will be deleted there.115 this only frees the memory allocated to save the list.116 */117 delete this->weaponMan;118 if( this->outData)119 delete[] this->outData;120 if( this->inData)121 delete[] this->inData;122 38 } 123 39 124 //#include "glgui_pushbutton.h"125 40 126 41 /** … … 133 48 134 49 PRINTF(4)("PLAYER INIT\n"); 135 travelSpeed = 15.0;136 bUp = bDown = bLeft = bRight = bAscend = bDescend = false;137 bFire = false;138 acceleration = 10.0;139 50 140 // GLGuiButton* button = new GLGuiPushButton(); 141 // button->show(); 142 // button->setLabel("orxonox"); 143 // button->setBindNode(this); 144 145 this->weaponMan = new WeaponManager(this); 146 this->weaponMan->setSlotCount(7); 147 148 this->weaponMan->setSlotPosition(0, Vector(-2.6, .1, -3.0)); 149 this->weaponMan->setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 150 151 this->weaponMan->setSlotPosition(1, Vector(-2.6, .1, 3.0)); 152 this->weaponMan->setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 153 154 this->weaponMan->setSlotPosition(2, Vector(-1.5, .5, -.5)); 155 this->weaponMan->setSlotDirection(2, Quaternion(-M_PI_4*.5, Vector(1,0,0))); 156 157 this->weaponMan->setSlotPosition(3, Vector(-1.5, .5, .5)); 158 this->weaponMan->setSlotDirection(3, Quaternion(M_PI_4*.5, Vector(1,0,0))); 159 160 this->weaponMan->setSlotPosition(4, Vector(-1.5, -.5, .5)); 161 this->weaponMan->setSlotDirection(4, Quaternion(-M_PI_4*.5+M_PI, Vector(1,0,0))); 162 163 this->weaponMan->setSlotPosition(5, Vector(-1.5, -.5, -.5)); 164 this->weaponMan->setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0))); 165 // 166 this->weaponMan->setSlotPosition(6, Vector(-1, 0.0, 0)); 167 this->weaponMan->setSlotCapability(6, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 168 // 169 // this->weaponMan->setSlotPosition(8, Vector(-2.5, -0.3, -2.0)); 170 // this->weaponMan->setSlotDirection(8, Quaternion(-M_PI, Vector(1,0,0))); 171 // 172 // this->weaponMan->setSlotPosition(9, Vector(-2.5, -0.3, 2.0)); 173 // this->weaponMan->setSlotDirection(9, Quaternion(+M_PI, Vector(1,0,0)));: 174 175 this->outBufferLength = 100; 176 this->outLength = 0; 177 this->recLength = 0; 178 this->inBufferLength = 100; 179 this->inLength = 0; 180 this->sentLength = 0; 181 this->outData = new byte[this->outBufferLength]; 182 this->inData = new byte[this->inBufferLength]; 51 this->controllable = NULL; 183 52 } 184 53 185 54 186 /** 187 * loads the Settings of a Player from an XML-element. 188 * @param root the XML-element to load the Player's properties from 189 */ 190 void Player::loadParams(const TiXmlElement* root) 55 bool Player::setControllable(Playable* controllable) 191 56 { 192 static_cast<WorldEntity*>(this)->loadParams(root); 193 194 195 57 if(controllable != NULL && controllable->subscribePlayer(this)) 58 { 59 this->controllable = controllable; 60 return true; 61 } 62 else 63 return false; 196 64 } 197 65 198 /** 199 * adds a weapon to the weapon list of player 200 * @param weapon to add 201 */ 202 void Player::addWeapon(Weapon* weapon) 203 { 204 this->weaponMan->addWeapon(weapon); 205 } 66 bool Player::disconnectControllable() 67 { 68 if(this->controllable == NULL) return true; 206 69 70 if(this->controllable->unsubscribePlayer(this)) 71 { 72 this->controllable = NULL; 73 return true; 74 } 75 else 76 return false; 77 } 207 78 208 /** 209 * removes a weapon from the player 210 * @param weapon to remove 211 */ 212 void Player::removeWeapon(Weapon* weapon) 213 { 214 this->weaponMan->removeWeapon(weapon); 215 } 79 void Player::process(const Event &event) 80 { 81 if (likely(this->controllable != NULL)) 82 this->controllable->process(event); 83 } 216 84 217 218 /**219 * effect that occurs after the player is spawned220 */221 void Player::postSpawn ()222 {223 //setCollision(new CollisionCluster(1.0, Vector(0,0,0)));224 }225 226 227 /**228 * the action occuring if the player left the game229 */230 void Player::leftWorld ()231 {}232 233 234 WorldEntity* ref = NULL;235 /**236 * this function is called, when two entities collide237 * @param entity: the world entity with whom it collides238 *239 * Implement behaviour like damage application or other miscellaneous collision stuff in this function240 */241 void Player::collidesWith(WorldEntity* entity, const Vector& location)242 {243 if (entity->isA(CL_TURRET_POWER_UP) && entity != ref)244 {245 this->ADDWEAPON();246 ref = entity;247 }248 // PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getClassName(), entity->getClassName(), location.x, location.y, location.z);249 }250 251 /**252 * draws the player after transforming him.253 */254 void Player::draw () const255 {256 glMatrixMode(GL_MODELVIEW);257 glPushMatrix();258 /* translate */259 glTranslatef (this->getAbsCoor ().x,260 this->getAbsCoor ().y,261 this->getAbsCoor ().z);262 /* rotate */263 Vector tmpRot = this->getAbsDir().getSpacialAxis();264 glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );265 this->model->draw();266 glPopMatrix();267 268 this->weaponMan->draw();269 270 //this->debug(0);271 }272 273 274 /**275 * the function called for each passing timeSnap276 * @param time The timespan passed since last update277 */278 void Player::tick (float time)279 {280 // player controlled movement281 this->move(time);282 283 this->weaponMan->tick(time);284 // weapon system manipulation285 this->weaponAction();286 }287 288 289 /**290 * action if player moves291 * @param time the timeslice since the last frame292 */293 void Player::move (float time)294 {295 Vector accel(0.0, 0.0, 0.0);296 Vector rot(0.0, 0.0, 0.0);297 float rotVal = 0.0;298 /* FIXME: calculating the direction and orthDirection every timeSlice is redundant! save it somewhere */299 /* calculate the direction in which the craft is heading */300 Vector direction (1.0, 0.0, 0.0);301 //direction = this->absDirection.apply (direction);302 Vector orthDirection (0.0, 0.0, 1.0);303 //orthDirection = orthDirection.cross (direction);304 305 306 if( this->outLength >= this->outBufferLength) return;307 308 if( this->bUp || this->bDown || this->bRight || this->bLeft)309 {310 this->outData[this->outLength++] = TIME;311 this->outData[this->outLength++] = (byte)(lround(time * 100.0f));312 313 PRINTF(0)("Writing TIME = %i, or %f\n", this->outData[this->outLength-1], time);314 }315 316 if( this->bUp && this->getRelCoor().x < 20)317 {318 accel += direction;319 this->outData[this->outLength++] = UP;320 }321 if( this->bDown && this->getRelCoor().x > -5)322 {323 accel -= direction;324 this->outData[this->outLength++] = DOWN;325 }326 if( this->bLeft && TrackManager::getInstance()->getWidth() > -this->getRelCoor().z*2)327 {328 accel -=(orthDirection);329 rot +=Vector(1,0,0);330 rotVal -= .4;331 this->outData[this->outLength++] = LEFT;332 }333 if( this->bRight && TrackManager::getInstance()->getWidth() > this->getRelCoor().z*2)334 {335 accel += orthDirection;336 rot += Vector(1,0,0);337 rotVal += .4;338 this->outData[this->outLength++] = RIGHT;339 }340 if (this->bAscend )341 {342 accel += Vector(0,1,0);343 rot += Vector(0,0,1);344 rotVal += .4;345 }346 if (this->bDescend )347 {348 accel -= Vector(0,1,0);349 rot += Vector(0,0,1);350 rotVal -= .4;351 }352 353 354 Vector move = accel * time *acceleration;355 356 /* if (accel.z < 0)357 this->setRelDirSoft(Quaternion(-.4, accel), 5);358 else if (accel.z > 0)359 this->setRelDirSoft(Quaternion(.4, accel), 5);360 else*/361 rot.normalize();362 this->setRelDirSoft(Quaternion(rotVal, rot), 5);363 this->shiftCoor (move);364 365 366 }367 368 369 /**370 * weapon manipulation by the player371 */372 void Player::weaponAction()373 {374 if( this->bFire)375 {376 this->weaponMan->fire();377 }378 }379 380 /**381 * @todo switch statement ??382 */383 void Player::process(const Event &event)384 {385 if( event.type == KeyMapper::PEV_UP)386 this->bUp = event.bPressed;387 else if( event.type == KeyMapper::PEV_DOWN)388 this->bDown = event.bPressed;389 else if( event.type == KeyMapper::PEV_RIGHT)390 this->bRight= event.bPressed;391 else if( event.type == KeyMapper::PEV_LEFT)392 this->bLeft = event.bPressed;393 else if( event.type == KeyMapper::PEV_FIRE1)394 this->bFire = event.bPressed;395 else if( event.type == KeyMapper::PEV_NEXT_WEAPON && event.bPressed)396 this->weaponMan->nextWeaponConfig();//if( !event.bPressed) this->bWeaponChange = !this->bWeaponChange;397 else if ( event.type == KeyMapper::PEV_PREVIOUS_WEAPON && event.bPressed)398 this->weaponMan->previousWeaponConfig();399 400 else if( event.type == SDLK_PAGEUP)401 this->bAscend = event.bPressed; //this->shiftCoor(0,.1,0);402 else if( event.type == SDLK_PAGEDOWN)403 this->bDescend = event.bPressed; //this->shiftCoor(0,-.1,0);404 }405 406 #include "weapons/aiming_turret.h"407 // FIXME THIS MIGHT BE CONSIDERED EITHER A FEATURE, OR A BUG408 void Player::ADDWEAPON()409 {410 Weapon* turret = NULL;411 412 if ((float)rand()/RAND_MAX < .1)413 {414 //if (this->weaponMan->hasFreeSlot(2, WTYPE_TURRET))415 {416 turret = new Turret();417 this->weaponMan->addWeapon(turret, 2);418 this->weaponMan->changeWeaponConfig(2);419 }420 }421 else422 {423 //if (this->weaponMan->hasFreeSlot(3))424 {425 turret = new AimingTurret();426 this->weaponMan->addWeapon(turret, 3);427 428 this->weaponMan->changeWeaponConfig(3);429 }430 }431 432 if(turret != NULL)433 {434 turret->setName("Turret");435 turret->setStateDuration(WS_SHOOTING, (float)rand()/RAND_MAX*.5+.1);436 }437 }438 439 440 441 442 /**443 * write data to Synchronizeable444 */445 void Player::writeBytes(const byte* data, int length)446 {447 // PRINTF(0)("Player: got %i bytes of data\n", length);448 this->inLength = length;449 450 /*451 bytes: | 0 | 1 |452 CODE DIST453 454 455 CODE:456 0 : Up457 1 : Down458 2 : Right459 3 : Left460 4 : TIME461 462 DIST:463 Coordinate diff multiplied by 100 and casted to a byte: byte a = (byte)(x * 100)464 465 */466 467 float time = 0.0f;468 469 Vector accel(0.0, 0.0, 0.0);470 Vector direction (1.0, 0.0, 0.0);471 Vector orthDirection (0.0, 0.0, 1.0);472 473 byte code = 0;474 475 /* iterate through all bytes */476 for( int i = 0; i < length; i++)477 {478 479 code = data[i];480 481 //PRINTF(0)("got byte: %u\n", data[i]);482 /* is it a time code? */483 if( code == TIME)484 {485 /* is it the first time */486 487 /* read out new movement */488 time = (float)(data[++i] / 100.0f);489 //PRINTF(0)("Got time: %f msec\n", time);490 }491 492 else if( code == UP && this->getRelCoor().x < 20)493 accel = accel+(direction*acceleration);494 else if( code == DOWN && this->getRelCoor().x > -5)495 accel = accel -(direction*acceleration);496 else if( code == LEFT && TrackManager::getInstance()->getWidth() > -this->getRelCoor().z*2)497 accel = accel - (orthDirection*acceleration);498 else if( code == RIGHT && TrackManager::getInstance()->getWidth() > this->getRelCoor().z*2)499 accel = accel + (orthDirection*acceleration);500 501 if( time > 0.0f )502 {503 /* apply movement */504 Vector move = accel * time;505 506 if (accel.z < 0)507 this->setRelDirSoft(Quaternion(-.4, Vector(1,0,0)), 5);508 else if (accel.z > 0)509 this->setRelDirSoft(Quaternion(.4, Vector(1,0,0)), 5);510 else511 this->setRelDirSoft(Quaternion(0, Vector(1,0,0)), 5);512 this->shiftCoor (move);513 }514 515 }516 517 518 519 520 521 /* and debug output */522 this->writeDebug();523 }524 525 526 /**527 * read data from Synchronizeable528 */529 int Player::readBytes(byte* data)530 {531 // PRINTF(0)("Player: sent %i bytes of data\n", this->sentLength);532 533 /* copy data */534 for( int i = 0; i < this->outLength; ++i)535 data[i] = this->outData[i];536 537 538 539 /* debug msg */540 this->readDebug();541 542 int length = this->outLength;543 this->outLength = 0;544 /* return the length of the test */545 return length;546 }547 548 549 void Player::writeDebug() const550 {551 552 }553 554 555 void Player::readDebug() const556 {557 558 }559 -
branches/network/src/world_entities/player.h
r5829 r5968 7 7 #define _PLAYER_H 8 8 9 #include "world_entity.h"10 #include "physics_interface.h"11 9 #include "event_listener.h" 12 10 13 template<class T> 14 class tList; 15 class Weapon; 16 class WeaponManager; 17 class Vector; 18 class Event; 11 /* Forward Declaration */ 12 class Playable; 19 13 20 14 //! Basic controllable WorldEntity … … 24 18 the player.cc for debug also 25 19 */ 26 class Player : public WorldEntity, publicEventListener20 class Player : public EventListener 27 21 { 28 friend class World;29 22 30 23 public: 31 24 Player(); 32 Player(const char* fileName);33 Player(const TiXmlElement* root);34 25 virtual ~Player(); 35 26 36 void init();37 void loadParams(const TiXmlElement* root);27 bool setControllable(Playable* controllalble); 28 inline Playable* getControllable() { return this->controllable; }; 38 29 39 void addWeapon(Weapon* weapon); 40 void removeWeapon(Weapon* weapon); 30 bool disconnectControllable(); 41 31 42 /* WorldEntity functions */ 43 virtual void postSpawn(); 44 virtual void leftWorld(); 45 46 virtual void collidesWith(WorldEntity* entity, const Vector& location); 47 virtual void tick(float time); 48 virtual void draw() const; 49 50 virtual void process(const Event &event); 51 52 /* Synchronizeable functions */ 53 virtual void writeBytes(const byte* data, int length); 54 virtual int readBytes(byte* data); 32 // eventListener extension. 33 virtual void process(const Event &event); 55 34 56 35 private: 57 void move(float time); 58 void weaponAction(); 36 void init(); 59 37 60 /* Synchronizeable functions */61 virtual void writeDebug() const;62 virtual void readDebug() const;63 64 // !! temporary !!65 void ADDWEAPON();66 38 67 39 private: 68 bool bUp; //!< up button pressed. 69 bool bDown; //!< down button pressed. 70 bool bLeft; //!< left button pressed. 71 bool bRight; //!< right button pressed. 72 bool bAscend; //!< ascend button pressed. 73 bool bDescend; //!< descend button presses. 74 bool bFire; //!< fire button pressed. 75 76 WeaponManager* weaponMan; //!< the weapon manager: managing a list of weapon to wepaon-slot mapping 77 78 Vector velocity; //!< the velocity of the player. 79 float travelSpeed; //!< the current speed of the player (to make soft movement) 80 float acceleration; //!< the acceleration of the player. 81 82 byte* inData; 83 int inLength; 84 int inBufferLength; 85 int recLength; 86 byte* outData; 87 int outLength; 88 int outBufferLength; 89 int sentLength; 90 40 Playable* controllable; //!< The one we controll or NULL if none 91 41 }; 92 42 -
branches/network/src/world_entities/power_ups/laser_power_up.cc
r5750 r5968 79 79 { 80 80 // PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getClassName(), entity->getClassName(), location.x, location.y, location.z); 81 if (entity->isA(CL_PLAY ER))81 if (entity->isA(CL_PLAYABLE)) 82 82 State::getWorldEntityList()->remove(this); 83 83 } -
branches/network/src/world_entities/power_ups/turret_power_up.cc
r5750 r5968 79 79 { 80 80 // PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getClassName(), entity->getClassName(), location.x, location.y, location.z); 81 if (entity->isA(CL_PLAY ER))81 if (entity->isA(CL_PLAYABLE)) 82 82 State::getWorldEntityList()->remove(this); 83 83 } -
branches/network/src/world_entities/weapons/aiming_turret.cc
r5819 r5968 26 26 27 27 #include "animation3d.h" 28 #include "sound_engine.h"29 28 30 29 #include "factory.h" … … 93 92 94 93 this->setCapability(WTYPE_ALLDIRS | WTYPE_TURRET); 95 this->setProjectileType(CL_ ROCKET);94 this->setProjectileType(CL_GUIDED_MISSILE); 96 95 97 96 … … 142 141 return; 143 142 144 143 pj->setVelocity(/*this->getVelocity()+*/(this->getAbsDir().apply(Vector(1,0,0))*250.0 + VECTOR_RAND(13) 145 144 /*target->getAbsCoor() - this->getAbsCoor()*/)*.5);//this->getVelocity()); 146 145 146 pj->setTarget(this->target->getParent()); 147 147 pj->setParent(NullParent::getInstance()); 148 148 pj->setAbsCoor(this->getEmissionPoint()); -
branches/network/src/world_entities/weapons/bomb.cc
r5769 r5968 17 17 #include "glincl.h" 18 18 #include "state.h" 19 #include "model.h" 20 #include "primitive_model.h" 21 22 #include "fast_factory.h" 19 23 #include "list.h" 20 #include "model.h"21 #include "vector.h"22 #include "fast_factory.h"23 24 25 #include "object_manager.h" 24 26 25 27 #include "particle_engine.h" … … 59 61 Bomb::~Bomb () 60 62 { 63 delete this->detonationSphere; 64 delete this->detonationMaterial; 61 65 62 66 } … … 71 75 this->setClassID(CL_BOMB, "Bomb"); 72 76 77 78 this->detonationSphere = new PrimitiveModel(PRIM_SPHERE); 79 this->detonationMaterial = new Material(); 80 this->detonationMaterial->setDiffuse(1, 0, 0); 81 // this->detonationMaterial->setTransparency(.1); 73 82 /** 74 83 * @todo: Write CL_PROTO_WORLD_ENTITY INTO THE src/defs/class_id.h (your own definition) … … 101 110 void Bomb::tick(float time) 102 111 { 103 //Vector v = *this->flightDirection * ( this->speed * time * 1000 + 0.1);104 Vector v = this->velocity * (time);105 this->shiftCoor(v);106 107 112 this->lifeCycle += time/this->lifeSpan; 108 113 if( this->lifeCycle >= 1.0) … … 114 119 this->deactivate(); 115 120 } 121 else if (this->lifeCycle > 0.9f) 122 this->detonate ((this->lifeCycle-.89) *1000.0); 123 else 124 { 125 Vector v = this->velocity * (time); 126 this->shiftCoor(v); 127 } 116 128 } 117 129 … … 133 145 glMultMatrixf((float*)matrix); 134 146 135 if (model) 136 model->draw(); 147 if (this->lifeCycle < .9) 148 { 149 if (model) 150 model->draw(); 151 } 152 else 153 { 154 glScalef((this->lifeCycle-.89) *1000.0, 155 (this->lifeCycle-.89) *1000.0, 156 (this->lifeCycle-.89) *1000.0); 157 this->detonationMaterial->select(); 158 this->detonationSphere->draw(); 159 } 137 160 glPopMatrix(); 138 161 } … … 145 168 void Bomb::collidesWith (WorldEntity* entity, const Vector& location) 146 169 { 147 this->detonate(); 170 if (this->lifeCycle < .9f && entity->isA(CL_NPC)) 171 this->lifeCycle = 0.9f; 148 172 } 149 173 … … 157 181 { 158 182 State::getWorldEntityList()->remove(this); 183 this->lifeCycle = 0.0f; 159 184 Bomb::fastFactory->kill(this); 160 185 } 161 186 162 void Bomb::detonate( )187 void Bomb::detonate(float size) 163 188 { 164 tIterator<WorldEntity>* it = State::getWorldEntityList()->getIterator(); 165 WorldEntity* lm = it->firstElement(); 166 167 while(lm != NULL) 189 std::list<WorldEntity*>* detonationList = ObjectManager::distanceFromObject(*this, size, CL_NPC); 190 if (detonationList != NULL) 168 191 { 169 170 lm = it->nextElement(); 192 while( !detonationList->empty() ) 193 { 194 detonationList->front()->collidesWith(this, Vector(0,0,0)); 195 detonationList->pop_front(); 196 } 197 delete detonationList; 171 198 } 172 199 } -
branches/network/src/world_entities/weapons/bomb.h
r5750 r5968 8 8 9 9 #include "projectile.h" 10 10 11 class FastFactory; 11 12 class ParticleSystem; 12 13 class ParticleEmitter; 14 class Material; 13 15 14 16 //! A Class to ... … … 31 33 virtual void collidesWith (WorldEntity* entity, const Vector& location); 32 34 virtual void activate(); 33 virtual void detonate();34 35 virtual void deactivate(); 36 37 void detonate(float size); 35 38 36 39 private: … … 40 43 41 44 ParticleEmitter* emitter; 42 45 Model* detonationSphere; 46 Material* detonationMaterial; 43 47 }; 44 48 -
branches/network/src/world_entities/weapons/cannon.cc
r5819 r5968 32 32 #include "list.h" 33 33 #include "animation3d.h" 34 #include "sound_engine.h"35 34 36 35 #include "null_parent.h" … … 83 82 this->setStateDuration(WS_DEACTIVATING, .4); 84 83 85 this->setMaximumEnergy(100, 1);86 this->increaseEnergy( 30);84 this->setMaximumEnergy(100, 20); 85 this->increaseEnergy(100); 87 86 //this->minCharge = 2; 88 87 -
branches/network/src/world_entities/weapons/ground_turret.cc
r5819 r5968 145 145 void GroundTurret::collidesWith (WorldEntity* entity, const Vector& location) 146 146 { 147 147 if (entity->isA(CL_PROJECTILE)) 148 this->setAbsDirSoft(Quaternion(-90, Vector(0,0,1)), 90); 148 149 } 149 150 -
branches/network/src/world_entities/weapons/guided_missile.cc
r5779 r5968 48 48 this->energyMin = 1; 49 49 this->energyMax = 10; 50 this->lifeSpan = 5 ;51 this->agility = 5 ;50 this->lifeSpan = 5.0; 51 this->agility = 5.0; 52 52 this->maxVelocity = 100; 53 53 -
branches/network/src/world_entities/weapons/test_gun.cc
r5819 r5968 32 32 #include "list.h" 33 33 #include "animation3d.h" 34 #include "sound_engine.h"35 34 36 35 #include "null_parent.h" -
branches/network/src/world_entities/weapons/turret.cc
r5819 r5968 26 26 #include "list.h" 27 27 #include "animation3d.h" 28 #include "sound_engine.h"29 28 30 29 #include "factory.h" -
branches/network/src/world_entities/weapons/weapon.cc
r5750 r5968 28 28 #include "load_param.h" 29 29 #include "state.h" 30 #include "sound_engine.h"31 30 #include "animation3d.h" 32 31 #include "vector.h" 32 33 #include "sound_source.h" 34 #include "sound_buffer.h" 33 35 34 36 //////////////////// -
branches/network/src/world_entities/weapons/weapon_manager.cc
r5779 r5968 110 110 this->crossHairSizeAnim->addKeyFrame(100, .05, ANIM_LINEAR); 111 111 this->crossHairSizeAnim->addKeyFrame(50, .01, ANIM_LINEAR); 112 113 this->targetIterator = NULL;114 112 } 115 113 … … 337 335 } 338 336 } 339 }340 341 342 /**343 * Selects an Entity from the NPC-list, and returns the Target344 */345 PNode* WeaponManager::getSomeTarget()346 {347 if (this->targetIterator == NULL)348 {349 std::list<BaseObject*>* npcList = ClassList::getList(CL_NPC);350 if (npcList != NULL)351 {352 this->targetIterator = npcList->begin();353 }354 else355 return NULL;356 }357 358 ///FIXME359 // this->targetIterator++;360 PNode* retNode = dynamic_cast<PNode*>((*targetIterator));361 // if (retNode == NULL && this->targetIterator->getList()->getSize() > 0)362 // retNode = dynamic_cast<PNode*>(targetIterator->firstElement());363 364 return retNode;365 }366 367 368 /**369 * Selects an Entity from the Entity-List, that is near of the carrier PNode.370 * @param carrier: The PNode from which the distance should be measured371 * @param distance: The Maximum Distance to Return.372 */373 PNode* WeaponManager::getDistanceTarget(const PNode* carrier, float distance)374 {375 std::list<BaseObject*>* npcList = ClassList::getList(CL_NPC);376 if (npcList != NULL)377 {378 list<BaseObject*>::iterator node;379 for (node= npcList->begin(); node != npcList->end(); node++)380 if ((carrier->getAbsCoor() - dynamic_cast<PNode*>(*node)->getAbsCoor()).len() < distance)381 return dynamic_cast<PNode*>(*node);382 }383 return this->getFixedTarget();384 337 } 385 338 -
branches/network/src/world_entities/weapons/weapon_manager.h
r5779 r5968 80 80 /** @returns a fixed target namely the Crosshair's 3D position */ 81 81 inline PNode* getFixedTarget() const { return this->crosshair; }; 82 PNode* getSomeTarget();83 PNode* getDistanceTarget(const PNode* carrier, float distance);84 82 85 83 void fire(); … … 109 107 Crosshair* crosshair; //!< an aim. 110 108 tAnimation<Crosshair>* crossHairSizeAnim; //!< An animation for the crosshair (scaling) 111 112 std::list<BaseObject*>::iterator targetIterator; //!< An iterator for traversion lists of enemies.113 109 };
Note: See TracChangeset
for help on using the changeset viewer.