Changeset 10698 in orxonox.OLD for trunk/src/util
- Timestamp:
- Jun 14, 2007, 5:33:43 PM (18 years ago)
- Location:
- trunk/src/util
- Files:
-
- 7 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.