- Timestamp:
- Jun 14, 2007, 5:33:43 PM (18 years ago)
- Location:
- trunk/src
- Files:
-
- 58 edited
- 18 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/ai/swarm_gorel.cc
r10618 r10698 23 23 24 24 //calculate movement parameters.. 25 float averageRadius ;25 float averageRadius = 0; 26 26 for (it=members.begin(); it!= members.end(); it++ ){ 27 27 averageRadius+=it->second->getNPCRadius(); -
trunk/src/defs/include_paths.am
r10376 r10698 31 31 32 32 AM_CXXFLAGS+=-I$(MAINSRCDIR)/../extern_libs 33 34 AM_LDFLAGS+=-L$(MAINSRCDIR)/../extern_libs -
trunk/src/defs/orxonox_globals.h
r10638 r10698 71 71 #define CONFIG_NAME_DEBUG_LEVEL "Debug-Level" 72 72 73 // even ets73 // events 74 74 #define CONFIG_NAME_PLAYER_FORWARD "Forward" 75 75 #define CONFIG_NAME_PLAYER_BACKWARD "Backward" … … 83 83 #define CONFIG_NAME_PLAYER_STRAFE_RIGHT "StrafeRight" 84 84 #define CONFIG_NAME_PLAYER_JUMP "Jump" 85 #define CONFIG_NAME_PLAYER_CROUCH "Crouch" 85 86 86 87 #define CONFIG_NAME_PLAYER_ACTION "Action" -
trunk/src/lib/collision_detection/aabb_tree_node.cc
r10013 r10698 740 740 741 741 /* DRAW POLYGONS */ 742 if( drawMode & DRAW_BV_POLYGON || drawMode & DRAW_ALL || drawMode & DRAW_BV_BLENDED)742 if( (drawMode & DRAW_BV_POLYGON) || (drawMode & DRAW_ALL) || (drawMode & DRAW_BV_BLENDED)) 743 743 { 744 744 if (top) -
trunk/src/lib/event/key_mapper.cc
r10638 r10698 47 47 int KeyMapper::PEV_JUMP = EV_UNKNOWN; 48 48 int KeyMapper::PEV_ACTION = EV_UNKNOWN; 49 int KeyMapper::PEV_CROUCH = EV_UNKNOWN; 49 50 50 51 int KeyMapper::PEV_FIRE1 = EV_UNKNOWN; … … 87 88 {&KeyMapper::PEV_JUMP, CONFIG_NAME_PLAYER_JUMP, SDLK_SPACE}, 88 89 {&KeyMapper::PEV_ACTION, CONFIG_NAME_PLAYER_ACTION, SDLK_u}, 90 {&KeyMapper::PEV_CROUCH, CONFIG_NAME_PLAYER_CROUCH, SDLK_LCTRL}, 91 89 92 90 93 {&KeyMapper::PEV_FIRE1, CONFIG_NAME_PLAYER_FIRE, EV_MOUSE_BUTTON_LEFT}, -
trunk/src/lib/event/key_mapper.h
r10638 r10698 58 58 static int PEV_JUMP; //!< jump 59 59 static int PEV_ACTION; //!< the action (or use) key 60 static int PEV_CROUCH; //!< crouch 60 61 61 62 static int PEV_FIRE1; //!< fire button 1 -
trunk/src/lib/graphics/importer/bsp/bsp_manager.cc
r10643 r10698 173 173 // erase alreadyVisible 174 174 for(int i = 0; i < this->bspFile->numFaces; i++) this->alreadyVisible[i] = false; 175 float tmp = 0;175 // float tmp = 0; 176 176 //this->opal.clear(); 177 177 //this->trasparent.clear(); … … 186 186 187 187 this->viewDir= State::getCamera()->getAbsDirX(); 188 float d = (cam.x*viewDir.x + cam.y*viewDir.y + cam.z * viewDir.z);188 // float d = (cam.x*viewDir.x + cam.y*viewDir.y + cam.z * viewDir.z); 189 189 190 190 BspTreeNode* ActLeaf = this->getLeaf(this->bspFile->root, &ship); … … 254 254 255 255 for(int i = 0; i < this->bspFile->numLeafs ; ++i ) { 256 leaf& camLeaf = (this->bspFile->leaves)[ActLeaf->leafIndex] ;256 // leaf& camLeaf = (this->bspFile->leaves)[ActLeaf->leafIndex] ; 257 257 leaf& curLeaf = (this->bspFile->leaves)[i] ; 258 258 int& cluster = curLeaf.cluster; … … 1696 1696 1697 1697 1698 float BspManager::checkCollisionRay(Vector StartPoint, Vector Direction, float length ) 1699 { 1700 Direction.normalize(); // Oder besser vor dem Fkt-Aufruf schon normalisieren 1701 this->outputStartsOut = true; 1702 this->outputAllSolid = false; 1703 this->outputFraction = 1.0f; 1704 this->inputStart = StartPoint; 1705 Vector End = StartPoint + (Direction)*length; 1706 this->inputEnd = End; 1707 1708 this->checkCollisionRayN(this->root, 0.0f, 1.0f, &StartPoint, &(End) ); 1709 1710 return (this->outputFraction * length); 1711 1712 } 1713 1714 1698 1715 1699 1716 /** -
trunk/src/lib/graphics/importer/bsp/bsp_manager.h
r10618 r10698 77 77 void checkCollision(WorldEntity* worldEntity); /*!< WorldEntities use this function to check wheter they collided with the BspEntity. 78 78 If a collision has been detected, the collides-function of worldEntity will be called.*/ 79 float checkCollisionRay(Vector StartPoint, Vector Direction, float length ) ; 79 80 80 81 int sortTransparency; //!< sort transparent textures -
trunk/src/lib/math/quaternion.h
r10695 r10698 50 50 51 51 /** @param q: the Quaternion to compare with this one. @returns true if the Quaternions are the same, false otherwise */ 52 inline bool operator== (const Quaternion& q) const { return (unlikely(this->v==q.v&&this->w==q.w))?true:false; };52 inline bool operator== (const Quaternion& q) const { return (unlikely(this->v==q.v&&this->w==q.w))?true:false; }; 53 53 /** @param q: the Quaternion to compare with this one. @returns true if the Quaternions are the same, false otherwise */ 54 inline bool operator!= (const Quaternion& q) const { return (unlikely(this->v!=q.v||this->w!=q.w))?true:false; };54 inline bool operator!= (const Quaternion& q) const { return (unlikely(this->v!=q.v||this->w!=q.w))?true:false; }; 55 55 /** @param f: a real value @return a Quaternion containing the quotient */ 56 56 inline Quaternion operator/ (const float& f) const { return (unlikely(f==0.0)) ? Quaternion() : Quaternion(this->v/f, this->w/f); }; … … 118 118 119 119 120 inlinevoid slerpTo(const Quaternion& toQuat, float t);120 void slerpTo(const Quaternion& toQuat, float t); 121 121 static Quaternion quatSlerp(const Quaternion& from, const Quaternion& to, float t); 122 122 -
trunk/src/lib/math/vector.h
r10376 r10698 51 51 52 52 /** @param index The index of the "array" @returns the x/y/z coordinate */ 53 inline float operator[] (float index) const {if( index == 0) return this->x; if( index == 1) return this->y; if( index == 2) return this->z; }53 inline float operator[] (float index) const {if( index == 0) return this->x; if( index == 1) return this->y; if( index == 2) return this->z; else return this->x; } 54 54 /** @param v The vector to add @returns the addition between two vectors (this + v) */ 55 55 inline Vector operator+ (const Vector& v) const { return Vector(x + v.x, y + v.y, z + v.z); }; … … 64 64 /** @param v The vector to substract @returns the substraction between two vectors (this - v) */ 65 65 inline Vector operator- (const sVec3D& v) const { return Vector(x - v[0], y - v[1], z - v[2]); } 66 /** @returns the substraction between (0, 0, 0) and this (null-this) */ 67 inline Vector operator- () const { return Vector(-x, -y, -z); } 66 68 /** @param v The vector to substract @returns the substraction between two vectors (this -= v) */ 67 69 inline const Vector& operator-= (const Vector& v) { this->x -= v.x; this->y -= v.y; this->z -= v.z; return *this; }; -
trunk/src/story_entities/game_world.cc
r10618 r10698 695 695 AtmosphericEngine::getInstance()->draw(); 696 696 697 /* draw bounding boxes */ 697 698 if( unlikely( this->showBV)) 698 699 { -
trunk/src/util/Makefile.am
r10618 r10698 26 26 animation/animation_player.cc \ 27 27 \ 28 track/track.cc 28 track/track.cc \ 29 track/action_box.cc 29 30 30 31 noinst_HEADERS = \ … … 49 50 animation/t_animation.h \ 50 51 \ 51 track/track.h 52 track/track.h \ 53 track/action_box.h -
trunk/src/util/hud.cc
r10516 r10698 11 11 ### File Specific: 12 12 main-programmer: Benjamin Grauer 13 co-programmer: ...13 co-programmer: Benjamin Knecht 14 14 */ 15 15 … … 52 52 this->energyWidget = NULL; 53 53 this->shieldWidget = NULL; 54 this-> armorWidget = NULL;55 //this->leftRect = NULL;56 //this->rightRect = NULL;54 this->healthWidget = NULL; 55 this->leftRect = NULL; 56 this->rightRect = NULL; 57 57 this->resX = 1; 58 58 this->resY = 1; … … 62 62 this->rightRect = new OrxGui::GLGuiImage(); 63 63 this->leftRect = new OrxGui::GLGuiImage(); 64 this->topRect = new OrxGui::GLGuiImage(); 65 this->bottomRect = new OrxGui::GLGuiImage(); 66 this->middleRect = new OrxGui::GLGuiImage(); 64 67 65 68 this->inputLine = new OrxGui::GLGuiInputLine(); 66 this->inputLine->setParent2D(this);69 //this->inputLine->setParent2D(this); 67 70 this->notifier = new OrxGui::GLGuiNotifier(); 68 this->notifier->setParent2D(this); 69 notifier->setAbsCoor2D(100,100); 71 this->notifier->setParent2D(this->bottomRect); 72 notifier->setRelCoor2D(5,5); 73 74 this->barSocket = new OrxGui::GLGuiImage(); 75 this->barSocket->setParent2D(this->bottomRect); 70 76 71 77 this->_radar = new OrxGui::GLGuiRadar(); … … 88 94 89 95 delete this->_radar; 96 delete this->barSocket; 90 97 delete this->rightRect; 91 98 delete this->leftRect; 99 delete this->topRect; 100 delete this->bottomRect; 101 delete this->middleRect; 102 92 103 //if (this->shipValuesBox != NULL) 93 104 //delete this->shipValuesBox; … … 135 146 } 136 147 137 this->updateResolution(); 138 } 139 140 void Hud::setShi ledWidget(OrxGui::GLGuiWidget* widget)148 this->updateResolution(); 149 } 150 151 void Hud::setShieldWidget(OrxGui::GLGuiWidget* widget) 141 152 { 142 153 /* … … 169 180 } 170 181 171 void Hud::setArmorWidget(OrxGui::GLGuiWidget* widget) 172 { 173 /* 174 if (this->shipValuesBox == NULL) 175 this->createShipValuesBox(); 176 */ 177 178 // decopple old widget 179 if (this->armorWidget != NULL) 180 { 181 this->armorWidget->hide(); 182 } 183 184 this->armorWidget = widget; 185 if (this->armorWidget != NULL) 186 { 187 //this->armorWidget->shiftDir2D(270); 188 //this->shipValuesBox->pack(this->armorWidget); 189 //dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->armorWidget)->setStandardSettings(); 190 this->armorWidget->setParent2D(this->leftRect); 191 dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->armorWidget)->setDisplayedImage("textures/gui/gui_health_icon.png"); 192 this->armorWidget->show(); 193 /* this->armorWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png"); 194 this->armorWidget->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/ 182 void Hud::setHealthWidget(OrxGui::GLGuiWidget* widget) 183 { 184 if( this->playmode == FirstPerson ) 185 { 186 this->healthWidget = new OrxGui::GLGuiBar(); 187 dynamic_cast<OrxGui::GLGuiBar*> (this->healthWidget)->setMaximum(dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (widget)->getBarWidget()->maximum()); 188 dynamic_cast<OrxGui::GLGuiBar*> (this->healthWidget)->setValue(dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (widget)->getBarWidget()->value()); 189 this->healthWidget->setParent2D(this->barSocket); 190 } 191 else 192 { 193 /* 194 if (this->shipValuesBox == NULL) 195 this->createShipValuesBox(); 196 */ 197 198 // decopple old widget 199 if (this->healthWidget != NULL) 200 { 201 this->healthWidget->hide(); 202 } 203 204 this->healthWidget = widget; 205 if (this->healthWidget != NULL) 206 { 207 //this->healthWidget->shiftDir2D(270); 208 //this->shipValuesBox->pack(this->healthWidget); 209 //dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->healthWidget)->setStandardSettings(); 210 this->healthWidget->setParent2D(this->leftRect); 211 //dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->healthWidget)->setDisplayedImage("textures/gui/gui_health_icon.png"); 212 this->healthWidget->show(); 213 /* this->healthWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png"); 214 this->healthWidget->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/ 215 } 216 } 217 218 this->updateResolution(); 219 } 220 221 222 void Hud::setImplantWidget(OrxGui::GLGuiWidget* widget) 223 { 224 //if (this->shipValuesBox == NULL) 225 //this->createShipValuesBox(); 226 227 // decopple old widget 228 if (this->implantWidget != NULL) 229 { 230 this->implantWidget->hide(); 231 } 232 233 this->implantWidget = widget; 234 if (this->implantWidget != NULL) 235 { 236 //this->energyWidget->shiftDir2D(270); 237 //dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->energyWidget)->setDisplayedName("Electronics"); 238 //this->shipValuesBox->pack(this->energyWidget); 239 //dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->energyWidget)->setStandardSettings(); 240 this->implantWidget->setParent2D(this->leftRect); 241 dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->implantWidget)->setDisplayedImage("textures/gui/gui_electronics_icon.png"); 242 this->implantWidget->show(); 243 /* this->energyWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png"); 244 this->energyWidget->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/ 195 245 } 196 246 … … 341 391 342 392 this->setSize2D(.2 * this->resX, this->resY); 343 this->notifier->setAbsCoor2D(0.7 * this->resX, 0.3 * this->resY); 344 this->notifier->setWidgetSize(0.25 * this->resX, 0.6 * this->resY); 393 if( this->playmode != FirstPerson ) 394 { 395 this->notifier->setAbsCoor2D(0.7 * this->resX, 0.3 * this->resY); 396 this->notifier->setWidgetSize(0.25 * this->resX, 0.6 * this->resY); 397 } 345 398 346 399 int overlayWidth = 0; … … 348 401 overlayWidth = this->resX * (overlayPercentage)/(200); 349 402 else 350 overlayWidth = this->resX * 0.1;403 overlayWidth = this->resX / 10; // fixed warning! 351 404 //if (overlayWidth < 100) 352 405 //overlayWidth = 100; … … 354 407 this->rightRect->hide(); 355 408 this->leftRect->hide(); 356 357 this->leftRect->setParent2D(this); 358 this->leftRect->setWidgetSize(float(overlayWidth), float(this->resY)); 359 this->leftRect->setAbsCoor2D(0,0); 360 this->leftRect->setBackgroundTexture(Texture()); 361 this->leftRect->setBackgroundColor(Color(0,0,0.7,0.2)); 362 this->leftRect->setForegroundTexture(Texture()); 363 this->leftRect->setForegroundColor(Color(0,0,0,0)); 364 365 this->rightRect->setParent2D(this); 366 this->rightRect->setWidgetSize(float(overlayWidth), float(this->resY)); 367 this->rightRect->setAbsCoor2D(this->resX - overlayWidth,0); 368 this->rightRect->setBackgroundTexture(Texture()); 369 this->rightRect->setBackgroundColor(Color(0,0,0.7,0.2)); 370 this->rightRect->setForegroundTexture(Texture()); 371 this->rightRect->setForegroundColor(Color(0,0,0,0)); 372 409 410 if( this->playmode != FirstPerson ) 411 { 412 this->leftRect->setParent2D(this); 413 this->leftRect->setWidgetSize(float(overlayWidth), float(this->resY)); 414 this->leftRect->setAbsCoor2D(0,0); 415 this->leftRect->setBackgroundTexture(Texture()); 416 this->leftRect->setBackgroundColor(Color(0,0,0.7,0.2)); 417 this->leftRect->setForegroundTexture(Texture()); 418 this->leftRect->setForegroundColor(Color(0,0,0,0)); 419 420 this->rightRect->setParent2D(this); 421 this->rightRect->setWidgetSize(float(overlayWidth), float(this->resY)); 422 this->rightRect->setAbsCoor2D(this->resX - overlayWidth,0); 423 this->rightRect->setBackgroundTexture(Texture()); 424 this->rightRect->setBackgroundColor(Color(0,0,0.7,0.2)); 425 this->rightRect->setForegroundTexture(Texture()); 426 this->rightRect->setForegroundColor(Color(0,0,0,0)); 427 } 428 else 429 { 430 this->bottomRect->setParent2D(this); 431 this->bottomRect->setWidgetSize(float(this->resX), float(overlayWidth)); 432 this->bottomRect->setAbsCoor2D(0, this->resY - overlayWidth); 433 this->topRect->setParent2D(this); 434 this->topRect->setWidgetSize(float(this->resX), float(overlayWidth)); 435 this->topRect->setAbsCoor2D(0, 0); 436 this->middleRect->setParent2D(this); 437 this->middleRect->setWidgetSize(float(this->resY)/2, float(this->resY)/2); 438 this->middleRect->setAbsCoor2D(float(this->resX - this->resY/2)/2, float(this->resY)/4); 439 } 373 440 374 441 if (this->overlayActive == true) … … 382 449 { 383 450 PRINTF(4)("UPDATING RADAR\n"); 384 this->_radar->setParent2D(this->leftRect); 451 if( this->playmode != FirstPerson ) 452 this->_radar->setParent2D(this->leftRect); 453 else 454 this->_radar->setParent2D(this->topRect); 385 455 if (radarCenterNode == NULL) 386 456 this->_radar->setCenterNode(State::getPlayer()->getPlayable()); … … 397 467 398 468 int statWidgetsNumber = 0; 399 float expected ArmorSizeX = 0;400 float expected ArmorSizeY = 0;469 float expectedHealthSizeX = 0; 470 float expectedHealthSizeY = 0; 401 471 float newSizeY = 0; float newSizeX = 0; 402 472 float moduloWidth = 0; 403 473 404 if (this->armorWidget != NULL) 405 { 406 expectedArmorSizeX = 150; 407 expectedArmorSizeY = 50; 408 statWidgetsNumber++; 409 } 410 474 if( this->playmode != FirstPerson ) 475 { 476 if (this->healthWidget != NULL) 477 { 478 expectedHealthSizeX = 150; 479 expectedHealthSizeY = 50; 480 statWidgetsNumber++; 481 } 482 483 if (this->shieldWidget != NULL) 484 statWidgetsNumber++; 485 486 if (this->energyWidget != NULL) 487 statWidgetsNumber++; 488 489 if (expectedHealthSizeY * statWidgetsNumber > overlayWidth) 490 { 491 newSizeY = overlayWidth / float(statWidgetsNumber); 492 newSizeX = expectedHealthSizeX; 493 PRINTF(0)("Statwidgets resized\n"); 494 } 495 else 496 { 497 newSizeY = expectedHealthSizeY; 498 newSizeX = expectedHealthSizeX; 499 moduloWidth = int(overlayWidth) % int(expectedHealthSizeY * statWidgetsNumber); 500 } 501 502 float posY = overlayWidth + newSizeX; 503 504 if (this->healthWidget != NULL) 505 { 506 this->healthWidget->setSize2D(newSizeX, newSizeY); 507 this->healthWidget->setRelCoor2D((statWidgetsNumber - 1) * newSizeY + 3 * moduloWidth / (statWidgetsNumber + 1),posY); 508 } 509 if (this->shieldWidget != NULL) 510 { 511 this->shieldWidget->setSize2D(newSizeX, newSizeY); 512 this->shieldWidget->setRelCoor2D((statWidgetsNumber - 2) * newSizeY + 2 *moduloWidth / (statWidgetsNumber + 1),posY); 513 } 514 if (this->energyWidget != NULL) 515 { 516 this->energyWidget->setSize2D(newSizeX, newSizeY); 517 this->energyWidget->setRelCoor2D(moduloWidth / (statWidgetsNumber + 1),posY); 518 } 519 } 520 else 521 { 522 this->barSocket->setParent2D(this->bottomRect); 523 this->barSocket->setWidgetSize( float(overlayWidth), float(overlayWidth)); 524 this->barSocket->setRelCoor2D(0,this->resX - float(overlayWidth)); 525 526 this->healthWidget->setRelCoor2D(10,-20); 527 } 528 529 530 /* 531 if (this->healthWidget != NULL) 532 this->healthWidget->setRelCoor2D(100,0.2*this->resY + this->healthWidget->getSizeX2D()); 411 533 if (this->shieldWidget != NULL) 412 statWidgetsNumber++; 413 534 this->shieldWidget->setRelCoor2D(60,0.2*this->resY + this->healthWidget->getSizeX2D()); 414 535 if (this->energyWidget != NULL) 415 statWidgetsNumber++; 416 417 if (expectedArmorSizeY * statWidgetsNumber > overlayWidth) 418 { 419 newSizeY = overlayWidth / float(statWidgetsNumber); 420 newSizeX = expectedArmorSizeX; 421 PRINTF(0)("Statwidgets resized\n"); 422 } 423 else 424 { 425 newSizeY = expectedArmorSizeY; 426 newSizeX = expectedArmorSizeX; 427 moduloWidth = int(overlayWidth) % int(expectedArmorSizeY * statWidgetsNumber); 428 } 429 430 float posY = overlayWidth + newSizeX; 431 432 if (this->armorWidget != NULL) 433 { 434 this->armorWidget->setSize2D(newSizeX, newSizeY); 435 this->armorWidget->setRelCoor2D((statWidgetsNumber - 1) * newSizeY + 3 * moduloWidth / (statWidgetsNumber + 1),posY); 436 } 437 if (this->shieldWidget != NULL) 438 { 439 this->shieldWidget->setSize2D(newSizeX, newSizeY); 440 this->shieldWidget->setRelCoor2D((statWidgetsNumber - 2) * newSizeY + 2 *moduloWidth / (statWidgetsNumber + 1),posY); 441 } 442 if (this->energyWidget != NULL) 443 { 444 this->energyWidget->setSize2D(newSizeX, newSizeY); 445 this->energyWidget->setRelCoor2D(moduloWidth / (statWidgetsNumber + 1),posY); 446 } 447 448 /* 449 if (this->armorWidget != NULL) 450 this->armorWidget->setRelCoor2D(100,0.2*this->resY + this->armorWidget->getSizeX2D()); 451 if (this->shieldWidget != NULL) 452 this->shieldWidget->setRelCoor2D(60,0.2*this->resY + this->armorWidget->getSizeX2D()); 453 if (this->energyWidget != NULL) 454 this->energyWidget->setRelCoor2D(20,0.2*this->resY + this->armorWidget->getSizeX2D()); 536 this->energyWidget->setRelCoor2D(20,0.2*this->resY + this->healthWidget->getSizeX2D()); 455 537 */ 456 //this->shieldWidget->setRelCoor2D(0.1*this->resX + this-> armorWidget->getSizeX2D(),0);457 //this->energyWidget->setRelCoor2D(0.1*this->resX + this-> armorWidget->getSizeX2D() + this->shieldWidget->getSizeX2D(),0);538 //this->shieldWidget->setRelCoor2D(0.1*this->resX + this->healthWidget->getSizeX2D(),0); 539 //this->energyWidget->setRelCoor2D(0.1*this->resX + this->healthWidget->getSizeX2D() + this->shieldWidget->getSizeX2D(),0); 458 540 } 459 541 -
trunk/src/util/hud.h
r10368 r10698 28 28 29 29 public: 30 31 typedef enum { 32 Vertical = 1, //!< Vertical (seen from left or right/move in x-z) 33 Horizontal = 2, //!< Horizontal (seet from the top/move in x-y) 34 FromBehind = 4, //!< Seen from behind (move in z-y) 35 Full3D = 8, //!< Full featured 3D-mode. (move in all directions x-y-z) 36 FirstPerson = 16, 37 38 PlaymodeCount = 5, 39 } Playmode; 40 30 41 Hud(); 31 42 virtual ~Hud(); … … 36 47 void notifyUser(const std::string& message); 37 48 49 inline void setMode(Hud::Playmode playmode) {this->playmode = playmode;}; 50 inline Hud::Playmode getMode() {return this->playmode;}; 38 51 39 52 void setBackGround(); 40 53 void setEnergyWidget(OrxGui::GLGuiWidget* widget); 41 void setShiledWidget(OrxGui::GLGuiWidget* widget); 42 void setArmorWidget(OrxGui::GLGuiWidget* widget); 54 void setShieldWidget(OrxGui::GLGuiWidget* widget); 55 void setHealthWidget(OrxGui::GLGuiWidget* widget); 56 void setImplantWidget(OrxGui::GLGuiWidget* widget); 57 43 58 inline OrxGui::GLGuiWidget* getEnergyWidget() {return this->energyWidget;}; 44 59 inline OrxGui::GLGuiWidget* getShieldWidget() {return this->shieldWidget;}; 45 inline OrxGui::GLGuiWidget* getArmorWidget() {return this->armorWidget;}; 60 inline OrxGui::GLGuiWidget* getHealthWidget() {return this->healthWidget;}; 61 inline OrxGui::GLGuiWidget* getImplantWidget() {return this->implantWidget;}; 46 62 47 63 void setWeaponManager(WeaponManager* weaponMan, WeaponManager* weaponManSec = NULL); … … 82 98 unsigned int resX; 83 99 unsigned int resY; 100 101 Hud::Playmode playmode; 84 102 85 103 float travelZoneWidth; //the percentage of the screen, the player has got for his movements. should always be a value between 0 and 1; … … 87 105 OrxGui::GLGuiWidget* energyWidget; 88 106 OrxGui::GLGuiWidget* shieldWidget; 89 OrxGui::GLGuiWidget* armorWidget; 107 OrxGui::GLGuiWidget* healthWidget; 108 OrxGui::GLGuiWidget* implantWidget; 90 109 91 110 OrxGui::GLGuiNotifier* notifier; … … 96 115 OrxGui::GLGuiWidget* rightRect; 97 116 OrxGui::GLGuiWidget* leftRect; 117 OrxGui::GLGuiWidget* topRect; 118 OrxGui::GLGuiWidget* bottomRect; 119 OrxGui::GLGuiWidget* middleRect; 120 OrxGui::GLGuiWidget* barSocket; 98 121 bool overlayActive; 99 122 int overlayPercentage; //the percentage of the screen, the player has got for his movements. should always be a value between 0 and 1; -
trunk/src/util/state.cc
r10643 r10698 56 56 int State::menuID = -1; 57 57 58 ActionBox* State::actionBox = NULL; 58 59 59 60 /** -
trunk/src/util/state.h
r10643 r10698 20 20 class CameraMan; 21 21 class ScriptManager; 22 class ActionBox; 22 23 23 24 … … 130 131 /** @returns the scroller-travelnode (center of the screen) */ 131 132 static PNode* getTravelNode() { return State::travelNode; } 133 134 /** sets the action box (this is where the fighting takes place) */ 135 static void setActionBox( ActionBox* ab ){ State::actionBox = ab; } 136 /** @returns the action box (this is where the fighting takes place) */ 137 static ActionBox* getActionBox(){ return State::actionBox; } 132 138 133 139 … … 146 152 static Player* player; //!< A reference to the Player 147 153 static PNode* travelNode; //!< A reference to the scroller-travelnode 154 static ActionBox* actionBox; //!< A reference to the action box 148 155 149 156 static SkyBox* skyBox; //!< The SkyBox used in the current world. -
trunk/src/util/track/track.cc
r10618 r10698 29 29 30 30 #include "debug.h" 31 #include "action_box.h" 31 32 32 33 ObjectListDefinition(Track); … … 65 66 this->duration = 20; 66 67 this->endTime = 20; 67 this->width = 10; 68 this->width = 24; 69 this->height = 18; 70 this->depth = 200; 71 this->stretch = 4; 68 72 this->curve = new BezierCurve(); 69 73 this->trackNode = new PNode(PNode::getNullParent(), PNODE_ALL); … … 71 75 this->localTime = 0; 72 76 this->pause = false; 77 78 this->actionBox = NULL; 73 79 } 74 80 … … 94 100 } 95 101 LOAD_PARAM_END_CYCLE(element); 102 103 LoadParam(root, "ActionBox", this, Track, addActionBox ); 96 104 } 97 105 … … 252 260 { 253 261 Vector tmp = this->calcPos(); 254 255 262 263 256 264 Vector dV = tmp - this->trackNode->getAbsCoor(); 257 265 float dx = speed * dt; 258 266 float ratio = dx / dV.len(); 259 267 260 268 if( dt > 0.0f) 261 269 { … … 264 272 } 265 273 tmp = this->calcPos(); 266 274 267 275 Vector v(0.0, 1.0, 0.0); 268 276 Quaternion quat = Quaternion(this->calcDir(), v); 269 277 Quaternion q(-PI/2, v); 270 278 quat = quat * q; 271 279 272 280 // move trackNode of the track 273 281 this->trackNode->shiftCoor(tmp - this->trackNode->getAbsCoor()); … … 331 339 glPopMatrix(); 332 340 } 341 342 /** 343 * creates new action box and assignes it to this track 344 * @param width_2 width/2 of near end 345 * @param height_2 height/2 of near end 346 * @param depth depth 347 * @param stretch far end will be stretched with this factor 348 */ 349 void Track::addActionBox( float width_2, float height_2, float depth, float stretch ) 350 { 351 actionBox = new ActionBox( this, width_2, height_2, depth, stretch ); 352 } 353 354 355 -
trunk/src/util/track/track.h
r10498 r10698 12 12 class PNode; 13 13 class TiXmlElement; 14 class ActionBox; 14 15 15 16 class Track : public BaseObject … … 42 43 float duration; //!< The time used to cross this Track (curve). 43 44 float endTime; //!< The time at which this Track ends. 44 float width; //!< Th width of the Path. This tells the Player(s), how far he(they) can go to the left/right. 45 float width; //!< The width of the action box, next to the player. 46 float height; //!< The Height of the action box, next to the player 47 float depth; //!< Depth of the action box 48 float stretch; //!< multiplyer between w/h at player and w/h at far end of the action box 45 49 46 50 int nodeCount; //!< The count of points this Track has. 47 51 Curve* curve; //!< The Curve of this Track 52 53 ActionBox* getActionBox(){ return this->actionBox; } 48 54 49 55 private: 50 56 void init(); 51 52 57 53 58 private: 54 59 CurveType curveType; //!< The CurveType the entire TrackSystem will have. … … 57 62 int mode; //!< Defines the behaviour of the Track. 58 63 bool pause; //!< Defines if the track runs (false) or not (true) 64 65 ActionBox* actionBox; 66 67 void addActionBox( float width_2, float height_2, float depth, float stretch ); 68 69 59 70 }; 60 71 -
trunk/src/world_entities/WorldEntities.am
r10695 r10698 1 2 1 ## THE SUBCLASSES. THESE MUST BE DYNAMICALLY LINKED OR COMPILED IN DIRECTLY 3 2 WorldEntities_SOURCES_ = \ … … 12 11 world_entities/npcs/repair_station.cc \ 13 12 world_entities/npcs/attractor_mine.cc \ 13 world_entities/npcs/actionbox_enemy.cc \ 14 world_entities/npcs/adm_turret.cc \ 14 15 \ 15 16 \ … … 32 33 world_entities/weapons/spike_thrower.cc \ 33 34 world_entities/weapons/acid_launcher.cc \ 35 world_entities/weapons/rf_cannon.cc \ 36 world_entities/weapons/disruptor.cc \ 37 world_entities/weapons/nadion_laser.cc \ 38 world_entities/weapons/bsp_weapon.cc \ 34 39 \ 35 40 world_entities/projectiles/lbolt.cc \ … … 47 52 world_entities/projectiles/spike.cc \ 48 53 world_entities/projectiles/acid_splash.cc \ 54 world_entities/projectiles/plasma_pulse.cc \ 55 world_entities/projectiles/nadion_blast.cc \ 49 56 \ 50 57 world_entities/projectiles/projectile_weapon.cc \ … … 158 165 npcs/repair_station.h \ 159 166 npcs/attractor_mine.h \ 167 npcs/actionbox_enemy.h \ 168 npcs/adm_turret.h \ 160 169 \ 161 170 environments/environment.h \ … … 196 205 weapons/spike_thrower.h \ 197 206 weapons/acid_launcher.h \ 207 weapons/rf_cannon.h \ 208 weapons/disruptor.h \ 209 weapons/nadion_laser.h \ 210 weapons/bsp_weapon.h \ 198 211 \ 199 212 projectiles/lbolt.h \ … … 212 225 projectiles/spike_ball.h \ 213 226 projectiles/acid_splash.h \ 227 projectiles/plasma_pulse.h \ 228 projectiles/nadion_blast.h \ 214 229 \ 215 230 projectiles/projectile_weapon.h \ -
trunk/src/world_entities/creatures/fps_player.cc
r10618 r10698 19 19 #include "interactive_model.h" 20 20 #include "state.h" 21 #include "tools/camera.h" 22 #include "player.h" 21 23 22 24 #include "src/lib/util/loading/factory.h" … … 51 53 ->addMethod("getAbsCoorY", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorY)) 52 54 ->addMethod("getAbsCoorZ", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorZ)) 55 ->addMethod("displayHUDText", Executor1<FPSPlayer, lua_State*, const std::string&>(&FPSPlayer::displayHUDText)) 53 56 ); 54 57 … … 95 98 this->bPosBut = false; 96 99 this->bFire = false; 100 this->bFire2 = false; 101 this->changeZoom = true; 102 this->inZoomMode = false; 103 this->changingZoom = false; 97 104 98 105 this->xMouse = 0.0f; … … 116 123 registerEvent(KeyMapper::PEV_RIGHT); 117 124 registerEvent(KeyMapper::PEV_FIRE1); 125 registerEvent(KeyMapper::PEV_FIRE2); 118 126 registerEvent(KeyMapper::PEV_JUMP); 127 registerEvent(KeyMapper::PEV_CROUCH); 119 128 registerEvent(EV_MOUSE_MOTION); 120 129 … … 149 158 150 159 this->getWeaponManager().getFixedTarget()->setParent(&this->cameraNode); 151 this->getWeaponManager().getFixedTarget()->setRelCoor(1000,0,0); 160 this->getWeaponManager().getFixedTarget()->setParentMode(PNODE_ALL); 161 this->getWeaponManager().getFixedTarget()->setRelCoor(10,0,0); 152 162 153 163 … … 179 189 } 180 190 181 191 /** 192 * was probabably designed for setting direction of FPSPlayer 193 * but hey, this connot work like this, can it? 194 */ 182 195 void FPSPlayer::setPlayDirection(const Quaternion& quat, float speed) 183 196 { … … 186 199 } 187 200 188 201 /** 202 * Resets FPSPlayer stats and freezes its moving directions 203 * 204 */ 189 205 void FPSPlayer::reset() 190 206 { … … 195 211 this->xMouse = 0.0f; 196 212 this->yMouse = 0.0f; 213 this->inZoomMode = false; 197 214 198 215 this->setHealth(80); 199 216 } 200 217 201 218 /** 219 * Defines what happens to camera and other important elements when changing 220 * into FPS-view 221 */ 202 222 void FPSPlayer::enter() 203 223 { … … 206 226 State::getCameraNode()->setParentSoft(&this->cameraNode); 207 227 State::getCameraTargetNode()->setParentSoft(&this->cameraNode); 208 209 this->getWeaponManager().getFixedTarget()->setParent(State::getCameraTargetNode()); 210 this->getWeaponManager().getFixedTarget()->setRelCoor(0,0,0); 228 229 State::getCamera()->setViewMode(Camera::ViewFPS); 230 231 this->getWeaponManager().getFixedTarget()->setParent(&this->cameraNode); 232 //this->getWeaponManager().getFixedTarget()->setParentMode(PNODE_ALL); 233 //this->getWeaponManager().getFixedTarget()->setRelCoor(100,0,0); 211 234 212 235 if ( !State::isOnline() ) … … 216 239 } 217 240 241 /** 242 * Defines what happens if active player leaves FPSPlayer 243 * (basicly hides crosshair and frees camera) 244 */ 218 245 void FPSPlayer::leave() 219 246 { … … 230 257 void FPSPlayer::tick (float time) 231 258 { 232 259 // Second init-step 233 260 if ( !this->initWeapon ) 234 261 { … … 239 266 this->getWeaponManager().getParentNode()->setParentMode(PNODE_ROTATE_AND_MOVE); 240 267 this->getWeaponManager().getFixedTarget()->setParent(&this->cameraNode); 241 this->getWeaponManager().getFixedTarget()->setParentMode(PNODE_ROTATE_AND_MOVE); 268 //this->getWeaponManager().getFixedTarget()->setParentMode(PNODE_ROTATE_AND_MOVE); 269 State::getCamera()->setViewMode(Camera::ViewFPS); 242 270 243 271 … … 251 279 } 252 280 253 254 AABB* box = this->getModelAABB(); 255 if( box != NULL) 256 { 281 } 282 // end of second init-step 283 284 // This box represents the dimension of the used model 285 AABB* box = this->getModelAABB(); 286 287 if( box != NULL) 288 { 257 289 float f = 1.0; 290 if( this->bCrouch ) 291 f = 0.3*f; 292 258 293 this->cameraNode.setRelCoor(0, box->halfLength[1] * f, 0); 259 // this->cameraNode.setRelCoor(10, box->halfLength[1] * f, 0); 260 261 float v = 0.1f; 262 this->getWeaponManager().setSlotPosition(0, Vector(-8.0, box->halfLength[1] * v, 1.1)); 263 this->getWeaponManager().setSlotPosition(1, Vector(5.0, box->halfLength[1] * v, 0.0)); 264 } 265 } 266 294 // this->cameraNode.setRelCoor(10, box->halfLength[1] * f, 0); 295 float v = 0.1f; 296 this->getWeaponManager().setSlotPosition(0, Vector(-8.0, box->halfLength[1] * v, 1.1)); 297 this->getWeaponManager().setSlotPosition(1, Vector(5.0, box->halfLength[1] * v, 0.0)); 298 } 299 300 /* 301 if( this->bFire2 ) 302 { 303 304 // to change Zoom on click 305 if( this->changeZoom ) 306 { 307 this->changeZoom = false; 308 if( this->inZoomMode ) 309 { 310 State::getCamera()->setViewMode(Camera::ViewFPS); 311 this->inZoomMode = false; 312 } 313 else 314 { 315 State::getCamera()->setViewMode(Camera::ViewFPSZoom); 316 this->inZoomMode = true; 317 } 318 319 } 320 321 } 322 else 323 { 324 this->changeZoom = true; 325 }*/ 326 if( this->bFire2 ) 327 { 328 if( this->changeZoom ) 329 { 330 if( !this->inZoomMode || this->changingZoom ) 331 { 332 this->inZoomMode = true; 333 this->changingZoom = true; 334 float fovy = State::getCamera()->getFovy(); 335 if( fovy > 30 ) 336 State::getCamera()->setFovy( fovy - 10*time ); 337 } 338 else 339 { 340 State::getCamera()->setViewMode(Camera::ViewFPS); 341 this->inZoomMode = false; 342 this->changeZoom = false; 343 } 344 } 345 } 346 else 347 { 348 this->changeZoom = true; 349 this->changingZoom = false; 350 } 267 351 268 352 this->getWeaponManager().tick(time); … … 301 385 xMouse *= time ; 302 386 yMouse *= time ; 303 304 heading -= xMouse/5.; 305 attitude-= yMouse/5.; 387 388 float amount; 389 390 if( this->inZoomMode ) 391 amount = 2.; 392 else 393 amount = 5.; 394 395 heading -= xMouse/amount; 396 attitude-= yMouse/amount; 306 397 307 398 … … 346 437 }*/ 347 438 348 velocity *= 100; 439 int speed; 440 if( this->bCrouch ) 441 speed = 50; 442 else 443 speed = 100; 444 velocity *= speed; 349 445 350 446 if( this->getModel( 0) != NULL && this->getModel(0)->isA(InteractiveModel::staticClassID())) 351 447 { 352 if( this->bJump) 353 { 354 if( this->jumpAcceleration < 1.0f) 448 if( this->bJump) 355 449 { 356 this->jumpAcceleration = 300.0f; 357 358 if( ((InteractiveModel*)this->getModel(0))->getAnimation() != JUMP) 359 ((InteractiveModel*)this->getModel(0))->setAnimation(JUMP); 360 } 361 } 362 else if(velocity.len() != 0.0f) 363 { 364 if( ((InteractiveModel*)this->getModel(0))->getAnimation() != RUN) 365 ((InteractiveModel*)this->getModel(0))->setAnimation(RUN); 366 } 367 else 368 { 369 if( ((InteractiveModel*)this->getModel(0))->getAnimation() != STAND) 370 ((InteractiveModel*)this->getModel(0))->setAnimation(STAND); 371 } 450 if( this->jumpAcceleration < 1.0f) 451 { 452 this->jumpAcceleration = 300.0f; 453 454 if( ((InteractiveModel*)this->getModel(0))->getAnimation() != JUMP) 455 ((InteractiveModel*)this->getModel(0))->setAnimation(JUMP); 456 } 457 } 458 else if(velocity.len() != 0.0f) 459 { 460 if( this->bCrouch ) 461 { 462 if( ((InteractiveModel*)this->getModel(0))->getAnimation() != CROUCH_WALK) 463 ((InteractiveModel*)this->getModel(0))->setAnimation(CROUCH_WALK); 464 } 465 else 466 { 467 if( ((InteractiveModel*)this->getModel(0))->getAnimation() != RUN) 468 ((InteractiveModel*)this->getModel(0))->setAnimation(RUN); 469 } 470 471 } 472 else 473 { 474 if( this->bCrouch ) 475 { 476 if( ((InteractiveModel*)this->getModel(0))->getAnimation() != CROUCH_STAND) 477 ((InteractiveModel*)this->getModel(0))->setAnimation(CROUCH_STAND); 478 } 479 else 480 { 481 if( ((InteractiveModel*)this->getModel(0))->getAnimation() != STAND) 482 ((InteractiveModel*)this->getModel(0))->setAnimation(STAND); 483 } 484 } 485 486 if( this->bFire ) 487 { 488 if( this->bCrouch ) 489 { 490 if( ((InteractiveModel*)this->getModel(0))->getAnimation() != CROUCH_ATTACK) 491 ((InteractiveModel*)this->getModel(0))->setAnimation(CROUCH_ATTACK); 492 } 493 else 494 { 495 if( ((InteractiveModel*)this->getModel(0))->getAnimation() != ATTACK) 496 ((InteractiveModel*)this->getModel(0))->setAnimation(ATTACK); 497 } 498 } 372 499 } 373 500 … … 390 517 this->fallVelocity = 0.0f; 391 518 } 392 if((velocity *time).len() < 10.0f) this->shiftCoor( velocity*time ); 393 else{ 519 if((velocity * time).len() < 10.0f) this->shiftCoor( velocity*time ); 520 else 521 { 394 522 velocity.normalize(); 395 523 velocity *= 10.0f; 396 524 this->shiftCoor( velocity ); 397 } 398 399 525 } 400 526 401 527 … … 409 535 if( this->aimingSystem != NULL) 410 536 this->aimingSystem->flushList(); 537 411 538 } 412 539 … … 426 553 427 554 /** 428 * process555 * checks events 429 556 */ 430 557 void FPSPlayer::process(const Event &event) … … 440 567 else if( event.type == KeyMapper::PEV_BACKWARD) 441 568 this->bBackward = event.bPressed; //this->shiftCoor(0,-.1,0); 569 else if( event.type == KeyMapper::PEV_JUMP) 570 this->bJump = event.bPressed; 571 else if( event.type == KeyMapper::PEV_FIRE1) 572 this->bFire = event.bPressed; 573 else if( event.type == KeyMapper::PEV_FIRE2) 574 this->bFire2 = event.bPressed; 575 else if( event.type == KeyMapper::PEV_CROUCH) 576 this->bCrouch = event.bPressed; 442 577 else if( event.type == EV_MOUSE_MOTION) 443 578 { … … 445 580 this->yMouse += event.yRel; 446 581 } 447 else if( event.type == KeyMapper::PEV_JUMP) 448 { 449 this->bJump = event.bPressed; 450 } 451 else if( event.type == KeyMapper::PEV_FIRE1) 452 { 453 this->bFire = event.bPressed; 454 } 455 } 456 457 582 } 583 584 /** 585 * respawns FPSplayer 586 */ 458 587 void FPSPlayer::respawn( ) 459 588 { … … 466 595 } 467 596 468 597 /** 598 * Kills the FPSplayer defining its killer 599 */ 469 600 void FPSPlayer::destroy( WorldEntity* killer ) 470 601 { … … 474 605 } 475 606 607 void FPSPlayer::displayHUDText( const std::string& message ) 608 { 609 State::getPlayer()->hud().notifyUser(message); 610 } -
trunk/src/world_entities/creatures/fps_player.h
r10566 r10698 36 36 virtual void tick(float time); 37 37 virtual void draw() const; 38 39 void displayHUDText( const std::string& message ); 38 40 39 41 … … 43 45 void init(); 44 46 45 bool bLeft; 46 bool bRight; 47 bool bForward; 48 bool bBackward; 49 bool bJump; //!< jumping 50 bool bPosBut; //!< position button 51 bool bFire; //!< fire button 47 bool bLeft; //!< strafe left 48 bool bRight; //!< strafe right 49 bool bForward; //!< walk forward 50 bool bBackward; //!< walk backward 51 bool bJump; //!< jumping 52 bool bPosBut; //!< position button 53 bool bFire; //!< fire button 54 bool bFire2; //!< alternate fire button 55 bool bCrouch; //!< crouch button 52 56 53 float xMouse; 54 float yMouse; 57 float xMouse; //!< mouse moved in x-Direction 58 float yMouse; //!< mouse moved in y-Direction 55 59 56 60 57 float heading; 58 float attitude; 61 float heading; //!< the direction where the player heads to 62 float attitude; //!< defines the camera angle to the x-z-plane 59 63 60 PNode cameraNode; 64 PNode cameraNode; //!< the "eyes" of the player (or call it head if you want) 61 65 62 float fallVelocity; 63 float jumpAcceleration; 66 float fallVelocity; //!< velocity for falling down 67 float jumpAcceleration; //!< the jump acceleration 64 68 65 69 bool initWeapon; 70 bool changeZoom; //!< zoom sight of player 71 bool inZoomMode; //!< zoomsight 72 bool changingZoom; 66 73 67 AimingSystem* aimingSystem; 74 AimingSystem* aimingSystem; //!< aiming system of the player 68 75 69 float damageTicker; //!< ticker for dealing damage 76 float damageTicker; //!< ticker for dealing damage 77 70 78 }; 71 79 -
trunk/src/world_entities/effects/billboard.cc
r10618 r10698 11 11 ### File Specific: 12 12 main-programmer: David Hasenfratz 13 co-programmer: Nicolas Schlumberger 13 14 */ 14 15 … … 69 70 70 71 this->texColor = NULL; 72 73 this->pulseMagnitude = .5; 74 this->bPulse = false; 75 76 this->angularSpeed = M_2_PI; //360; 77 this->angle = 0; 78 79 this->setUpdateFunction((*sinf)); 71 80 } 72 81 … … 113 122 void Billboard::tick(float dt) 114 123 { 124 this->angle += dt * this->angularSpeed; 125 if (this->angle > M_2_PI) 126 this->angle -= M_2_PI; 127 // curMagnitude = updatePulse(this->angle); 115 128 } 116 129 … … 145 158 v.normalize(); 146 159 147 v *= sizeX; 148 h *= sizeY; 160 float tmp = 1; 161 if (this->bPulse) 162 tmp += this->pulseMagnitude * sinf(this->angle); //updatePulse(this->angle); 163 164 v *= sizeX * tmp; 165 h *= sizeY * tmp; 149 166 150 167 //v += this->getAbsCoor(); -
trunk/src/world_entities/effects/billboard.h
r10433 r10698 26 26 void colorTexture(const Color col); 27 27 28 //!< Pulsing Capability, changes size of the grid 29 inline void togglePluse () {this->bPulse = !bPulse; }; 30 inline void setPulse () { this->bPulse = true; }; 31 inline void setPulse ( bool state ) {this->bPulse = state; }; 32 inline float getPulse () { return this->bPulse; }; 33 34 inline void setPulseMagnitude(float mag) {this->pulseMagnitude = mag; }; 35 28 36 virtual void tick(float dt); 29 37 virtual void draw() const; 30 38 39 inline void setUpdateFunction(float (*updateFct)(float value)) { if( updateFct) this->updatePulse = updateFct;}; 40 31 41 private: 42 43 float (*updatePulse)(float value); 44 32 45 Material* material; 33 46 Color* texColor; 34 47 float sizeX; 35 48 float sizeY; 49 50 bool bPulse; 51 float pulseMagnitude; 52 float curMagnitude; 53 float angle; 54 float angularSpeed; 36 55 }; 37 56 -
trunk/src/world_entities/effects/blink.cc
r10618 r10698 67 67 this->bBoard->setTexture("textures/light/blink.png"); 68 68 69 // /Standard values69 //!< Standard values 70 70 this->bBoard->setAbsCoor(0, 0, 0); 71 71 // default position if not set in xml -
trunk/src/world_entities/effects/explosion.h
r10695 r10698 32 32 virtual void tick (float time); 33 33 34 private: 34 void setLifeTime( float lifeTime ){ this->lifeTime = lifeTime; } 35 36 protected: 35 37 static FastFactory* fastFactory; 36 38 -
trunk/src/world_entities/effects/wobblegrid.cc
r10618 r10698 10 10 11 11 ### File Specific: 12 main-programmer: David Hasenfratz12 main-programmer: Marc Schärer 13 13 */ 14 14 -
trunk/src/world_entities/npcs/adm_turret.cc
r10694 r10698 140 140 this->isCeil = false; 141 141 this->playerVisible = false; 142 this->weapon = NULL; 142 143 143 144 … … 147 148 { 148 149 WorldEntity::tick(dt); 149 this->weapon->fire(false);150 if (this->weapon) this->weapon->fire(false); 150 151 this->updatePlayerVisible(); 151 152 … … 167 168 float angle = dv1.dot(dv2); 168 169 if (angle > 0.999) 169 170 this->weapon->fire(true);171 170 { 171 if (this->weapon) this->weapon->fire(true); 172 } 172 173 } 173 174 else -
trunk/src/world_entities/npcs/npc.cc
r10618 r10698 407 407 { 408 408 int slot = ws->getWeaponSlot(); 409 int side = ws->getWeaponSide(); 409 // int side = ws->getWeaponSide(); //FIXME / REMOVE: is not used 410 410 this->getWeaponManager().setSlotPosition(slot, (*it).second->getCenter()); 411 411 this->getWeaponManager().setSlotDirection(slot, ws->getRelDir()); -
trunk/src/world_entities/playable.h
r10368 r10698 32 32 typedef enum { 33 33 Vertical = 1, //!< Vertical (seen from left or right/move in x-z) 34 Horizontal = 2, //!< Horizontal (see tfrom the top/move in x-y)34 Horizontal = 2, //!< Horizontal (seen from the top/move in x-y) 35 35 FromBehind = 4, //!< Seen from behind (move in z-y) 36 36 Full3D = 8, //!< Full featured 3D-mode. (move in all directions x-y-z) -
trunk/src/world_entities/player.cc
r10516 r10698 19 19 20 20 #include "event_handler.h" 21 #include "creatures/fps_player.h" 21 22 22 23 #include "state.h" … … 74 75 PRINTF(4)("Enter new Playable\n"); 75 76 this->playable = playable; 76 this->_hud.setArmorWidget(this->playable->getHealthWidget()); 77 if (dynamic_cast<SpaceShip*>(this->playable) != 0) 77 78 if( playable->isA(FPSPlayer::staticClassID()) ) 79 { 80 this->_hud.setMode(Hud::FirstPerson); 81 this->_hud.setHealthWidget(this->playable->getHealthWidget()); 82 } 83 else 84 { 85 this->_hud.setMode(Hud::Full3D); 86 this->_hud.setHealthWidget(this->playable->getHealthWidget()); 87 } 88 /*if (dynamic_cast<SpaceShip*>(this->playable) != 0) 78 89 this->_hud.setWeaponManager(&this->playable->getWeaponManager(), &dynamic_cast<SpaceShip*>(this->playable)->getWeaponManagerSecondary()); 79 90 else 80 this->_hud.setWeaponManager(&this->playable->getWeaponManager()); 91 this->_hud.setWeaponManager(&this->playable->getWeaponManager());*/ 81 92 82 93 this->playable->setPlayer(this); -
trunk/src/world_entities/projectiles/acid_splash.cc
r10511 r10698 116 116 this->toList(OM_NULL); 117 117 //this->toList(OM_DEAD); 118 this->removeNode();119 118 // this->removeNode(); 119 120 120 AcidSplash::fastFactory->kill(this); 121 121 } -
trunk/src/world_entities/projectiles/hbolt.cc
r10618 r10698 46 46 this->setMinEnergy(10); 47 47 this->setHealthMax(0); 48 this->lifeSpan = 2.0;48 this->lifeSpan = 3.0; 49 49 50 50 this->angle = 0; … … 116 116 117 117 this->toList(OM_DEAD); 118 this->removeNode();118 // this->removeNode(); 119 119 HBolt::fastFactory->kill(this); 120 120 … … 177 177 glPushAttrib(GL_ENABLE_BIT); 178 178 glDisable(GL_LIGHTING); 179 //glDisable(GL_FOG);179 glDisable(GL_FOG); 180 180 181 181 glMatrixMode(GL_MODELVIEW); … … 184 184 // float matrix[4][4]; 185 185 glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z); 186 this->halo->draw(); 187 186 188 Vector tmpRot = this->getAbsDir().getSpacialAxis(); 187 189 glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z ); … … 189 191 // glMultMatrixf((float*)matrix); 190 192 this->getModel()->draw(); 191 this->halo->draw();192 193 193 194 glPopMatrix(); -
trunk/src/world_entities/projectiles/laser.cc
r10114 r10698 100 100 101 101 this->toList(OM_NULL); 102 this->removeNode();102 // this->removeNode(); 103 103 Laser::fastFactory->kill(this); 104 104 } -
trunk/src/world_entities/projectiles/lbolt.cc
r10618 r10698 62 62 this->halo = new Billboard(); 63 63 this->halo->setSize(.35, .35); 64 this->halo->setTexture("hbolt_halo. png");64 this->halo->setTexture("hbolt_halo.jpg"); 65 65 this->halo->setVisibility(false); 66 66 67 this->halo->setPulse(); 67 68 68 69 } … … 120 121 121 122 this->toList(OM_DEAD); 122 this->removeNode();123 // this->removeNode(); 123 124 LBolt::fastFactory->kill(this); 124 125 } … … 148 149 149 150 angle += LBolt::rotationSpeed * dt; 151 if(angle > 360) 152 angle -= 360; 150 153 151 154 for( ObjectList<NPC>::const_iterator eIterator = NPC::objectList().begin(); eIterator !=NPC::objectList().end(); eIterator++) … … 183 186 float matrix[4][4]; 184 187 glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z); 185 Vector tmpRot = this->getAbsDir().getSpacialAxis(); 188 this->halo->draw(); 189 190 Vector tmpRot; 191 tmpRot = this->flightDirection.getNormalized(); 192 glRotatef(this->angle, tmpRot.x, tmpRot.y, tmpRot.z); 193 tmpRot = this->getAbsDir().getSpacialAxis(); 186 194 glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z ); 187 glRotatef(this->angle, 1.0, 0.0, 0.0); 195 188 196 this->getAbsDir().matrix (matrix); 189 197 glMultMatrixf((float*)matrix); 190 198 this->getModel()->draw(); 191 199 192 this->halo->draw();193 194 200 glPopMatrix(); 195 201 glPopAttrib(); -
trunk/src/world_entities/projectiles/mbolt.cc
r10618 r10698 145 145 this->toList(OM_NULL); 146 146 //this->toList(OM_DEAD); 147 this->removeNode();147 // this->removeNode(); 148 148 MBolt::fastFactory->kill(this); 149 149 } … … 212 212 float matrix[4][4]; 213 213 glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z); 214 glRotatef(this->angle, 1.0f, 0.0f, 0.0f); //spinning missile 214 // glRotatef(this->angle, 1.0f, 0.0f, 0.0f); //spinning missile 215 glRotatef(this->angle, this->flightDirection.x, this->flightDirection.y, this->flightDirection.z); 215 216 this->getAbsDir().matrix (matrix); 216 217 glMultMatrixf((float*)matrix); -
trunk/src/world_entities/projectiles/rail_projectile.cc
r10114 r10698 99 99 100 100 this->toList(OM_NULL); 101 this->removeNode();101 // this->removeNode(); 102 102 RailProjectile::fastFactory->kill(this); 103 103 } -
trunk/src/world_entities/projectiles/spike.cc
r10368 r10698 111 111 112 112 this->toList(OM_NULL); 113 this->removeNode();113 // this->removeNode(); 114 114 Spike::fastFactory->kill(this); 115 115 } -
trunk/src/world_entities/projectiles/spike_ball.cc
r10511 r10698 149 149 150 150 this->toList(OM_NULL); 151 this->removeNode();151 // this->removeNode(); 152 152 SpikeBall::fastFactory->kill(this); 153 153 } -
trunk/src/world_entities/projectiles/swarm_projectile.cc
r10618 r10698 134 134 135 135 this->toList(OM_DEAD); 136 this->removeNode();136 // this->removeNode(); 137 137 SwarmProjectile::fastFactory->kill(this); 138 138 } … … 200 200 this->deactivate(); 201 201 202 203 204 202 /** old guiding function*/ 205 206 float projectileVelocity = this->getVelocity().len(); 203 static float projectileVelocity = this->getVelocity().len(); 207 204 if (target != NULL){ 208 205 Vector estTargetDir = (this->target->getAbsCoor() - this->getAbsCoor()).getNormalized(); … … 225 222 226 223 this->angle += this->rotationSpeed * time; 227 228 while (this->angle > 360) 229 { 230 this->angle -= 360; 231 } 224 while (this->angle > 360) { this->angle -= 360; } 232 225 233 226 this->lastDir = this->curDir; … … 240 233 PRINTF(0)("Target was hit by Swarm Missile!\n"); 241 234 } 242 elseif( this->target == NULL)235 if( this->target == NULL) 243 236 this->deactivate(); 244 237 } -
trunk/src/world_entities/space_ships/space_ship.cc
r10618 r10698 22 22 #include "util/loading/resource_manager.h" 23 23 24 #include "world_entities/weapons/weapon_manager.h" 25 24 26 #include "weapons/test_gun.h" 25 27 #include "weapons/light_blaster.h" 26 28 #include "weapons/medium_blaster.h" 27 29 #include "weapons/heavy_blaster.h" 30 #include "weapons/rf_cannon.h" 31 #include "weapons/nadion_laser.h" 32 #include "weapons/disruptor.h" 28 33 #include "weapons/swarm_launcher.h" 29 34 #include "weapons/spike_thrower.h" … … 61 66 #include "tools/cameraman.h" 62 67 68 #include "tools/mount_point.h" 69 #include "weapons/weapon_slot.h" 63 70 64 71 #include "util/loading/load_param.h" … … 66 73 67 74 #include "track/track.h" 68 69 70 // #include "lib/gui/gl_gui/glgui_bar.h" 71 // #include "lib/gui/gl_gui/glgui_pushbutton.h" 72 75 #include "track/action_box.h" 73 76 74 77 … … 156 159 //weapons: 157 160 158 Weapon* wpRight1 = new LightBlaster (); 159 wpRight1->setName( "LightBlaster"); 160 Weapon* wpLeft1 = new LightBlaster (); 161 wpLeft1->setName( "LightBlaster"); 162 163 Weapon* wpRight2 = new MediumBlaster (); 164 wpRight2->setName( "MediumBlaster"); 165 Weapon* wpLeft2 = new MediumBlaster (); 166 wpLeft2->setName( "MediumBlaster"); 167 168 Weapon* wpRight3 = new HeavyBlaster (1); 169 wpRight3->setName( "HeavyBlaster"); 170 Weapon* wpLeft3 = new HeavyBlaster (0); 171 wpLeft3->setName( "HeavyBlaster"); 172 173 Weapon* cannon = new SwarmLauncher(); 174 cannon->setName( "SwarmLauncher"); 175 /* 176 Weapon* spike = new SpikeThrower(); 177 spike->setName( "SpikeThrower" ); 178 179 180 Weapon* acid0 = new AcidLauncher(); 181 acid0->setName( "AcidSplasher" ); 182 183 Weapon* acid1 = new AcidLauncher(); 184 acid1->setName( "AcidSplasher" );*/ 185 186 187 this->weaponMan.addWeapon( wpLeft1, 0, 0); 188 this->weaponMan.addWeapon( wpRight1, 0, 1); 189 190 this->weaponMan.addWeapon( wpLeft2, 1, 2); 191 this->weaponMan.addWeapon( wpRight2, 1, 3); 192 193 this->weaponMan.addWeapon( wpLeft3, 2, 4); 194 this->weaponMan.addWeapon( wpRight3, 2, 5); 195 196 this->weaponMan.addWeapon( wpLeft1, 3, 0); 197 this->weaponMan.addWeapon( wpRight1, 3, 1); 198 199 this->weaponMan.addWeapon( wpLeft2, 3, 2); 200 this->weaponMan.addWeapon( wpRight2, 3, 3); 201 202 this->weaponMan.addWeapon( wpLeft3, 3, 4); 203 this->weaponMan.addWeapon( wpRight3, 3, 5); 204 205 206 // this->weaponMan.addWeapon( acid0, 3, 0); 207 // this->weaponMan.addWeapon( acid1, 3, 1); 208 209 210 this->secWeaponMan.addWeapon( cannon, 0, 2); 211 // this->secWeaponMan.addWeapon( spike, 1, 3); 212 // this->secWeaponMan.addWeapon( acid0, 2, 2); 213 // this->secWeaponMan.addWeapon( acid1, 2, 3); 214 215 216 this->weaponMan.changeWeaponConfig(3); 161 this->weaponMan.setParentEntity( this); 162 this->secWeaponMan.setParentEntity( this); 163 164 this->weaponMan.setSlotCount(8); 165 this->secWeaponMan.setSlotCount(6); 166 167 this->weaponMan.createWeaponSlot(0, 3.270, 1.028, .155, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 168 this->weaponMan.createWeaponSlot(1, 3.270, 1.028, -.155, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 169 this->weaponMan.createWeaponSlot(2, 4.385, .063, .876, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 170 this->weaponMan.createWeaponSlot(3, 4.385, -.063, -.876, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 171 this->weaponMan.createWeaponSlot(4, 1.635, -.612, 2.691, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 172 this->weaponMan.createWeaponSlot(5, 1.536, -.612, -2.691, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 173 this->weaponMan.createWeaponSlot(6, 1.536, -.612, 3.254, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 174 this->weaponMan.createWeaponSlot(7, 1.536, -.612, -3.254, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 175 176 177 this->weaponMan.addWeaponToSlot(0, 0, "RFCannon"); 178 this->weaponMan.addWeaponToSlot(0, 1, "RFCannon"); 179 this->weaponMan.addWeaponToSlot(0, 2, "RFCannon"); 180 this->weaponMan.addWeaponToSlot(0, 3, "RFCannon"); 181 this->weaponMan.addWeaponToSlot(1, 0, "RFCannon"); 182 this->weaponMan.addWeaponToSlot(1, 1, "RFCannon"); 183 this->weaponMan.addWeaponToSlot(1, 2, "RFCannon"); 184 this->weaponMan.addWeaponToSlot(1, 3, "RFCannon"); 185 186 this->weaponMan.addWeaponToSlot(0, 4, "NadionLaser"); 187 this->weaponMan.addWeaponToSlot(0, 5, "NadionLaser"); 188 this->weaponMan.addWeaponToSlot(2, 4, "NadionLaser"); 189 this->weaponMan.addWeaponToSlot(2, 5, "NadionLaser"); 190 191 this->weaponMan.addWeaponToSlot(0, 6, "Disruptor"); 192 this->weaponMan.addWeaponToSlot(0, 7, "Disruptor"); 193 this->weaponMan.addWeaponToSlot(3, 6, "Disruptor"); 194 this->weaponMan.addWeaponToSlot(3, 7, "Disruptor"); 195 196 197 this->secWeaponMan.createWeaponSlot(0, 1.5, 3, 0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 198 this->secWeaponMan.createWeaponSlot(1, 2.6, 0, 3.0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 199 this->secWeaponMan.createWeaponSlot(2, 1.5, 0, -.5, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 200 this->secWeaponMan.createWeaponSlot(3, 1.5, 0, .5, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 201 this->secWeaponMan.createWeaponSlot(4, 1.5, 0, .5, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 202 this->secWeaponMan.createWeaponSlot(5, 1.5, 0, -.5, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 203 204 this->secWeaponMan.addWeaponToSlot(0, 2, "SwarmLauncher"); 205 206 207 this->weaponMan.changeWeaponConfig(0); 217 208 this->secWeaponMan.changeWeaponConfig(0); 218 209 219 210 220 // curWeaponPrimary = 3;221 // curWeaponSecondary = 0;222 223 211 Playable::weaponConfigChanged(); 224 212 225 reactorOutput = 10; 226 227 weaponEnergyRegen = 10; // 10 einheiten pro Sekunde 228 engineSpeedBase = 15; 229 shieldRegen = 2; 230 231 shieldEnergyShare = 0.3; 232 weaponEnergyShare = 0.3; 233 engineEnergyShare = 0.4; 234 235 shieldCur = 100; 236 shieldMax = 100; 237 shieldTH = .2 * shieldMax; // shield power must be 20% before shield kicks in again 238 239 this->setHealth( 100); 240 this->setHealthMax( 100); 241 242 electronicCur = 50; 243 electronicMax = 50; 244 electronicRegen = 3; 245 electronicTH = .7 * electronicMax; // 30% of eDamage can be handled by the ship 246 247 248 this->loadModel("models/spaceships/human_spaceship_fighter.obj", .25); 213 this->bInit = false; 214 215 loadEnergyShare(.3,.3,.4); 216 loadShield(80, 100, .2, 2); 217 loadHealth(100, 100); 218 loadElectronic(40, 50, .7, 3.0); 219 loadReactor(10); 220 loadWeapon(10); 221 loadEngine(15); 222 223 // this->loadModel("models/spaceships/fighter_redesign9.obj"); 249 224 //this->setVisibiliy(false); 250 225 251 226 bForward = bBackward = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = bFire = bSecFire = false; 252 227 253 this->setHealthMax(shieldMax);254 this->setHealth(shieldCur);228 // this->setHealthMax(shieldMax); 229 // this->setHealth(shieldCur); 255 230 256 231 this->travelNode = new PNode(); … … 260 235 this->cameraNode.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE); 261 236 262 // widget handling 263 /* 264 this->electronicWidget = new OrxGui::GLGuiEnergyWidgetVertical(); 265 this->electronicWidget->setDisplayedName(std::string(this->getClassName()) + " Electronics:"); 266 this->electronicWidget->setSize2D(30,400); 267 this->electronicWidget->setAbsCoor2D(150,200); 268 this->electronicWidget->shiftDir2D(270); 269 this->updateElectronicWidget(); 270 this->shieldWidget = new OrxGui::GLGuiEnergyWidgetVertical(); 271 this->shieldWidget->setDisplayedName(std::string(this->getClassName()) + " Shield:"); 272 this->shieldWidget->setSize2D(30,400); 273 this->shieldWidget->setAbsCoor2D(200,200); 274 this->shieldWidget->shiftDir2D(270); 275 this->updateShieldWidget(); 276 if (this->hasPlayer()) 277 { 278 State::getPlayer()->hud().setShiledWidget(this->shieldWidget); 279 State::getPlayer()->hud().setEnergyWidget(this->electronicWidget); 280 } 281 */ 282 this->electronicWidget = NULL; 283 this->shieldWidget = NULL; 237 238 // this->electronicWidget = NULL; 239 // this->shieldWidget = NULL; 284 240 285 241 //add events to the eventlist … … 298 254 registerEvent(EV_MOUSE_MOTION); 299 255 300 this->weaponMan.setParentEntity( this);301 this->secWeaponMan.setParentEntity( this);302 303 this->weaponMan.setSlotCount(8);304 305 this->weaponMan.setSlotPosition(0, Vector(0.0, 0, -3.0));306 this->weaponMan.setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);307 308 this->weaponMan.setSlotPosition(1, Vector(0.0, 0, 3.0));309 this->weaponMan.setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);310 311 this->weaponMan.setSlotPosition(2, Vector(1.0, 0, -1.5));312 this->weaponMan.setSlotDirection(2, Quaternion(-M_PI_4*.5, Vector(1,0,0)));313 314 this->weaponMan.setSlotPosition(3, Vector(1.0, 0, 1.5));315 this->weaponMan.setSlotDirection(3, Quaternion(M_PI_4*.5, Vector(1,0,0)));316 317 this->weaponMan.setSlotPosition(4, Vector(1.5, 0, .5));318 this->weaponMan.setSlotDirection(4, Quaternion(-M_PI_4*.5+M_PI, Vector(1,0,0)));319 320 this->weaponMan.setSlotPosition(5, Vector(1.5, 0, -.5));321 this->weaponMan.setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0)));322 323 this->weaponMan.setSlotPosition(6, Vector(0.5, 0, 2.5));324 this->weaponMan.setSlotDirection(6, Quaternion(-M_PI_4*.5+M_PI, Vector(1,0,0)));325 326 this->weaponMan.setSlotPosition(7, Vector(0.5, 0, -2.5));327 this->weaponMan.setSlotDirection(7, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0)));328 329 this->secWeaponMan.setSlotPosition(0, Vector(1.5, 0, 0));330 this->secWeaponMan.setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);331 332 this->secWeaponMan.setSlotPosition(1, Vector(2.6, 0, 3.0));333 this->secWeaponMan.setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);334 335 this->secWeaponMan.setSlotPosition(2, Vector(1.5, 0, -.5));336 this->secWeaponMan.setSlotDirection(2, Quaternion(-M_PI_4*.5, Vector(1,0,0)));337 338 this->secWeaponMan.setSlotPosition(3, Vector(1.5, 0, .5));339 this->secWeaponMan.setSlotDirection(3, Quaternion(M_PI_4*.5, Vector(1,0,0)));340 341 this->secWeaponMan.setSlotPosition(4, Vector(1.5, 0, .5));342 this->secWeaponMan.setSlotDirection(4, Quaternion(-M_PI_4*.5+M_PI, Vector(1,0,0)));343 344 this->secWeaponMan.setSlotPosition(5, Vector(1.5, 0, -.5));345 this->secWeaponMan.setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0)));346 347 256 348 257 this->weaponMan.getFixedTarget()->setParent(this); … … 384 293 this->setSupportedPlaymodes(Playable::Horizontal | Playable::Vertical); 385 294 386 /// FIXME387 // this->trail = new Trail( 5, 10, .2, this);388 // this->trail->setTexture( "textures/engine.png");389 //390 // this->trailL = new Trail( 5, 10, .2, this);391 // this->trailL->setTexture( "textures/engine.png");392 //393 // this->trailR = new Trail( 5, 10, .2, this);394 // this->trailR->setTexture( "textures/engine.png");395 396 295 397 296 this->toList(OM_GROUP_00); 398 297 399 //FIXME Just testaddition to show the wobblegrid 400 /* 401 this->test = new Wobblegrid(5);402 test->setTexture("textures/blub.png");403 404 test->setAbsCoor( this->getAbsCoor() + Vector(0, 2, 0));405 test->setParent( this);406 */ 407 298 299 dynamic_cast<WorldEntity*>(this)->createHealthWidget(); 300 dynamic_cast<WorldEntity*>(this)->createShieldWidget(); 301 dynamic_cast<WorldEntity*>(this)->createElectronicWidget(); 302 303 if ( this->hasPlayer() ){ 304 State::getPlayer()->hud().setShieldWidget(this->getShieldWidget()); 305 State::getPlayer()->hud().setEnergyWidget(this->getElectronicWidget()); 306 } 408 307 } 409 308 … … 415 314 void SpaceShip::loadParams(const TiXmlElement* root) 416 315 { 316 if(!root) 317 return; 318 417 319 Playable::loadParams(root); 418 320 … … 422 324 LoadParam(root, "actionWidthPercentage", this, SpaceShip, setActionWidthPercentage); 423 325 424 State::getCamera()->setViewMode(Camera::ViewTop); 326 State::getCamera()->setViewMode(Camera::ViewNormal); 327 State::getCameraTargetNode()->setParent(this); 328 State::getCamera()->setParent(this); 329 330 LoadParam(root, "loadReactor", this, SpaceShip, loadReactor) 331 .describe("set reactor output"); 332 LoadParam(root, "loadShield", this, WorldEntity, loadShield) 333 .describe("set shield parameters: current strenght , max strenght, threshhold value (0..1), regeneration rate"); 334 LoadParam(root, "loadHealth", this, WorldEntity, loadHealth) 335 .describe("set armor/health parameters: current strenght , max strenght"); 336 LoadParam(root, "loadElectronic", this, WorldEntity, loadElectronic) 337 .describe("set electronics parameters: current strenght , max strenght, threshhold value (0..1), regeneration rate"); 338 LoadParam(root, "loadEngine", this, SpaceShip, loadEngine) 339 .describe("set base speed"); 340 LoadParam(root, "loadEnergyShare", this, SpaceShip, loadEnergyShare) 341 .describe("set energy partitioning: shield, weapons, engine (sum should be 1)"); 342 LoadParam(root, "loadWeapon", this, SpaceShip, loadWeapon) 343 .describe("set weapon regeneration"); 344 345 /* 346 LOAD_PARAM_START_CYCLE(root, element); 347 { 348 LoadParamXML_CYCLE(element, "weaponMan", this->weaponMan, WeaponManager, loadWeapons) 349 .describe("loads Weapons"); 350 } 351 LOAD_PARAM_END_CYCLE(element); 352 353 LOAD_PARAM_START_CYCLE(root, element); 354 { 355 LoadParamXML_CYCLE(element, "secWeaponMan", this->secWeaponMan, WeaponManager, loadWeapons) 356 .describe("loads Weapons"); 357 } 358 LOAD_PARAM_END_CYCLE(element);*/ 425 359 } 426 360 … … 435 369 bForward = bBackward = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = bFire = bSecFire = false; 436 370 437 //xMouse = yMouse = 0;438 439 this-> setHealth(80);371 this->resetHealth(); 372 this->resetShield(); 373 this->resetElectronic(); 440 374 this->velocity = Vector(0.0, 0.0, 0.0); 441 375 } … … 448 382 State::getPlayer()->hud().setRadarCenterNode(this->travelNode); 449 383 State::getPlayer()->hud().setOverlayActive(true); 450 //dynamic_cast <OrxGui::GLGuiEnergyWidgetVertical*> (State::getPlayer()->hud().getArmorWidget())->setDisplayedName("Armor");451 //dynamic_cast<Element2D*>(this->secWeaponMan.getFixedTarget())->setVisibility( true);452 //this->attachCamera();453 // this->setPlaymode(Playable::Horizontal);454 384 } 455 385 … … 461 391 State::getCamera()->setEventHandling(true); 462 392 State::getPlayer()->hud().setRadarCenterNode(NULL); 463 //dynamic_cast<Element2D*>(this->secWeaponMan.getFixedTarget())->setVisibility( false);464 //this->detachCamera();465 393 } 466 394 … … 473 401 if(this->hasPlayer()) 474 402 Playable::postSpawn(); 475 476 //setCollision(new CollisionCluster(1.0, Vector(0,0,0)));477 403 } 478 404 … … 525 451 void SpaceShip::tick (float time) 526 452 { 453 454 // if( !this->bInit) 455 // { 456 // // now get slots from the mount points 457 // std::map<int, MountPoint*>::iterator it = this->mountPointMap.begin(); 458 // for( ;it != this->mountPointMap.end(); it++) 459 // { 460 // WeaponSlot* ws = dynamic_cast<WeaponSlot*>((*it).second->getMount()); 461 // if( ws != NULL && ws->isA(WeaponSlot::staticClassID())) 462 // { 463 // int slot = ws->getWeaponSlot(); 464 // // int side = ws->getWeaponSide(); //FIXME / REMOVE: is not used// HACK needed for some weapons (left/right) 465 // this->getWeaponManager().setSlotPosition(slot, (*it).second->getCenter()); 466 // this->getWeaponManager().setSlotDirection(slot, ws->getRelDir()); 467 // // PRINTF(0)("setting slot %i\n", slot); 468 // // (*it).second->getCenter().debug(); 469 // } 470 // } 471 // this->bInit = true; 472 // } 473 527 474 // Playable::tick(time); 528 475 … … 636 583 if (!(State::getCamera()->getEventHandling())) 637 584 { 585 //PRINTF(0)("\n\n\n\n\n\n\n\nSETCAMERA %x\n\n\n\n\n\n\n", State::getCamera()); 638 586 if( event.type == KeyMapper::PEV_VIEW0) 639 587 { … … 750 698 PRINTF(5)("ship hit for (%f,%f) \n",pDamage,eDamage); 751 699 752 if( this->shieldActive) { 753 if( this->shieldCur > pDamage) { 754 this->shieldCur = this->shieldCur - pDamage; 755 } 756 else { // shield <= pDamage 757 this->shieldCur -=pDamage; 758 this->shieldActive = false; //shield collapses 759 pDamage += this->shieldCur; 760 if( !this->shieldActive) { 761 this->armorCur -= pDamage / 2; // remaining damages hits armor at half rate 762 this->electronicCur -= eDamage; 763 } 764 } 765 } 766 else { 767 this->armorCur = this->armorCur - pDamage; 768 this->electronicCur = this->electronicCur - eDamage; 769 } 770 if( this->armorCur <= 0) { /* FIXME implement shipcrash*/ } 700 static float tmp = this->decreaseShield(pDamage); 701 if( tmp > 0) 702 if ( this->decreaseHealth(tmp / 2) > 0) 771 703 this->destroy(this); 772 704 773 updateElectronicWidget(); 774 updateShieldWidget(); 775 776 this->setHealth( this->armorCur); 777 } 778 779 780 void SpaceShip::regen(float time){ 781 float tmp; 782 if (this->armorCur != this->armorMax || this->armorRegen != 0){ 783 tmp = this->armorCur + this->armorRegen * time; 784 if ( tmp > electronicMax) 785 this->armorCur = this->armorMax; 786 else 787 this->armorCur = tmp; 788 } 789 if (this->shieldCur != this->shieldMax || this->shieldRegen != 0){ 790 tmp = this->shieldCur + (this->shieldRegen + this->reactorOutput * this->shieldEnergyShare) * time; 791 if( tmp > shieldMax) 792 this->shieldCur = this->shieldMax; 793 else 794 this->shieldCur = tmp; 795 this->shieldActive = ( this->shieldActive || this->shieldCur > shieldTH); 796 797 updateShieldWidget(); 798 } 799 800 this->setHealth( this->shieldCur); // FIXME currently just to test share system 801 802 if (this->electronicCur != this->electronicMax || this->electronicRegen != 0){ 803 tmp = this->electronicCur + this->electronicRegen * time; 804 if ( tmp > electronicMax) 805 this->electronicCur = this->electronicMax; 806 else 807 this->electronicCur = tmp; 808 809 updateElectronicWidget(); 810 } 811 812 } 705 } 706 813 707 814 708 … … 819 713 void SpaceShip::weaponRegen(float time) 820 714 { 821 float energy = ( this->reactorOutput * this->weaponEnergyShare + this->weaponEnergyRegen) * time;715 float energy = ( this->reactorOutput * this->weaponEnergyShare + this->weaponEnergyRegen) * time ; 822 716 Weapon* weapon; 823 for( unsigned int i=0; i < this->weaponMan.getSlotCount(); i++)824 {717 int weaponCount = 0; 718 for( unsigned int i=0; i < this->weaponMan.getSlotCount(); i++) { 825 719 weapon = this->weaponMan.getWeapon(i); 826 if( weapon != NULL && weapon->isActive()) 827 { 720 if( weapon != NULL && weapon->isActive()) { 721 weaponCount++; 722 } 723 } 724 725 if (weaponCount == 0) 726 return; 727 energy *= ( this->weaponMan.getSlotCount() / (float)weaponCount ); 728 729 for( unsigned int i=0; i < this->weaponMan.getSlotCount(); i++) { 730 weapon = this->weaponMan.getWeapon(i); 731 if( weapon != NULL && weapon->isActive()) { 828 732 weapon->increaseEnergy( energy); 829 733 } 830 831 734 } 832 735 // weaponMan.increaseAmmunition( weapon, energy); … … 834 737 835 738 836 void SpaceShip::enterPlaymode(Playable::Playmode playmode) 837 { 739 void SpaceShip::enterPlaymode(Playable::Playmode playmode){ 838 740 switch(playmode) 839 741 { … … 895 797 } 896 798 break; 799 800 801 case Playable::Vertical: 802 { 803 this->travelNode->setAbsCoor(this->getAbsCoor()); 804 this->travelNode->updateNode(0.01f); 805 806 this->isTravelDistanceInit = false; 807 808 if(this->entityTrack) 809 this->travelNode->setParent(this->entityTrack->getTrackNode()); 810 811 this->setParent(this->travelNode); 812 this->setRelCoor(0,0,0); 813 814 State::getCameraNode()->setParentSoft(this->travelNode); 815 //State::getCameraNode()->setParentSoft(this); 816 //State::getCameraNode()->setRelCoorSoft(-0.01, 40, 0); 817 State::getCameraTargetNode()->setParentSoft(this->travelNode); 818 //State::getCameraTargetNode()->setParentSoft(this); 819 //State::getCameraTargetNode()->setRelCoorSoft(0,0,0); 820 //this->setCameraMode(Camera::ViewNormal); 821 State::getCamera()->setEventHandling(false); 822 823 PRINTF(0)("\n\n\n\n\n\n\n\nSETCAMERA %x\n\n\n\n\n\n\n", State::getCamera()); 824 State::getCamera()->setViewMode(Camera::ViewNormal); 825 State::getCameraTargetNode()->setParent(this); 826 State::getCamera()->setParent(this); 827 828 829 registerEvent(KeyMapper::PEV_VIEW0); 830 registerEvent(KeyMapper::PEV_VIEW1); 831 registerEvent(KeyMapper::PEV_VIEW2); 832 registerEvent(KeyMapper::PEV_VIEW3); 833 registerEvent(KeyMapper::PEV_VIEW4); 834 registerEvent(KeyMapper::PEV_VIEW5); 835 836 State::getCamera()->setParentMode(PNODE_ALL); 837 838 break; 839 } 897 840 898 841 default: … … 1058 1001 } 1059 1002 case Playable::Vertical: 1003 { 1004 if ( !entityTrack || !entityTrack->getActionBox() ) 1005 { 1006 break; 1007 } 1008 ActionBox * box = entityTrack->getActionBox(); 1009 1010 this->travelVelocity = Vector(0, 0, 0); 1011 float ssss = 50; 1012 if ( this->bForward ) 1013 { 1014 this->travelVelocity += Vector( 0, ssss, 0 ); 1015 } 1016 if ( this->bBackward ) 1017 { 1018 this->travelVelocity += Vector( 0, -ssss, 0 ); 1019 } 1020 if ( this->bLeft ) 1021 { 1022 this->travelVelocity += Vector( 0, 0, -ssss ); 1023 } 1024 if ( this->bRight ) 1025 { 1026 this->travelVelocity += Vector( 0, 0, ssss ); 1027 } 1028 1029 Vector ds = this->travelVelocity*dt; 1030 Vector newPos = this->getRelCoor() + ds; 1031 if ( newPos.y < -(box->getHeight_2()) || newPos.y > box->getHeight_2() ) 1032 { 1033 this->travelVelocity.y = 0; 1034 } 1035 if ( newPos.z > box->getWidth_2() || newPos.z < -(box->getWidth_2()) ) 1036 { 1037 this->travelVelocity.z = 0; 1038 } 1039 } 1060 1040 break; 1061 1041 default: … … 1099 1079 } 1100 1080 1101 void SpaceShip::updateElectronicWidget() 1102 { 1103 if (this->electronicWidget != NULL) 1104 { //if it exists already: update it 1105 this->electronicWidget->setMaximum(this->electronicMax); 1106 this->electronicWidget->setValue(this->electronicCur); 1107 } 1108 else 1109 { //create the widget 1110 this->electronicWidget = new OrxGui::GLGuiEnergyWidgetVertical(); 1111 this->electronicWidget->getBarWidget()->setChangedValueColor(Color(1,0,0,1)); 1112 //this->electronicWidget->setDisplayedName("Electronics:"); 1113 //this->electronicWidget->setSize2D(100,20); 1114 //this->electronicWidget->setAbsCoor2D(150,200); 1115 this->updateElectronicWidget(); 1116 if (this->hasPlayer()) 1117 State::getPlayer()->hud().setEnergyWidget(this->electronicWidget); 1118 } 1119 } 1120 1121 void SpaceShip::updateShieldWidget() 1122 { 1123 if (this->shieldWidget != NULL) 1124 { 1125 this->shieldWidget->setMaximum(this->shieldMax); 1126 this->shieldWidget->setValue(this->shieldCur);; 1127 } 1128 else 1129 { 1130 this->shieldWidget = new OrxGui::GLGuiEnergyWidgetVertical(); 1131 this->shieldWidget->getBarWidget()->setChangedValueColor(Color(1,0,0,1)); 1132 //this->shieldWidget->setDisplayedName("Shield:"); 1133 //his->shieldWidget->setSize2D(100,20); 1134 //this->shieldWidget->setAbsCoor2D(200,200); 1135 this->updateShieldWidget(); 1136 if (this->hasPlayer()) 1137 State::getPlayer()->hud().setShiledWidget(this->shieldWidget); 1138 } 1139 } 1081 // void SpaceShip::updateElectronicWidget() 1082 // { 1083 // if (this->electronicWidget != NULL) 1084 // { //if it exists already: update it 1085 // this->electronicWidget->setMaximum(this->electronicMax); 1086 // this->electronicWidget->setValue(this->electronicCur); 1087 // } 1088 // else 1089 // { //create the widget 1090 // this->electronicWidget = new OrxGui::GLGuiEnergyWidgetVertical(); 1091 // this->electronicWidget->getBarWidget()->setChangedValueColor(Color(1,0,0,1)); 1092 // //this->electronicWidget->setDisplayedName("Electronics:"); 1093 // //this->electronicWidget->setSize2D(100,20); 1094 // //this->electronicWidget->setAbsCoor2D(150,200); 1095 // this->updateElectronicWidget(); 1096 // if (this->hasPlayer()) 1097 // State::getPlayer()->hud().setEnergyWidget(this->electronicWidget); 1098 // } 1099 // } 1100 // 1101 // void SpaceShip::updateShieldWidget() 1102 // { 1103 // if (this->shieldWidget != NULL) 1104 // { 1105 // this->shieldWidget->setMaximum(this->shieldMax); 1106 // this->shieldWidget->setValue(this->shieldCur);; 1107 // } 1108 // else 1109 // { 1110 // this->shieldWidget = new OrxGui::GLGuiEnergyWidgetVertical(); 1111 // this->shieldWidget->getBarWidget()->setChangedValueColor(Color(1,0,0,1)); 1112 // //this->shieldWidget->setDisplayedName("Shield:"); 1113 // //his->shieldWidget->setSize2D(100,20); 1114 // //this->shieldWidget->setAbsCoor2D(200,200); 1115 // this->updateShieldWidget(); 1116 // if (this->hasPlayer()) 1117 // State::getPlayer()->hud().setShiledWidget(this->shieldWidget); 1118 // } 1119 // } 1120 1140 1121 1141 1122 void SpaceShip::setCameraDistance(float dist) … … 1176 1157 1177 1158 State::getPlayer()->hud().setOverlayPercentage(100-int(100*this->actionWidthPercentage)); 1178 PRINTF(0)("TravelDistance has been updated\n");1159 // PRINTF(0)("TravelDistance has been updated\n"); 1179 1160 this->isTravelDistanceInit = true; 1180 1161 } … … 1189 1170 this->isTravelDistanceInit = false; 1190 1171 }; 1172 1173 -
trunk/src/world_entities/space_ships/space_ship.h
r10531 r10698 12 12 #include "playable.h" 13 13 #include "extendable.h" 14 #include "world_entity.h" 14 15 15 16 // Forward Declaration … … 63 64 inline WeaponManager& getWeaponManagerSecondary() { return this->secWeaponMan; }; 64 65 65 //Functions for GUI 66 inline float getShieldCur() { return this->shieldCur; }; //!< returns current shield value 67 inline float getShieldMax() { return this->shieldMax; }; //!< returns maximum shield value 68 69 inline float getArmorCur() { return this->armorCur; }; //!< returns current armor value 70 inline float getArmorMax() { return this->armorMax; }; //!< returns current armor value 71 72 inline float getElectronicCur() { return this->electronicCur; }; //!< returns current electronic value 73 inline float getElectronicMax() { return this->electronicMax; }; //!< returns current electronic value 66 //!< functions for XML loading 67 void loadReactor(float output) {this->reactorOutput = output; }; 68 void loadEngine( float speedBase) {this->engineSpeedBase = speedBase; }; 69 void loadEnergyShare(float shield, float weapon, float engine) 70 { float tmp = shield + weapon + engine; if (unlikely (tmp > 1)) { tmp = 1/tmp; } 71 // HACK dirty safety hack, prevents total share being bigger than 1!! 72 this->shieldEnergyShare = shield * tmp; 73 this->weaponEnergyShare = weapon * tmp; 74 this->engineEnergyShare = engine * tmp; }; 75 inline void loadWeapon(float regen) { this->weaponEnergyRegen = regen; }; 76 77 void addWeaponToSlot(int wm, int config, int slot, const std::string& weaponName); 74 78 75 79 inline PNode* getTravelNode() { return this->travelNode; }; … … 86 90 virtual void movement (float dt); 87 91 88 // 92 89 93 90 94 void nextWeaponConfig(); … … 92 96 93 97 virtual void hit(float damage, WorldEntity* killer); 94 98 95 99 void setCameraDistance(float dist); 96 100 … … 100 104 //void calculateVelocity(float time); 101 105 102 void regen(float time); //!< handler for shield and electronic regeneration106 // void regen(float time); //!< handler for shield and electronic regeneration 103 107 104 108 void weaponRegen(float time); //!< weapon energy regeneration 105 109 106 inline bool systemFailure() { return (this->electronicCur < float(rand())/float(RAND_MAX) * this->electronicTH); };107 108 void updateElectronicWidget();109 void updateShieldWidget();110 // inline bool systemFailure() { return (this->getElectronic() < float(rand())/float(RAND_MAX) * this->getElectronicTH()); }; 111 112 // void updateElectronicWidget(); 113 // void updateShieldWidget(); 110 114 111 115 //WeaponManager weaponMan; //!< the primary weapon manager: managing a list of energy weapons to wepaon-slot mapping … … 115 119 116 120 //ship atributes 117 float shieldCur; //!< current shield 118 float shieldMax; //!< maximum shield 119 float shieldEnergyShare; //!< percentage of reactor output 120 float shieldRegen; //!< shield regeneration rate per second 121 float shieldTH; //!< shield threshhold for reactivation 122 bool shieldActive; //!< wheather the shield is working 123 OrxGui::GLGuiEnergyWidgetVertical* shieldWidget; //!< holds the widget that shows the shield bar 124 125 float armorCur; //!< current armor 126 float armorMax; //!< maximum armor 127 float armorRegen; //!< armor regeneration per tick (usable on bioships?) 121 // float shieldCur; //!< current shield 122 // float shieldMax; //!< maximum shield 123 // float shieldRegen; //!< shield regeneration rate per second 124 // float shieldTH; //!< shield threshhold for reactivation 125 // bool shieldActive; //!< wheather the shield is working 126 // OrxGui::GLGuiEnergyWidgetVertical* shieldWidget; //!< holds the widget that shows the shield bar 127 128 // float armorCur; //!< current armor 129 // float armorMax; //!< maximum armor 130 // float armorRegen; //!< armor regeneration per tick (usable on bioships?) 128 131 //note that the armor widget is set on the health- widget in world- entity (see in player.cc) 129 132 130 float electronicCur; //!< current electronic131 float electronicMax; //!< maximum electronic132 float electronicRegen; //!< electronic regenration rate per tick133 float electronicTH; //!< Threshhold for electronic failure134 OrxGui::GLGuiEnergyWidgetVertical* electronicWidget; //!< holds the widget that shows the electronic bar133 // float electronicCur; //!< current electronic 134 // float electronicMax; //!< maximum electronic 135 // float electronicRegen; //!< electronic regenration rate per tick 136 // float electronicTH; //!< Threshhold for electronic failure 137 // OrxGui::GLGuiEnergyWidgetVertical* electronicWidget; //!< holds the widget that shows the electronic bar 135 138 136 139 float engineSpeedCur; //!< speed output for movement = speed base + energy share part … … 138 141 int enginePowerConsume; //!< energy needed 139 142 float engineEnergyShare; //!< percentage of reactor output 143 float shieldEnergyShare; //!< percentage of reactor output 140 144 141 145 int weaponEnergySlot; //!< number of energy weapon slots … … 147 151 148 152 float reactorOutput; //!< reactor output 149 float reactorCapacity; //!< reactor capacity153 // float reactorCapacity; //!< reactor capacity 150 154 151 155 int curWeaponPrimary; //!< current primary weapon config 152 156 int curWeaponSecondary; //!< current secondary weapon config 153 157 154 bool bForward; 155 bool bBackward; 158 bool bForward; //!< up button pressed. 159 bool bBackward; //!< down button pressed. 156 160 bool bLeft; //!< left button pressed. 157 161 bool bRight; //!< right button pressed. … … 161 165 bool bRollR; //!< rolling button pressed (right) 162 166 bool bSecFire; //!< second fire button pressed 167 168 bool bInit; //!< set true, if MP have been loaded 163 169 164 170 /* … … 208 214 209 215 byte oldMask; //!< used for synchronisation 210 216 /* 211 217 Trail* trail; //!< Burst trail 212 218 Trail* trailL; //!< Burst trail 213 219 Trail* trailR; //!< Burst trail 214 220 */ 215 221 216 222 }; -
trunk/src/world_entities/spectator.cc
r10682 r10698 28 28 29 29 #include "player.h" 30 31 #include "util/track/action_box.h" 30 32 31 33 … … 300 302 else if( event.type == KeyMapper::PEV_BACKWARD) 301 303 this->bBackward = event.bPressed; //this->shiftCoor(0,-.1,0); 304 else if ( event.type == KeyMapper::PEV_JUMP ) 305 { 306 if ( State::getActionBox() && State::getActionBox()->isPointInBox( this->getAbsCoor() ) ) 307 { 308 PRINTF(0)("IN BOX\n"); 309 } 310 else 311 { 312 PRINTF(0)("NOT IN BOX\n"); 313 } 314 } 302 315 else if( event.type == EV_MOUSE_MOTION) 303 316 { -
trunk/src/world_entities/tools/camera.cc
r10618 r10698 203 203 this->setRelCoor(Vector(-0.05, this->viewTopDistance , 0)); 204 204 this->target->setRelCoor(0,0,0); 205 break; 206 } 207 case Camera::ViewFPS: 208 { 209 this->fovy = viewNormalFovy; 210 this->toFovy = viewNormalFovy; 211 this->setRelCoorSoft(this->viewFrontDistance, 0, 0, 5); 212 this->target->setRelCoorSoft(Vector(10,0,0), 5); 213 break; 214 } 215 case Camera::ViewFPSZoom: 216 { 217 this->fovy = viewNormalFovy; 218 this->toFovy = 30; 219 this->setRelCoorSoft(2, 0, 0, 5); 220 this->target->setRelCoorSoft(Vector(10,0,0), 5); 205 221 } 206 222 } -
trunk/src/world_entities/tools/camera.h
r10618 r10698 34 34 ViewLeft, 35 35 ViewRight, 36 ViewTop 36 ViewTop, 37 ViewFPS, 38 ViewFPSZoom 37 39 }; 38 40 public: -
trunk/src/world_entities/tools/mount_point.cc
r10618 r10698 22 22 23 23 #include "weapons/weapon_slot.h" 24 #include "weapons/weapon.h" 24 25 25 26 #include "particles/particle_system.h" … … 36 37 * construct 37 38 */ 38 MountPoint::MountPoint (const Vector& up, const Vector& forward, const Vector& center, const std::string& name)39 MountPoint::MountPoint (const Vector& up, const Vector& forward, const Vector& center, const std::string& name) 39 40 { 40 41 // PRINTF(0)("Created mount point %s\n", name.c_str()); … … 153 154 this->getRelDir()*Quaternion(M_PI, Vector(0,1,0))); 154 155 } 156 155 157 } 156 158 } -
trunk/src/world_entities/weapons/aiming_system.cc
r10013 r10698 112 112 void AimingSystem::hit(float damage, WorldEntity* killer) 113 113 { 114 if( this->owner != killer )114 if( this->owner != killer && killer != this && !killer->isA( AimingSystem::staticClassID() ) ) 115 115 { 116 116 //PRINTF(0)("real hit: %s\n", killer->getClassCName()); … … 127 127 void AimingSystem::tick(float dt) 128 128 { 129 130 131 129 } 132 130 -
trunk/src/world_entities/weapons/heavy_blaster.cc
r10618 r10698 98 98 // this->model = (Model*)ResourceManager::getInstance()->load("models/guns/test_gun.obj", OBJ, RP_CAMPAIGN); 99 99 100 this->loadModel("models/guns/frag_cannon .obj", .4);100 this->loadModel("models/guns/frag_cannon2.obj", .4); 101 101 102 102 … … 131 131 this->objComp[i] = new PNode* [this->getSegs()]; 132 132 this->emissionPoint[i] = new PNode; 133 this->emissionPoint[i]->setParent(this); //< One EmissionPoint, that is a PNode connected to the weapon. You can set this to the exitting point of the Projectiles133 this->emissionPoint[i]->setParent(this); //Parenting emissionPoint to Weapons 134 134 this->emissionPoint[i]->setName("EmissionPoint"); 135 135 this->emissionPoint[i]->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT); … … 156 156 157 157 158 // Animation3D* animB0Shoot = this->getAnimation(WS_SHOOTING0, this->objComp[0][0]);159 // Animation3D* animB1Shoot = this->getAnimation(WS_SHOOTING1, this->objComp2);160 // Animation3D* animB2Shoot = this->getAnimation(WS_SHOOTING2, this->objComp3);161 // Animation3D* animT0Shoot = this->getAnimation(WS_SHOOTING3, this->objComp[0][1]);162 // Animation3D* animT1Shoot = this->getAnimation(WS_SHOOTING4, this->objComp5);163 // Animation3D* animT2Shoot = this->getAnimation(WS_SHOOTING5, this->objComp6);164 165 166 // this->shootAnim[0][0]->setInfinity(ANIM_INF_CONSTANT);167 // animB1Shoot->setInfinity(ANIM_INF_CONSTANT);168 // animB2Shoot->setInfinity(ANIM_INF_CONSTANT);169 // animT0Shoot->setInfinity(ANIM_INF_CONSTANT);170 // animT1Shoot->setInfinity(ANIM_INF_CONSTANT);171 // animT2Shoot->setInfinity(ANIM_INF_CONSTANT);172 173 158 for (int i = 0; i < this->getBarrels(); i++){ 174 this->shootAnim[i][0]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.0 5, ANIM_LINEAR, ANIM_NULL);159 this->shootAnim[i][0]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.01, ANIM_LINEAR, ANIM_NULL); 175 160 this->shootAnim[i][0]->addKeyFrame(Vector(-0.3, 0.0, 0.0), Quaternion(), 0.9, ANIM_LINEAR, ANIM_NULL); 176 this->shootAnim[i][0]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.5 5, ANIM_LINEAR, ANIM_NULL);177 178 this->shootAnim[i][1]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0. 05, ANIM_LINEAR, ANIM_NULL);161 this->shootAnim[i][0]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.5, ANIM_LINEAR, ANIM_NULL); 162 163 this->shootAnim[i][1]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL); 179 164 this->shootAnim[i][1]->addKeyFrame(Vector(-0.4, 0.0, 0.0), Quaternion(), 1.2, ANIM_LINEAR, ANIM_NULL); 180 this->shootAnim[i][1]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.2 5, ANIM_LINEAR, ANIM_NULL);165 this->shootAnim[i][1]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.2, ANIM_LINEAR, ANIM_NULL); 181 166 } 182 167 … … 186 171 animation2->setInfinity(ANIM_INF_CONSTANT); 187 172 animation3->setInfinity(ANIM_INF_CONSTANT); 188 189 // this->setEmissionPoint(3.8, 1.2, 0, 0);190 173 191 174 animation2->addKeyFrame(Vector(0.0, -1.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL); … … 207 190 pj->setParent(PNode::getNullParent()); 208 191 209 // pj->setVelocity(this->getAbsDir().apply(Vector(1,0,0))*250 + VECTOR_RAND(5));210 // pj->setVelocity(this->getAbsDir().apply(Vector(1,0,0))*130 + VECTOR_RAND(1));211 192 pj->setVelocity(this->getAbsDir().apply(Vector(1,0,0))*130 + VECTOR_RAND(1)); 212 193 213 194 pj->setAbsCoor(this->emissionPoint[this->activeBarrel]->getAbsCoor()); 214 // pj->setAbsCoor(this->getEmissionPoint(0));215 195 pj->setAbsDir(this->getAbsDir()); 216 // pj->toList(OM_GROUP_01_PROJ);217 196 pj->activate(); 218 197 -
trunk/src/world_entities/weapons/laser_cannon.cc
r10415 r10698 55 55 this->registerObject(this, LaserCannon::_objectList); 56 56 57 // this->model = (Model*)ResourceManager::getInstance()->load("models/guns/laser_cannon.obj", OBJ, RP_CAMPAIGN);57 this->setScaling (5); 58 58 59 this->loadModel("models/guns/lasercannon.obj", 5.0f);59 this->loadModel("models/guns/lasercannon.obj", this->getScaling()); 60 60 61 61 this->setStateDuration(WS_SHOOTING, .1); … … 75 75 this->setProjectileTypeC("RailProjectile"); 76 76 this->prepareProjectiles(100); 77 this->setEmissionPoint(Vector(2.8,0,0) * 5.0);77 this->setEmissionPoint(Vector(2.8,0,0) * this->getScaling()); 78 78 } 79 79 -
trunk/src/world_entities/weapons/light_blaster.cc
r10618 r10698 90 90 this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL | WTYPE_LIGHT); 91 91 this->setProjectileTypeC("LBolt"); 92 this->prepareProjectiles( 100);92 this->prepareProjectiles(25); 93 93 94 94 this->setBarrels(3); … … 106 106 this->emissionPoint[i]->setName("EmissionPoint"); 107 107 this->emissionPoint[i]->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT); 108 // this->shootAnim[i] = new Animation3D* [this->getSegs()];109 108 for(int j = 0; j < this->getSegs(); j++) 110 109 { … … 114 113 } 115 114 } 116 /*117 this->emissionPoint[0]->setRelCoor(Vector(1.19, 0.0, 0.1));118 this->emissionPoint[1]->setRelCoor(Vector(1.19, -0.07, -0.05));119 this->emissionPoint[2]->setRelCoor(Vector(1.19, 0.07, -0.05));*/120 115 121 116 this->emissionPoint[0]->setRelCoor(Vector(2.2, 0.0, 0.1)); … … 130 125 animation2->setInfinity(ANIM_INF_CONSTANT); 131 126 animation3->setInfinity(ANIM_INF_CONSTANT); 132 133 // this->setEmissionPoint(3.8, 1.2, 0);134 135 // for (int i = 0; i < this->getBarrels(); i++){136 // this->shootAnim[i][0]->addKeyFrame(Vector(), Quaternion(i * 120, Vector(1.0, 0.0, 0.0)), 0.049, ANIM_NULL, ANIM_LINEAR);137 // this->shootAnim[i][0]->addKeyFrame(Vector(), Quaternion((i+1)*120, Vector(1.0, 0.0, 0.0)), 0.001, ANIM_NULL, ANIM_LINEAR);138 // }139 127 140 128 -
trunk/src/world_entities/weapons/medium_blaster.cc
r10618 r10698 69 69 void MediumBlaster::init() 70 70 { 71 this->loadModel("models/guns/blaster.obj", .33); 71 this->setScaling(.3333); 72 73 this->loadModel("models/guns/blaster.obj", this->getScaling()); 72 74 73 75 this->setStateDuration(WS_SHOOTING, 0.2); // 5 Schuss pro Sekunde … … 82 84 83 85 this->setActionSound(WA_SHOOT, "sounds/guns/laser.wav"); 84 this->setActionSound(WA_ACTIVATE, "sounds/voices/lasers.wav");86 // this->setActionSound(WA_ACTIVATE, "sounds/voices/lasers.wav"); 85 87 this->setActionSound(WA_RELOAD, "sounds/spawn/alien_generator.wav"); 86 88 87 89 this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL | WTYPE_LIGHT); 88 this->setProjectileTypeC("MBolt"); // FIXME temp project type until the blaste class exist89 this->prepareProjectiles(10 0);90 this->setProjectileTypeC("MBolt"); 91 this->prepareProjectiles(10); 90 92 91 93 … … 95 97 96 98 this->objComp = new PNode**[this->getBarrels()]; 99 this->emissionPoint = new PNode*[this->getBarrels()]; 97 100 this->shootAnim = new Animation3D**[this->getBarrels()]; 98 101 for (int i = 0; i < this->getBarrels(); i++) 99 102 { 100 103 this->objComp[i] = new PNode* [this->getSegs()]; 104 this->emissionPoint[i] = new PNode; 105 this->emissionPoint[i]->setParent(this); //Parenting emissionPoint to Weapon 106 this->emissionPoint[i]->setName("EmissionPoint"); 107 this->emissionPoint[i]->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT); 101 108 this->shootAnim[i] = new Animation3D* [this->getSegs()]; 102 109 for(int j = 0; j < this->getSegs(); j++) … … 109 116 110 117 for (int i = 0; i < this->getBarrels(); i++){ 111 this->shootAnim[i][0]->addKeyFrame(Vector(0.0, 0.0, 0.0) , Quaternion(), 0.04, ANIM_LINEAR, ANIM_NULL);112 this->shootAnim[i][0]->addKeyFrame(Vector(- 0.333, 0.0, 0.0), Quaternion(), 0.15, ANIM_LINEAR, ANIM_NULL);113 this->shootAnim[i][0]->addKeyFrame(Vector(0.0, 0.0, 0.0) , Quaternion(), 0.01, ANIM_LINEAR, ANIM_NULL);114 115 this->shootAnim[i][1]->addKeyFrame(Vector(0.0, 0.0, 0.0) , Quaternion(), 0.04, ANIM_LINEAR, ANIM_NULL);116 this->shootAnim[i][1]->addKeyFrame(Vector(. 166, 0.0, 0.0), Quaternion(), 0.15, ANIM_LINEAR, ANIM_NULL);117 this->shootAnim[i][1]->addKeyFrame(Vector(0.0, 0.0, 0.0) , Quaternion(), 0.01, ANIM_LINEAR, ANIM_NULL);118 this->shootAnim[i][0]->addKeyFrame(Vector(0.0, 0.0, 0.0) * this->getScaling(), Quaternion(), 0.04, ANIM_LINEAR, ANIM_NULL); 119 this->shootAnim[i][0]->addKeyFrame(Vector(-1.0, 0.0, 0.0) * this->getScaling(), Quaternion(), 0.15, ANIM_LINEAR, ANIM_NULL); 120 this->shootAnim[i][0]->addKeyFrame(Vector(0.0, 0.0, 0.0) * this->getScaling(), Quaternion(), 0.01, ANIM_LINEAR, ANIM_NULL); 121 122 this->shootAnim[i][1]->addKeyFrame(Vector(0.0, 0.0, 0.0) * this->getScaling(), Quaternion(), 0.04, ANIM_LINEAR, ANIM_NULL); 123 this->shootAnim[i][1]->addKeyFrame(Vector(.5, 0.0, 0.0) * this->getScaling(), Quaternion(), 0.15, ANIM_LINEAR, ANIM_NULL); 124 this->shootAnim[i][1]->addKeyFrame(Vector(0.0, 0.0, 0.0) * this->getScaling(), Quaternion(), 0.01, ANIM_LINEAR, ANIM_NULL); 118 125 } 119 126 … … 124 131 animation3->setInfinity(ANIM_INF_CONSTANT); 125 132 126 127 this->setEmissionPoint(1.3, 0, 0); 133 this->emissionPoint[0]->setRelCoor(Vector(3.9, 0.0, 0.0) * this->getScaling()); 128 134 129 135 animation2->addKeyFrame(Vector(0.0, -1.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL); -
trunk/src/world_entities/weapons/medium_blaster.h
r10516 r10698 33 33 PNode*** objComp; 34 34 Animation3D*** shootAnim; 35 PNode** emissionPoint; 35 36 36 37 int activeBarrel; -
trunk/src/world_entities/weapons/weapon.cc
r10529 r10698 134 134 for(int i = 0; i < this->barrels; i++){ 135 135 this->emissionPoint[i] = new PNode; 136 this->emissionPoint[i]->setParent(this); //< One EmissionPoint, that is a PNode connected to the weapon. You can set this to the exitting point of the Projectiles136 this->emissionPoint[i]->setParent(this); //Parenting emissionPoint to Weapons 137 137 this->emissionPoint[i]->setName("EmissionPoint"); 138 138 this->emissionPoint[i]->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT); … … 158 158 // set this object to be synchronized over network 159 159 //this->setSynchronized(true); 160 }161 162 /**163 * needed, if there are more than one barrel or segments164 */165 void Weapon::init2()166 {167 if (this->barrels == 1 && this->segs == 1)168 return;169 170 delete this->emissionPoint[0];171 delete this->emissionPoint;172 delete this->shootAnim[0];173 delete this->shootAnim;174 175 this->shootAnim = new Animation3D**[this->barrels];176 this->emissionPoint = new PNode*[this->barrels];177 for(int i = 0; i < this->barrels; i++){178 this->emissionPoint[i] = new PNode;179 this->emissionPoint[i]->setParent(this); //< One EmissionPoint, that is a PNode connected to the weapon. You can set this to the exitting point of the Projectiles180 this->emissionPoint[i]->setName("EmissionPoint");181 this->emissionPoint[i]->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);182 this->shootAnim[i] = new Animation3D* [this->segs];183 }184 }185 186 /**187 * deconstructor for init2188 */189 void Weapon::deconstr()190 {191 for(int i = 0; i < this->barrels; i++) {192 delete this->emissionPoint[i];193 for (int j = 0; j < this->segs; j++)194 delete this->shootAnim[i][j];195 delete this->shootAnim[i];196 }197 198 delete this->emissionPoint;199 delete this->shootAnim;200 160 } 201 161 -
trunk/src/world_entities/weapons/weapon.h
r10516 r10698 124 124 Projectile* getProjectile(); 125 125 126 inline void setScaling(float scaling) { this->scaling = scaling; }; 127 inline float getScaling() { return this->scaling; }; 126 128 127 129 // EMISSION … … 181 183 inline void setSegs(int segs) { this->segs = segs; }; 182 184 183 inline Animation3D* getShootAnim(int barrel, int seg) { return this->shootAnim[barrel][seg]; };184 inline void setShootAnim(int barrel, int seg, PNode* component) { this->shootAnim[barrel][seg] = this->getAnimation(barrel, seg, component); };185 186 void init2();185 // inline Animation3D* getShootAnim(int barrel, int seg) { return this->shootAnim[barrel][seg]; }; 186 // inline void setShootAnim(int barrel, int seg, PNode* component) { this->shootAnim[barrel][seg] = this->getAnimation(barrel, seg, component); }; 187 188 // void init2(); 187 189 void deconstr(); 188 190 … … 248 250 PNode* defaultTarget; //!< A target for targeting Weapons. 249 251 252 float scaling; //!< Local scaling factor. any scaling will be done through this vector. 253 250 254 //////////// 251 255 // PHASES // -
trunk/src/world_entities/weapons/weapon_manager.cc
r10544 r10698 1 2 1 /* 3 2 orxonox - the future of 3D-vertical-scrollers … … 36 35 /** 37 36 * @brief this initializes the weaponManager for a given nnumber of weapon slots 38 * @param number of weapon slots of the model/ship <= 8(limitied)37 * @param number of weapon slots of the model/ship <= 10 (limitied) 39 38 */ 40 39 WeaponManager::WeaponManager(WorldEntity* parent) … … 146 145 BaseObject::loadParams(root); 147 146 148 LoadParam(root, "slot -count", this, WeaponManager, setSlotCount)147 LoadParam(root, "slotCount", this, WeaponManager, setSlotCount) 149 148 .describe("how many slots(cannons) the WeaponManager can handle"); 149 150 150 151 151 LOAD_PARAM_START_CYCLE(root, element); … … 156 156 } 157 157 LOAD_PARAM_END_CYCLE(element); 158 159 158 160 } 159 161 … … 357 359 * @param slotCapability the capability @see WeaponSlotCapability 358 360 */ 359 void WeaponManager::setSlotCapability(int slot, long slotCapability)361 void WeaponManager::setSlotCapability(int slot, unsigned long slotCapability) 360 362 { 361 363 if (slot > slotCount) -
trunk/src/world_entities/weapons/weapon_manager.h
r10437 r10698 60 60 // setting up the WeaponManager with the following functions 61 61 void setSlotPosition(int slot, const Vector& position, PNode* parent = NULL); 62 // inline void setSlotPosition(float slot, float x, float y,float z) {setSlotPosition((int)slot, Vector(x,y,z));}; 62 63 void setSlotDirection(int slot, const Quaternion& rotation); 63 64 /** @param slot the slot to get the relative position from @returns the relative position of the Carrier to the Slot */ 64 65 const Vector& getSlotPosition(int slot) const; 65 void setSlotCapability(int slot, long slotCapability);66 void setSlotCapability(int slot, unsigned long slotCapability); 66 67 /** @param slot the slot to get the capabilities from @returns the capabilies */ 67 68 long getSlotCapability(int slot) const; … … 76 77 bool addWeapon(Weapon* weapon, int configID = -1, int slotID = -1); 77 78 void removeWeapon(Weapon* weapon, int configID = -1); 79 80 inline void createWeaponSlot(int slot, float x, float y, float z, long capability) { 81 this->setSlotPosition(slot, Vector( x, y, z)); 82 this->setSlotCapability(slot, capability); }; 83 84 inline void addWeaponToSlot(int config, int slot, const std::string& weaponName){ 85 this->addWeapon( Weapon::createWeapon( weaponName ), config, slot); }; 86 78 87 79 88 Weapon* getWeapon(int slotID) const; -
trunk/src/world_entities/weapons/weapon_slot.cc
r10534 r10698 42 42 43 43 WeaponSlot::~WeaponSlot() 44 {} 44 { 45 } 45 46 46 47 … … 55 56 56 57 LoadParam(root, "slot", this, WeaponSlot, setWeaponConfig) 57 .describe("sets the weapon slot"); 58 .describe("sets the weapon slot"); 59 60 LoadParam(root, "currentWeapon", this, WeaponSlot, setCurrentWeapon) 61 .describe("creates and set next weapon"); 62 63 LoadParam(root, "nextWeapon", this, WeaponSlot, setNextWeapon) 64 .describe("creates and set next weapon"); 58 65 } 59 66 … … 63 70 void WeaponSlot::setWeaponClass() 64 71 { 65 66 72 } 67 73 -
trunk/src/world_entities/weapons/weapon_slot.h
r10534 r10698 8 8 9 9 #include "p_node.h" 10 10 #include "weapon.h" 11 11 12 12 class Weapon; … … 36 36 inline void setNextWeapon(Weapon* weapon) { this->nextWeapon = weapon; } 37 37 38 inline void setNextWeapon(const std::string& weaponName){this->nextWeapon = Weapon::createWeapon(weaponName); }; 39 inline void setCurrentWeapon(const std::string& weaponName){ this->currentWeapon = Weapon::createWeapon(weaponName); }; 40 38 41 39 42 inline void setWeaponConfig(int slot, int side) { this->weaponSlot = slot; this->weaponSide = side; } -
trunk/src/world_entities/world_entity.cc
r10618 r10698 75 75 this->aabbNode = NULL; 76 76 this->healthWidget = NULL; 77 this->electronicWidget = NULL; 78 this->shieldWidget = NULL; 77 79 this->healthMax = 1.0f; 78 80 this->health = 1.0f; … … 128 130 129 131 // Delete the obbTree 130 if( this->obbTree != NULL)132 if( this->obbTree) 131 133 delete this->obbTree; 132 134 133 if (this->healthWidget != NULL)135 if (this->healthWidget) 134 136 delete this->healthWidget; 137 138 if(this->shieldWidget) 139 delete this->shieldWidget; 140 141 if( this->electronicWidget) 142 delete this->electronicWidget; 135 143 136 144 this->unsubscribeReactions(); … … 776 784 this->updateHealthWidget(); 777 785 return 0.0; 778 779 } 786 } 787 780 788 781 789 /** … … 792 800 this->updateHealthWidget(); 793 801 } 802 803 804 805 /** 806 * @param shiled the Shieldstength to add. 807 * @returns the shield left (this->shieldMax - shiled + this->shield) 808 */ 809 float WorldEntity::increaseShield(float shiled) 810 { 811 this->shield += shield; 812 if (this->shield > this->shieldTH * this->shieldMax) { this->bShieldActive = true; } 813 if (this->shield > this->shieldMax) 814 { 815 float retShield = this->shieldMax - this->shield; 816 this->shield = this->shieldMax; 817 // this->updateShieldWidget(); 818 return retShield; 819 } 820 // this->updateShieldWidget(); 821 return 0.0; 822 } 823 824 /** 825 * @param shield the Shieldstrength to be removed 826 * @returns 0.0 or the rest, if the shield drops belew 0.0 827 */ 828 float WorldEntity::decreaseShield(float shield) 829 { 830 this->shield -= shield; 831 832 if (this->shield <= 0) 833 { 834 float retShield = -this->shield; 835 // this->updateShieldWidget(); 836 this->bShieldActive = false; 837 return retShield; 838 } 839 // this->updateShieldWidget(); 840 return 0.0; 841 } 842 843 794 844 795 845 /** … … 813 863 } 814 864 865 866 /** 867 * @brief creates the ImplantWidget 868 * 869 * since not all entities need an ImpantWidget, it is only created on request. 870 */ 871 void WorldEntity::createImplantWidget() 872 { 873 if (this->implantWidget == NULL) 874 { 875 this->implantWidget = new OrxGui::GLGuiEnergyWidgetVertical(); 876 //this->impantWidget->setDisplayedName("Implant"); 877 //this->impantWidget->setSize2D(100,20); 878 //this->impantWidget->setAbsCoor2D(100,200); 879 880 //this->updateImplantWidget(); 881 } 882 else 883 PRINTF(3)("Allready created the ImlpantWidget for %s::%s\n", this->getClassCName(), this->getCName()); 884 } 885 886 887 888 void WorldEntity::createShieldWidget() 889 { 890 if (this->shieldWidget == NULL) 891 { 892 this->shieldWidget = new OrxGui::GLGuiEnergyWidgetVertical(); 893 this->updateShieldWidget(); 894 } 895 else 896 PRINTF(3)("Allready created the ShieldWidget for %s::%s\n", this->getClassCName(), this->getCName()); 897 } 898 899 void WorldEntity::createElectronicWidget() 900 { 901 if (this->electronicWidget == NULL) 902 { 903 this->electronicWidget = new OrxGui::GLGuiEnergyWidgetVertical(); 904 this->updateElectronicWidget(); 905 } 906 else 907 PRINTF(3)("Allready created the ElectronicWidget for %s::%s\n", this->getClassCName(), this->getCName()); 908 } 909 910 911 815 912 void WorldEntity::increaseHealthMax(float increaseHealth) 816 913 { … … 822 919 OrxGui::GLGuiWidget* WorldEntity::getHealthWidget() 823 920 { 824 this->createHealthWidget(); 921 if ( this->healthWidget == NULL) 922 this->createHealthWidget(); 825 923 return this->healthWidget; 826 924 } 925 926 927 928 OrxGui::GLGuiWidget* WorldEntity::getImplantWidget() 929 { 930 this->createImplantWidget(); 931 return this->implantWidget; 932 } 933 934 935 936 OrxGui::GLGuiWidget* WorldEntity::getShieldWidget() 937 { 938 if ( this->shieldWidget == NULL) 939 this->createShieldWidget(); 940 return this->shieldWidget; 941 } 942 943 944 OrxGui::GLGuiWidget* WorldEntity::getElectronicWidget() 945 { 946 if ( this->electronicWidget == NULL) 947 this->createElectronicWidget(); 948 return this->electronicWidget; 949 } 950 951 952 827 953 828 954 /** … … 830 956 * (creates the widget if needed) 831 957 */ 832 void WorldEntity::setHealthWidgetVisibilit (bool visibility)958 void WorldEntity::setHealthWidgetVisibility(bool visibility) 833 959 { 834 960 if (visibility) … … 890 1016 } 891 1017 } 1018 1019 /** 1020 * @brief updates the Electronic Widget 1021 */ 1022 //!< xferred from spaceship 1023 void WorldEntity::updateElectronicWidget(){ 1024 if (this->electronicWidget != NULL) 1025 { //if it exists already: update it 1026 this->electronicWidget->setMaximum(this->electronicMax); 1027 this->electronicWidget->setValue(this->electronic); 1028 } 1029 else 1030 { //create the widget 1031 this->electronicWidget = new OrxGui::GLGuiEnergyWidgetVertical(); 1032 this->electronicWidget->getBarWidget()->setChangedValueColor(Color(1,0,0,1)); 1033 //this->electronicWidget->setDisplayedName("Electronics:"); 1034 //this->electronicWidget->setSize2D(100,20); 1035 //this->electronicWidget->setAbsCoor2D(150,200); 1036 this->updateElectronicWidget(); 1037 // if ( dynamic_cast<SpaceShip*>(this)->hasPlayer() ) 1038 // State::getPlayer()->hud().setEnergyWidget(this->electronicWidget); 1039 } 1040 } 1041 1042 /** 1043 * @brief updates the ShieldWidget 1044 */ 1045 //!< xferred from spaceship 1046 void WorldEntity::updateShieldWidget() 1047 { 1048 if (this->shieldWidget != NULL) 1049 { 1050 this->shieldWidget->setMaximum(this->shieldMax); 1051 this->shieldWidget->setValue(this->shield);; 1052 } 1053 else 1054 { 1055 this->shieldWidget = new OrxGui::GLGuiEnergyWidgetVertical(); 1056 this->shieldWidget->getBarWidget()->setChangedValueColor(Color(1,0,0,1)); 1057 //this->shieldWidget->setDisplayedName("Shield:"); 1058 //his->shieldWidget->setSize2D(100,20); 1059 //this->shieldWidget->setAbsCoor2D(200,200); 1060 this->updateShieldWidget(); 1061 // if (dynamic_cast<SpaceShip*>(this)->hasPlayer()) 1062 // State::getPlayer()->hud().setShieldWidget(this->shieldWidget); 1063 } 1064 } 1065 892 1066 893 1067 … … 985 1159 } 986 1160 1161 1162 void WorldEntity::regen(float time){ 1163 static float tmp; 1164 increaseHealth(time * this->healthRegen); 1165 increaseShield(time * this->shieldRegen); 1166 // updateHealthWidget(); 1167 // updateShieldWidget(); 1168 1169 //this->setHealth( this->shieldCur); // FIXME currently just to test share system 1170 1171 if (this->electronic != this->electronicMax || this->electronicRegen != 0){ 1172 tmp = this->electronic + this->electronicRegen * time; 1173 if ( tmp > electronicMax) 1174 this->electronic = this->electronicMax; 1175 else 1176 this->electronic = tmp; 1177 1178 updateElectronicWidget(); 1179 } 1180 1181 } -
trunk/src/world_entities/world_entity.h
r10540 r10698 161 161 void increaseHealthMax(float increaseHealth); 162 162 OrxGui::GLGuiWidget* getHealthWidget(); 163 OrxGui::GLGuiWidget* getImplantWidget(); 164 OrxGui::GLGuiWidget* getShieldWidget(); 165 OrxGui::GLGuiWidget* getElectronicWidget(); 163 166 bool hasHealthWidget() const { return this->healthWidget != NULL; }; 167 168 float getShield() const { return this->shield; }; 169 float getShieldMax() const { return this->shieldMax; }; 170 float increaseShield(float shield); 171 float decreaseShield(float shield); 172 bool getShieldActive() { return this->bShieldActive; }; 173 174 float getElectronic() const { return this->electronic; }; 175 float getElectronicMax() const { return this->electronicMax; }; 176 float increaseElectronic(float electronic); 177 float decreaseElectronic(float electronic); 178 179 bool systemFailure() { return (this->electronic < float(rand())/float(RAND_MAX) * this->electronicTH); }; 180 181 void resetElectronic() { this->electronic = this->electronicMax; }; 182 void resetShield() { this->shield = this->shieldMax; this->bShieldActive = true; }; 183 void resetHealth() { this->health = this->healthMax; }; 184 185 void createHealthWidget(); 186 void createShieldWidget(); 187 void createElectronicWidget(); 188 189 void regen(float time); 190 191 void loadShield(float cur, float max, float th, float regen) 192 { this->setShield(cur); this->setShieldMax(max); this->setShieldTH(th); this->setShieldRegen(regen); }; 193 void loadHealth(float cur, float max, float regen = 0) { this->setHealth(cur); this->setHealthMax(max); this->setHealthRegen(regen); }; 194 void loadElectronic(float cur, float max, float th, float regen) 195 { this->setElectronic(cur); this->setElectronicMax(max); this->setElectronicTH(th); this->setElectronicRegen(regen); }; 196 164 197 165 198 virtual void varChangeHandler( std::list<int> & id ); … … 181 214 void pauseTrack(bool stop); 182 215 216 // void updateHealthWidget(); 217 // void updateElectronicWidget(); 218 // void updateShieldWidget(); 183 219 184 220 protected: 185 void setHealth(float health) { this->health = health; this->updateHealthWidget();};186 void setHealthWidgetVisibilit (bool visibility);221 inline void setHealth(float health) { this->health = health; this->updateHealthWidget();}; 222 void setHealthWidgetVisibility(bool visibility); 187 223 void setHealthMax(float healthMax); 188 void createHealthWidget(); 224 // void createHealthWidget(); 225 // void createShieldWidget(); 226 // void createElectronicWidget(); 227 void setHealthRegen(float regen) { this->healthRegen = regen; }; 228 void createImplantWidget(); 189 229 // CharacterAttributes* charAttr; //!< the character attributes of a world_entity 230 231 void setShield(float shield) { this->shield = shield; }; 232 void setShieldMax(float shield) { this->shieldMax = shield; }; 233 void setShieldTH(float th) { this->shieldTH = th; }; 234 void setShieldRegen(float regen) { this->shieldRegen = regen; }; 235 void setShieldActive(bool active) { this->bShieldActive = active; }; 236 237 void setElectronic(float electronic) { this->electronic = electronic; }; 238 void setElectronicMax(float electronic) { this->electronicMax = electronic; }; 239 void setElectronicTH(float th) { this->electronicTH = th; }; 240 void setElectronicRegen(float regen) { this->electronicRegen = regen; }; 190 241 191 242 inline void drawDebugTrack(int flag) { this->bDrawTrack = (bool)flag; } 192 243 inline bool isDrawTrack() const { return this->bDrawTrack; } 193 244 194 195 245 private: 196 246 void updateHealthWidget(); 247 void updateElectronicWidget(); 248 void updateShieldWidget(); 197 249 void addTrack(const TiXmlElement* root); 198 250 199 251 200 252 201 202 203 253 protected: 254 std::vector<MountPoint*> mountPoints; //!< A list with mount points for this model 255 std::map<int, MountPoint*> mountPointMap; 204 256 205 257 206 258 207 259 private: 208 /// TODO maybe we will move the following three entries and the corresponding functions to Playable AND NPC 260 261 //!< TODO maybe we will move the following three entries and the corresponding functions to Playable AND NPC 262 //!< started transfering shield/electronic/health from spaceship to WE! (nico, 4.Jun.07) 263 209 264 float damage; //!< the damage dealt to other objects by colliding. 210 265 float health; //!< The Energy of this Entity, if the Entity has any energy at all. 211 float healthMax; //!< The Maximal energy this entity can take. 266 float healthMax; //!< The Maximal energy this entity can take. 267 float implantEnergy; //!< energy of implants 268 float healthRegen; //!< Regeneration Rate of Health, mesured in units per second 212 269 OrxGui::GLGuiEnergyWidgetVertical* healthWidget; //!< The Slider (if wanted). 270 OrxGui::GLGuiEnergyWidgetVertical* implantWidget; 271 272 float shield; //!< current shield 273 float shieldMax; //!< maximum shield 274 float shieldRegen; //!< shield regeneration rate per second 275 float shieldTH; //!< shield threshhold for reactivation 276 bool bShieldActive; //!< wheather the shield is working 277 OrxGui::GLGuiEnergyWidgetVertical* shieldWidget; //!< holds the widget that shows the shield bar 278 279 float electronic; //!< current electronic 280 float electronicMax; //!< maximum electronic 281 float electronicRegen; //!< electronic regenration rate per tick 282 float electronicTH; //!< Threshhold for electronic failure 283 OrxGui::GLGuiEnergyWidgetVertical* electronicWidget; //!< holds the widget that shows the electronic bar 284 213 285 214 286 std::vector<Model*> models; //!< The model that should be loaded for this entity. … … 247 319 float healthMax_write; 248 320 int healthMax_handle; 321 322 249 323 250 324
Note: See TracChangeset
for help on using the changeset viewer.