Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 3, 2005, 9:55:33 PM (19 years ago)
Author:
bensch
Message:

orxonox/branches/textEngine: added bind-node ability, so now the text tries to follow a given PNode (currently trackNode)
the work is not finished, so do not expect too much

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/textEngine/src/lib/graphics/font/glfont.cc

    r3714 r3715  
    5555#include <string.h>
    5656
     57#include "p_node.h"
     58#include "vector.h"
    5759#include "debug.h"
    5860
     
    128130  this->currentText = new Text;
    129131
     132  this->currentText->bindNode = NULL;
    130133  this->currentText->text = NULL;
    131134  this->currentText->texture = 0;
     
    171174}
    172175
     176void GLFont::setBindNode(PNode* bindNode)
     177{
     178  this->currentText->bindNode = bindNode;
     179}
     180
     181
    173182/**
    174183   \brief Sets a new Text to the font
     
    245254void GLFont::draw(void)
    246255{
     256  GLdouble modMat[16];
     257  GLint viewPort[4];
     258  glGetDoublev(GL_PROJECTION_MATRIX, this->projMat);
     259  glGetDoublev(GL_MODELVIEW_MATRIX, modMat);
     260  glGetIntegerv(GL_VIEWPORT, viewPort);
    247261  this->enter2DMode();
     262
     263
     264  Vector pos;
     265  if (this->currentText->bindNode)
     266    {
     267      GLdouble x = this->currentText->bindNode->getAbsCoor().x;
     268      GLdouble y = this->currentText->bindNode->getAbsCoor().y;
     269      GLdouble z = this->currentText->bindNode->getAbsCoor().z;
     270      GLdouble tmp[3];
     271      gluProject(x, y, z, modMat, projMat, viewPort, tmp, tmp+1, tmp+2);
     272      printf("test %f %f %f,\n", tmp[0], tmp[1], tmp[2]);
     273      pos.x = tmp[0];
     274      pos.y = tmp[1];
     275      pos.z = tmp[2];
     276    }
    248277
    249278  glBindTexture(GL_TEXTURE_2D, this->currentText->texture);
    250279  glEnable(GL_TEXTURE_2D);
    251280  glBegin(GL_QUADS);
    252 
     281 
    253282  glTexCoord2f(this->currentText->texCoord.minU, this->currentText->texCoord.minV);
    254   glVertex2i(20,   20  );
     283  glVertex2i(pos.x,   pos.y  );
    255284
    256285  glTexCoord2f(this->currentText->texCoord.maxU, this->currentText->texCoord.minV);
    257   glVertex2i(20+this->currentText->textPosSize.w, 20  );
     286  glVertex2i(pos.x + this->currentText->textPosSize.w, pos.y  );
    258287
    259288  glTexCoord2f(this->currentText->texCoord.maxU, this->currentText->texCoord.maxV);
    260   glVertex2i(20+this->currentText->textPosSize.w, 20+this->currentText->textPosSize.h);
     289  glVertex2i(pos.x + this->currentText->textPosSize.w, pos.y + this->currentText->textPosSize.h);
    261290
    262291  glTexCoord2f(this->currentText->texCoord.minU, this->currentText->texCoord.maxV);
    263   glVertex2i(20, 20+this->currentText->textPosSize.h);
     292  glVertex2i(pos.x, pos.y + this->currentText->textPosSize.h);
    264293
    265294  glEnd();
     
    555584
    556585}
     586
     587
     588void m_inverse(const float *m, float *out)
     589{
     590    float det;
     591    det=  m[0]*m[5]*m[10];
     592    det+= m[4]*m[9]*m[2];
     593    det+= m[8]*m[1]*m[6];
     594    det-= m[8]*m[5]*m[2];
     595    det-= m[4]*m[1]*m[10];
     596    det-= m[0]*m[9]*m[6];
     597   
     598    if(det!= 0.0)
     599        det=1.0/det;
     600    out[0]=  (m[5]*m[10]-m[9]*m[6])*det;
     601    out[1]= -(m[1]*m[10]-m[9]*m[2])*det;
     602    out[2]=  (m[1]*m[6]-m[5]*m[2])*det;
     603    out[3]= 0.0;
     604    out[4]= -(m[4]*m[10]-m[8]*m[6])*det;
     605    out[5]=  (m[0]*m[10]-m[8]*m[2])*det;
     606    out[6]= -(m[0]*m[6]-m[4]*m[2])*det;
     607    out[7]= 0.0;
     608    out[8]=  (m[4]*m[9]-m[8]*m[5])*det;
     609    out[9]= -(m[0]*m[9]-m[8]*m[1])*det;
     610    out[10]= (m[0]*m[5]-m[4]*m[1])*det;
     611    out[11]= 0.0;
     612    out[12]=- (m[12]*out[0]+m[13]*out[4]+m[14]*out[8]);
     613    out[13]=- (m[12]*out[1]+m[13]*out[5]+m[14]*out[9]);
     614    out[14]=- (m[12]*out[2]+m[13]*out[6]+m[14]*out[10]);
     615    out[15]= 1.0;
     616}
     617
     618
     619Vector mvMult(const float *mat, const Vector* vec)
     620{
     621  Vector tmp;
     622  tmp.x = mat[0]*vec->x+mat[1]*vec->y+mat[2]*vec->z;
     623  tmp.y = mat[4]*vec->x+mat[5]*vec->y+mat[6]*vec->z;
     624  tmp.z = mat[8]*vec->x+mat[9]*vec->y+mat[10]*vec->z;
     625  return tmp;
     626}
Note: See TracChangeset for help on using the changeset viewer.