Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5420 in orxonox.OLD for trunk


Ignore:
Timestamp:
Oct 22, 2005, 1:57:29 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: Font is now Right, and the Rendering 'should be' faster.

Location:
trunk/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/coord/p_node.cc

    r5419 r5420  
    3636/**
    3737 *  standard constructor
    38 */
     38 */
    3939PNode::PNode ()
    4040{
     
    4646/**
    4747 * @param root the load-Element for the PNode
    48 */
     48 */
    4949PNode::PNode(const TiXmlElement* root)
    5050{
     
    6060 * @param absCoordinate the Absolute coordinate of the Object
    6161 * @param parent The parent-node of this node.
    62 */
     62 */
    6363PNode::PNode (const Vector& absCoor, PNode* parent )
    6464{
     
    116116 *  initializes a PNode
    117117 * @param parent the parent for this PNode
    118 */
     118 */
    119119void PNode::init(PNode* parent)
    120120{
     
    136136 *  loads parameters of the PNode
    137137 * @param root the XML-element to load the properties of
    138 */
     138 */
    139139void PNode::loadParams(const TiXmlElement* root)
    140140{
     
    176176 *  set relative coordinates
    177177 * @param relCoord relative coordinates to its parent
    178 
    179    it is very importand, that you use this function, if you want to update the
    180    relCoordinates. If you don't use this, the PNode won't recognize, that something
    181    has changed and won't update the children Nodes.
    182 */
     178 *
     179 *
     180 * it is very importand, that you use this function, if you want to update the
     181 * relCoordinates. If you don't use this, the PNode won't recognize, that something
     182 * has changed and won't update the children Nodes.
     183 */
    183184void PNode::setRelCoor (const Vector& relCoord)
    184185{
     
    199200 * @param z z-relative coordinates to its parent
    200201 * @see  void PNode::setRelCoor (const Vector& relCoord)
    201 */
     202 */
    202203void PNode::setRelCoor (float x, float y, float z)
    203204{
     
    306307 *  shift coordinate relative
    307308 * @param shift shift vector
    308 
    309    this function shifts the current coordinates about the vector shift. this is
    310    usefull because from some place else you can:
    311    PNode* someNode = ...;
    312    Vector objectMovement = calculateShift();
    313    someNode->shiftCoor(objectMovement);
    314 
    315    otherwise you would have to:
    316    PNode* someNode = ...;
    317    Vector objectMovement = calculateShift();
    318    Vector currentCoor = someNode->getRelCoor();
    319    Vector newCoor = currentCoor + objectMovement;
    320    someNode->setRelCoor(newCoor);
     309 *
     310 * this function shifts the current coordinates about the vector shift. this is
     311 * usefull because from some place else you can:
     312 * PNode* someNode = ...;
     313 * Vector objectMovement = calculateShift();
     314 * someNode->shiftCoor(objectMovement);
     315 *
     316 * this is the internal method of:
     317 * PNode* someNode = ...;
     318 * Vector objectMovement = calculateShift();
     319 * Vector currentCoor = someNode->getRelCoor();
     320 * Vector newCoor = currentCoor + objectMovement;
     321 * someNode->setRelCoor(newCoor);
    321322 *
    322323 */
     
    417418
    418419/**
    419  *  sets the absolute direction
     420 * sets the absolute direction
    420421 * @param absDir absolute coordinates
    421422 */
     
    461462 * @param child child reference
    462463 * use this to add a child to this node.
    463 */
     464 */
    464465void PNode::addChild (PNode* child)
    465466{
     
    491492 *
    492493 * Children from pNode will not be lost, they are referenced to NullPointer
    493 */
     494 */
    494495void PNode::removeChild (PNode* child)
    495496{
     
    504505/**
    505506 *  remove this pnode from the tree and adds all following to NullParent
    506 
    507    this can be the case, if an entity in the world is being destroyed.
    508 */
     507 *
     508 * this can be the case, if an entity in the world is being destroyed.
     509 */
    509510void PNode::remove()
    510511{
     
    525526 * sets the parent of this PNode
    526527 * @param parent the Parent to set
    527 */
     528 */
    528529void PNode::setParent (PNode* parent)
    529530{
     
    604605 *  updates the absCoordinate/absDirection
    605606 * @param dt The time passed since the last update
    606 
    607    this is used to go through the parent-tree to update all the absolute coordinates
    608    and directions. this update should be done by the engine, so you don't have to
    609    worry, normaly...
    610 */
     607 *
     608 * this is used to go through the parent-tree to update all the absolute coordinates
     609 * and directions. this update should be done by the engine, so you don't have to
     610 * worry, normaly...
     611 */
    611612void PNode::update (float dt)
    612613{
     
    713714 * (0: all children will be debugged, 1: only this PNode, 2: this and direct children, ...)
    714715 * @param level !! INTERNAL !! The n-th level of the Node we draw (this is internal and only for nice output).
    715 */
     716 */
    716717void PNode::debug(unsigned int depth, unsigned int level) const
    717718{
  • trunk/src/lib/graphics/render2D/render_2d.h

    r5417 r5420  
    22 * @file render_2d.h
    33 * @brief Definition of the 2D-rendering engine singleton Class
    4  * @todo implement Layer-rendering
    5 */
     4 */
    65
    76#ifndef _RENDER_2D_H
  • trunk/src/lib/graphics/text_engine/font.cc

    r5418 r5420  
    412412
    413413  this->initGlyphs(32, numberOfGlyphs);
    414   this->glyphArray[32]->width = .5f; //!< @todo find out the real size of a Space
     414//  this->glyphArray[32]->width = .5f; //!< @todo find out the real size of a Space
    415415
    416416  int rectSize = this->findOptimalFastTextureSize();
     
    437437  tmpRect.x = 0; tmpRect.y = 0; tmpRect.w = tmpSurf->w; tmpRect.h = tmpSurf->h;
    438438  SDL_SetClipRect(tmpSurf, &tmpRect);
    439   int maxLineHeight = 0;
     439  int maxLineHeight = this->getMaxHeight();
    440440
    441441  // all the interessting Glyphs
     
    453453      {
    454454        tmpRect.x = 0;
    455         tmpRect.y = tmpRect.y + maxLineHeight + 1;
    456         maxLineHeight = 0;
     455        tmpRect.y = tmpRect.y + maxLineHeight;
    457456      }
    458457      if (tmpRect.y + maxLineHeight > tmpSurf->h)
     
    470469      {
    471470        SDL_SetAlpha(glyphSurf, 0, 0);
    472 
     471        int tmp = tmpRect.y;
     472        tmpRect.y += this->getMaxAscent()-(int)((float)tmpGlyph->bearingY*this->renderSize);
    473473        SDL_BlitSurface(glyphSurf, NULL, tmpSurf, &tmpRect);
    474         tmpGlyph->texCoord[0] = (float)tmpRect.x/(float)tmpSurf->w;
    475         tmpGlyph->texCoord[1] = (float)(tmpRect.x + tmpGlyph->advance*this->renderSize)/(float)tmpSurf->w;
     474        tmpRect.y = tmp;
     475
     476        tmpGlyph->texCoord[0] = (float)(tmpRect.x)/(float)tmpSurf->w;
     477        tmpGlyph->texCoord[1] = (float)(tmpRect.x + tmpGlyph->width*(float)this->renderSize)/(float)tmpSurf->w;
    476478        tmpGlyph->texCoord[2] = (float)(tmpRect.y)/(float)tmpSurf->w;
    477         tmpGlyph->texCoord[3] = (float)(tmpRect.y+tmpGlyph->height*this->renderSize)/(float)tmpSurf->w;
     479        tmpGlyph->texCoord[3] = (float)(tmpRect.y+this->getMaxHeight())/(float)tmpSurf->w;
    478480        SDL_FreeSurface(glyphSurf);
    479 
    480         tmpRect.x += (int)(tmpGlyph->advance*this->renderSize)+1;
    481 
    482               // Outputting Glyphs to BMP-files.
     481        tmpRect.x += (int)(tmpGlyph->advance * this->renderSize)+1;
     482
    483483        /*
    484         char outname[512];
     484        // Outputting Glyphs to BMP-files.
     485        char outname[1024];
    485486        if (i < 10)
    486487        sprintf( outname, "%s-glyph-00%d.bmp", this->getName(), i );
     
    489490        else
    490491        sprintf( outname, "%s-glyph-%d.bmp", this->getName(), i );
    491         SDL_SaveBMP(tmpSurf, outname);
    492         */
     492        SDL_SaveBMP(tmpSurf, outname);*/
    493493      }
    494494    }
    495495  }
     496  // outputting the GLYPH-table
     497  //   char outName[1024];
     498  //   sprintf( outName, "%s-glyphs.bmp", this->getName());
     499  //   SDL_SaveBMP(tmpSurf, outName);
    496500
    497501  GLuint texture;
  • trunk/src/lib/graphics/text_engine/text.cc

    r5419 r5420  
    243243    {
    244244      glTranslatef(getAbsCoor2D().x, getAbsCoor2D().y, 0);
    245       glRotatef(this->getAbsDir2D(), 0,0,1);
     245      glRotatef(this->getAbsDir2D(), 0, 0, 1);
    246246      Glyph* tmpGlyph;
    247247      float posX = 0.0f;
     
    253253
    254254          glTexCoord2f(tmpGlyph->texCoord[0], tmpGlyph->texCoord[2]);
    255           glVertex2d(posX, - tmpGlyph->bearingY * this->size);
     255          glVertex2d(posX, 0);
    256256
    257257          glTexCoord2f(tmpGlyph->texCoord[0], tmpGlyph->texCoord[3]);
    258           glVertex2d(posX, (tmpGlyph->height - tmpGlyph->bearingY)*this->size);
     258          glVertex2d(posX, this->size);
    259259
    260260          glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[3]);
    261           glVertex2d(posX+tmpGlyph->width*this->size, (tmpGlyph->height - tmpGlyph->bearingY)*this->size);
     261          glVertex2d(posX+tmpGlyph->width*this->size, this->size);
    262262
    263263          glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[2]);
    264           glVertex2d(posX+tmpGlyph->width*this->size, - tmpGlyph->bearingY*this->size);
     264          glVertex2d(posX+tmpGlyph->width*this->size, 0);
    265265
    266266          glEnd();
  • trunk/src/lib/gui/gl_gui/glgui_pushbutton.cc

    r5418 r5420  
    1919
    2020#include "text.h"
     21#include "material.h"
    2122
    2223using namespace std;
     
    4546{
    4647  this->setClassID(CL_GLGUI_PUSHBUTTON, "GLGuiPushButton");
     48//  this->label->setRelCoor2D(10, 10);
    4749
     50  this->backMat = new Material();
     51  this->backMat->setDiffuse(0, 0, 0);
     52
     53  this->setSize2D(label->getSizeX2D()+10, label->getSizeY2D()+10);
    4854}
    4955
     
    5359void GLGuiPushButton::draw() const
    5460{
    55   this->label->draw();
     61  this->backMat->select();
     62  glPushMatrix();
     63  glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0);
     64  glBegin(GL_QUADS);
     65
     66  glVertex2d(0,0);
     67  glVertex2d(0, this->getSizeY2D());
     68  glVertex2d(this->getSizeX2D(), this->getSizeY2D());
     69  glVertex2d(this->getSizeX2D(),0);
     70
     71  glEnd();
     72  glPopMatrix();
     73
     74//   this->label->draw();
    5675//  printf("test");
    5776}
  • trunk/src/lib/math/vector.cc

    r5005 r5420  
    1515
    1616   Quaternion code borrowed from an Gamasutra article by Nick Bobick and Ken Shoemake
     17
     18   2005-06-02: Benjamin Grauer: speed up, and new Functionality to Vector (mostly inline now)
    1719*/
    1820
     
    3032 *  returns the this-vector normalized to length 1.0
    3133 * @todo there is some error in this function, that i could not resolve. it just does not, what it is supposed to do.
    32 */
     34 */
    3335Vector Vector::getNormalized() const
    3436{
     
    5355/**
    5456 *  Outputs the values of the Vector
    55 */
     57 */
    5658void Vector::debug() const
    5759{
     
    7779 *
    7880 * @TODO !!! OPTIMIZE THIS !!!
    79 */
     81 */
    8082Quaternion::Quaternion (const Vector& dir, const Vector& up)
    8183{
     
    110112 * @param pitch: the pitch in radians
    111113 * @param yaw: the yaw in radians
    112 */
     114 */
    113115Quaternion::Quaternion (float roll, float pitch, float yaw)
    114116{
     
    136138 *  convert the Quaternion to a 4x4 rotational glMatrix
    137139 * @param m: a buffer to store the Matrix in
    138 */
     140 */
    139141void Quaternion::matrix (float m[4][4]) const
    140142{
     
    167169 * @param to where
    168170 * @param t the time this transformation should take value [0..1]
    169 
    170171 * @returns the Result of the smooth move
    171 */
     172 */
    172173Quaternion Quaternion::quatSlerp(const Quaternion& from, const Quaternion& to, float t)
    173174{
     
    194195    }
    195196
    196   //if( (1.0 - cosom) > DELTA )
    197   //{
    198197  omega = acos(cosom);
    199198  sinom = sin(omega);
    200199  scale0 = sin((1.0 - t) * omega) / sinom;
    201200  scale1 = sin(t * omega) / sinom;
    202   //}
    203   /*
    204     else
    205     {
    206     scale0 = 1.0 - t;
    207     scale1 = t;
    208     }
    209   */
    210 
    211 
    212   /*
    213     Quaternion res;
    214     res.v.x = scale0 * from.v.x + scale1 * tol[0];
    215     res.v.y = scale0 * from.v.y + scale1 * tol[1];
    216     res.v.z = scale0 * from.v.z + scale1 * tol[2];
    217     res.w = scale0 * from.w + scale1 * tol[3];
    218   */
    219201  return Quaternion(Vector(scale0 * from.v.x + scale1 * tol[0],
    220                            scale0 * from.v.y + scale1 * tol[1],
    221                            scale0 * from.v.z + scale1 * tol[2]),
     202                    scale0 * from.v.y + scale1 * tol[1],
     203                    scale0 * from.v.z + scale1 * tol[2]),
    222204                    scale0 * from.w + scale1 * tol[3]);
    223205}
     
    227209 *  convert a rotational 4x4 glMatrix into a Quaternion
    228210 * @param m: a 4x4 matrix in glMatrix order
    229 */
     211 */
    230212Quaternion::Quaternion (float m[4][4])
    231213{
  • trunk/src/lib/math/vector.h

    r5419 r5420  
     1/*
     2   orxonox - the future of 3D-vertical-scrollers
     3
     4   Copyright (C) 2004 orx
     5
     6   This program is free software; you can redistribute it and/or modify
     7   it under the terms of the GNU General Public License as published by
     8   the Free Software Foundation; either version 2, or (at your option)
     9   any later version.
     10
     11### File Specific:
     12   main-programmer: Christian Meyer
     13   co-programmer: ...
     14*/
     15
    116/*!
    217 * @file vector.h
  • trunk/src/lib/shell/shell.cc

    r5398 r5420  
    8484  this->textSize = 20;
    8585  this->lineSpacing = 0;
    86   this->bActive = false;
     86  this->bActive = true;
    8787  this->fontFile = new char[strlen(SHELL_DEFAULT_FONT)+1];
    8888  strcpy(this->fontFile, SHELL_DEFAULT_FONT);
     
    9494  this->setBackgroundColor(SHELL_DEFAULT_BACKGROUND_COLOR);
    9595
     96  this->deactivate();
    9697  // register the shell at the ShellBuffer
    9798  ShellBuffer::getInstance()->registerShell(this);
     
    135136  {
    136137    this->bufferText[i]->setText(bufferIT->getCurrent(), true);
     138    this->bufferText[i]->setVisibility(true);
    137139    bufferIT->prevStep();
    138140  }
     
    159161    this->bufferText[i]->setText(bufferIT->getCurrent(), false);
    160162    bufferIT->prevStep();
     163    this->bufferText[i]->setVisibility(false);
    161164  }
    162165  delete bufferIT;
     
    254257    this->shellInput->setColor(this->textColor[0], this->textColor[1], this->textColor[2]);
    255258    this->shellInput->setBlending(this->textColor[3]);
    256     this->shellInput->setRelCoor2D(5, (this->textSize + this->lineSpacing)*this->bufferDisplaySize + this->textSize);
     259    this->shellInput->setRelCoor2D(5, (this->textSize + this->lineSpacing)*(this->bufferDisplaySize));
    257260  }
    258261
     
    271274  }
    272275  this->shellHeight = (this->textSize + this->lineSpacing) * (bufferDisplaySize+1);
    273 
    274276}
    275277
     
    501503Vector Shell::calculateLinePosition(unsigned int lineNumber)
    502504{
    503   return Vector(5, (this->textSize + this->lineSpacing)*(this->bufferDisplaySize - lineNumber -1) + this->textSize, 0);
     505  return Vector(5, (this->textSize + this->lineSpacing)*(this->bufferDisplaySize - lineNumber - 2) + this->textSize, 0);
    504506}
    505507
  • trunk/src/world_entities/player.cc

    r5396 r5420  
    149149  GLGuiButton* button = new GLGuiPushButton();
    150150  button->show();
    151   button->setLabel("test");
     151  button->setLabel("orxonox");
    152152  button->setBindNode(this);
    153153
Note: See TracChangeset for help on using the changeset viewer.