- Timestamp:
- Jun 11, 2005, 12:55:48 AM (19 years ago)
- Location:
- orxonox/trunk/src
- Files:
-
- 74 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/defs/class_list.h
r4596 r4597 108 108 109 109 110 // WorldEntities (range from 0x00000201 to 0x00000 5ff)110 // WorldEntities (range from 0x00000201 to 0x000004ff) 111 111 CL_CAMERA = 0x00000201, 112 112 CL_CAMERA_TARGET = 0x00000202, … … 122 122 123 123 124 CL_EVENT = 0x00000a08, 125 CL_KEY_MAPPER = 0x00000a09, 124 // gamePlay (range from 0x00000500 0x000005ff) 125 CL_EVENT = 0x00000501, 126 CL_KEY_MAPPER = 0x00000502, 127 128 CL_WEAPON_MANAGER = 0x00000503, 129 130 // Physics stuff (range from 0x00000600 to 0x000007ff) 131 CL_PHYSICS_CONNECTION = 0x00000601, 132 // Collision 133 CL_COLLISION = 0x00000611, 134 CL_BV_TREE = 0x00000612, 135 CL_BV_TREE_NODE = 0x00000613, 136 CL_OBB_TREE = 0x00000614, 137 CL_OBB_TREE_NODE = 0x00000615, 138 CL_BOUNDING_VOLUME = 0x00000616, 139 CL_OBB = 0x00000617, 140 CL_BOUNDING_SPHERE = 0x00000618, 126 141 127 142 // graphical stuff (range from 0x00000800 to 0x000009ff) 128 143 CL_TEXT = 0x00000801, 129 CL_MATERIAL = 0x00000802, 130 CL_MODEL = 0x00000803, //!< \todo make this a SUBCLASS maybe 131 CL_OBJMODEL = 0x00000804, 132 CL_PROMITIVE_MODEL = 0x00000805, 133 CL_MD2Model = 0x00000806, 134 CL_LIGHT = 0x00000807, 135 CL_PARTICLE_EMITTER = 0x00000808, 136 CL_PARTICLE_SYSTEM = 0x00000809, 144 CL_FONT = 0x00000802, 145 CL_MATERIAL = 0x00000803, 146 CL_MODEL = 0x00000804, //!< \todo make this a SUBCLASS maybe 147 CL_OBJMODEL = 0x00000805, 148 CL_PROMITIVE_MODEL = 0x00000806, 149 CL_MD2Model = 0x00000807, 150 CL_LIGHT = 0x00000808, 151 CL_PARTICLE_EMITTER = 0x00000809, 152 CL_PARTICLE_SYSTEM = 0x0000080a, 153 CL_ENVIRONMENT = 0x00000810, 137 154 // GL-menu 138 155 CL_GLMENU_IMAGE_SCREEN = 0x00000901, 139 156 140 // Collision 141 CL_COLLISION, 142 CL_BV_TREE, 143 CL_BV_TREE_NODE, 144 CL_OBB_TREE, 145 CL_OBB_TREE_NODE, 146 CL_BOUNDING_VOLUME, 147 CL_OBB, 148 CL_BOUNDING_SPHERE, 157 // sound stuff (range from 0x00000a00 to 0x00000aff) 158 CL_SOUND_BUFFER = 0x00000a01, 159 CL_SOUND_SOURCE = 0x00000a02, 149 160 150 // misc: (range from 0x00000a00 to 0x00000bff) 151 CL_ANIMATION = 0x00000a01, 152 // CL_ANIMATION3D = 0x00000a02, 153 CL_FACTORY = 0x00000a02, 154 CL_INI_PARSER = 0x00000a03, 155 CL_LIST = 0x00000a04, 156 CL_SUBSTRING = 0x00000a05, 157 CL_LOAD_PARAM = 0x00000a06, 158 CL_CURVE = 0x00000a07, 159 CL_VECTOR = 0x00000a08, 160 CL_CHARACTER_ATTRIBUTES = 0x00000a09, 161 CL_NUMBER 161 162 // misc: (range from 0x00000b00 to 0x00000cff) 163 CL_ANIMATION = 0x00000b01, 164 // CL_ANIMATION3D = 0x00000b02, 165 CL_QUICK_ANIMATION = 0x00000b02, 166 CL_FACTORY = 0x00000b03, 167 CL_INI_PARSER = 0x00000b04, 168 CL_LIST = 0x00000b05, 169 CL_SUBSTRING = 0x00000b06, 170 CL_LOAD_PARAM = 0x00000b07, 171 CL_CURVE = 0x00000b08, 172 CL_VECTOR = 0x00000b09, 173 CL_CHARACTER_ATTRIBUTES = 0x00000b0a, 174 CL_TRACK_ELEMENT = 0x00000b0b, 175 CL_NUMBER = 0x00000b0c 162 176 }; 163 177 -
orxonox/trunk/src/glmenu/glmenu_imagescreen.cc
r4453 r4597 1 1 2 2 3 /* 3 /* 4 4 orxonox - the future of 3D-vertical-scrollers 5 5 … … 13 13 ### File Specific: 14 14 main-programmer: Patrick Boenzli 15 co-programmer: 15 co-programmer: 16 16 */ 17 17 … … 28 28 using namespace std; 29 29 /** 30 \brief standard constructor31 */32 GLMenuImageScreen::GLMenuImageScreen ()33 {34 this->init();35 }36 37 /**38 30 \param root The Element to load the GLMenu from 39 31 */ 40 32 GLMenuImageScreen::GLMenuImageScreen(const TiXmlElement* root) 41 33 { 42 this->init();43 this->loadParams(root);44 }45 46 /**47 \brief Loads a GLMenu from an inputElement48 \param root The Element to load the GLMenu from49 */50 void GLMenuImageScreen::loadParams(const TiXmlElement* root)51 {52 LoadParam<GLMenuImageScreen>(root, "BackgroundImage", this, &GLMenuImageScreen::setBackgroundImage)53 .describe("sets the image to load onto the loadscreen");54 55 LoadParam<GLMenuImageScreen>(root, "BackgroundPS", this, &GLMenuImageScreen::setPosScale)56 .describe("The Position and Scale of the Background Image in %(0-1.0). PosX, PosY, SizeX, SizeY");57 58 LoadParam<GLMenuImageScreen>(root, "BarImage", this, &GLMenuImageScreen::setBarImage)59 .describe("sets the image of the LoadingBar");60 61 LoadParam<GLMenuImageScreen>(root, "BarPS", this, &GLMenuImageScreen::setBarPosScale)62 .describe("The Position and Scale of the Loading Bar in %(0-1.0). PosX, PosY, SizeX, SizeY");63 64 LoadParam<GLMenuImageScreen>(root, "ElementCount", this, &GLMenuImageScreen::setMaximum)65 .describe("The Count of elements to load into the bar (this is only a maximum value)");66 }67 68 /**69 \brief standard deconstructor70 \todo this deconstructor is not jet implemented - do it71 */72 GLMenuImageScreen::~GLMenuImageScreen()73 {74 delete this->backMat;75 delete this->barMat;76 }77 78 /**79 \brief function to init the screen80 */81 void GLMenuImageScreen::init ()82 {83 34 this->setClassID(CL_GLMENU_IMAGE_SCREEN, "GLMenuImageScreen"); 84 35 this->setName("GLMenuLoadScreen"); 85 36 // Select Our VU Meter Background Texture 86 37 this->backMat = new Material("load_screen"); … … 92 43 this->setBarPosScale( .6, .75, .3, .1); 93 44 // End of Background image code. 94 } 95 96 /** 45 46 if (root) 47 this->loadParams(root); 48 } 49 50 /** 51 \brief Loads a GLMenu from an inputElement 52 \param root The Element to load the GLMenu from 53 */ 54 void GLMenuImageScreen::loadParams(const TiXmlElement* root) 55 { 56 LoadParam<GLMenuImageScreen>(root, "BackgroundImage", this, &GLMenuImageScreen::setBackgroundImage) 57 .describe("sets the image to load onto the loadscreen"); 58 59 LoadParam<GLMenuImageScreen>(root, "BackgroundPS", this, &GLMenuImageScreen::setPosScale) 60 .describe("The Position and Scale of the Background Image in %(0-1.0). PosX, PosY, SizeX, SizeY"); 61 62 LoadParam<GLMenuImageScreen>(root, "BarImage", this, &GLMenuImageScreen::setBarImage) 63 .describe("sets the image of the LoadingBar"); 64 65 LoadParam<GLMenuImageScreen>(root, "BarPS", this, &GLMenuImageScreen::setBarPosScale) 66 .describe("The Position and Scale of the Loading Bar in %(0-1.0). PosX, PosY, SizeX, SizeY"); 67 68 LoadParam<GLMenuImageScreen>(root, "ElementCount", this, &GLMenuImageScreen::setMaximum) 69 .describe("The Count of elements to load into the bar (this is only a maximum value)"); 70 } 71 72 /** 73 \brief standard deconstructor 74 \todo this deconstructor is not jet implemented - do it 75 */ 76 GLMenuImageScreen::~GLMenuImageScreen() 77 { 78 delete this->backMat; 79 delete this->barMat; 80 } 81 82 /** 97 83 \brief sets the background image name 98 84 \param backImageName name of the backgroun-image … … 191 177 192 178 193 /** 179 /** 194 180 \brief call this to trigger a progress event 195 181 196 182 this has to redraw the progress bar and the whole image 197 183 */ … … 211 197 glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); 212 198 213 PRINTF(4)("GLMenuImagEscreen::draw() - drawing step %i/%i\n", 214 199 PRINTF(4)("GLMenuImagEscreen::draw() - drawing step %i/%i\n", 200 this->currentValue, this->maxValue); 215 201 216 202 /* screen size */ 217 203 int screenWidth = GraphicsEngine::getInstance()->getResolutionX(); 218 204 int screenHeight = GraphicsEngine::getInstance()->getResolutionY(); 219 205 220 206 int imageWidth = (int)(screenWidth * this->scaleX); 221 207 int imageHeight = (int)(screenHeight * this->scaleY); … … 229 215 int barW = (int)(this->barW *screenWidth); 230 216 int barH = (int)(this->barH *screenHeight); 231 217 232 218 float val = (float)this->currentValue/(float)this->maxValue; 233 219 234 220 if( val > barW) 235 221 val = barW; … … 245 231 glTexCoord2i(1, 0); glVertex2i(offsetX + imageWidth, offsetY); 246 232 glEnd(); 247 233 248 234 glDisable(GL_TEXTURE_2D); 249 235 /* draw white border */ … … 256 242 glColor3f(1.0, 1.0, 1.0); 257 243 glEnd(); 258 244 259 245 /* draw the progress bar */ 260 246 barMat->select(); … … 275 261 glColor3f(1.0, 1.0, 1.0); 276 262 glEnd(); 277 278 /* draw black border 263 264 /* draw black border 279 265 glBegin(GL_QUADS); 280 266 glColor3f(0.0, 0.0, 0.0); … … 285 271 glColor3f(1.0, 1.0, 1.0); 286 272 glEnd(); 287 273 288 274 */ 289 275 290 276 GraphicsEngine::leave2DMode(); 291 277 292 SDL_GL_SwapBuffers(); 293 } 294 295 278 SDL_GL_SwapBuffers(); 279 } 280 281 -
orxonox/trunk/src/glmenu/glmenu_imagescreen.h
r4453 r4597 1 /*! 1 /*! 2 2 \file glmenu_imagescreen.h 3 3 \brief class to display a LoadScreen … … 16 16 17 17 public: 18 GLMenuImageScreen (); 19 GLMenuImageScreen (const TiXmlElement* root); 18 GLMenuImageScreen (const TiXmlElement* root = NULL); 20 19 void loadParams(const TiXmlElement* root); 21 20 virtual ~GLMenuImageScreen (); 22 21 23 void init();22 void draw (); 24 23 25 void draw ();26 27 24 void setBackgroundImage(const char* backImageName); 28 25 void setPosition(float offsetX, float offsetY); -
orxonox/trunk/src/lib/graphics/graphics_engine.cc
r4536 r4597 1 /* 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 … … 29 29 \todo this constructor is not jet implemented - do it 30 30 */ 31 GraphicsEngine::GraphicsEngine () 32 { 31 GraphicsEngine::GraphicsEngine () 32 { 33 this->setClassID(CL_GRAPHICS_ENGINE, "GraphicsEngine"); 34 this->setName("GraphicsEngine"); 33 35 this->bDisplayFPS = false; 34 36 this->minFPS = 9999; 35 37 this->maxFPS = 0; 36 this->setClassID(CL_GRAPHICS_ENGINE, "GraphicsEngine");37 38 38 39 this->fullscreen = false; … … 51 52 \brief destructs the graphicsEngine. 52 53 */ 53 GraphicsEngine::~GraphicsEngine () 54 GraphicsEngine::~GraphicsEngine () 54 55 { 55 56 // delete what has to be deleted here … … 79 80 if( videoInfo == NULL) 80 81 { 81 PRINTF(1)("Failed getting Video Info :%s\n", SDL_GetError()); 82 PRINTF(1)("Failed getting Video Info :%s\n", SDL_GetError()); 82 83 SDL_Quit (); 83 84 } 84 85 if( videoInfo->hw_available) 85 86 this->videoFlags |= SDL_HWSURFACE; 86 else 87 else 87 88 this->videoFlags |= SDL_SWSURFACE; 88 89 /* … … 93 94 // setting up the Resolution 94 95 this->setResolution(800, 600, 16); 95 96 96 97 // Set window labeling 97 98 SDL_WM_SetCaption ("Orxonox " PACKAGE_VERSION, "Orxonox " PACKAGE_VERSION); 98 99 99 100 // TO DO: Create a cool icon and use it here 100 101 char* loadPic = new char[strlen(ResourceManager::getInstance()->getDataDir())+ 100]; 101 102 sprintf(loadPic, "%s%s", ResourceManager::getInstance()->getDataDir(), "pictures/orxonox-icon32x32.bmp"); 102 SDL_WM_SetIcon(SDL_LoadBMP(loadPic), NULL); 103 SDL_WM_SetIcon(SDL_LoadBMP(loadPic), NULL); 103 104 delete loadPic; 104 105 // Enable default GL stuff … … 117 118 //SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); 118 119 //SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); 119 120 121 SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); 122 SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16); 123 SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 0); 120 121 122 SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); 123 SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16); 124 SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 0); 124 125 SDL_GL_SetAttribute( SDL_GL_ACCUM_RED_SIZE, 0); 125 126 SDL_GL_SetAttribute( SDL_GL_ACCUM_GREEN_SIZE, 0); … … 144 145 else 145 146 fullscreenFlag = 0; 146 147 147 148 printf ("ok\n"); 148 149 if((this->screen = SDL_SetVideoMode(this->resolutionX, this->resolutionY, this->bitsPerPixel, this->videoFlags | fullscreenFlag)) == NULL) … … 195 196 /** 196 197 \brief entering 2D Mode 197 198 198 199 this is a GL-Projection-mode, that is orthogonal, for placing the font in fron of everything else 199 200 */ … … 202 203 GraphicsEngine::storeMatrices(); 203 204 SDL_Surface *screen = SDL_GetVideoSurface(); 204 205 205 206 /* Note, there may be other things you need to change, 206 207 depending on how you have your OpenGL state set up. … … 215 216 glEnable(GL_BLEND); 216 217 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 217 218 218 219 glViewport(0, 0, screen->w, screen->h); 219 220 220 221 glMatrixMode(GL_PROJECTION); 221 222 glPushMatrix(); 222 223 glLoadIdentity(); 223 224 224 225 glOrtho(0.0, (GLdouble)screen->w, (GLdouble)screen->h, 0.0, 0.0, 1.0); 225 226 226 227 glMatrixMode(GL_MODELVIEW); 227 228 glPushMatrix(); 228 229 glLoadIdentity(); 229 230 230 231 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); 231 232 } … … 238 239 glMatrixMode(GL_MODELVIEW); 239 240 glPopMatrix(); 240 241 241 242 glMatrixMode(GL_PROJECTION); 242 243 glPopMatrix(); 243 244 244 245 glPopAttrib(); 245 246 } 246 247 247 248 /** 248 \brief stores the GL_matrices 249 \brief stores the GL_matrices 249 250 */ 250 251 void GraphicsEngine::storeMatrices(void) … … 271 272 /* Get available fullscreen/hardware modes */ 272 273 this->videoModes=SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_HWSURFACE); 273 274 274 275 /* Check is there are any modes available */ 275 276 if(this->videoModes == (SDL_Rect **)0){ … … 277 278 exit(-1); 278 279 } 279 280 280 281 /* Check if our resolution is restricted */ 281 282 if(this->videoModes == (SDL_Rect **)-1){ … … 301 302 if( unlikely(this->currentFPS > this->maxFPS)) this->maxFPS = this->currentFPS; 302 303 if( unlikely(this->currentFPS < this->minFPS)) this->minFPS = this->currentFPS; 303 304 304 305 #ifndef NO_TEXT 305 306 char tmpChar1[20]; … … 315 316 } 316 317 } 317 318 318 319 /** 319 320 \brief displays the Frames per second … … 335 336 this->geTextMinFPS = TextEngine::getInstance()->createText("fonts/druid.ttf", 35, TEXT_DYNAMIC, 0, 255, 0); 336 337 this->geTextMinFPS->setAlignment(TEXT_ALIGN_LEFT); 337 this->geTextMinFPS->setPosition(5, 560); 338 this->geTextMinFPS->setPosition(5, 560); 338 339 #endif /* NO_TEXT */ 339 340 } … … 341 342 } 342 343 343 344 -
orxonox/trunk/src/lib/graphics/light.cc
r4519 r4597 1 1 2 2 3 /* 3 /* 4 4 orxonox - the future of 3D-vertical-scrollers 5 5 … … 36 36 { 37 37 this->setClassID(CL_LIGHT, "Light"); 38 char tmpName[ 7];39 sprintf(tmpName, "Light %d", lightNumber);38 char tmpName[10]; 39 sprintf(tmpName, "Light[%d]", lightNumber); 40 40 this->setName(tmpName); 41 41 … … 43 43 // enable The light 44 44 glEnable(lightsV[lightNumber]); // postSpawn 45 45 46 46 // set values (defaults) 47 47 this->lightNumber = lightNumber; … … 179 179 /** 180 180 \brief draws this Light. Being a World-entity the possibility to do this lies at hand. 181 */ 181 */ 182 182 void Light::draw() 183 183 { … … 195 195 PRINT(0)(":: %d :: -- reference %p\n", this->lightNumber, this); 196 196 PRINT(0)(" GL-state: "); 197 GLboolean param; 197 GLboolean param; 198 198 glGetBooleanv(lightsV[this->lightNumber], ¶m); 199 199 if (param) … … 201 201 else 202 202 PRINT(0)("OFF\n"); 203 203 204 204 PRINT(0)(" Position: %f/%f/%f\n", this->lightPosition[0], this->lightPosition[1], this->lightPosition[2]); 205 205 PRINT(0)(" DiffuseColor: %f/%f/%f\n", this->diffuseColor[0], this->diffuseColor[1], this->diffuseColor[2]); … … 215 215 \brief standard constructor for a Light 216 216 */ 217 LightManager::LightManager () 217 LightManager::LightManager () 218 218 { 219 219 this->setClassID(CL_LIGHT_MANAGER, "LightManager"); … … 229 229 /** 230 230 \brief standard deconstructor 231 231 232 232 first disables Lighting 233 233 … … 235 235 and in the end sets the singleton Reference to zero. 236 236 */ 237 LightManager::~LightManager () 237 LightManager::~LightManager () 238 238 { 239 239 glDisable(GL_LIGHTING); 240 240 241 241 // this will be done either by worldEntity, or by pNode as each light is one of them 242 242 // for (int i = 0; i < NUMBEROFLIGHTS; i++) … … 270 270 for (int i = 0; i < NUMBEROFLIGHTS; i++) 271 271 if (!this->lights[i]) 272 return addLight(i); 272 return addLight(i); 273 273 PRINTF(1)("no more light slots availiable. All %d already taken\n", NUMBEROFLIGHTS); 274 274 return -1; … … 302 302 { 303 303 if (!this->currentLight) 304 { 304 { 305 305 PRINTF(2)("no Light defined yet. Please define at least one light first befor editing.\n"); 306 306 return; … … 316 316 { 317 317 if (!this->currentLight) 318 { 318 { 319 319 PRINTF(1)("no Light defined yet. So you cannot delete any Light right now.\n"); 320 320 return; … … 392 392 { 393 393 if (!this->currentLight) 394 { 394 { 395 395 PRINTF(2)("no Light defined yet. Please define at least one light first befor editing.\n"); 396 396 return; … … 409 409 { 410 410 if (!this->currentLight) 411 { 411 { 412 412 PRINTF(2)("no Light defined yet. Please define at least one light first befor editing.\n"); 413 413 return; … … 426 426 { 427 427 if (!this->currentLight) 428 { 428 { 429 429 PRINTF(2)("no Light defined yet. Please define at least one light first befor editing.\n"); 430 430 return; … … 443 443 { 444 444 if (!this->currentLight) 445 { 445 { 446 446 PRINTF(2)("no Light defined yet. Please define at least one light first befor editing.\n"); 447 447 return; … … 458 458 { 459 459 if (!this->currentLight) 460 { 460 { 461 461 PRINTF(2)("no Light defined yet. Please define at least one light first befor editing.\n"); 462 462 return; … … 473 473 { 474 474 if (!this->currentLight) 475 { 475 { 476 476 PRINTF(2)("no Light defined yet. Please define at least one light first befor editing.\n"); 477 477 return; … … 488 488 { 489 489 if (!this->currentLight) 490 { 490 { 491 491 PRINTF(2)("no Light defined yet\n"); 492 492 return Vector(.0, .0, .0); … … 498 498 499 499 /** 500 \returns the Position of Light 500 \returns the Position of Light 501 501 \param lightNumber lightnumber 502 502 */ … … 539 539 if (this->lights[i]) 540 540 { 541 541 this->lights[i]->debug(); 542 542 } 543 543 PRINT(0)("--------------------------------\n"); -
orxonox/trunk/src/lib/graphics/text_engine.cc
r4537 r4597 1 /* 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 … … 16 16 17 17 !! IMPORTANT !! When using ttf fonts clear the license issues prior to 18 adding them to orxonox. This is really important, because we do not 18 adding them to orxonox. This is really important, because we do not 19 19 want to offend anyone. 20 20 */ … … 46 46 \param type The renderType to display this font in 47 47 48 this constructor is private, because the user should initialize 48 this constructor is private, because the user should initialize 49 49 a text with the TextEngine. 50 50 */ … … 68 68 /** 69 69 \brief deletes a Text out of memory 70 70 71 71 This also ereases the text from the textList of the TextEngine 72 72 */ … … 117 117 char* tmpText = this->text; 118 118 while (*tmpText != '\0') 119 120 121 122 123 124 125 119 { 120 if(glyphArray[*tmpText]) 121 { 122 width += glyphArray[*tmpText]->width; 123 } 124 tmpText++; 125 } 126 126 this->posSize.w = width; 127 127 } … … 174 174 if (likely(this->font != NULL)) 175 175 tmpSurf = TTF_RenderText_Blended(this->font->font, 176 177 176 this->text, 177 this->color); 178 178 if (tmpSurf) 179 179 this->texture = loadTexture(tmpSurf, &this->texCoord); … … 208 208 pos.z = tmp[2]; 209 209 } 210 else 210 else 211 211 { 212 212 pos.x = this->posSize.x; … … 232 232 glEnable(GL_TEXTURE_2D); 233 233 glBegin(GL_QUADS); 234 234 235 235 glTexCoord2f(this->texCoord.minU, this->texCoord.minV); 236 236 glVertex2f(pos.x, pos.y ); 237 237 238 238 glTexCoord2f(this->texCoord.maxU, this->texCoord.minV); 239 239 glVertex2f(pos.x + this->posSize.w, pos.y ); 240 240 241 241 glTexCoord2f(this->texCoord.maxU, this->texCoord.maxV); 242 242 glVertex2f(pos.x + this->posSize.w, pos.y + this->posSize.h); 243 243 244 244 glTexCoord2f(this->texCoord.minU, this->texCoord.maxV); 245 245 glVertex2f(pos.x, pos.y + this->posSize.h); 246 246 247 247 glEnd(); 248 248 } … … 257 257 char* tmpText = this->text; 258 258 while (*tmpText != '\0') 259 260 261 262 263 264 265 266 259 { 260 if(glyphArray[*tmpText]) 261 { 262 glCallList(glyphArray[*tmpText]->displayList); 263 glTranslatef(glyphArray[*tmpText]->width, 0, 0); 264 } 265 tmpText++; 266 } 267 267 } 268 268 glPopMatrix(); … … 299 299 Uint32 saved_flags; 300 300 Uint8 saved_alpha; 301 301 302 302 /* Use the surface width and height expanded to powers of 2 */ 303 303 w = powerOfTwo(surface->w); … … 311 311 } 312 312 image = SDL_CreateRGBSurface(SDL_SWSURFACE, 313 314 313 w, h, 314 32, 315 315 #if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */ 316 0x000000FF, 317 0x0000FF00, 318 0x00FF0000, 319 316 0x000000FF, 317 0x0000FF00, 318 0x00FF0000, 319 0xFF000000 320 320 #else 321 322 0x00FF0000, 323 0x0000FF00, 324 321 0xFF000000, 322 0x00FF0000, 323 0x0000FF00, 324 0x000000FF 325 325 #endif 326 326 ); 327 327 if ( image == NULL ) { 328 328 return 0; 329 329 } 330 330 331 331 /* Save the alpha blending attributes */ 332 332 saved_flags = surface->flags&(SDL_SRCALPHA|SDL_RLEACCELOK); … … 335 335 SDL_SetAlpha(surface, 0, 0); 336 336 } 337 337 338 338 /* Copy the surface into the GL texture image */ 339 339 area.x = 0; … … 342 342 area.h = surface->h; 343 343 SDL_BlitSurface(surface, &area, image, &area); 344 344 345 345 /* Restore the alpha blending attributes */ 346 346 if ( (saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA ) { 347 347 SDL_SetAlpha(surface, saved_flags, saved_alpha); 348 348 } 349 349 350 350 /* Create an OpenGL texture for the image */ 351 351 glGenTextures(1, &texture); … … 354 354 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 355 355 glTexImage2D(GL_TEXTURE_2D, 356 357 358 359 360 361 362 356 0, 357 GL_RGBA, 358 w, h, 359 0, 360 GL_RGBA, 361 GL_UNSIGNED_BYTE, 362 image->pixels); 363 363 SDL_FreeSurface(image); /* No longer needed */ 364 364 365 365 return texture; 366 366 } 367 367 368 368 /** 369 \brief Quick utility function for texture creation 369 \brief Quick utility function for texture creation 370 370 \param input an integer 371 371 \returns the next bigger 2^n-integer than input … … 374 374 { 375 375 int value = 1; 376 376 377 377 while ( value < input ) { 378 378 value <<= 1; … … 395 395 Font::Font(const char* fontFile, unsigned int fontSize, Uint8 r, Uint8 g, Uint8 b) 396 396 { 397 this->setClassID(CL_FONT, "Font"); 397 398 // setting default values. 398 399 this->font = NULL; 399 400 this->fontFile = NULL; 400 401 this->glyphArray = NULL; 401 this->fastTextureID = 0; 402 402 this->fastTextureID = 0; 403 403 404 this->setSize(fontSize); 404 405 … … 423 424 { 424 425 for (int i = 0; i < FONT_HIGHEST_KNOWN_CHAR; i++) 425 426 delete this->glyphArray[i]; 426 427 delete []this->glyphArray; 427 428 } … … 441 442 if (!this->fontFile) 442 443 { 444 this->setName(fontFile); 443 445 this->fontFile = new char[strlen(fontFile)+1]; 444 446 strcpy(this->fontFile, fontFile); 445 447 446 448 this->font = TTF_OpenFont(this->fontFile, this->fontSize); 447 449 if(!this->font) 448 449 450 451 450 { 451 PRINTF(1)("TTF_OpenFont: %s\n", TTF_GetError()); 452 return false; 453 } 452 454 else 453 455 return true; 454 456 } 455 457 else … … 468 470 { 469 471 this->renderStyle = TTF_STYLE_NORMAL; 470 472 471 473 for (int i = 0; i < strlen(renderStyle); i++) 472 if (strncmp(renderStyle+i, "b", 1) == 0) 474 if (strncmp(renderStyle+i, "b", 1) == 0) 473 475 this->renderStyle |= TTF_STYLE_BOLD; 474 476 else if (strncmp(renderStyle+i, "i", 1) == 0) 475 477 this->renderStyle |= TTF_STYLE_ITALIC; 476 else if (strncmp(renderStyle+i, "u", 1) == 0) 478 else if (strncmp(renderStyle+i, "u", 1) == 0) 477 479 this->renderStyle |= TTF_STYLE_UNDERLINE; 478 480 … … 547 549 and MUST be deleted by the user.. 548 550 549 This only works for horizontal fonts. see 551 This only works for horizontal fonts. see 550 552 http://freetype.sourceforge.net/freetype2/docs/tutorial/step2.html 551 553 for more info about vertical Fonts … … 557 559 if (likely (this->font!= NULL)) 558 560 TTF_GlyphMetrics(this->font, rg->character, 559 560 561 561 &rg->minX, &rg->maxX, 562 &rg->minY, &rg->maxY, 563 &rg->advance); 562 564 rg->height = rg->maxY - rg->minY; 563 565 rg->width = rg->maxX - rg->minX; … … 569 571 GLuint Font::createFastTexture(void) 570 572 { 571 /* interesting GLYPHS: 573 /* interesting GLYPHS: 572 574 * 32: space 573 575 * 33-47: Special Characters. … … 589 591 SDL_Rect tmpRect; // this represents a Rectangle for blitting. 590 592 SDL_Surface* tmpSurf = SDL_CreateRGBSurface(SDL_SWSURFACE, 591 592 593 rectSize, rectSize, 594 32, 593 595 #if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */ 594 0x000000FF, 595 0x0000FF00, 596 0x00FF0000, 597 596 0x000000FF, 597 0x0000FF00, 598 0x00FF0000, 599 0xFF000000 598 600 #else 599 600 0x00FF0000, 601 0x0000FF00, 602 601 0xFF000000, 602 0x00FF0000, 603 0x0000FF00, 604 0x000000FF 603 605 #endif 604 606 ); 605 607 tmpRect.x = 0; tmpRect.y = 0; tmpRect.w = tmpSurf->w; tmpRect.h = tmpSurf->h; 606 608 SDL_SetClipRect(tmpSurf, &tmpRect); … … 614 616 615 617 if (tmpGlyph = this->glyphArray[i]) 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 618 { 619 if (tmpGlyph->height > maxLineHeight) 620 maxLineHeight = tmpGlyph->height; 621 622 if (tmpRect.x+tmpGlyph->width > tmpSurf->w) 623 { 624 tmpRect.x = 0; 625 tmpRect.y = tmpRect.y + maxLineHeight + 1; 626 maxLineHeight = 0; 627 } 628 if (tmpRect.y + maxLineHeight > tmpSurf->h) 629 { 630 PRINTF(1)("Protection, so font cannot write over the boundraries error (this should not heappen\n"); 631 break; 632 } 633 // reading in the new Glyph 634 if (likely(this->font != NULL)) 635 glyphSurf = TTF_RenderGlyph_Blended(this->font, i, this->fastColor); 636 if( glyphSurf != NULL ) 637 { 638 639 SDL_SetAlpha(glyphSurf, 0, 0); 640 641 SDL_BlitSurface(glyphSurf, NULL, tmpSurf, &tmpRect); 642 TexCoord tmpTexCoord; 643 tmpTexCoord.minU = (float)tmpRect.x/(float)tmpSurf->w; 644 tmpTexCoord.maxU = (float)(tmpRect.x+tmpGlyph->width)/(float)tmpSurf->w; 645 tmpTexCoord.minV = (float)tmpRect.y/(float)tmpSurf->w; 646 tmpTexCoord.maxV = (float)(tmpRect.y+tmpGlyph->height)/(float)tmpSurf->w; 647 tmpGlyph->displayList = glGenLists(1); 648 649 glNewList(tmpGlyph->displayList, GL_COMPILE); 650 glBegin(GL_QUADS); 651 glTexCoord2f(tmpTexCoord.minU, tmpTexCoord.minV); 652 glVertex2d(0, 0); 653 glTexCoord2f(tmpTexCoord.minU, tmpTexCoord.maxV); 654 glVertex2d(0, tmpGlyph->height); 655 glTexCoord2f(tmpTexCoord.maxU, tmpTexCoord.maxV); 656 glVertex2d(tmpGlyph->width, tmpGlyph->height); 657 glTexCoord2f(tmpTexCoord.maxU, tmpTexCoord.minV); 658 glVertex2d(tmpGlyph->width, 0); 659 glEnd(); 660 glEndList(); 661 SDL_FreeSurface(glyphSurf); 662 663 tmpRect.x += tmpGlyph->width + 1; 664 665 // Outputting Glyphs to BMP-files. 666 /* 667 char outname[64]; 668 if (i < 10) 669 sprintf( outname, "glyph-00%d.bmp", i ); 670 else if (i <100) 671 sprintf( outname, "glyph-0%d.bmp", i ); 672 else 673 sprintf( outname, "glyph-%d.bmp", i ); 674 SDL_SaveBMP(tmpSurf, outname); 675 */ 676 } 677 } 676 678 } 677 679 … … 682 684 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 683 685 glTexImage2D(GL_TEXTURE_2D, 684 685 686 687 688 689 690 686 0, 687 GL_RGBA, 688 tmpSurf->w, tmpSurf->h, 689 0, 690 GL_RGBA, 691 GL_UNSIGNED_BYTE, 692 tmpSurf->pixels); 691 693 SDL_FreeSurface(tmpSurf); 692 694 return texture; … … 707 709 this->glyphArray = new Glyph*[FONT_HIGHEST_KNOWN_CHAR]; 708 710 for (int i = 0; i < FONT_HIGHEST_KNOWN_CHAR; i++) 709 710 } 711 711 this->glyphArray[i] = NULL; 712 } 713 712 714 Uint16 lastGlyph = from + count; 713 715 714 716 for (int i = from; i <= lastGlyph; i++) 715 717 { … … 723 725 \returns the optimal size to use as the texture size 724 726 725 \todo: this algorithm can be a lot more faster, althought it does 727 \todo: this algorithm can be a lot more faster, althought it does 726 728 not really matter within the init-context, and 128 glyphs. 727 729 728 This function searches for a 2^n sizes texture-size, this is for 730 This function searches for a 2^n sizes texture-size, this is for 729 731 openGL-version < 1.2 compatibility ( and because it is realy easy like this :)) 730 732 */ … … 743 745 maxLineHeight = 0; 744 746 for (i = 0; i < FONT_HIGHEST_KNOWN_CHAR; i++) 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 747 { 748 if(tmpGlyph = this->glyphArray[i]) 749 { 750 // getting the height of the highest Glyph in the Line. 751 if (tmpGlyph->height > maxLineHeight) 752 maxLineHeight = tmpGlyph->height; 753 754 if (x + tmpGlyph->width > size) 755 { 756 x = 0; 757 y = y + maxLineHeight; 758 maxLineHeight = 0; 759 } 760 if (y + maxLineHeight + 1 > size) 761 break; 762 x += tmpGlyph->width + 1; 763 764 } 765 } 764 766 if (i == FONT_HIGHEST_KNOWN_CHAR) 765 767 sizeOK = true; 766 768 else 767 769 size *= 2; 768 770 } 769 771 return size; … … 801 803 \brief standard constructor 802 804 */ 803 TextEngine::TextEngine () 805 TextEngine::TextEngine () 804 806 { 805 807 this->setClassID(CL_TEXT_ENGINE, "TextEngine"); 808 this->setName("TextEngine"); 806 809 this->enableFonts(); 807 810 … … 818 821 819 822 */ 820 TextEngine::~TextEngine () 823 TextEngine::~TextEngine () 821 824 { 822 825 this->disableFonts(); 823 826 824 827 delete this->textList; 825 828 … … 835 838 { 836 839 if(TTF_Init()==-1) 837 840 PRINTF(1)("TTF_Init: %s\n", TTF_GetError()); 838 841 839 842 TextEngine::checkVersion(); … … 932 935 /** 933 936 \brief outputs some nice Debug information 934 937 935 938 \todo there should also be something outputted about Font 936 939 */ … … 941 944 PRINT(0)("+-------------------------------+\n"); 942 945 PRINT(0)("Reference: %p; Text Counts: %d\n", this, this->textList->getSize()); 943 946 944 947 tIterator<Text>* textIterator = textList->getIterator(); 945 948 Text* text = textIterator->nextElement(); … … 973 976 else 974 977 { 975 PRINTF(2)("compiled with SDL_ttf version: %d.%d.%d\n", 976 977 978 979 980 PRINTF(2)("running with SDL_ttf version: %d.%d.%d\n", 981 982 983 978 PRINTF(2)("compiled with SDL_ttf version: %d.%d.%d\n", 979 compile_version.major, 980 compile_version.minor, 981 compile_version.patch); 982 983 PRINTF(2)("running with SDL_ttf version: %d.%d.%d\n", 984 link_version.major, 985 link_version.minor, 986 link_version.patch); 984 987 return false; 985 988 } -
orxonox/trunk/src/lib/graphics/text_engine.h
r4536 r4597 1 /*! 1 /*! 2 2 \file text_engine.h 3 3 \brief Definition of textEngine, the Font and the Text … … 30 30 31 31 //! An enumerator for the text alignment. 32 enum TEXT_ALIGNMENT { TEXT_ALIGN_LEFT, 33 TEXT_ALIGN_RIGHT, 34 TEXT_ALIGN_CENTER, 35 TEXT_ALIGN_SCREEN_CENTER }; 32 enum TEXT_ALIGNMENT 33 { 34 TEXT_ALIGN_LEFT, 35 TEXT_ALIGN_RIGHT, 36 TEXT_ALIGN_CENTER, 37 TEXT_ALIGN_SCREEN_CENTER 38 }; 36 39 37 40 /* some default values */ 38 41 #define FONT_DEFAULT_SIZE 50 //!< default size of the Text 39 #define FONT_DEFAULT_TEXT 42 #define FONT_DEFAULT_TEXT "orxonox 1234567890" //!< default text to display 40 43 #define FONT_DEFAULT_COLOR_R 255 //!< default red part (color) of the text 41 44 #define FONT_DEFAULT_COLOR_G 255 //!< default red green (color) of the text … … 86 89 int bearingY; //!< How much is above the Origin 87 90 int advance; //!< How big a Glyph would be in monospace-mode 88 91 89 92 // OpenGL-specific 90 93 // TexCoord texCoord; //!< A Texture Coordinate for this glyph. … … 117 120 118 121 void draw(void) const; 119 122 120 123 void debug(void) const; 121 124 122 125 private: 123 126 Text(Font* font, int type = TEXT_DYNAMIC); 124 127 125 128 static GLuint loadTexture(SDL_Surface* surface, TexCoord* texCoord); 126 129 static int powerOfTwo(int input); … … 139 142 TexCoord texCoord; //!< Texture-coordinates \todo fix this to have a struct 140 143 SDL_Rect posSize; //!< An SDL-Rectangle representing the position and size of the Text on the screen. 141 144 142 145 PNode* bindNode; //!< A node the Text is bind to. (if NULL thr node will not be bound to anything.) 143 146 }; … … 147 150 //////////// 148 151 //! A class to handle a Font of a certain ttf-File, Size and Color. 149 class Font 152 class Font : public BaseObject 150 153 { 151 154 friend class Text; … … 170 173 /** \returns the texture to the fast-texture */ 171 174 inline GLuint getFastTextureID(void) const {return fastTextureID;} 172 175 173 176 private: 174 177 int getMaxHeight(void); … … 193 196 unsigned int fontSize; //!< The size of the font in pixels. each Font has one size. 194 197 int renderStyle; //!< The Renderstyle 195 198 196 199 Glyph** glyphArray; //!< An Array of all the Glyphs stored in the Array of Glyphs. 197 200 GLuint fastTextureID; //!< The fast textureID. … … 205 208 /////////////////// 206 209 //! A singleton Class that operates as a Handler for generating and rendering Text in 2D 207 class TextEngine : public BaseObject 210 class TextEngine : public BaseObject 208 211 { 209 212 public: … … 213 216 214 217 Text* createText(const char* fontFile, 215 216 217 218 219 220 218 unsigned int fontSize = FONT_DEFAULT_SIZE, 219 int textType = TEXT_DYNAMIC, 220 Uint8 r = FONT_DEFAULT_COLOR_R, 221 Uint8 g = FONT_DEFAULT_COLOR_G, 222 Uint8 b = FONT_DEFAULT_COLOR_B); 223 221 224 void deleteText(Text* text); 222 225 void flush(void); 223 226 224 227 void draw(void) const; 225 228 226 229 void debug(void) const; 227 230 -
orxonox/trunk/src/lib/math/curve.h
r4472 r4597 1 1 2 /*! 2 /*! 3 3 \file curve.h 4 4 \brief A basic 3D curve framework 5 5 6 6 Contains classes to handle curves 7 */ 7 */ 8 8 9 9 #ifndef _CURVE_H … … 49 49 /** \param t the value on the curve [0-1] \returns quaternion of the rotation */ 50 50 virtual Quaternion calcQuat(float t) = 0; 51 51 52 52 // DEBUG 53 53 void debug(void); … … 86 86 virtual Vector calcAcc(float t); 87 87 virtual Quaternion calcQuat(float t); 88 89 88 89 90 90 Vector getPos(void) const; 91 91 -
orxonox/trunk/src/lib/particles/particle_emitter.cc
r4496 r4597 1 /* 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 … … 31 31 \brief standard constructor 32 32 */ 33 ParticleEmitter::ParticleEmitter(const Vector& direction, float angle, float emissionRate, 34 float velocity) 35 { 33 ParticleEmitter::ParticleEmitter(const Vector& direction, float angle, float emissionRate, 34 float velocity) 35 { 36 this->setClassID(CL_PARTICLE_EMITTER, "ParticleEmitter"); 36 37 this->type = EMITTER_DOT; 37 38 this->emitterSize = 1.0; … … 64 65 removes the EmitterSystem from the ParticleEngine 65 66 */ 66 ParticleEmitter::~ParticleEmitter () 67 ParticleEmitter::~ParticleEmitter () 67 68 { 68 69 ParticleEngine::getInstance()->removeEmitter(this); … … 91 92 LoadParam<ParticleEmitter>(root, "emission-velocity", this, &ParticleEmitter::setEmissionVelocity) 92 93 .describe("How fast the particles are emittet (their initial speed)"); 93 94 94 95 LoadParam<ParticleEmitter>(root, "spread", this, &ParticleEmitter::setSpread) 95 96 .describe("The angle the particles are emitted from (angle, deviation)"); … … 224 225 float count = (dt+this->saveTime) * this->emissionRate; 225 226 this->saveTime = modff(count, &count) / this->emissionRate; 226 PRINTF(5)("emitting %f particles, saving %f seconds for the next round\n", count, this->saveTime); 227 227 PRINTF(5)("emitting %f particles, saving %f seconds for the next round\n", count, this->saveTime); 228 228 229 if (likely(count > 0)) 229 230 { 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 231 Vector inheritVelocity = this->getVelocity() * this->inheritSpeed; 232 for (int i = 0; i < count; i++) 233 // emmits from EMITTER_DOT, 234 { 235 Vector randDir = Vector(rand()-RAND_MAX/2, rand()-RAND_MAX/2, rand()-RAND_MAX/2); 236 randDir.normalize(); 237 randDir = (this->getAbsDir()*Quaternion(angle + randomAngle *((float)rand()/RAND_MAX -.5), randDir)).apply(this->direction); 238 Vector velocityV = randDir.getNormalized()*this->velocity + inheritVelocity; 239 240 // this should spread the Particles evenly. if the Emitter is moved around quickly 241 Vector equalSpread = this->getVelocity() * rand()/RAND_MAX * dt; 242 Vector extension; // the Vector for different fields. 243 244 if (this->type & 2) 245 { 246 extension = Vector(this->emitterSize * ((float)rand()/RAND_MAX -.5), 0, this->emitterSize * ((float)rand()/RAND_MAX - .5)); 247 extension = this->getAbsDir().apply(extension); 248 } 249 else if (this->type & 8) 250 { 251 extension = Vector((float)rand()/RAND_MAX -.5, (float)rand()/RAND_MAX -.5, (float)rand()/RAND_MAX -.5) * this->emitterSize; 252 } 253 254 system->addParticle(this->getAbsCoor() + extension - equalSpread, velocityV); 255 256 } 256 257 } 257 258 } -
orxonox/trunk/src/lib/particles/particle_emitter.h
r4493 r4597 1 /*! 1 /*! 2 2 \file particle_emitter.h 3 3 \brief Definition of a ParticleEmitter … … 9 9 #include "p_node.h" 10 10 11 // FORWARD DEFINITION 11 // FORWARD DEFINITION 12 12 class ParticleSystem; 13 13 class TiXmlElement; 14 14 15 15 //! The form of the Emitter to emit from 16 typedef enum EMITTER_TYPE { EMITTER_DOT = 1, 17 EMITTER_PLANE = 2, 18 EMITTER_SPHERE= 4, 19 EMITTER_CUBE = 8 }; 16 typedef enum EMITTER_TYPE 17 { 18 EMITTER_DOT = 1, 19 EMITTER_PLANE = 2, 20 EMITTER_SPHERE = 4, 21 EMITTER_CUBE = 8 22 }; 20 23 21 24 //! A class to handle an Emitter. … … 24 27 public: 25 28 ParticleEmitter(const Vector& direction, float angle = .5, 26 29 float emissionRate = 1.0, float velocity = 1.0); 27 30 ParticleEmitter(const TiXmlElement* root); 28 31 virtual ~ParticleEmitter(void); 29 32 30 33 void loadParams(const TiXmlElement* root); 31 34 -
orxonox/trunk/src/lib/particles/particle_engine.cc
r4519 r4597 1 /* 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 … … 30 30 \brief standard constructor 31 31 */ 32 ParticleEngine::ParticleEngine () 32 ParticleEngine::ParticleEngine () 33 33 { 34 34 this->setClassID(CL_PARTICLE_ENGINE, "ParticleEngine"); 35 this->setName("ParticleEngine"); 35 36 36 37 this->systemList = new tList<ParticleSystem>; … … 47 48 \brief deletes all the system, emitters, connections and Lists 48 49 */ 49 ParticleEngine::~ParticleEngine () 50 ParticleEngine::~ParticleEngine () 50 51 { 51 52 // delete all remaining systems … … 113 114 { 114 115 if (tmpConnection->emitter == emitter && tmpConnection->system == system) 115 116 117 118 119 120 116 { 117 PRINTF(2)("Connection between Emitter and System already added\n"); 118 delete tmpConIt; 119 return; 120 } 121 121 122 tmpConnection = tmpConIt->nextElement(); 122 123 } 123 124 delete tmpConIt; 124 125 125 126 126 127 … … 144 145 { 145 146 if (tmpConnection->system == system) 146 147 this->breakConnection(tmpConnection); 147 148 tmpConnection = tmpConIt->nextElement(); 148 149 } … … 165 166 { 166 167 if (tmpConnection->emitter == emitter) 167 168 this->breakConnection(tmpConnection); 168 169 tmpConnection = tmpConIt->nextElement(); 169 170 } … … 191 192 if (tmpConnection->emitter == emitter && tmpConnection->system == system) 192 193 { 193 194 195 194 this->breakConnection(tmpConnection); 195 delete tmpConIt; 196 return true; 196 197 } 197 198 tmpConnection = tmpConIt->nextElement(); … … 268 269 { 269 270 if (!strcmp(systemName, tmpSys->getName())) 270 271 272 273 271 { 272 delete tmpIt; 273 return tmpSys; 274 } 274 275 tmpSys = tmpIt->nextElement(); 275 276 } … … 291 292 count++; 292 293 if ( count == number) 293 294 295 296 294 { 295 delete tmpIt; 296 return tmpSys; 297 } 297 298 tmpSys = tmpIt->nextElement(); 298 299 } … … 312 313 { 313 314 if (!strcmp(emitterName, tmpEmit->getName())) 314 315 316 317 315 { 316 delete tmpIt; 317 return tmpEmit; 318 } 318 319 tmpEmit = tmpIt->nextElement(); 319 320 } … … 336 337 count++; 337 338 if ( count == number) 338 339 340 341 339 { 340 delete tmpIt; 341 return tmpEmit; 342 } 342 343 tmpEmit = tmpIt->nextElement(); 343 344 } … … 356 357 PRINT(0)(" Reference: %p\n", ParticleEngine::singletonRef); 357 358 PRINT(0)(" Count: Emitters: %d; Systems: %d, Connections: %d\n", 358 359 this->emitterList->getSize(), this->systemList->getSize(), this->connectionList->getSize()); 359 360 if (this->connectionList->getSize() > 0) 360 361 { … … 365 366 ParticleConnection* tmpConnection = tmpConIt->nextElement(); 366 367 while(tmpConnection) 367 368 369 370 368 { 369 PRINT(0)(" Emitter '%s' emitts into System '%s'\n", tmpConnection->emitter->getName(), tmpConnection->system->getName()); 370 tmpConnection = tmpConIt->nextElement(); 371 } 371 372 delete tmpConIt; 372 373 } … … 376 377 ParticleSystem* tmpSys = tmpIt->nextElement(); 377 378 while(tmpSys) 378 379 380 381 379 { 380 tmpSys->debug(); 381 tmpSys = tmpIt->nextElement(); 382 } 382 383 delete tmpIt; 383 384 } -
orxonox/trunk/src/lib/particles/particle_system.cc
r4515 r4597 1 /* 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 … … 41 41 { 42 42 this->setClassID(CL_PARTICLE_SYSTEM, "ParticleSystem"); 43 43 44 this->material = NULL; 44 45 this->maxCount = maxCount; … … 125 126 /** 126 127 \brief Sets the lifespan of newly created particles 127 */ 128 */ 128 129 void ParticleSystem::setLifeSpan(float lifeSpan, float randomLifeSpan) 129 130 { … … 197 198 { 198 199 Particle* tickPart = particles; // the particle to Tick 199 Particle* prevPart = NULL; // 200 Particle* prevPart = NULL; // 200 201 while (likely(tickPart != NULL)) 201 202 { 202 203 // applying force to the System. 203 204 if (likely (tickPart->mass > 0.0)) 204 205 tickPart->velocity += tickPart->extForce / tickPart->mass * dt; 205 206 206 207 // rendering new position. 207 208 tickPart->position = tickPart->position + tickPart->velocity * dt; 208 209 tickPart->radius = radiusAnim.getValue(tickPart->lifeCycle) 209 210 + randRadiusAnim.getValue(tickPart->lifeCycle) * tickPart->radiusRand; 210 211 211 212 tickPart->mass = massAnim.getValue(tickPart->lifeCycle) 212 213 213 + randMassAnim.getValue(tickPart->lifeCycle) * tickPart->massRand; 214 214 215 tickPart->extForce = Vector(0,0,0); 215 216 … … 223 224 224 225 if (this->conserve < 1.0) 225 226 tickPart->velocity = tickPart->velocity * this->conserve; 226 227 // find out if we have to delete tickPart 227 228 if (unlikely((tickPart->lifeCycle += dt/tickPart->lifeTime) >= 1.0)) 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 229 { 230 // remove the particle from the list 231 if (likely(prevPart != NULL)) 232 { 233 prevPart->next = tickPart->next; 234 tickPart->next = this->deadList; 235 this->deadList = tickPart; 236 tickPart = prevPart->next; 237 } 238 else 239 { 240 prevPart = NULL; 241 this->particles = tickPart->next; 242 tickPart->next = this->deadList; 243 this->deadList = tickPart; 244 tickPart = this->particles; 245 } 246 --this->count; 247 } 247 248 else 248 { 249 250 251 252 } 253 } 254 255 /** 249 { 250 prevPart = tickPart; 251 tickPart = tickPart->next; 252 } 253 } 254 } 255 256 /** 256 257 \brief applies some force to a Particle. 257 258 \param field the Field to apply. … … 281 282 282 283 Particle* drawPart = particles; 283 284 284 285 switch (this->particleType) 285 286 { … … 289 290 glDepthMask(GL_FALSE); 290 291 291 material->select(); 292 material->select(); 292 293 //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_MODULATE); 293 294 294 295 295 296 while (likely(drawPart != NULL)) 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 297 { 298 glColor4fv(drawPart->color); 299 //! \todo implement a faster code for the look-at Camera algorithm. 300 301 const PNode* camera = State::getInstance()->getCamera(); //!< \todo MUST be different 302 Vector cameraPos = camera->getAbsCoor(); 303 Vector cameraTargetPos = State::getInstance()->getCameraTarget()->getAbsCoor(); 304 Vector view = cameraTargetPos - cameraPos; 305 Vector up = Vector(0, 1, 0); 306 up = camera->getAbsDir().apply(up); 307 Vector h = up.cross(view); 308 Vector v = h.cross(view); 309 h.normalize(); 310 v.normalize(); 311 v *= .5 * drawPart->radius; 312 h *= .5 * drawPart->radius; 313 314 glBegin(GL_TRIANGLE_STRIP); 315 glTexCoord2i(1, 1); 316 glVertex3f(drawPart->position.x - h.x - v.x, 317 drawPart->position.y - h.y - v.y, 318 drawPart->position.z - h.z - v.z); 319 glTexCoord2i(0, 1); 320 glVertex3f(drawPart->position.x - h.x + v.x, 321 drawPart->position.y - h.y + v.y, 322 drawPart->position.z - h.z + v.z); 323 glTexCoord2i(1, 0); 324 glVertex3f(drawPart->position.x + h.x - v.x, 325 drawPart->position.y + h.y - v.y, 326 drawPart->position.z + h.z - v.z); 327 glTexCoord2i(0, 0); 328 glVertex3f(drawPart->position.x + h.x + v.x, 329 drawPart->position.y + h.y + v.y, 330 drawPart->position.z + h.z + v.z); 331 332 glEnd(); 333 334 drawPart = drawPart->next; 335 } 335 336 glDepthMask(GL_TRUE); 336 337 break; … … 340 341 glBegin(GL_LINES); 341 342 while (likely(drawPart != NULL)) 342 343 344 345 346 347 348 349 343 { 344 glColor4fv(drawPart->color); 345 glVertex3f(drawPart->position.x, drawPart->position.y, drawPart->position.z); 346 glVertex3f(drawPart->position.x - drawPart->velocity.x, 347 drawPart->position.y - drawPart->velocity.y, 348 drawPart->position.z - drawPart->velocity.z); 349 drawPart = drawPart->next; 350 } 350 351 glEnd(); 351 352 break; 352 353 353 354 case PARTICLE_DOT: 354 355 glBegin(GL_POINTS); 355 356 while (likely(drawPart != NULL)) 356 357 358 359 360 361 362 363 357 { 358 glColor4fv(drawPart->color); 359 360 glLineWidth(drawPart->radius); 361 362 glVertex3f(drawPart->position.x, drawPart->position.y, drawPart->position.z); 363 drawPart = drawPart->next; 364 } 364 365 glEnd(); 365 366 break; … … 380 381 // if it is the first Particle 381 382 if (unlikely(particles == NULL)) 382 383 384 385 386 387 388 389 390 391 392 393 394 383 { 384 if (likely(deadList != NULL)) 385 { 386 this->particles = this->deadList; 387 deadList = deadList->next; 388 } 389 else 390 { 391 PRINTF(5)("Generating new Particle\n"); 392 this->particles = new Particle; 393 } 394 this->particles->next = NULL; 395 } 395 396 // filling the List from the beginning 396 397 else 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 398 { 399 Particle* tmpPart; 400 if (likely(deadList != NULL)) 401 { 402 tmpPart = this->deadList; 403 deadList = deadList->next; 404 } 405 else 406 { 407 PRINTF(5)("Generating new Particle\n"); 408 tmpPart = new Particle; 409 } 410 tmpPart->next = this->particles; 411 this->particles = tmpPart; 412 } 413 413 414 particles->lifeTime = this->lifeSpan + (float)(rand()/RAND_MAX)* this->randomLifeSpan; 414 415 particles->lifeCycle = 0.0; -
orxonox/trunk/src/lib/particles/particle_system.h
r4493 r4597 1 /*! 1 /*! 2 2 \file particle_system.h 3 3 … … 23 23 24 24 //! An enumerator for the different types of particles. 25 typedef enum PARTICLE_TYPE { PARTICLE_DOT = PARTICLE_DOT_MASK, 26 PARTICLE_SPARK = PARTICLE_SPARK_MASK, 27 PARTICLE_SPRITE = PARTICLE_SPRITE_MASK, 28 PARTICLE_MULTI_SPRITE = PARTICLE_SPRITE_MASK | PARTICLE_MULTI_MASK, 29 PARTICLE_MODEL = PARTICLE_MODEL_MASK, 30 PARTICLE_MULTI_MODE = PARTICLE_MODEL_MASK | PARTICLE_MULTI_MASK }; 25 typedef enum PARTICLE_TYPE 26 { 27 PARTICLE_DOT = PARTICLE_DOT_MASK, 28 PARTICLE_SPARK = PARTICLE_SPARK_MASK, 29 PARTICLE_SPRITE = PARTICLE_SPRITE_MASK, 30 PARTICLE_MULTI_SPRITE = PARTICLE_SPRITE_MASK | PARTICLE_MULTI_MASK, 31 PARTICLE_MODEL = PARTICLE_MODEL_MASK, 32 PARTICLE_MULTI_MODE = PARTICLE_MODEL_MASK | PARTICLE_MULTI_MASK 33 }; 31 34 32 35 #define PARTICLE_DEFAULT_MAX_COUNT 200 //!< A default count of particles in the system. … … 59 62 //! A class to handle ParticleSystems 60 63 class ParticleSystem : public WorldEntity, public PhysicsInterface { 61 64 62 65 public: 63 66 ParticleSystem(unsigned int maxCount = PARTICLE_DEFAULT_MAX_COUNT, 64 67 PARTICLE_TYPE type = PARTICLE_DEFAULT_TYPE); 65 68 virtual ~ParticleSystem(); 66 69 … … 116 119 117 120 GLuint* glID; //!< A List of different gl-List-ID's 118 GLuint dialectCount; //!< How many different types of particles are there in the Particle System 121 GLuint dialectCount; //!< How many different types of particles are there in the Particle System 119 122 120 123 // per particle attributes -
orxonox/trunk/src/lib/particles/quick_animation.cc
r4479 r4597 1 /* 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 … … 27 27 using namespace std; 28 28 29 30 29 /** 31 30 \brief standard constructor … … 33 32 QuickAnimation::QuickAnimation (void) 34 33 { 35 this->setClass Name("QuickAnimation");34 this->setClassID(CL_QUICK_ANIMATION, "QuickAnimation"); 36 35 37 36 this->first = this->current = NULL; … … 47 46 this->current = this->first; 48 47 QuickKeyFrame delKF; 49 48 50 49 while (this->current != NULL) 51 50 { … … 54 53 this->current = this->first; 55 54 } 56 57 55 } 58 56 … … 70 68 // if it is between some keyframes 71 69 if ((!this->current->next && this->current->position < position) 72 73 70 || (this->current->position < position && this->current->next->position > position)) 71 break; 74 72 // if it is the same as an already existing keyframe 75 73 else if (this->current->position == position) 76 74 return false; 77 75 this->current = this->current->next; 78 76 } … … 92 90 newKey->value = value; 93 91 newKey->position = position; 94 92 95 93 this->current = this->first; 96 94 … … 110 108 { 111 109 if (this->current->position < position+region && this->current->position > position-region) 112 113 114 115 116 this->current = this->current->next; 110 { 111 this->current->value = value; 112 return true; 113 } 114 this->current = this->current->next; 117 115 } 118 116 this->current = this->first; … … 122 120 /* 123 121 \param position The position where to find the Node to kill 124 122 125 123 bool QuickAnimation::removeEntry(float position) 126 124 { 127 125 this->current = this->first; 128 QuickKeyFrame* last = 129 126 QuickKeyFrame* last = 127 130 128 while (this->current) 131 129 { 132 130 if (this->current->position == position) 133 131 { 134 135 132 133 136 134 } 137 this->current = this->current->next; 135 this->current = this->current->next; 138 136 } 139 137 this->current = this->first; … … 145 143 \param position the position to get the value from :) 146 144 */ 147 float QuickAnimation::getValue(float position) 145 float QuickAnimation::getValue(float position) 148 146 { 149 147 if (unlikely(this->first == NULL)) … … 154 152 { 155 153 if (unlikely(position < this->current->position)) 156 157 158 159 160 154 { 155 if (position <= this->first->position) 156 return this->first->value; 157 this->current = this->first; 158 } 161 159 while (likely(this->current->next != NULL && position > this->current->next->position)) 162 160 this->current = this->current->next; 163 161 if (this->current->next == NULL) 164 165 162 return this->current->value; 163 166 164 return this->current->value + (this->current->next->value - this->current->value) 167 165 * ((position-this->current->position) / (this->current->next->position -this->current->position)); 168 166 } 169 167 } -
orxonox/trunk/src/lib/particles/quick_animation.h
r4479 r4597 1 /*! 1 /*! 2 2 \file quick_animation.h 3 3 \brief Definition of the QuickAnimation-class … … 21 21 this class is optimized for a raising value. eg. 100 particles sorted 22 22 by age. 23 \todo speedUP this stuff (especially getValue) 23 24 */ 24 25 class QuickAnimation : public BaseObject { -
orxonox/trunk/src/lib/physics/physics_connection.cc
r4480 r4597 1 /* 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 … … 31 31 PhysicsConnection::PhysicsConnection(PhysicsInterface* subject, Field* field) 32 32 { 33 this->setClassID(CL_PHYSICS_CONNECTION, "PhysicsConnection"); 33 34 this->type = PCON_PhysIField; 34 35 this->subject = subject; … … 43 44 44 45 */ 45 PhysicsConnection::~PhysicsConnection () 46 PhysicsConnection::~PhysicsConnection () 46 47 { 47 48 PhysicsEngine::getInstance()->removeConnection(this); 48 49 } 49 50 50 /** 51 /** 51 52 \brief applies the Force to some Object. 52 53 */ -
orxonox/trunk/src/lib/physics/physics_connection.h
r4480 r4597 1 /*! 1 /*! 2 2 \file physics_connection.h 3 3 \brief Definition of The Physical Connection Class. 4 4 */ 5 5 6 #ifndef _PHYSICS_CONNECTION_H 6 #ifndef _PHYSICS_CONNECTION_H 7 7 #define _PHYSICS_CONNECTION_H 8 8 … … 14 14 15 15 //! An enumerator for different ConnectionTypes 16 typedef enum PCON_Type { PCON_PhysIPhysI = 0, 17 PCON_PhysIField = 1}; 16 typedef enum PCON_Type 17 { 18 PCON_PhysIPhysI = 1, 19 PCON_PhysIField = 2 20 }; 18 21 19 22 … … 34 37 private: 35 38 PCON_Type type; //!< What kind of connection this is. 36 39 37 40 PhysicsInterface* subject; //!< The main Subject of this Connection. 38 41 PhysicsInterface* partner2; //!< The second partner of this Connection. 39 42 40 43 Field* field; //!< The field to connect either subject of ParticleSystem to. 41 44 }; -
orxonox/trunk/src/lib/physics/physics_engine.cc
r4558 r4597 30 30 PhysicsEngine::PhysicsEngine() 31 31 { 32 this->setClassName ("PhysicsEngine");33 34 35 36 32 this->setClassID(CL_PHYSICS_ENGINE, "PhysicsEngine"); 33 this->setName("PhysicsEngine"); 34 this->connections = new tList<PhysicsConnection>; 35 this->interfaces = new tList<PhysicsInterface>; 36 this->fields = new tList<Field>; 37 37 } 38 38 -
orxonox/trunk/src/lib/physics/physics_interface.cc
r4558 r4597 35 35 /** 36 36 \brief standard constructor 37 */37 */ 38 38 PhysicsInterface::PhysicsInterface (void* objectPointer) 39 39 { 40 this->setClassID(CL_PHYSICS_INTERFACE, "PhysicsInterface"); 40 41 this->objectPointer = objectPointer; 41 42 42 // this->setClassName ("PhysicsInterface"); 43 this->mass = 1; 44 this->massChildren = 0; 45 this->forceSum = Vector(0, 0, 0); 46 this->bForceApplied = false; 43 this->mass = 1; 44 this->massChildren = 0; 45 this->forceSum = Vector(0, 0, 0); 46 this->bForceApplied = false; 47 47 48 48 PhysicsEngine::getInstance()->addPhysicsInterface(this); -
orxonox/trunk/src/lib/physics/physics_interface.h
r4558 r4597 28 28 class PhysicsInterface : virtual public BaseObject 29 29 { 30 31 30 public: 32 31 PhysicsInterface(void* objectPointer); -
orxonox/trunk/src/lib/sound/sound_engine.cc
r4519 r4597 1 /* 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 … … 40 40 SoundBuffer::SoundBuffer(const char* fileName) 41 41 { 42 this->setClassID(CL_SOUND_BUFFER, "SoundBuffer"); 43 this->setName(fileName); 44 42 45 SoundEngine::getInstance()->addBuffer(this); 43 46 … … 45 48 ALvoid* data; 46 49 ALsizei freq; 47 50 48 51 ALenum result; 49 52 … … 57 60 if ((result = alGetError()) != AL_NO_ERROR) 58 61 SoundEngine::PrintALErrorString(result); 59 62 60 63 // send the loaded wav data to the buffer 61 64 alBufferData(this->bufferID, format, data, this->size, freq); … … 83 86 SoundSource::SoundSource(SoundBuffer* buffer, PNode* sourceNode) 84 87 { 88 this->setClassID(CL_SOUND_SOURCE, "SoundSource"); 89 85 90 ALenum result; 86 91 … … 161 166 \brief standard constructor 162 167 */ 163 SoundEngine::SoundEngine () 164 { 165 this->setClassName ("SoundEngine"); 166 168 SoundEngine::SoundEngine () 169 { 170 this->setClassID(CL_SOUND_ENGINE, "SoundEngine"); 171 this->setName("SoundEngine"); 172 167 173 this->listener = NULL; 168 174 this->bufferList = new tList<SoundBuffer>; … … 179 185 180 186 */ 181 SoundEngine::~SoundEngine () 187 SoundEngine::~SoundEngine () 182 188 { 183 189 SoundEngine::singletonRef = NULL; … … 262 268 { 263 269 if (buffer == enumSource->getBuffer()) 264 270 delete enumSource; 265 271 enumSource = sourceIterator->nextElement(); 266 272 } … … 300 306 { 301 307 alListener3f(AL_POSITION, 302 303 304 308 this->listener->getAbsCoor().x, 309 this->listener->getAbsCoor().y, 310 this->listener->getAbsCoor().z); 305 311 alListener3f(AL_VELOCITY, 306 307 308 312 this->listener->getVelocity().x, 313 this->listener->getVelocity().y, 314 this->listener->getVelocity().z); 309 315 Vector absDirV = this->listener->getAbsDirV(); 310 316 ALfloat orientation [6] = {1,0,0, absDirV.x, absDirV.y, absDirV.z}; … … 321 327 if (likely(enumSource->getNode()!=NULL)) 322 328 { 323 324 325 326 327 328 329 330 329 alSource3f(enumSource->getID(), AL_POSITION, 330 enumSource->getNode()->getAbsCoor().x, 331 enumSource->getNode()->getAbsCoor().y, 332 enumSource->getNode()->getAbsCoor().z); 333 alSource3f(enumSource->getID(), AL_VELOCITY, 334 enumSource->getNode()->getVelocity().x, 335 enumSource->getNode()->getVelocity().y, 336 enumSource->getNode()->getVelocity().z); 331 337 } 332 338 enumSource = iterator->nextElement(); … … 347 353 SoundSource* enumSource = sourceIterator->nextElement(); 348 354 while (enumSource) 349 350 351 352 353 355 { 356 if (enumBuffer == enumSource->getBuffer()) 357 break; 358 enumSource = sourceIterator->nextElement(); 359 } 354 360 delete sourceIterator; 355 361 if (enumSource == NULL) 356 362 ResourceManager::getInstance()->unload(enumBuffer); 357 363 enumBuffer = bufferIterator->nextElement(); 358 364 } … … 402 408 PRINTF(4)("AL_NO_ERROR\n"); 403 409 break; 404 410 405 411 case AL_INVALID_NAME: 406 412 PRINTF(2)("AL_INVALID_NAME\n"); -
orxonox/trunk/src/lib/sound/sound_engine.h
r4519 r4597 1 /*! 1 /*! 2 2 \file sound_engine.h 3 \brief Definition of the SoundEngine singleton Class 3 \brief Definition of the SoundEngine singleton Class 4 4 */ 5 5 … … 20 20 21 21 //! A class that represents a datastructure to play Sounds. 22 class SoundBuffer 22 class SoundBuffer : public BaseObject 23 23 { 24 24 public: … … 37 37 38 38 //! A class that represents a SoundSource 39 class SoundSource 39 class SoundSource : virtual public BaseObject 40 40 { 41 41 public: 42 42 SoundSource(SoundBuffer* buffer, PNode* sourceNode = NULL); 43 43 ~SoundSource(void); 44 44 45 45 // user interaction 46 46 void play(); … … 48 48 void pause(); 49 49 void rewind(); 50 50 51 51 // development functions 52 52 /** \returns The ID of this Source */ 53 53 inline ALuint getID(void) const { return this->sourceID; } 54 54 /** \returns the SoundBuffer of this Source */ 55 inline SoundBuffer* getBuffer(void) const { return this->buffer; } 55 inline SoundBuffer* getBuffer(void) const { return this->buffer; } 56 56 /** \returns the SourceNode of this Source */ 57 57 inline PNode* getNode(void) const { return this->sourceNode;} -
orxonox/trunk/src/lib/util/ini_parser.cc
r4381 r4597 1 /* 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 … … 28 28 IniParser::IniParser (const char* filename) 29 29 { 30 this->setClassID(CL_INI_PARSER, "IniParser"); 31 30 32 stream = NULL; 31 33 bInSection = false; … … 50 52 char* tmpName = ResourceManager::homeDirCheck(filename); 51 53 if( filename == NULL) return -1; 52 if( stream != NULL) 54 if( stream != NULL) fclose (stream); 53 55 if( (stream = fopen (tmpName, "r")) == NULL) 54 56 { … … 71 73 bInSection = false; 72 74 if( stream == NULL) return -1; 73 75 74 76 char linebuffer[PARSELINELENGHT]; 75 77 char secbuffer[PARSELINELENGHT]; 76 78 char* ptr; 77 79 78 80 rewind (stream); 79 81 while( !feof( stream)) … … 85 87 // check for section identifyer 86 88 if( sscanf (linebuffer, "[%s", secbuffer) == 1) 87 88 89 90 91 92 93 94 95 96 97 89 { 90 if( (ptr = strchr( secbuffer, ']')) != NULL) 91 { 92 *ptr = 0; 93 if( !strcmp( secbuffer, section)) 94 { 95 bInSection = true; 96 return 0; 97 } 98 } 99 } 98 100 } 99 101 return -1; … … 114 116 } 115 117 if( !bInSection) return -1; 116 118 117 119 char linebuffer[PARSELINELENGHT]; 118 120 char* ptr; 119 121 120 122 while( !feof( stream)) 121 123 { … … 125 127 if( (ptr = strchr( linebuffer, '\n')) != NULL) *ptr = 0; 126 128 if( linebuffer[0] == '[') 127 128 129 130 129 { 130 bInSection = false; 131 return -1; 132 } 131 133 sscanf(linebuffer, "%s = %s", name, value); 132 134 return 0; 133 135 /* 134 135 136 137 138 139 140 141 136 if( (ptr = strchr( tmpBuffer, '=')) != NULL) 137 { 138 if( ptr == linebuffer) continue; 139 strcpy (value, &ptr[1]); 140 strncpy (name, linebuffer, strlen (linebuffer) - strlen (value) - 1); 141 printf ("%s, %s\n", value, name); 142 return 0; 143 } 142 144 */ 143 145 } 144 return -1; 146 return -1; 145 147 } 146 148 … … 151 153 \param defvalue: what should be returned in case the entry cannot be found 152 154 \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 153 155 154 156 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 155 157 lead to unwanted behaviour. … … 159 161 strcpy (internbuf, defvalue); 160 162 if( getSection (section) == -1) return internbuf; 161 163 162 164 char namebuf[PARSELINELENGHT]; 163 165 char valuebuf[PARSELINELENGHT]; 164 166 165 167 while( nextVar (namebuf, valuebuf) != -1) 166 168 { 167 169 if( !strcmp (name, namebuf)) 168 169 170 171 170 { 171 strcpy (internbuf, valuebuf); 172 return internbuf; 173 } 172 174 } 173 175 return internbuf; -
orxonox/trunk/src/lib/util/ini_parser.h
r4482 r4597 2 2 \file ini_parser.h 3 3 \brief A small ini file parser 4 4 5 5 Can be used to find a defined [Section] in an ini file and get the VarName=Value entries 6 6 */ … … 12 12 #include <string.h> 13 13 #include <stdlib.h> 14 #include "base_object.h" 14 15 15 16 #define PARSELINELENGHT 512 //!< how many chars to read at once … … 17 18 //! ini-file parser 18 19 /** 19 20 This class can be used to load an initializer file and parse it's contents for variablename=value pairs. 20 21 */ 21 class IniParser { 22 class IniParser : public BaseObject 23 { 22 24 public: 23 25 IniParser (const char* filename); 24 26 ~IniParser (); 25 27 26 28 char* getVar(const char* name, char* section, char* defvalue); 27 29 int openFile(const char* name); … … 33 35 bool bInSection; //!< if the requested parameter is in the section. 34 36 char internbuf[PARSELINELENGHT]; //!< a buffer 35 37 36 38 37 39 }; -
orxonox/trunk/src/lib/util/substring.cc
r4220 r4597 1 /* 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 … … 11 11 ### File Specific: 12 12 main-programmer: Christian Meyer 13 co-programmer: ... 13 co-programmer: Benjamin Grauer 14 15 2005-06-10: some naming conventions 14 16 */ 15 17 … … 28 30 { 29 31 n = 0; 30 32 31 33 assert( string != NULL); 32 34 33 35 for( int i = 0; i < strlen(string); i++) if( string[i] == ',') n++; 34 36 35 37 n += 1; 36 38 37 39 strings = new char*[n]; 38 40 39 41 assert (strings != NULL); 40 42 41 43 int i = 0; 42 44 int l = 0; 43 45 44 46 const char* offset = string; 45 47 char* end = strchr( string, ','); … … 57 59 end = strchr( offset, ','); 58 60 } 59 61 60 62 strings[i] = new char[l + 1]; 61 63 l = strlen( offset); … … 73 75 delete strings[i]; 74 76 } 75 77 76 78 delete strings; 77 79 } -
orxonox/trunk/src/lib/util/substring.h
r4482 r4597 1 /*! 1 /*! 2 2 \file substring.h 3 3 \brief a small class to get the parts of a string separated by commas … … 13 13 SubString(const char* string); 14 14 ~SubString(); 15 15 16 16 int getCount(); 17 17 const char* getString( int i); 18 18 19 19 private: 20 20 char** strings; //!< strings produced from a single string splitted in multiple strings -
orxonox/trunk/src/orxonox.cc
r4556 r4597 56 56 { 57 57 this->setClassID(CL_ORXONOX, "Orxonox"); 58 this->setName("orxonox"); 58 59 59 60 this->resourceManager = NULL; -
orxonox/trunk/src/story_entities/campaign.cc
r4324 r4597 1 1 2 2 3 /* 3 /* 4 4 orxonox - the future of 3D-vertical-scrollers 5 5 … … 13 13 ### File Specific: 14 14 main-programmer: Patrick Boenzli 15 co-programmer: 15 co-programmer: 16 16 */ 17 17 … … 32 32 33 33 34 Campaign::Campaign () 35 { 34 Campaign::Campaign () 35 { 36 this->setClassID(CL_CAMPAIGN, "Campaign"); 36 37 this->entities = new tList<StoryEntity>(); 37 38 this->isInit = false; 38 39 } 39 40 40 Campaign::Campaign ( TiXmlElement* root) 41 { 41 Campaign::Campaign ( TiXmlElement* root) 42 { 43 //! \todo loading with load_param.... 44 this->setClassID(CL_CAMPAIGN, "Campaign"); 42 45 TiXmlElement* element; 43 46 const char* string; 44 47 int id; 45 48 46 49 PRINTF(3)("Loading Campaign...\n"); 47 50 48 51 assert( root != NULL); 49 52 GameLoader* loader = GameLoader::getInstance(); 50 53 51 54 this->entities = new tList<StoryEntity>(); 52 55 this->isInit = false; 53 56 54 57 // grab all the necessary parameters 55 58 string = grabParameter( root, "identifier"); … … 60 63 } 61 64 else this->setStoryID( id); 62 65 63 66 // find WorldList 64 67 element = root->FirstChildElement( "WorldList"); … … 69 72 else 70 73 element = element->FirstChildElement(); 71 74 72 75 // load Worlds/Subcampaigns/Whatever 73 76 StoryEntity* lastCreated = NULL; … … 77 80 StoryEntity* created = (StoryEntity*) loader->fabricate( element); 78 81 /* 79 if( lastCreated != NULL) 80 82 if( lastCreated != NULL) 83 created->setNextStoryID( lastCreated->getStoryID()); 81 84 else 82 85 created->setNextStoryID( WORLD_ID_GAMEEND); 83 86 */ 84 87 if( created != NULL) 85 86 this->addEntity( created); 87 88 88 { 89 this->addEntity( created); 90 lastCreated = created; 91 } 89 92 element = element->NextSiblingElement(); 90 93 } 91 //if( lastCreated != NULL) 94 //if( lastCreated != NULL) 92 95 //lastCreated->setStoryID( WORLD_ID_GAMEEND); 93 96 } … … 111 114 { 112 115 ErrorMessage errorCode; 113 if( !this->isInit) return errorCode; 116 if( !this->isInit) return errorCode; 114 117 if( storyID == WORLD_ID_GAMEEND) return errorCode; 115 118 this->running = true; … … 126 129 se->start(); 127 130 se->destroy(); 128 131 129 132 delete se; 130 133 … … 133 136 se = this->getStoryEntity(nextWorldID); 134 137 this->currentEntity = se; 135 if( ( nextWorldID == WORLD_ID_GAMEEND) ||( se == NULL) ) 136 137 138 139 140 141 142 138 if( ( nextWorldID == WORLD_ID_GAMEEND) ||( se == NULL) ) 139 { 140 PRINTF(0)("Quitting campaing story loop\n"); 141 if(se != NULL) 142 delete se; 143 return errorCode; 144 } 145 143 146 } 144 147 } … … 162 165 { 163 166 this->running = false; 164 if(this->currentEntity != NULL) 167 if(this->currentEntity != NULL) 165 168 { 166 169 this->currentEntity->stop(); … … 182 185 183 186 184 /** 187 /** 185 188 \brief adds an game stroy entity to the campaign 186 189 … … 206 209 { 207 210 this->removeEntity(this->getStoryEntity(storyID)); 208 211 209 212 } 210 213 … … 251 254 tList<StoryEntity>* l; 252 255 StoryEntity* entity = NULL; 253 l = this->entities->getNext(); 254 while( l != NULL) 255 { 256 l = this->entities->getNext(); 257 while( l != NULL) 258 { 256 259 entity = l->getObject(); 257 260 l = l->getNext(); … … 260 263 //printf("Campaing::getStoryEntity() - now looping, found entity nr=%i\n", id); 261 264 if(id == storyID) 262 263 264 265 265 { 266 //printf("Campaing::getStoryEntity() - yea, this is what we where looking for: %id\n"); 267 return entity; 268 } 266 269 267 270 } … … 271 274 tIterator<StoryEntity>* iterator = this->entities->getIterator(); 272 275 StoryEntity* entity = iterator->nextElement(); 273 while( entity != NULL) 274 { 276 while( entity != NULL) 277 { 275 278 int id = entity->getStoryID(); 276 279 //printf("Campaing::getStoryEntity() - now looping, found entity nr=%i\n", id); 277 280 if(id == storyID) 278 279 280 281 281 { 282 //printf("Campaing::getStoryEntity() - yea, this is what we where looking for: %id\n"); 283 return entity; 284 } 282 285 entity = iterator->nextElement(); 283 286 } -
orxonox/trunk/src/story_entities/campaign.h
r4261 r4597 32 32 void removeEntity(int storyID); 33 33 void removeEntity(StoryEntity* se); 34 34 35 35 void nextLevel(); 36 36 void previousLevel(); -
orxonox/trunk/src/story_entities/story_def.h
r3472 r4597 20 20 #define WORLD_ID_GAMEEND 999 21 21 22 #define MAX_STORY_ENTITIES 99 //! >maximal StoryEntities in a Campaign22 #define MAX_STORY_ENTITIES 99 //!< maximal StoryEntities in a Campaign 23 23 24 24 #endif /* _STORY_DEF_H */ -
orxonox/trunk/src/story_entities/story_entity.cc
r4592 r4597 26 26 StoryEntity::StoryEntity () 27 27 { 28 this->setClassID(CL_STORY_ENTITY );28 this->setClassID(CL_STORY_ENTITY, "StoryEntity"); 29 29 } 30 30 StoryEntity::~StoryEntity () {} -
orxonox/trunk/src/story_entities/story_entity.h
r4261 r4597 1 /*! 1 /*! 2 2 \file story_entity.h 3 3 \brief holds the base class of everything that is playable - that is part of the story 4 */ 4 */ 5 5 6 6 -
orxonox/trunk/src/story_entities/world.cc
r4596 r4597 769 769 //GLMenuImageScreen* 770 770 this->glmis = new GLMenuImageScreen(); 771 this->glmis->init();772 771 this->glmis->setMaximum(8); 773 // this->glmis->draw();774 772 775 773 PRINTF(3)("World::displayLoadScreen - end\n"); -
orxonox/trunk/src/util/animation/animation.cc
r3988 r4597 1 /* 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 … … 22 22 /** 23 23 \brief creates a new Animation 24 24 25 25 This also adds the Animation automatically to the AnimationPlayer's list 26 26 */ 27 27 Animation::Animation(void) 28 { 28 { 29 this->setClassID(CL_ANIMATION, "Animation"); 30 29 31 // initialize a beginning KeyFrame, that will be deleted afterwards 30 32 this->keyFrameCount = 0; … … 43 45 /** 44 46 \brief destructs the Animation 45 47 46 48 this also takes the animation out of the AnimationPlayer's list (if it is there) 47 49 */ … … 54 56 \brief tells the AnimationPlayer, that we do not wish to handle this animation 55 57 automatically. 56 58 57 59 This means that it will not be ticked, and not be deleted with the AnimationPlayer 58 60 */ -
orxonox/trunk/src/util/animation/animation.h
r4485 r4597 1 /*! 1 /*! 2 2 \file animation.h 3 3 A Subclass for all animations in orxonox … … 31 31 deprecated QUADRATIC 32 32 */ 33 typedef enum ANIM_FUNCTION {ANIM_CONSTANT, 34 ANIM_LINEAR, 35 ANIM_SINE, 36 ANIM_COSINE, 37 ANIM_EXP, 38 ANIM_NEG_EXP, 39 ANIM_QUADRATIC, 40 ANIM_RANDOM, 41 ANIM_NULL}; 33 typedef enum ANIM_FUNCTION 34 { 35 ANIM_CONSTANT, 36 ANIM_LINEAR, 37 ANIM_SINE, 38 ANIM_COSINE, 39 ANIM_EXP, 40 ANIM_NEG_EXP, 41 ANIM_QUADRATIC, 42 ANIM_RANDOM, 43 ANIM_NULL 44 }; 45 42 46 #define ANIM_DEFAULT_FUNCTION ANIM_LINEAR //!< A default function to choose from the above set 43 47 … … 49 53 ANIM_INF_DELETE deletes the animation. !! THIS IS DANGEROUS !! only do this with non-class variables 50 54 */ 51 typedef enum ANIM_INFINITY {ANIM_INF_CONSTANT, 52 ANIM_INF_REPLAY, 53 ANIM_INF_REWIND, 54 ANIM_INF_DELETE};//, ANIM_INF_LINEAR, ANIM_INF_PINGPONG; 55 typedef enum ANIM_INFINITY 56 { 57 ANIM_INF_CONSTANT, 58 ANIM_INF_REPLAY, 59 ANIM_INF_REWIND, 60 ANIM_INF_DELETE 61 }; //, ANIM_INF_LINEAR, ANIM_INF_PINGPONG}; 55 62 56 63 //! A Superclass for describing an animation (all animations will be derived from this one) 57 64 /** implement in subclasses: 58 * 65 * 59 66 * De-/Constructor 60 67 * Animation Functions … … 65 72 * virtual rewind, to go to the first Keyframe. (other functions will call this one) 66 73 */ 67 class Animation 74 class Animation : public BaseObject 68 75 { 69 76 public: -
orxonox/trunk/src/util/animation/animation3d.cc
r4485 r4597 51 51 /** 52 52 \brief standard deconstructor 53 53 54 54 deletes all the Keyframes 55 55 */ … … 89 89 */ 90 90 void Animation3D::addKeyFrame(Vector position, Quaternion direction, float duration, 91 91 ANIM_FUNCTION animFuncMov, ANIM_FUNCTION animFuncRot) 92 92 { 93 93 // some small check … … 101 101 102 102 KeyFrame3D* tmpKeyFrame; 103 103 104 104 // when adding the first frame 105 105 if (this->keyFrameCount == 0) … … 114 114 // when adding the second frame 115 115 if (this->currentKeyFrame == this->nextKeyFrame) 116 116 this->nextKeyFrame = tmpKeyFrame; 117 117 this->keyFrameList->add(tmpKeyFrame); 118 118 } … … 136 136 { 137 137 if (this->bRunning) 138 { 138 { 139 139 this->localTime += dt; 140 140 if (localTime >= this->currentKeyFrame->duration) 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 } 141 { 142 if (likely(this->keyFramesToPlay != 0)) 143 { 144 if (unlikely(this->keyFramesToPlay > 0)) 145 --this->keyFramesToPlay; 146 // switching to the next Key-Frame 147 this->localTime -= this->currentKeyFrame->duration; 148 this->currentKeyFrame = this->nextKeyFrame; 149 // checking, if we should still Play the animation 150 if (this->currentKeyFrame == this->keyFrameList->lastElement()) 151 this->handleInfinity(); 152 this->nextKeyFrame = this->keyFrameList->nextElement(this->currentKeyFrame); 153 this->setAnimFuncMov(this->currentKeyFrame->animFuncMov); 154 this->setAnimFuncRot(this->currentKeyFrame->animFuncRot); 155 } 156 else 157 this->pause(); 158 } 159 159 /* now animate it */ 160 160 (this->*animFuncMov)(this->localTime); … … 257 257 else 258 258 v = (this->nextKeyFrame->position - this->currentKeyFrame->position) * (2.0 + sin( M_PI * (- timePassed /this->currentKeyFrame->duration)) )/ 2.0; 259 259 260 260 this->object->shiftCoor(v - this->currentKeyFrame->lastPosition); 261 261 this->currentKeyFrame->lastPosition = v; … … 279 279 /* 280 280 this->object->setRelCoor( this->nextKeyFrame->position - 281 282 281 (this->nextKeyFrame->position - this->currentKeyFrame->position) * 282 (1.0 + cos( M_PI * timePassed / this->currentKeyFrame->duration))/2.0); 283 283 */ 284 284 } … … 309 309 /* 310 310 this->object->setRelCoor( this->currentKeyFrame->position + 311 (this->nextKeyFrame->position - this->currentKeyFrame->position) * 312 311 (this->nextKeyFrame->position - this->currentKeyFrame->position) * 312 (1.0 - expf(- timePassed * expFactorMov)) ); 313 313 */ 314 314 } … … 334 334 { 335 335 /* 336 this->object->setRelCoor(this->currentKeyFrame->position + 337 336 this->object->setRelCoor(this->currentKeyFrame->position + 337 (this->nextKeyFrame->position - this->currentKeyFrame->position) * (float)rand()/(float)RAND_MAX); 338 338 this->object->setRelDir(this->currentKeyFrame->direction + 339 339 (this->nextKeyFrame->direction - this->currentKeyFrame->direction)* (float)rand()/(float)RAND_MAX); 340 340 */ 341 341 } … … 401 401 void Animation3D::rLinear(float timePassed) const 402 402 { 403 this->object->setRelDir(quatSlerp( this->nextKeyFrame->direction, 404 this->currentKeyFrame->direction, 405 403 this->object->setRelDir(quatSlerp( this->nextKeyFrame->direction, 404 this->currentKeyFrame->direction, 405 timePassed/this->currentKeyFrame->duration) ); 406 406 } 407 407 … … 420 420 scale = 1.0 - sin( M_PI * timePassed / this->currentKeyFrame->duration); 421 421 422 this->object->setRelDir(quatSlerp( this->nextKeyFrame->direction, 423 this->currentKeyFrame->direction, 424 422 this->object->setRelDir(quatSlerp( this->nextKeyFrame->direction, 423 this->currentKeyFrame->direction, 424 scale) ); 425 425 } 426 426 … … 435 435 { 436 436 float scale = cos(M_PI * timePassed / this->currentKeyFrame->duration); 437 this->object->setRelDir(quatSlerp( this->nextKeyFrame->direction, 438 this->currentKeyFrame->direction, 439 437 this->object->setRelDir(quatSlerp( this->nextKeyFrame->direction, 438 this->currentKeyFrame->direction, 439 scale) ); 440 440 } 441 441 … … 458 458 { 459 459 float scale = (1.0 - expf(- timePassed * expFactorRot)); 460 this->object->setRelDir(quatSlerp( this->nextKeyFrame->direction, 461 this->currentKeyFrame->direction, 462 460 this->object->setRelDir(quatSlerp( this->nextKeyFrame->direction, 461 this->currentKeyFrame->direction, 462 scale) ); 463 463 } 464 464 -
orxonox/trunk/src/util/animation/animation3d.h
r4485 r4597 1 /*! 1 /*! 2 2 \file animation3d.h 3 3 */ … … 33 33 Animation3D(PNode* object); 34 34 virtual ~Animation3D(void); 35 35 36 36 virtual void rewind(void); 37 37 … … 40 40 41 41 virtual void tick(float dt); 42 42 43 43 private: 44 44 // animation functions -
orxonox/trunk/src/util/animation/animation_player.cc
r4485 r4597 1 /* 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 … … 26 26 \brief standard constructor 27 27 */ 28 AnimationPlayer::AnimationPlayer () 28 AnimationPlayer::AnimationPlayer () 29 29 { 30 this->setClassID(CL_ANIMATION_PLAYER, "AnimationPlayer"); 30 this->setClassID(CL_ANIMATION_PLAYER, "AnimationPlayer"); 31 this->setName("AnimationPlayer"); 31 32 32 33 33 this->animationList = new tList<Animation>(); 34 this->play(); 34 35 } 35 36 … … 43 44 44 45 !! DANGER !! when unloading the AnimationPlayer no other Function 45 should reference any Animations, from the animationList because it 46 automatically deletes them. 46 should reference any Animations, from the animationList because it 47 automatically deletes them. 47 48 This usually happens when unloading a World. 48 49 */ 49 AnimationPlayer::~AnimationPlayer () 50 AnimationPlayer::~AnimationPlayer () 50 51 { 51 52 // deleting the Animation List AND all the elements of the List … … 61 62 62 63 when adding a Animation the Animation will too be deleted when 63 the AnimationPlayer gets deleted. Consider not adding it, or 64 the AnimationPlayer gets deleted. Consider not adding it, or 64 65 unadding it with animation->notHandled(); 65 66 */ … … 80 81 /** 81 82 \brief empties the list AND deletes all the Animations 82 */ 83 */ 83 84 void AnimationPlayer::flush(void) 84 85 { … … 99 100 100 101 /** 101 \brief Ticks all the animations in animationList 102 \brief Ticks all the animations in animationList 102 103 \param timePassed the time passed since the last tick. 103 104 */ … … 110 111 Animation* anim = animIt->nextElement(); 111 112 while( anim != NULL) 112 113 114 115 116 117 118 119 120 113 { 114 anim->tick(timePassed); 115 if(unlikely(anim->ifDelete())) 116 { 117 this->animationList->remove(anim); 118 delete anim; 119 } 120 anim = animIt->nextElement(); 121 } 121 122 delete animIt; 122 123 } … … 150 151 { 151 152 if(anim->getBaseObject() == baseObject) 152 153 154 155 153 { 154 delete animIt; 155 return anim; 156 } 156 157 anim = animIt->nextElement(); 157 158 } -
orxonox/trunk/src/util/animation/animation_player.h
r4485 r4597 1 /*! 1 /*! 2 2 \file animation_player.h 3 3 */ … … 15 15 <b>AnimationPlayer usage:</b> \n 16 16 17 <b>Initialisation</b>: AnimationPlayer::getInstance() does the trick this is 17 <b>Initialisation</b>: AnimationPlayer::getInstance() does the trick this is 18 18 usually done when initializing a world \n 19 19 <b>Adding Animations</b>: create an Animation the following Way: … … 21 21 \li set some parameters: also see the specific classes for more info 22 22 \n 23 if you do not want a specific Animation to be handled by the AnimationPlayer, you have to 23 if you do not want a specific Animation to be handled by the AnimationPlayer, you have to 24 24 unload it explicitely with animation->doNotHandle(); 25 25 \n -
orxonox/trunk/src/util/animation/t_animation.h
r3982 r4597 14 14 */ 15 15 16 /*! 16 /*! 17 17 \file t_animation.h 18 18 */ … … 80 80 */ 81 81 template<class T> 82 tAnimation<T>::tAnimation (T* object, void (T::*funcToAnim)(float)) 82 tAnimation<T>::tAnimation (T* object, void (T::*funcToAnim)(float)) 83 83 { 84 84 // create a new List … … 100 100 /** 101 101 \brief standard deconstructor 102 102 103 103 deletes all the Keyframes 104 104 */ 105 105 template<class T> 106 tAnimation<T>::~tAnimation () 106 tAnimation<T>::~tAnimation () 107 107 { 108 108 // delete all the KeyFrames … … 158 158 159 159 KeyFrameF* tmpKeyFrame; 160 160 161 161 // when adding the first frame 162 162 if (this->keyFrameCount == 0) … … 170 170 // when adding the second frame 171 171 if (this->currentKeyFrame == this->nextKeyFrame) 172 172 this->nextKeyFrame = tmpKeyFrame; 173 173 this->keyFrameList->add(tmpKeyFrame); 174 174 } … … 191 191 this->localTime += dt; 192 192 if (localTime >= this->currentKeyFrame->duration) 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 this->setAnimFunc(this->currentKeyFrame->animFunc); 209 210 211 212 213 193 { 194 if (likely(this->keyFramesToPlay != 0)) 195 { 196 if (unlikely(this->keyFramesToPlay > 0)) 197 --this->keyFramesToPlay; 198 // switching to the next Key-Frame 199 this->localTime -= this->currentKeyFrame->duration; 200 201 this->currentKeyFrame = this->nextKeyFrame; 202 // checking, if we should still Play the animation 203 if (this->currentKeyFrame == this->keyFrameList->lastElement()) 204 this->handleInfinity(); 205 this->nextKeyFrame = this->keyFrameList->nextElement(this->currentKeyFrame); 206 207 printf("%p from:%f to:%f\n", this->currentKeyFrame,this->currentKeyFrame->value, this->nextKeyFrame->value); 208 this->setAnimFunc(this->currentKeyFrame->animFunc); 209 } 210 else 211 this->pause(); 212 } 213 214 214 (this->object->*(funcToAnim))((this->*animFunc)(this->localTime)); 215 215 } … … 243 243 case ANIM_NEG_EXP: 244 244 { 245 246 247 245 this->animFunc = &tAnimation<T>::negExp; 246 expFactor = - 1.0 / this->currentKeyFrame->duration * logf(DELTA_X); 247 break; 248 248 } 249 249 case ANIM_QUADRATIC: … … 273 273 */ 274 274 template<class T> 275 float tAnimation<T>::linear(float timePassed) const 275 float tAnimation<T>::linear(float timePassed) const 276 276 { 277 277 return this->currentKeyFrame->value + (this->nextKeyFrame->value - this->currentKeyFrame->value) … … 287 287 { 288 288 if (timePassed * 2.0 < this->currentKeyFrame->duration) 289 return this->currentKeyFrame->value + (this->nextKeyFrame->value - this->currentKeyFrame->value) 289 return this->currentKeyFrame->value + (this->nextKeyFrame->value - this->currentKeyFrame->value) 290 290 * sin( M_PI * timePassed / this->currentKeyFrame->duration)/2; 291 else 291 else 292 292 return this->nextKeyFrame->value - (this->nextKeyFrame->value - this->currentKeyFrame->value) 293 293 * sin( M_PI * (1.0 - timePassed / this->currentKeyFrame->duration))/2; … … 350 350 float tAnimation<T>::random(float timePassed) const 351 351 { 352 return this->currentKeyFrame->value + 352 return this->currentKeyFrame->value + 353 353 (this->nextKeyFrame->value - this->currentKeyFrame->value) * 354 354 (float)rand()/(float)RAND_MAX; -
orxonox/trunk/src/util/garbage_collector.cc
r4592 r4597 36 36 { 37 37 this->setClassID(CL_GARBAGE_COLLECTOR, "GarbageCollector"); 38 this->setName("GarbageCollector"); 39 38 40 this->time = 0; 39 41 this->delay = 1.5f; /* clean up all 5.0 seconds */ -
orxonox/trunk/src/util/loading/factory.cc
r4492 r4597 1 /* 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 … … 21 21 22 22 /* -------------------------------------------------- 23 * 23 * Factory 24 24 * -------------------------------------------------- 25 25 */ … … 27 27 /** 28 28 \brief constructor 29 29 30 30 set everything to zero and define factoryName 31 31 */ 32 32 Factory::Factory (const char* factoryName) 33 33 { 34 this->setClassID(CL_FACTORY, "Factory"); 35 this->setName(factoryName); 36 34 37 this->factoryName = NULL; 35 38 this->setFactoryName(factoryName); 36 39 next = NULL; 37 40 38 41 initialize(); 39 42 } … … 41 44 /** 42 45 \brief destructor 43 46 44 47 clear the Q 45 48 */ -
orxonox/trunk/src/util/loading/factory.h
r4492 r4597 1 /* 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 … … 14 14 */ 15 15 16 /*! 16 /*! 17 17 \file factory.h 18 18 \brief A loadable object handler … … 27 27 #include "tinyxml.h" 28 28 #include "load_param.h" 29 #include "base_object.h" 29 30 #include "debug.h" 30 31 31 /** 32 /** 32 33 Creates a factory to a Loadable Class. 33 34 this should be used at the beginning of all the Classes that should be loadable (in the cc-file) 35 \todo make factoryName a BaseObject-parameter. (else it would be redundant) 34 36 */ 35 #define CREATE_FACTORY(CLASS_NAME) tFactory<CLASS_NAME>* global_##CLASS_NAME##Factory = new tFactory<CLASS_NAME>(#CLASS_NAME) 37 #define CREATE_FACTORY(CLASS_NAME) tFactory<CLASS_NAME>* global_##CLASS_NAME##Factory = new tFactory<CLASS_NAME>(#CLASS_NAME) 36 38 37 39 //! The Factory is a loadable object handler 38 class Factory {40 class Factory : public BaseObject { 39 41 40 42 public: 41 43 Factory (const char* factoryName = NULL); 42 44 ~Factory (); 43 45 44 46 45 47 virtual BaseObject* fabricate(const TiXmlElement* root); … … 53 55 /** \returns the next factory */ 54 56 Factory* getNext(void) const { return this->next; }; 55 57 56 58 protected: 57 59 char* factoryName; //!< the name of the factory … … 69 71 tFactory(const char* factoryName); 70 72 virtual ~tFactory(); 71 73 72 74 private: 73 75 BaseObject* fabricate(const TiXmlElement* root); … … 83 85 PRINTF(5)("fileName: %s loadable\n", this->factoryName); 84 86 } 85 87 86 88 87 89 template<class T> … … 90 92 91 93 template<class T> 92 BaseObject* tFactory<T>::fabricate(const TiXmlElement* root) 93 { 94 BaseObject* tFactory<T>::fabricate(const TiXmlElement* root) 95 { 94 96 if(!strcmp(root->Value(), getFactoryName())) 95 97 return new T ( root); 96 else if( getNext() != NULL) 98 else if( getNext() != NULL) 97 99 return getNext()->fabricate( root); 98 else 100 else 99 101 return NULL; 100 102 } -
orxonox/trunk/src/util/loading/game_loader.cc
r4511 r4597 1 1 2 2 3 /* 3 /* 4 4 orxonox - the future of 3D-vertical-scrollers 5 5 … … 39 39 \brief simple constructor 40 40 */ 41 GameLoader::GameLoader () 42 { 41 GameLoader::GameLoader () 42 { 43 this->setClassID(CL_GAME_LOADER, "GameLoader"); 44 this->setName("GameLoader"); 43 45 first = NULL; 44 46 } … … 110 112 switch(campaignID) 111 113 { 112 /* 113 114 115 116 114 /* 115 Debug Level 0: Debug level used to test the base frame work. 116 As you can see, all storyentity data is allocated before game 117 start. the storyentity will load themselfs shortly before start 118 through the StoryEntity::init() funtion. 117 119 */ 118 120 case DEBUG_CAMPAIGN_0: 119 121 { 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 122 Campaign* debugCampaign = new Campaign(); 123 124 World* world0 = new World(DEBUG_WORLD_0); 125 world0->setNextStoryID(WORLD_ID_1); 126 debugCampaign->addEntity(world0, WORLD_ID_0); 127 128 World* world1 = new World(DEBUG_WORLD_1); 129 world1->setNextStoryID(WORLD_ID_2); 130 debugCampaign->addEntity(world1, WORLD_ID_1); 131 132 World* world2 = new World(DEBUG_WORLD_2); 133 world2->setNextStoryID(WORLD_ID_GAMEEND); 134 debugCampaign->addEntity(world2, WORLD_ID_2); 135 136 this->currentCampaign = debugCampaign; 137 break; 136 138 } 137 139 } … … 139 141 140 142 141 /** 143 /** 142 144 \brief starts the current entity 143 \returns error code if this action has caused a error 145 \returns error code if this action has caused a error 144 146 */ 145 147 ErrorMessage GameLoader::start() … … 150 152 151 153 152 /** 154 /** 153 155 \brief stops the current entity 154 156 \returns error code if this action has caused a error … … 168 170 169 171 170 /** 172 /** 171 173 \brief pause the current entity 172 174 \returns error code if this action has caused a error … … 182 184 183 185 184 /** 186 /** 185 187 \brief resumes a pause 186 188 \returns error code if this action has caused a error … … 218 220 can load everything it needs into memory then. 219 221 */ 220 222 221 223 if( fileName == NULL) 222 224 { … … 224 226 return NULL; 225 227 } 226 228 227 229 TiXmlDocument* XMLDoc = new TiXmlDocument( fileName); 228 230 // load the campaign document … … 234 236 return NULL; 235 237 } 236 238 237 239 // check basic validity 238 240 TiXmlElement* root = XMLDoc->RootElement(); 239 241 assert( root != NULL); 240 242 241 243 if( strcmp( root->Value(), "Campaign")) 242 244 { … … 246 248 return NULL; 247 249 } 248 250 249 251 // construct campaign 250 252 Campaign* c = new Campaign( root); 251 253 252 254 // free the XML data 253 255 delete XMLDoc; … … 258 260 259 261 /** 260 \brief handle keyboard commands 262 \brief handle keyboard commands 261 263 \param event the event to handle 262 264 */ … … 265 267 if( event.type == KeyMapper::PEV_NEXT_WORLD) 266 268 { 267 if( likely(event.bPressed)) 268 269 270 269 if( likely(event.bPressed)) 270 { 271 this->nextLevel(); 272 } 271 273 } 272 274 else if( event.type == KeyMapper::PEV_PREVIOUS_WORLD) 273 275 { 274 276 if( likely(event.bPressed)) 275 276 277 277 { 278 this->previousLevel(); 279 } 278 280 } 279 281 else if( event.type == KeyMapper::PEV_PAUSE) 280 282 { 281 283 if( likely(event.bPressed)) 282 283 284 285 286 287 284 { 285 if(this->isPaused) 286 this->resume(); 287 else 288 this->pause(); 289 } 288 290 } 289 291 else if( event.type == KeyMapper::PEV_QUIT) … … 322 324 void GameLoader::registerFactory( Factory* factory) 323 325 { 324 325 326 327 328 329 326 assert( factory != NULL); 327 328 PRINTF(4)("Registered factory for '%s'\n", factory->getFactoryName()); 329 330 if( first == NULL) first = factory; 331 else first->registerFactory( factory); 330 332 } 331 333 … … 338 340 { 339 341 assert( element != NULL); 340 342 341 343 if( first == NULL) 342 344 { … … 344 346 return NULL; 345 347 } 346 348 347 349 if( element->Value() != NULL) 348 350 { 349 351 PRINTF(4)("Attempting fabrication of a '%s'\n", element->Value()); 350 352 BaseObject* b = first->fabricate( element); 351 if( b == NULL) 352 353 else 354 353 if( b == NULL) 354 PRINTF(2)("Failed to fabricate a '%s'\n", element->Value()); 355 else 356 PRINTF(4)("Successfully fabricated a '%s'\n", element->Value()); 355 357 return b; 356 358 } 357 359 358 360 PRINTF(2)("Fabricate failed, TiXmlElement did not contain a value\n"); 359 361 360 362 return NULL; 361 363 } -
orxonox/trunk/src/util/loading/load_param.cc
r4501 r4597 1 /* 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 … … 30 30 */ 31 31 BaseLoadParam::BaseLoadParam(const TiXmlElement* root, BaseObject* object, const char* paramName, 32 int paramCount, bool multi, ...) 33 { 32 int paramCount, bool multi, ...) 33 { 34 this->setClassID(CL_LOAD_PARAM, "LoadParam"); 34 35 this->loadString = NULL; 35 36 … … 39 40 { 40 41 if (likely(!multi)) 41 42 this->loadString = grabParameter(root, paramName); 42 43 else 43 44 45 46 47 48 49 50 44 { 45 if (!strcmp(root->Value(), paramName)) 46 { 47 const TiXmlNode* val = root->FirstChild(); 48 if( val->ToText()) 49 this->loadString = val->Value(); 50 } 51 } 51 52 } 52 53 … … 64 65 va_start (types, multi); 65 66 for(int i = 0; i < paramCount; i++) 66 67 68 69 70 67 { 68 const char* tmpTypeName = va_arg (types, const char*); 69 this->paramDesc->types[i] = new char[strlen(tmpTypeName)+1]; 70 strcpy(this->paramDesc->types[i], tmpTypeName); 71 } 71 72 va_end(types); 72 73 … … 131 132 { 132 133 if (i > 0) 133 134 PRINT(3)(","); 134 135 PRINT(3)("%s", this->types[i]); 135 136 } … … 194 195 { 195 196 if (!strcmp(enumClassDesc->className, className)) 196 197 198 199 197 { 198 delete iterator; 199 return enumClassDesc; 200 } 200 201 enumClassDesc = iterator->nextElement(); 201 202 } … … 216 217 { 217 218 if (!strcmp(enumParamDesc->paramName, paramName)) 218 219 220 221 219 { 220 delete iterator; 221 return enumParamDesc; 222 } 222 223 enumParamDesc = iterator->nextElement(); 223 224 } … … 243 244 LoadParamDescription* enumParamDesc = paramIT->nextElement(); 244 245 while (enumParamDesc) 245 246 247 248 246 { 247 enumParamDesc->print(); 248 enumParamDesc = paramIT->nextElement(); 249 } 249 250 delete paramIT; 250 251 … … 267 268 const TiXmlElement* element; 268 269 const TiXmlNode* node; 269 270 270 271 if (root == NULL) 271 272 return NULL; 272 273 assert( parameterName != NULL); 273 274 274 275 element = root->FirstChildElement( parameterName); 275 276 if( element == NULL) return NULL; 276 277 277 278 node = element->FirstChild(); 278 279 while( node != NULL) -
orxonox/trunk/src/util/loading/load_param.h
r4592 r4597 22 22 #define _LOAD_PARAM_H 23 23 24 #include "base_object.h" 24 25 #include "factory.h" 25 26 #include "debug.h" … … 228 229 229 230 //! abstract Base class for a Loadable parameter 230 class BaseLoadParam 231 class BaseLoadParam : public BaseObject 231 232 { 232 233 public: -
orxonox/trunk/src/util/object_manager.cc
r4592 r4597 29 29 { 30 30 this->setClassID(CL_OBJECT_MANAGER, "ObjectManager"); 31 this->setName("ObjectManager"); 31 32 32 33 this->managedObjectList = new tList<BaseObject>*[CL_NUMBER]; -
orxonox/trunk/src/util/resource_manager.cc
r4534 r4597 1 /* 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 … … 47 47 \brief standard constructor 48 48 */ 49 ResourceManager::ResourceManager () 50 { 51 this->setClassID(CL_RESOURCE_MANAGER, "ResourceManager"); 52 this->dataDir = NULL; 53 this->setDataDir("./"); 54 this->imageDirs = new tList<char>(); 55 this->resourceList = new tList<Resource>(); 49 ResourceManager::ResourceManager () 50 { 51 this->setClassID(CL_RESOURCE_MANAGER, "ResourceManager"); 52 this->setName("ResourceManager"); 53 54 this->dataDir = NULL; 55 this->setDataDir("./"); 56 this->imageDirs = new tList<char>(); 57 this->resourceList = new tList<Resource>(); 56 58 } 57 59 … … 62 64 \brief standard destructor 63 65 */ 64 ResourceManager::~ResourceManager (void) 66 ResourceManager::~ResourceManager (void) 65 67 { 66 68 // deleting the Resources-List … … 106 108 107 109 /** 108 \brief checks for the DataDirectory, by looking if 110 \brief checks for the DataDirectory, by looking if 109 111 \param fileInside is inisde?? 110 112 */ … … 117 119 return false; 118 120 } 119 121 120 122 char* testFile = new char[strlen(this->dataDir)+strlen(fileInside)+1]; 121 123 sprintf(testFile, "%s%s", this->dataDir, fileInside); … … 141 143 char* tmpDir = tmpImageDirs->nextElement(); 142 144 while(tmpDir) 143 144 145 146 147 148 149 150 151 145 { 146 if (!strcmp(tmpDir, imageDir)) 147 { 148 PRINTF(4)("Path %s already loaded\n", imageDir); 149 delete tmpImageDirs; 150 return true; 151 } 152 tmpDir = tmpImageDirs->nextElement(); 153 } 152 154 delete tmpImageDirs; 153 155 … … 185 187 else if (!strcmp(fileName, "cube") || 186 188 !strcmp(fileName, "sphere") || 187 189 !strcmp(fileName, "plane") || 188 190 !strcmp(fileName, "cylinder") || 189 191 !strcmp(fileName, "cone")) … … 203 205 #endif /* NO_TEXT */ 204 206 #ifndef NO_TEXTURES 205 else 207 else 206 208 tmpType = IMAGE; 207 209 #endif /* NO_TEXTURES */ … … 221 223 */ 222 224 void* ResourceManager::load(const char* fileName, ResourceType type, ResourcePriority prio, 223 225 void* param1, void* param2, void* param3) 224 226 { 225 227 // searching if the resource was loaded before. … … 230 232 tmpResource->count++; 231 233 if(tmpResource->prio < prio) 232 234 tmpResource->prio = prio; 233 235 } 234 236 else … … 248 250 // Checking for the type of resource \see ResourceType 249 251 switch(type) 250 252 { 251 253 #ifndef NO_MODEL 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 254 case OBJ: 255 if (param1) 256 tmpResource->modelSize = *(float*)param1; 257 else 258 tmpResource->modelSize = 1.0; 259 260 if(ResourceManager::isFile(fullName)) 261 tmpResource->pointer = new OBJModel(fullName, tmpResource->modelSize); 262 else 263 { 264 PRINTF(2)("Sorry, %s does not exist. Loading a cube-Model instead\n", fullName); 265 tmpResource->pointer = ResourceManager::load("cube", PRIM, prio, &tmpResource->modelSize); 266 } 267 break; 268 case PRIM: 269 if (param1) 270 tmpResource->modelSize = *(float*)param1; 271 else 272 tmpResource->modelSize = 1.0; 273 274 if (!strcmp(tmpResource->name, "cube")) 275 tmpResource->pointer = new PrimitiveModel(PRIM_CUBE, tmpResource->modelSize); 276 else if (!strcmp(tmpResource->name, "sphere")) 277 tmpResource->pointer = new PrimitiveModel(PRIM_SPHERE, tmpResource->modelSize); 278 else if (!strcmp(tmpResource->name, "plane")) 279 tmpResource->pointer = new PrimitiveModel(PRIM_PLANE, tmpResource->modelSize); 280 else if (!strcmp(tmpResource->name, "cylinder")) 281 tmpResource->pointer = new PrimitiveModel(PRIM_CYLINDER, tmpResource->modelSize); 282 else if (!strcmp(tmpResource->name, "cone")) 283 tmpResource->pointer = new PrimitiveModel(PRIM_CONE, tmpResource->modelSize); 284 break; 285 case MD2: 286 if(ResourceManager::isFile(fullName)) 287 { 288 if (param1) 289 { 290 tmpResource->skinFileName = new char[strlen((const char*)param1)+1]; 291 strcpy(tmpResource->skinFileName, (const char*) param1); 292 } 293 else 294 tmpResource->skinFileName = NULL; 295 tmpResource->pointer = new MD2Data(fullName, tmpResource->skinFileName); 296 } 297 break; 296 298 #endif /* NO_MODEL */ 297 299 #ifndef NO_TEXT 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 300 case TTF: 301 if (param1) 302 tmpResource->ttfSize = *(int*)param1; 303 else 304 tmpResource->ttfSize = FONT_DEFAULT_SIZE; 305 if (param2) 306 { 307 Vector* tmpVec = (Vector*)param2; 308 tmpResource->ttfColorR = (int)tmpVec->x; 309 tmpResource->ttfColorG = (int)tmpVec->y; 310 tmpResource->ttfColorB = (int)tmpVec->z; 311 } 312 else 313 { 314 tmpResource->ttfColorR = FONT_DEFAULT_COLOR_R; 315 tmpResource->ttfColorG = FONT_DEFAULT_COLOR_G; 316 tmpResource->ttfColorB = FONT_DEFAULT_COLOR_B; 317 } 318 319 if(isFile(fullName)) 320 tmpResource->pointer = new Font(fullName, 321 tmpResource->ttfSize, 322 tmpResource->ttfColorR, 323 tmpResource->ttfColorG, 324 tmpResource->ttfColorB); 325 else 326 PRINTF(2)("Sorry, %s does not exist. Not loading Font\n", fullName); 327 break; 326 328 #endif /* NO_TEXT */ 327 329 #ifndef NO_AUDIO 328 329 330 331 330 case WAV: 331 if(isFile(fullName)) 332 tmpResource->pointer = new SoundBuffer(fullName); 333 break; 332 334 #endif /* NO_AUDIO */ 333 335 #ifndef NO_TEXTURES 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 336 case IMAGE: 337 if(isFile(fullName)) 338 { 339 PRINTF(4)("Image %s resides to %s\n", fileName, fullName); 340 tmpResource->pointer = new Texture(fullName); 341 } 342 else 343 { 344 tIterator<char>* iterator = imageDirs->getIterator(); 345 tmpDir = iterator->nextElement(); 346 //tmpDir = imageDirs->enumerate(); 347 while(tmpDir) 348 { 349 char* imgName = new char[strlen(tmpDir)+strlen(fileName)+1]; 350 sprintf(imgName, "%s%s", tmpDir, fileName); 351 if(isFile(imgName)) 352 { 353 PRINTF(4)("Image %s resides to %s\n", fileName, imgName); 354 tmpResource->pointer = new Texture(imgName); 355 delete []imgName; 356 break; 357 } 358 delete []imgName; 359 tmpDir = iterator->nextElement(); 360 } 361 delete iterator; 362 } 363 if(!tmpResource) 364 PRINTF(2)("!!Image %s not Found!!\n", fileName); 365 break; 364 366 #endif /* NO_TEXTURES */ 365 366 367 368 369 367 default: 368 tmpResource->pointer = NULL; 369 PRINTF(1)("No type found for %s.\n !!This should not happen unless the Type is not supported yet.!!\n", tmpResource->name); 370 break; 371 } 370 372 if (tmpResource->pointer) 371 373 this->resourceList->add(tmpResource); 372 374 delete []fullName; 373 375 } 374 376 if (tmpResource->pointer) 375 377 return tmpResource->pointer; 376 else 378 else 377 379 { 378 380 PRINTF(2)("Resource %s could not be loaded\n", fileName); … … 413 415 { 414 416 if (resource->count <= 0) 415 416 417 418 417 { 418 // deleting the Resource 419 switch(resource->type) 420 { 419 421 #ifndef NO_MODEL 420 421 422 423 424 425 426 422 case OBJ: 423 case PRIM: 424 delete (Model*)resource->pointer; 425 break; 426 case MD2: 427 delete (MD2Data*)resource->pointer; 428 break; 427 429 #endif /* NO_MODEL */ 428 430 #ifndef NO_AUDIO 429 430 431 431 case WAV: 432 delete (SoundBuffer*)resource->pointer; 433 break; 432 434 #endif /* NO_AUDIO */ 433 435 #ifndef NO_TEXT 434 435 436 436 case TTF: 437 delete (Font*)resource->pointer; 438 break; 437 439 #endif /* NO_TEXT */ 438 440 #ifndef NO_TEXTURES 439 440 441 441 case IMAGE: 442 delete (Texture*)resource->pointer; 443 break; 442 444 #endif /* NO_TEXTURES */ 443 444 445 446 447 448 449 450 451 452 445 default: 446 PRINTF(1)("NOT YET IMPLEMENTED !!FIX FIX!!\n"); 447 return false; 448 break; 449 } 450 // deleting the List Entry: 451 PRINTF(4)("Resource %s safely removed.\n", resource->name); 452 delete []resource->name; 453 this->resourceList->remove(resource); 454 } 453 455 else 454 456 PRINTF(4)("Resource %s not removed, because there are still %d References to it.\n", resource->name, resource->count); 455 457 } 456 458 else … … 471 473 { 472 474 if (enumRes->prio <= prio) 473 474 475 476 477 475 if (enumRes->count == 0) 476 unload(enumRes, prio); 477 else 478 PRINTF(2)("unable to unload %s because there are still %d references to it\n", 479 enumRes->name, enumRes->count); 478 480 //enumRes = resourceList->nextElement(); 479 481 enumRes = iterator->nextElement(); … … 492 494 */ 493 495 Resource* ResourceManager::locateResourceByInfo(const char* fileName, ResourceType type, 494 496 void* param1, void* param2, void* param3) 495 497 { 496 498 // Resource* enumRes = resourceList->enumerate(); … … 500 502 { 501 503 if (enumRes->type == type && !strcmp(fileName, enumRes->name)) 502 503 504 505 506 507 504 { 505 bool match = false; 506 bool subMatch = false; 507 508 switch (type) 509 { 508 510 #ifndef NO_MODEL 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 511 case PRIM: 512 case OBJ: 513 if (!param1) 514 { 515 if (enumRes->modelSize == 1.0) 516 match = true; 517 } 518 else if (enumRes->modelSize == *(float*)param1) 519 match = true; 520 break; 521 case MD2: 522 if (!param1) 523 { 524 if (enumRes->skinFileName == NULL) 525 match = true; 526 } 527 else if (!strcmp(enumRes->skinFileName, (const char*) param1)) 528 match = true; 529 break; 528 530 #endif /* NO_MODEL */ 529 531 #ifndef NO_TEXT 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 532 case TTF: 533 if (!param1) 534 { 535 if (enumRes->ttfSize == FONT_DEFAULT_SIZE) 536 subMatch = true; 537 } 538 else if (enumRes->modelSize =- *(int*)param1) 539 subMatch = true; 540 if(subMatch) 541 { 542 Vector* tmpVec = (Vector*)param2; 543 if (!param2) 544 { 545 if(enumRes->ttfColorR == FONT_DEFAULT_COLOR_R && 546 enumRes->ttfColorG == FONT_DEFAULT_COLOR_G && 547 enumRes->ttfColorB == FONT_DEFAULT_COLOR_B ) 548 match = true; 549 } 550 else if (enumRes->ttfColorR == (int)tmpVec->x && 551 enumRes->ttfColorG == (int)tmpVec->y && 552 enumRes->ttfColorB == (int)tmpVec->z ) 553 match = true; 554 } 555 break; 554 556 #endif /* NO_TEXT */ 555 556 557 558 559 560 561 562 563 564 557 default: 558 match = true; 559 break; 560 } 561 if (match) 562 { 563 delete iterator; 564 return enumRes; 565 } 566 } 565 567 enumRes = iterator->nextElement(); 566 568 } … … 582 584 { 583 585 if (pointer == enumRes->pointer) 584 585 586 587 586 { 587 delete iterator; 588 return enumRes; 589 } 588 590 enumRes = iterator->nextElement(); 589 591 } … … 622 624 if (status.st_mode & (S_IFDIR 623 625 #ifndef __WIN32__ 624 626 | S_IFLNK 625 627 #endif 626 627 628 629 630 628 )) 629 { 630 delete tmpDirName; 631 return true; 632 } 631 633 else 632 633 634 635 634 { 635 delete tmpDirName; 636 return false; 637 } 636 638 } 637 639 else … … 653 655 if (!stat(tmpFileName, &status)) 654 656 { 655 if (status.st_mode & (S_IFREG 657 if (status.st_mode & (S_IFREG 656 658 #ifndef __WIN32__ 657 659 | S_IFLNK 658 660 #endif 659 660 661 662 663 661 )) 662 { 663 delete tmpFileName; 664 return true; 665 } 664 666 else 665 666 667 668 669 } 670 else 667 { 668 delete tmpFileName; 669 return false; 670 } 671 } 672 else 671 673 { 672 674 delete tmpFileName; … … 691 693 } 692 694 fclose(stream); 693 694 delete tmpName; 695 696 delete tmpName; 695 697 } 696 698 … … 708 710 } 709 711 710 /** 712 /** 711 713 \param name the Name of the file to check 712 714 \returns The name of the file, including the HomeDir … … 737 739 } 738 740 739 /** 741 /** 740 742 \param fileName the Name of the File to check 741 743 \returns The full name of the file, including the DataDir, and NULL if the file does not exist … … 748 750 749 751 char* retName = new char[strlen(ResourceManager::getInstance()->getDataDir()) 750 752 + strlen(fileName) + 1]; 751 753 sprintf(retName, "%s%s", ResourceManager::getInstance()->getDataDir(), fileName); 752 754 if (ResourceManager::isFile(retName) || ResourceManager::isDir(retName)) … … 790 792 PRINT(0)("Name: %s; References: %d; Type:", enumRes->name, enumRes->count); 791 793 switch (enumRes->type) 792 793 794 795 796 797 798 799 800 801 802 803 804 805 794 { 795 case OBJ: 796 PRINT(0)("ObjectModel\n"); 797 break; 798 case PRIM: 799 PRINT(0)("PrimitiveModel\n"); 800 break; 801 case IMAGE: 802 PRINT(0)("ImageFile (Texture)\n"); 803 break; 804 default: 805 PRINT(0)("SoundFile\n"); 806 break; 807 } 806 808 PRINT(0)("gets deleted at "); 807 809 switch(enumRes->prio) 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 810 { 811 default: 812 case RP_NO: 813 PRINT(0)("first posibility (0)\n"); 814 break; 815 case RP_LEVEL: 816 PRINT(0)("the end of the Level (1)\n"); 817 break; 818 case RP_CAMPAIGN: 819 PRINT(0)("the end of the campaign (2)\n"); 820 break; 821 case RP_GAME: 822 PRINT(0)("when leaving the game (3)\n"); 823 break; 824 } 823 825 enumRes = iterator->nextElement(); 824 826 } -
orxonox/trunk/src/util/resource_manager.h
r4534 r4597 1 /*! 1 /*! 2 2 \file resource_manager.h 3 3 \brief The Resource Manager checks if a file/resource is loaded. 4 4 5 If a file/resource was already loaded the resourceManager will 5 If a file/resource was already loaded the resourceManager will 6 6 return a void pointer to the desired resource. 7 7 Otherwise it will instruct the coresponding resource-loader to load, … … 9 9 10 10 it is possible to compile the resource Manager without some modules by 11 just adding the compile flag -D.... 11 just adding the compile flag -D.... 12 12 (NO_MODEL) 13 13 (NO_AUDIO) … … 23 23 #include "stdlibincl.h" 24 24 25 // FORWARD DEFINITION 25 // FORWARD DEFINITION 26 26 template<class T> class tList; 27 27 28 28 //! An eumerator for different fileTypes the resourceManager supports 29 typedef enum ResourceType { 29 typedef enum ResourceType 30 { 30 31 #ifndef NO_MODEL 31 32 OBJ, //!< loading .obj file … … 46 47 }; 47 48 48 //! An enumerator for different UNLOAD-types. 49 //! An enumerator for different UNLOAD-types. 49 50 /** 50 51 RP_NO: will be unloaded on request … … 53 54 RP_GAME: will be unloaded at the end of the whole Game (when closing orxonox) 54 55 */ 55 typedef enum ResourcePriority { RP_NO = 0, 56 RP_LEVEL = 1, 57 RP_CAMPAIGN = 2, 58 RP_GAME = 4 }; 56 typedef enum ResourcePriority 57 { 58 RP_NO = 0, 59 RP_LEVEL = 1, 60 RP_CAMPAIGN = 2, 61 RP_GAME = 4 62 }; 59 63 60 64 //! A Struct that keeps track about A resource its name its Type, and so on … … 63 67 void* pointer; //!< Pointer to the Resource. 64 68 int count; //!< How many times this Resource has been loaded. 65 69 66 70 char* name; //!< Name of the Resource. 67 71 ResourceType type; //!< ResourceType of this Resource. … … 84 88 //! The ResourceManager is a class, that decides if a file/resource should be loaded 85 89 /** 86 If a file/resource was already loaded the resourceManager will 90 If a file/resource was already loaded the resourceManager will 87 91 return a void pointer to the desired resource. 88 92 Otherwise it will instruct the corresponding resource-loader to load, … … 91 95 It does it by looking, if a desired file has already been loaded. 92 96 */ 93 class ResourceManager : public BaseObject 97 class ResourceManager : public BaseObject 94 98 { 95 99 public: … … 105 109 bool addImageDir(const char* imageDir); 106 110 void* load(const char* fileName, ResourcePriority prio = RP_NO, 107 111 void* param1 = NULL, void* param2 = NULL, void* param3 = NULL); 108 112 void* load(const char* fileName, ResourceType type, ResourcePriority prio = RP_NO, 109 113 void* param1 = NULL, void* param2 = NULL, void* param3 = NULL); 110 114 bool unload(void* pointer, ResourcePriority prio = RP_NO); 111 115 bool unload(Resource* resource, ResourcePriority = RP_NO); 112 116 bool unloadAllByPriority(ResourcePriority prio); 113 117 114 118 void debug(void); 115 119 116 120 117 121 // utility functions of this class … … 127 131 128 132 Resource* locateResourceByInfo(const char* fileName, ResourceType type, void* param1, void* param2, void* param3); 129 Resource* locateResourceByPointer(const void* pointer); 133 Resource* locateResourceByPointer(const void* pointer); 130 134 131 135 private: -
orxonox/trunk/src/util/state.cc
r4485 r4597 1 /* 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 … … 28 28 \brief standard constructor 29 29 */ 30 State::State () 30 State::State () 31 31 { 32 this->setClassName ("State"); 32 this->setClassID(CL_STATE, "State"); 33 this->setName("State"); 33 34 34 35 this->camera = NULL; … … 44 45 \brief standard deconstructor 45 46 */ 46 State::~State () 47 State::~State () 47 48 { 48 49 State::singletonRef = NULL; -
orxonox/trunk/src/util/state.h
r4485 r4597 1 /*! 1 /*! 2 2 \file state.h 3 3 \brief Definition of the States-singleton Class -
orxonox/trunk/src/util/track/pilot_node.cc
r4456 r4597 1 1 2 2 3 /* 3 /* 4 4 orxonox - the future of 3D-vertical-scrollers 5 5 … … 28 28 \brief standard constructor 29 29 */ 30 PilotNode::PilotNode () 30 PilotNode::PilotNode () 31 31 { 32 32 this->setClassID(CL_PILOT_PARENT, "PilotNode"); 33 this->setName("PilotNode"); 33 34 34 35 travelSpeed = 30.0; … … 40 41 \brief standard deconstructor 41 42 */ 42 PilotNode::~PilotNode () 43 PilotNode::~PilotNode () 43 44 { 44 45 45 46 } 46 47 47 /** 48 /** 48 49 \brief ticks the node 49 \param time the time about whitch to tick 50 \param time the time about whitch to tick \ 50 51 */ 51 52 void PilotNode::tick(float time) … … 73 74 direction = q.apply(direction); 74 75 75 76 76 77 77 78 Vector orthDirection(0,0,1); 78 79 orthDirection = q.apply(orthDirection); 79 80 80 81 if( this->bUp) 81 82 accel = accel+(direction*acceleration); … … 83 84 accel = accel -(direction*acceleration); 84 85 if( this->bLeft) 85 accel = accel - (orthDirection*acceleration); 86 accel = accel - (orthDirection*acceleration); 86 87 if( this->bRight) 87 88 accel = accel + (orthDirection*acceleration); 88 89 89 90 Vector move = accel * time; 90 91 this->shiftCoor (move); 91 92 92 93 Quaternion q1(-M_PI/4 * this->roll/40000.0, Vector(0,0,1)); 93 94 Quaternion q2(-M_PI/4 * this->pitch/30000.0, Vector(0,1,0)); -
orxonox/trunk/src/util/track/pilot_node.h
r4456 r4597 1 /*! 1 /*! 2 2 \file pilot_node.h 3 3 \brief Definition of a PilotNode -
orxonox/trunk/src/util/track/track_manager.cc
r4584 r4597 40 40 TrackElement::TrackElement(void) 41 41 { 42 this->setClassID(CL_TRACK_ELEMENT, "TrackElement"); 43 42 44 this->isFresh = true; 43 45 this->isHotPoint = false; … … 358 360 { 359 361 this->setClassID(CL_TRACK_MANAGER, "TrackManager"); 362 this->setName("TrackManager"); 360 363 361 364 TrackManager::singletonRef = this; // do this because otherwise the TrackNode cannot get The instance of the TrackManager -
orxonox/trunk/src/util/track/track_node.cc
r4489 r4597 1 1 2 2 3 /* 3 /* 4 4 orxonox - the future of 3D-vertical-scrollers 5 5 … … 28 28 \brief standard constructor 29 29 */ 30 TrackNode::TrackNode () 30 TrackNode::TrackNode () 31 31 { 32 32 this->setClassID(CL_TRACK_NODE, "TrackNode"); 33 this->setName("TrackNode"); /* absolete but still used... */33 this->setName("TrackNode"); 34 34 35 35 NullParent::getInstance()->addChild(this); … … 38 38 } 39 39 40 41 40 /** 42 41 \brief standard deconstructor 43 42 */ 44 TrackNode::~TrackNode () 43 TrackNode::~TrackNode () 45 44 { 46 45 -
orxonox/trunk/src/world_entities/environment.cc
r4490 r4597 1 1 2 2 3 /* 3 /* 4 4 orxonox - the future of 3D-vertical-scrollers 5 5 … … 13 13 ### File Specific 14 14 main-programmer: Patrick Boenzli 15 co-programmer: 15 co-programmer: 16 16 */ 17 17 … … 31 31 Environment::Environment () : WorldEntity() 32 32 { 33 33 this->setClassID(CL_ENVIRONMENT, "Environment"); 34 34 } 35 35 … … 38 38 \brief deletes an environment 39 39 */ 40 Environment::~Environment () 40 Environment::~Environment () 41 41 { 42 42 … … 67 67 \brief draws the Environment 68 68 */ 69 void Environment::draw () 69 void Environment::draw () 70 70 { 71 71 //this->getRelCoor().debug(); … … 74 74 glPushMatrix(); 75 75 float matrix[4][4]; 76 76 77 77 glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z); 78 78 //rotate 79 79 this->getAbsDir().matrix (matrix); 80 80 glMultMatrixf((float*)matrix); 81 81 82 82 this->model->draw(); 83 83 -
orxonox/trunk/src/world_entities/npc.cc
r3472 r4597 1 1 2 2 3 /* 3 /* 4 4 orxonox - the future of 3D-vertical-scrollers 5 5 … … 27 27 28 28 29 NPC::NPC() 30 : WorldEntity() 29 NPC::NPC() : WorldEntity() 31 30 { 31 this->setClassID(CL_NPC, "NPC"); 32 32 hasDied = 0; 33 33 } … … 41 41 } 42 42 43 void NPC::getPosition(float* x, float* y, float* z) 43 void NPC::getPosition(float* x, float* y, float* z) 44 44 { 45 *x = xCor; 46 *y = yCor; 45 *x = xCor; 46 *y = yCor; 47 47 *z = zCor; 48 48 } 49 49 50 void NPC::setCollisionRadius(float r) 50 void NPC::setCollisionRadius(float r) 51 51 { 52 52 collisionRadius = r; 53 53 } 54 54 55 float NPC::getCollisionRadius() 55 float NPC::getCollisionRadius() 56 56 { 57 57 return collisionRadius; … … 64 64 void NPC::paint() 65 65 { 66 //cout << "WorldEntity::WorldEntity();" << endl; 66 //cout << "WorldEntity::WorldEntity();" << endl; 67 67 /* fix: died flag approach is very stupid, just to show @ convention */ 68 68 if( hasDied == 0 ) { … … 75 75 } 76 76 77 void NPC::drawNPC() 77 void NPC::drawNPC() 78 78 { 79 79 -
orxonox/trunk/src/world_entities/player.cc
r4592 r4597 49 49 */ 50 50 this->setClassID(CL_PLAYER, "Player"); 51 51 52 this->model = (Model*)ResourceManager::getInstance()->load("models/reaplow.obj", OBJ, RP_CAMPAIGN); 52 53 travelSpeed = 15.0; … … 90 91 { 91 92 this->setClassID(CL_PLAYER, "Player"); 93 92 94 this->weapons = new tList<Weapon>(); 93 95 this->activeWeapon = NULL; -
orxonox/trunk/src/world_entities/power_up.cc
r3483 r4597 1 1 2 2 3 /* 3 /* 4 4 orxonox - the future of 3D-vertical-scrollers 5 5 … … 24 24 25 25 26 PowerUp::PowerUp () {} 26 PowerUp::PowerUp () 27 { 28 this->setClassID(CL_POWER_UP, "PowerUp"); 29 } 27 30 28 31 -
orxonox/trunk/src/world_entities/projectile.cc
r4464 r4597 1 1 2 2 3 /* 3 /* 4 4 orxonox - the future of 3D-vertical-scrollers 5 5 … … 13 13 ### File Specific 14 14 main-programmer: Patrick Boenzli 15 co-programmer: 15 co-programmer: 16 16 */ 17 17 … … 34 34 { 35 35 this->setClassID(CL_PROJECTILE, "Projectile"); 36 36 37 this->weapon = weapon; 37 38 this->flightDirection = NULL; … … 45 46 \brief standard deconstructor 46 47 */ 47 Projectile::~Projectile () 48 Projectile::~Projectile () 48 49 { 49 /* 50 do not delete the test projectModel, since it is pnode 51 and will be cleaned out by world 50 /* 51 do not delete the test projectModel, since it is pnode 52 and will be cleaned out by world 52 53 */ 53 54 //delete this->projectileModel; … … 110 111 \param time since last tick 111 112 */ 112 void Projectile::tick (float time) 113 void Projectile::tick (float time) 113 114 { 114 115 Vector v = this->velocity * (time); … … 131 132 \param place where it is hit 132 133 */ 133 void Projectile::hit (WorldEntity* entity, Vector* place) 134 void Projectile::hit (WorldEntity* entity, Vector* place) 134 135 {} 135 136 … … 138 139 \brief the function gets called, when the projectile is destroyed 139 140 */ 140 void Projectile::destroy () 141 void Projectile::destroy () 141 142 {} 142 143 143 144 144 void Projectile::draw () 145 void Projectile::draw () 145 146 { 146 147 glMatrixMode(GL_MODELVIEW); 147 148 glPushMatrix(); 148 149 149 float matrix[4][4]; 150 float matrix[4][4]; 150 151 glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z); 151 152 this->getAbsDir().matrix (matrix); 152 glMultMatrixf((float*)matrix); 153 glMultMatrixf((float*)matrix); 153 154 this->model->draw(); 154 155 -
orxonox/trunk/src/world_entities/projectile.h
r4464 r4597 1 /*! 1 /*! 2 2 \projectile.h 3 3 \brief a projectile, that is been shooted by a weapon 4 4 5 5 You can use this class to make some shoots, but this isn't the real idea. If you want to just test, if the 6 shooting funcions work, use the Projectile class. But if you want to implement your own shoots its 6 shooting funcions work, use the Projectile class. But if you want to implement your own shoots its 7 7 different:<br> 8 8 Make a new class and derive it from Projectile. To have a weapon work well, reimplement the functions … … 10 10 - void draw() 11 11 - void hit() (only if you have working collision detection) 12 When you have implemented these functions you have just to add the projectiles to your weapon. You ll want 13 to make this by looking into the function 12 When you have implemented these functions you have just to add the projectiles to your weapon. You ll want 13 to make this by looking into the function 14 14 - Weapon::fire() 15 15 there you just change the line: … … 27 27 class Weapon; 28 28 29 class Projectile : public WorldEntity 29 class Projectile : public WorldEntity 30 30 { 31 31 friend class World; … … 48 48 protected: 49 49 //physical attriutes like: force, speed, acceleration etc. 50 float speed;//!< this is the speed of the projectile51 float currentLifeTime;//!< this is the time, the projectile exists in this world (incremented by tick)52 float ttl;//!< time to life, after this time, the projectile will garbage collect itself53 Vector* flightDirection;//!< direction in which the shoot flights54 Weapon* weapon;//!< weapon the shoot belongs to55 56 Vector velocity;//!< velocity of the projectile57 Vector offsetVel;//!< offset velocity TEMP50 float speed; //!< this is the speed of the projectile 51 float currentLifeTime; //!< this is the time, the projectile exists in this world (incremented by tick) 52 float ttl; //!< time to life, after this time, the projectile will garbage collect itself 53 Vector* flightDirection; //!< direction in which the shoot flights 54 Weapon* weapon; //!< weapon the shoot belongs to 55 56 Vector velocity; //!< velocity of the projectile 57 Vector offsetVel; //!< offset velocity TEMP 58 58 }; 59 59 -
orxonox/trunk/src/world_entities/satellite.cc
r4320 r4597 1 1 2 2 3 /* 3 /* 4 4 orxonox - the future of 3D-vertical-scrollers 5 5 … … 13 13 ### File Specific: 14 14 main-programmer: Patrick Boenzli 15 co-programmer: 15 co-programmer: 16 16 */ 17 17 … … 32 32 { 33 33 this->setClassID(CL_SATELLITE, "Satellite"); 34 34 35 this->model = (Model*) ResourceManager::getInstance()->load("cube", RP_LEVEL); 35 36 this->speed = speed; … … 52 53 \brief this method is called every frame 53 54 \param time: the time in seconds that has passed since the last tick 54 55 55 56 Handle all stuff that should update with time inside this method (movement, animation, etc.) 56 57 */ 57 void Satellite::tick(float time) 58 void Satellite::tick(float time) 58 59 { 59 60 float w = this->speed * M_PI; 60 61 61 Quaternion rotation(w * time, *this->axis); 62 Quaternion rotation(w * time, *this->axis); 62 63 Quaternion v = this->getRelDir(); 63 64 64 65 this->setRelDir(v * rotation); 65 66 } … … 68 69 /** 69 70 \brief the entity is drawn onto the screen with this function 70 71 71 72 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. 72 73 */ 73 void Satellite::draw() 74 void Satellite::draw() 74 75 { 75 76 glMatrixMode(GL_MODELVIEW); 76 77 glPushMatrix(); 77 78 float matrix[4][4]; 78 79 79 80 /* translate */ 80 glTranslatef (this->getAbsCoor ().x, 81 this->getAbsCoor ().y, 82 81 glTranslatef (this->getAbsCoor ().x, 82 this->getAbsCoor ().y, 83 this->getAbsCoor ().z); 83 84 /* rotate */ 84 85 this->getAbsDir ().matrix (matrix); 85 86 glMultMatrixf((float*)matrix); 86 87 87 88 this->model->draw(); 88 89 glPopMatrix(); -
orxonox/trunk/src/world_entities/satellite.h
r3750 r4597 1 /*! 1 /*! 2 2 \file world_entity.h 3 3 \brief Definition of the basic WorldEntity … … 18 18 //! Basic class from which all interactive stuff in the world is derived from 19 19 class Satellite : public WorldEntity 20 { 20 { 21 21 friend class World; 22 22 … … 27 27 virtual void draw (); 28 28 virtual void tick (float time); 29 29 30 30 private: 31 Vector* axis;32 float speed;33 31 Vector* axis; 32 float speed; 33 34 34 35 35 }; -
orxonox/trunk/src/world_entities/skybox.cc
r4444 r4597 1 1 2 /* 2 /* 3 3 orxonox - the future of 3D-vertical-scrollers 4 4 … … 68 68 { 69 69 this->setClassID(CL_SKYBOX, "SkyBox"); 70 70 71 this->skyModel = NULL; 71 72 this->material = new Material*[6]; 72 for (int i = 0; i < 6; i++) 73 for (int i = 0; i < 6; i++) 73 74 { 74 75 this->material[i] = new Material(); … … 104 105 usage: give this function an argument like 105 106 setTexture("skybox", "jpg"); 106 and it will convert this to 107 and it will convert this to 107 108 setTextures("skybox_top.jpg", "skybox_bottom.jpg", "skybox_left.jpg", 108 109 "skybox_right.jpg", "skybox_front.jpg", "skybox_back.jpg"); … … 123 124 sprintf(front, "%s_front.%s", name, extension); 124 125 sprintf(back, "%s_back.%s", name, extension); 125 126 126 127 this->setTextures(top, bottom, left, right, front, back); 127 128 … … 180 181 /** 181 182 \brief rebuilds the SkyBox 182 183 183 184 this must be done, when changing the Size of the Skybox (runtime-efficency) 184 185 */ … … 189 190 skyModel = new Model(); 190 191 191 this->skyModel->addVertex (-0.5*size, -0.5*size, 0.5*size); 192 this->skyModel->addVertex (-0.5*size, -0.5*size, 0.5*size); 192 193 this->skyModel->addVertex (0.5*size, -0.5*size, 0.5*size); 193 194 this->skyModel->addVertex (-0.5*size, 0.5*size, 0.5*size); … … 222 223 this->skyModel->setMaterial(material[5]); 223 224 this->skyModel->addFace (4, VERTEX_TEXCOORD_NORMAL, 6,0,4, 0,1,4, 2,2,4, 4,3,4); // back 224 225 225 226 this->skyModel->finalize(); 226 227 } -
orxonox/trunk/src/world_entities/skybox.h
r4261 r4597 1 /*! 1 /*! 2 2 \file skybox.h 3 3 \brief Definition of the SkyBox, that handles the Display of an atmosphere for orxonox. … … 43 43 void rebuild(); 44 44 45 Model* skyModel; //!< A Model for the Sky. This must not be the same as the Model from WorldEntity, because it is not alocated through the ResourceManager.46 Material **material;//!< Materials for the SkyBox. sorted by number (0-5) top, bottom, left, right, front, back47 float size;//!< Size of the SkyBox. This should match the frustum maximum range.48 45 Model* skyModel; //!< A Model for the Sky. This must not be the same as the Model from WorldEntity, because it is not alocated through the ResourceManager. 46 Material** material; //!< Materials for the SkyBox. sorted by number (0-5) top, bottom, left, right, front, back 47 float size; //!< Size of the SkyBox. This should match the frustum maximum range. 48 49 49 }; 50 50 -
orxonox/trunk/src/world_entities/skysphere.cc
r4444 r4597 1 1 2 /* 2 /* 3 3 orxonox - the future of 3D-vertical-scrollers 4 4 … … 13 13 main-programmer: David Gruetter 14 14 co-programmer: Benjamin Grauer 15 16 Created by Dave: this file is actually quite similar to player.cc and so is 15 16 Created by Dave: this file is actually quite similar to player.cc and so is 17 17 skybox.h similar to player.h 18 18 With that said, things should be clear:) 19 19 20 20 Edited: 21 21 Bensch: more constructors, changeability, comments... … … 43 43 Skysphere::Skysphere(char* fileName) 44 44 { 45 this->setClassID(CL_SKYSPHERE, "SkySphere"); 46 45 47 if (fileName == NULL) 46 48 this->initialize("pictures/sky-replace.jpg"); … … 92 94 /** 93 95 \brief draws the Skysphere 94 96 95 97 This part is normally precessed in the "Painting Phase". 96 98 */ … … 105 107 //glRotatef(95.0f, 0.0f, 0.0f, 1.0f); 106 108 //glRotatef(-250.0f, 0.0, 1.0f, 0.0f); 107 109 108 110 skyMaterial->select(); 109 111 gluSphere(this->sphereObj, this->sphereRadius, 20, 20); -
orxonox/trunk/src/world_entities/skysphere.h
r3763 r4597 1 /*! 1 /*! 2 2 \file skysphere.h 3 3 \brief Definition of the Skysphere, that handles the Display of an atmosphere of orxonox. … … 34 34 virtual void draw(); 35 35 36 private: 37 GLUquadricObj *sphereObj; //!< A Placeholder for the SkySphere. 38 Material *skyMaterial; //!< A Material for the SkySphere. 39 float sphereRadius; //!< Radius of the SkySphere. This should match the frustum maximum range. 40 41 void initialize(char* fileName); 36 private: 37 void initialize(char* fileName); 38 39 private: 40 GLUquadricObj* sphereObj; //!< A Placeholder for the SkySphere. 41 Material* skyMaterial; //!< A Material for the SkySphere. 42 float sphereRadius; //!< Radius of the SkySphere. This should match the frustum maximum range. 42 43 }; 43 44 -
orxonox/trunk/src/world_entities/terrain.cc
r4320 r4597 1 /* 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 … … 28 28 29 29 */ 30 Terrain::Terrain () 30 Terrain::Terrain () 31 31 { 32 32 this->init(); … … 36 36 \brief Constructor for loading a Terrain out of a file 37 37 \param fileName The file to load data from. 38 38 39 39 this either loads out of an OBJ-file, or loads a heightmap if no .obj-extension is found. 40 40 */ 41 Terrain::Terrain(c har* fileName)41 Terrain::Terrain(const char* fileName) 42 42 { 43 43 this->init(); … … 68 68 69 69 */ 70 Terrain::~Terrain () 70 Terrain::~Terrain () 71 71 { 72 72 if (objectList) … … 78 78 { 79 79 this->setClassID(CL_TERRAIN, "Terrain"); 80 80 81 this->objectList = 0; 81 82 } … … 84 85 85 86 void Terrain::draw () 86 { 87 { 87 88 glMatrixMode(GL_MODELVIEW); 88 89 glPushMatrix(); 89 90 float matrix[4][4]; 90 91 91 92 /* translate */ 92 glTranslatef (this->getAbsCoor ().x, 93 this->getAbsCoor ().y, 94 93 glTranslatef (this->getAbsCoor ().x, 94 this->getAbsCoor ().y, 95 this->getAbsCoor ().z); 95 96 /* rotate */ 96 97 this->getAbsDir ().matrix (matrix); … … 112 113 objectList = glGenLists(1); 113 114 glNewList (objectList, GL_COMPILE); 114 115 115 116 glColor3f(1.0,0,0); 116 117 117 118 int sizeX = 100; 118 119 int sizeZ = 80; … … 121 122 float widthX = float (length /sizeX); 122 123 float widthZ = float (width /sizeZ); 123 124 124 125 float height [sizeX][sizeZ]; 125 126 Vector normal_vectors[sizeX][sizeZ]; 126 127 127 128 128 129 for ( int i = 0; i<sizeX-1; i+=1) 129 130 130 for (int j = 0; j<sizeZ-1;j+=1) 131 //height[i][j] = rand()/20046 + (j-25)*(j-25)/30; 131 132 #ifdef __WIN32__ 132 133 height[i][j]=(sin((float)j/3)*rand()*i/182400)*.5; 133 134 #else 134 135 height[i][j]=(sin((float)j/3)*rand()*(long)i/6282450500.0)*.5; 135 136 #endif 136 137 137 138 //Die Huegel ein wenig glaetten 138 139 for (int h=1; h<2;h++) 139 140 141 142 140 for (int i=1;i<sizeX-2 ;i+=1 ) 141 for(int j=1;j<sizeZ-2;j+=1) 142 height[i][j]=(height[i+1][j]+height[i][j+1]+height[i-1][j]+height[i][j-1])/4; 143 143 144 //Berechnung von normalen Vektoren 144 145 for(int i=1;i<sizeX-2;i+=1) 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 146 for(int j=1;j<sizeZ-2 ;j+=1) 147 { 148 Vector v1 = Vector (widthX*(1), height[i][j], widthZ*(j) ); 149 Vector v2 = Vector (widthX*(i-1), height[i-1][j], widthZ*(j)); 150 Vector v3 = Vector (widthX*(i), height[i][j+1], widthZ*(j+1)); 151 Vector v4 = Vector (widthX*(i+1), height[i+1][j], widthZ*(j)); 152 Vector v5 = Vector (widthX*(i), height[i][j-1], widthZ*(j-1)); 153 154 Vector c1 = v2 - v1; 155 Vector c2 = v3 - v1; 156 Vector c3= v4 - v1; 157 Vector c4 = v5 - v1; 158 Vector zero = Vector (0,0,0); 159 normal_vectors[i][j]=c1.cross(v3-v5)+c2.cross(v4-v2)+c3.cross(v5-v3)+c4.cross(v2-v4); 160 normal_vectors[i][j].normalize(); 161 } 162 162 163 glBegin(GL_QUADS); 163 164 int snowheight=3; 164 165 for ( int i = 0; i<sizeX; i+=1) 165 166 { 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 166 for (int j = 0; j<sizeZ;j+=1) 167 { 168 Vector v1 = Vector (widthX*(i), height[i][j]-20, widthZ*(j) -width/2); 169 Vector v2 = Vector (widthX*(i+1), height[i+1][j]-20, widthZ*(j) -width/2); 170 Vector v3 = Vector (widthX*(i+1), height[i+1][j+1]-20, widthZ*(j+1)-width/2); 171 Vector v4 = Vector (widthX*(i), height[i][j+1]-20, widthZ*(j+1)-width/2); 172 float a[3]; 173 if(height[i][j]<snowheight){ 174 a[0]=0; 175 a[1]=1.0-height[i][j]/10-.3; 176 a[2]=0; 177 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 178 } 179 else{ 180 a[0]=1.0; 181 a[1]=1.0; 182 a[2]=1.0; 183 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 184 185 } 186 glNormal3f(normal_vectors[i][j].x, normal_vectors[i][j].y, normal_vectors[i][j].z); 187 glVertex3f(v1.x, v1.y, v1.z); 188 if(height[i+1][j]<snowheight){ 189 a[0]=0; 190 a[1] =1.0-height[i+1][j]/10-.3; 191 a[2]=0; 192 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 193 } 194 else{ 195 a[0]=1.0; 196 a[1]=1.0; 197 a[2]=1.0; 198 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 199 200 } 201 glNormal3f(normal_vectors[i+1][j].x, normal_vectors[i+1][j].y, normal_vectors[i+1][j].z); 202 glVertex3f(v2.x, v2.y, v2.z); 203 if(height[i+1][j+1]<snowheight){ 204 a[0]=0; 205 a[1] =1.0-height[i+1][j+1]/10-.3; 206 a[2]=0; 207 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 208 } 209 else{ 210 a[0]=1.0; 211 a[1]=1.0; 212 a[2]=1.0; 213 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 214 215 216 } 217 glNormal3f(normal_vectors[i+1][j+1].x, normal_vectors[i+1][j+1].y, normal_vectors[i+1][j+1].z); 218 glVertex3f(v3.x, v3.y, v3.z); 219 if(height[i][j+1]<snowheight){ 220 a[0]=0; 221 a[1] =1.0-height[i+1][j+1]/10-.3; 222 a[2]=0; 223 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 224 } 225 else{ 226 a[0]=1.0; 227 a[1]=1.0; 228 a[2]=1.0; 229 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 230 } 231 glNormal3f(normal_vectors[i][j+1].x, normal_vectors[i][j+1].y, normal_vectors[i][j+1].z); 232 glVertex3f(v4.x, v4.y, v4.z); 233 234 } 234 235 glEnd(); 235 236 glEndList(); … … 239 240 { 240 241 /* 241 242 this->model = (OBJModel*) new Model(); 242 243 this->model->setName("CUBE"); 243 244 this->model->addVertex (-0.5, -0.5, 0.5); … … 249 250 this->model->addVertex (-0.5, -0.5, -0.5); 250 251 this->model->addVertex (0.5, -0.5, -0.5); 251 252 252 253 this->model->addVertexTexture (0.0, 0.0); 253 254 this->model->addVertexTexture (1.0, 0.0); … … 268 269 */ 269 270 } 270 271 } 271 272 } -
orxonox/trunk/src/world_entities/terrain.h
r3566 r4597 1 /*! 1 /*! 2 2 \file terrain.h 3 3 \brief Defines and handles the terrain of the World … … 20 20 21 21 //! A Class to handle Terrain of orxonox 22 class Terrain : public WorldEntity 22 class Terrain : public WorldEntity 23 23 { 24 24 25 25 public: 26 26 Terrain(); 27 Terrain(c har* fileName);27 Terrain(const char* fileName); 28 28 Terrain(DebugTerrain debugTerrain); 29 29 virtual ~Terrain(); 30 30 void init(); 31 31 32 32 void buildDebugTerrain(DebugTerrain debugTerrain); 33 33 virtual void draw(); -
orxonox/trunk/src/world_entities/test_bullet.cc
r4593 r4597 34 34 { 35 35 this->setClassID(CL_TEST_BULLET, "TestBullet"); 36 36 37 float modelSize = .5; 37 38 this->model = (Model*)ResourceManager::getInstance()->load("models/Rocket1.obj", OBJ, RP_LEVEL, (void*) &modelSize); -
orxonox/trunk/src/world_entities/test_gun.cc
r4592 r4597 43 43 creates a new weapon 44 44 */ 45 TestGun::TestGun (PNode* parent, const Vector& coordinate, const Quaternion& direction, int leftRight) 45 TestGun::TestGun (PNode* parent, const Vector& coordinate, 46 const Quaternion& direction, int leftRight) 46 47 : Weapon (parent, coordinate, direction) 47 48 { 48 49 this->setClassID(CL_TEST_GUN, "TestGun"); 50 49 51 this->model = (Model*)ResourceManager::getInstance()->load("models/test_gun.obj", OBJ, RP_CAMPAIGN); 50 52 this->idleTime = 0.2f; -
orxonox/trunk/src/world_entities/weapon.cc
r4000 r4597 1 1 2 2 3 /* 3 /* 4 4 orxonox - the future of 3D-vertical-scrollers 5 5 … … 13 13 ### File Specific 14 14 main-programmer: Patrick Boenzli 15 co-programmer: 15 co-programmer: 16 16 */ 17 17 … … 35 35 \param number of weapon slots of the model/ship <= 8 (limitied) 36 36 */ 37 WeaponManager::WeaponManager(int nrOfSlots) 38 { 37 WeaponManager::WeaponManager(int nrOfSlots) 38 { 39 this->setClassID(CL_WEAPON_MANAGER, "WeaponManager"); 40 39 41 for(int i = 0; i < W_MAX_CONFIGS; ++i) 40 42 { 41 43 this->configs[i].bUsed = false; 42 44 for(int j = 0; j < W_MAX_SLOTS; ++j) 43 45 this->configs[i].slots[j] = NULL; 44 46 } 45 47 this->nrOfSlots = nrOfSlots; … … 48 50 49 51 50 WeaponManager::~WeaponManager() 51 { 52 /* 53 i dont have to delete the weapons itself, because they are 52 WeaponManager::~WeaponManager() 53 { 54 /* 55 i dont have to delete the weapons itself, because they are 54 56 worldentities and therefore in the entities list of the world. 55 57 world will clean them up for me … … 59 61 this->configs[i].bUsed = false; 60 62 for(int j = 0; j < W_MAX_SLOTS; ++j) 61 63 this->configs[i].slots[j] = NULL; 62 64 } 63 65 } … … 72 74 if you add explicitly a weapon at config:n, slot:m, the weapon placed at this location will be 73 75 replaced by the weapon specified. if you use the W_FREE_SLOT, the manager will look for a free 74 slot in this weaponconfiguration. if there is non, the weapon won't be added and there will be 76 slot in this weaponconfiguration. if there is non, the weapon won't be added and there will be 75 77 a error message. 76 78 */ 77 void WeaponManager::addWeapon(Weapon* weapon, int configID, int slotID) 79 void WeaponManager::addWeapon(Weapon* weapon, int configID, int slotID) 78 80 { 79 81 if( slotID == W_FREE_SLOT) … … 81 83 int freeSlot = this->getNextFreeSlot( configID); 82 84 if( freeSlot < 0 || freeSlot >= this->nrOfSlots) 83 84 85 86 85 { 86 PRINTF(0)("There is no free slot in this WeaponConfig to dock this weapon at! Aborting\n"); 87 return; 88 } 87 89 PRINTF(3)("Added new Weapon to Config:%i/Slot:%i\n", configID, freeSlot); 88 90 this->configs[configID].bUsed = true; … … 108 110 this function will deactivate the weapons first, change the config and reactivate them later 109 111 */ 110 void WeaponManager::nextWeaponConf() 112 void WeaponManager::nextWeaponConf() 111 113 { 112 114 PRINTF(4)("Changing weapon configuration: from %i to next\n", this->currConfID); … … 116 118 for(i = this->currConfID + 1; i < W_MAX_CONFIGS && !this->configs[i].bUsed; ++i); 117 119 if( i == W_MAX_CONFIGS) this->currConfID = W_CONFIG0; 118 else this->currConfID = i; 119 120 120 else this->currConfID = i; 121 122 121 123 Weapon *w1, *w2; 122 124 for(int j = 0; j < W_MAX_SLOTS; ++j) … … 124 126 w1 = this->configs[lastConfID].slots[j]; 125 127 w2 = this->configs[this->currConfID].slots[j]; 126 128 127 129 if( w1 == w2) 128 129 130 130 { 131 printf("no need for change\n"); 132 } 131 133 else 132 133 134 135 136 137 138 139 140 141 142 143 134 { 135 if( w1 != NULL ) 136 { 137 w1->deactivate(); 138 printf("deactivating %i,%i\n", j,lastConfID); 139 } 140 if( w2 != NULL) 141 { 142 w2->activate(); 143 printf("activating %i,%i\n", j, this->currConfID); 144 } 145 } 144 146 } 145 147 } … … 199 201 { 200 202 if( this->configs[configID].slots[i] == NULL) 201 203 return i; 202 204 } 203 205 return -1; … … 214 216 creates a new weapon 215 217 */ 216 Weapon::Weapon (PNode* parent, const Vector& coordinate, const Quaternion& direction) 218 Weapon::Weapon (PNode* parent, const Vector& coordinate, const Quaternion& direction) 217 219 : WorldEntity() 218 220 { … … 236 238 \brief standard deconstructor 237 239 */ 238 Weapon::~Weapon () 240 Weapon::~Weapon () 239 241 { 240 242 // model will be deleted from WorldEntity-destructor 241 243 //this->worldEntities = NULL; 242 244 243 245 /* dont delete objectComponentsX here, they will be killed when the pnodes are cleaned out */ 244 246 … … 247 249 248 250 249 /** 251 /** 250 252 \brief enables the weapon 251 253 252 a weapon can be enabled/disabled because of various reasons. if a weapon is 254 a weapon can be enabled/disabled because of various reasons. if a weapon is 253 255 been enabled, it can interact in a world. elswhere it wont react to any 254 256 action. … … 260 262 261 263 262 /** 264 /** 263 265 \brief disables the weapon 264 266 265 a weapon can be enabled/disabled because of various reasons. if a weapon is 267 a weapon can be enabled/disabled because of various reasons. if a weapon is 266 268 been enabled, it can interact in a world. elswhere it wont react to any 267 269 action. … … 273 275 274 276 275 /** 277 /** 276 278 \brief checks if the weapon is enabled 277 279 \returns true if enabled 278 280 279 a weapon can be ebabled/disabled because of various reasons. if a weapon is 281 a weapon can be ebabled/disabled because of various reasons. if a weapon is 280 282 been enabled, it can interact in a world. elswhere it wont react to any 281 283 action. … … 314 316 \brief this activates the weapon 315 317 316 This is needed, since there can be more than one weapon on a ship. the 317 activation can be connected with an animation. for example the weapon is 318 been armed out. 318 This is needed, since there can be more than one weapon on a ship. the 319 activation can be connected with an animation. for example the weapon is 320 been armed out. 319 321 */ 320 322 void Weapon::activate() … … 325 327 \brief this deactivates the weapon 326 328 327 This is needed, since there can be more than one weapon on a ship. the 328 activation can be connected with an animation. for example the weapon is 329 This is needed, since there can be more than one weapon on a ship. the 330 activation can be connected with an animation. for example the weapon is 329 331 been armed out. 330 332 */ … … 352 354 can destroy the weapons of enemies or vice versa. 353 355 */ 354 void Weapon::hit (WorldEntity* entity, Vector* position) 356 void Weapon::hit (WorldEntity* entity, Vector* position) 355 357 {} 356 358 … … 362 364 hit, it can also be destoryed. 363 365 */ 364 void Weapon::destroy () 366 void Weapon::destroy () 365 367 {} 366 368 … … 369 371 \brief tick signal for time dependent/driven stuff 370 372 */ 371 void Weapon::tick (float time) 373 void Weapon::tick (float time) 372 374 {} 373 375 … … 383 385 \brief this will draw the weapon 384 386 */ 385 void Weapon::draw () 386 {} 387 387 void Weapon::draw () 388 {} 389 -
orxonox/trunk/src/world_entities/weapon.h
r4504 r4597 1 /*! 1 /*! 2 2 \file weapon.h 3 3 \brief a weapon that a player can use … … 12 12 o slowdown-factor: this is a factor d: exp(-d*x), d is element of all positive R. it determines how fast the firing-rate will slow down. if no slowdown: d=0, the bigger d is, the faster the weapon will slow down! 13 13 o energy-consumption: this determines the energy that has to be used to produce this projectile = costs per projectile 14 14 15 15 Furthermore there are some other attributes, that will help to represent a firing 16 16 weapon in this world: 17 17 o sound file/ressource: this is a pointer to the sound-file/ressource. however it may be represented 18 18 o shooting animation 19 19 20 20 21 21 a player defines one or more weapon configurations. a player has got one to eight … … 31 31 #define _WEAPON_H 32 32 33 #include "base_object.h" 33 34 #include "world_entity.h" 34 35 … … 74 75 //! this is a weapon Configuration: it has up to 8 slots 75 76 typedef struct weaponConfig { 76 bool bUsed; //<! is set to true, if this configuration is 77 bool bUsed; //<! is set to true, if this configuration is 77 78 Weapon* slots[8]; 78 79 }; 79 80 80 81 81 class WeaponManager {82 class WeaponManager : public BaseObject { 82 83 public: 83 84 WeaponManager(int nrOfSlots = 2); 84 85 ~WeaponManager(); 85 86 86 87 void addWeapon(Weapon* weapon, int configID = W_CONFIG0, int slotID = W_FREE_SLOT); 87 88 void removeWeapon(Weapon* weapon, int configID = W_CONFIG0); … … 96 97 int currConfID; //<! the currently selected config 97 98 weaponConfig configs[4]; //<! a list of four configurations 98 99 99 100 int getNextFreeSlot(int configID); 100 101 }; 101 102 102 class Weapon : public WorldEntity 103 class Weapon : public WorldEntity 103 104 { 104 105 friend class World; … … 107 108 Weapon (PNode* parent, const Vector& coordinate, const Quaternion& direction); 108 109 virtual ~Weapon (); 109 110 110 111 void enable(void); 111 112 void disable(void); … … 123 124 \brief sets a weapon idle time 124 125 \param idle time in ms 125 126 126 127 a weapon idle time is the time spend after a shoot until the weapon can 127 128 shoot again … … 131 132 \brief gets the weapon idle time 132 133 \returns idle time in ms 133 134 134 135 a weapon idle time is the time spend after a shoot until the weapon can 135 136 shoot again … … 139 140 \brief checks if the idle time is elapsed 140 141 \return true if time is elapsed 141 142 142 143 a weapon idle time is the time spend after a shoot until the weapon can 143 144 shoot again … … 147 148 /** 148 149 \brief fires the weapon 149 150 150 151 this is called from the player.cc, when fire-button is been pushed 151 152 */ … … 153 154 virtual void hit (WorldEntity* weapon, Vector* loc); 154 155 virtual void destroy(void); 155 156 156 157 virtual void tick(float time); 157 158 virtual void weaponIdle(void); -
orxonox/trunk/src/world_entities/world_entity.cc
r4570 r4597 31 31 { 32 32 this->setClassID(CL_WORLD_ENTITY, "WorldEntity"); 33 33 34 this->model = NULL; 34 35
Note: See TracChangeset
for help on using the changeset viewer.