Changeset 4597 in orxonox.OLD for orxonox/trunk/src/lib
- Timestamp:
- Jun 11, 2005, 12:55:48 AM (20 years ago)
- Location:
- orxonox/trunk/src/lib
- Files:
-
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.