Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3845 in orxonox.OLD for orxonox/trunk


Ignore:
Timestamp:
Apr 17, 2005, 1:19:54 AM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: now some text gets displayed, when changing the Track

Location:
orxonox/trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/graphics/text_engine.cc

    r3844 r3845  
    138138   \param alignment the alignment to set
    139139*/
    140 void Text::setAlignment(TEXT_ALIGNMENT alignemnt)
     140void Text::setAlignment(TEXT_ALIGNMENT alignment)
    141141{
    142142  this->alignment = alignment;
     
    185185  // setting the Position of this Text.
    186186  Vector pos;
    187   if (this->bindNode)
     187  if (this->alignment == TEXT_ALIGN_SCREEN_CENTER)
     188    {
     189      pos.x = GraphicsEngine::getInstance()->getResolutionX()/2 + this->posSize.x;
     190      pos.y = GraphicsEngine::getInstance()->getResolutionY()/2 + this->posSize.y;
     191      pos.z = 0;
     192    }
     193  else if (this->bindNode)
    188194    {
    189195      GLdouble x = this->bindNode->getAbsCoor().x;
     
    211217  if (this->alignment == TEXT_ALIGN_RIGHT)
    212218    glTranslatef(-this->posSize.w, 0, 0);
    213   else   if (this->alignment == TEXT_ALIGN_CENTER)
     219  else   if (this->alignment == TEXT_ALIGN_CENTER || this->alignment == TEXT_ALIGN_SCREEN_CENTER)
    214220    glTranslatef(-this->posSize.w/2, 0, 0);
    215221
  • orxonox/trunk/src/lib/graphics/text_engine.h

    r3843 r3845  
    3030
    3131//! An enumerator for the text alignment.
    32 enum TEXT_ALIGNMENT {TEXT_ALIGN_LEFT, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER};
     32enum TEXT_ALIGNMENT {TEXT_ALIGN_LEFT, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER, TEXT_ALIGN_SCREEN_CENTER};
    3333
    3434/* some default values */
     
    104104  void setText(const char* text);
    105105  void setPosition(int x, int y);
    106   void setAlignment(TEXT_ALIGNMENT alignemnt);
     106  void setAlignment(TEXT_ALIGNMENT alignment);
    107107  /** \param blending the blending intensity to set (between 0.0 and 1.0) */
    108108  inline void setBlending(float blending) {this->blending = blending;}
  • orxonox/trunk/src/track_manager.cc

    r3842 r3845  
    2323#include "stdincl.h"
    2424#include "list.h"
    25 
    26 
     25#include "text_engine.h"
     26#include "animation.h"
    2727
    2828#include <stdarg.h>
     
    386386  this->maxTime = 0;
    387387  this->trackElemCount = 1;
     388
    388389  this->trackNode = new TrackNode();
    389390  this->setBindSlave(this->trackNode);
     391  // initializing the Text
     392  this->trackText = TextEngine::getInstance()->createText("fonts/earth.ttf", 30, TEXT_DYNAMIC, 0, 255, 0);
     393  this->trackText->setAlignment(TEXT_ALIGN_SCREEN_CENTER);
     394  // initializing the Animation for the Text.
     395  this->textAnimation = new tAnim<Text>(this->trackText, &Text::setBlending);
     396  this->textAnimation->addKeyFrame(1.0, 1.0, ANIM_LINEAR);
     397  this->textAnimation->addKeyFrame(0.0, 1.0);
     398  this->textAnimation->setInfinity(ANIM_INF_CONSTANT);
    390399}
    391400
     
    929938      this->currentTrackElem = this->currentTrackElem->getChild(this->choosePath(this->currentTrackElem));
    930939      this->currentTrackElem->history = tmpHistoryElem;
     940      if (this->currentTrackElem->getName())
     941        {
     942          this->trackText->setText(this->currentTrackElem->getName());
     943          this->textAnimation->play();
     944        }
    931945    }
    932946  if (this->bindSlave)
     
    954968{
    955969  if (time == 0)
    956     this->currentTrackElem = this->firstTrackElem;
     970    {
     971      this->currentTrackElem = this->firstTrackElem;
     972      if (this->currentTrackElem->getName())
     973        {
     974          this->trackText->setText(this->currentTrackElem->getName());
     975          this->textAnimation->play();
     976        }
     977    }
    957978  this->localTime = time;
    958979}
  • orxonox/trunk/src/track_manager.h

    r3841 r3845  
    1515#include "base_object.h"
    1616
     17// Forward Definition
    1718class PNode;
     19class Text;
     20template<class T> class tAnim;
    1821template<class T> class tList;
    1922
     
    136139  float maxTime;                      //!< The maximal time the track has.
    137140  int trackElemCount;                 //!< The count of TrackElements that exist.
     141
     142  // external
    138143  PNode* bindSlave;                   //!< The node that is slave to the TrackManager. This node will be moved while update the TrackManager, and must NOT move itself.
    139144  PNode* trackNode;                   //!< The main TrackNode of this Track.
     145  Text* trackText;                    //!< The text to display when switching between Worlds.
     146  tAnim<Text>* textAnimation;         //!< An Animation for the Text.
    140147 
    141148  void initChildren(unsigned int childCount, TrackElement* trackElem = NULL);
Note: See TracChangeset for help on using the changeset viewer.