Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5378 in orxonox.OLD for trunk


Ignore:
Timestamp:
Oct 14, 2005, 6:54:55 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: crosshair now more compliant with Element2D
Element2D now also nows size

Location:
trunk/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/graphics/render2D/element_2d.cc

    r5377 r5378  
    123123  this->toCoordinate = NULL;
    124124  this->toDirection = NULL;
     125  this->setSize2D(1,1);
    125126
    126127  Render2D::getInstance()->registerElement2D(this);
  • trunk/src/lib/graphics/render2D/element_2d.h

    r5371 r5378  
    9898    inline bool isActive() { return this->active; };
    9999
     100
     101    inline void setSize2D(float x, float y) { this->sizeX = x, this->sizeY = y; };
     102    inline void setSizeX2D(float x) { this->sizeX = x; };
     103    inline void setSizeY2D(float y) { this->sizeY = y; };
     104    inline float getSizeX2D() const { return this->sizeX; };
     105    inline float getSizeY2D() const { return this->sizeY; };
    100106
    101107    // LIKE PNODE
     
    179185    virtual void draw() const = 0;
    180186
    181   protected:
     187  private:
     188    const PNode*            bindNode;           //!< a node over which to display this 2D-element
    182189    float                   sizeX;              //!< The size of the rendered item in x-direction
    183190    float                   sizeY;              //!< The size of the rendered Item in y-direction
    184 
    185   private:
    186     const PNode*            bindNode;           //!< a node over which to display this 2D-element
    187191
    188192    E2D_ALIGNMENT           alignment;          //!< How the Element is aligned around its Position
  • trunk/src/lib/graphics/text_engine/text.h

    r5369 r5378  
    7171    void setSize(float size) { this->size = size; };
    7272    /** @returns the Size of the Text */
    73     float getSize() const { return this->size; };
     73//    void getSize(float &x, float& y) const { return this->size; };
    7474
    7575    void setType(TEXT_RENDER_TYPE type);
  • trunk/src/world_entities/environment.cc

    r5361 r5378  
    3838  this->loadModel("models/ships/bolido.obj");
    3939
    40 /*  if(this->obbTree == NULL)
    41     this->obbTree = new OBBTree(4, (sVec3D*)this->model->getVertexArray(), this->model->getVertexCount());*/
     40  if(this->obbTree == NULL)
     41    this->obbTree = new OBBTree(4, (sVec3D*)this->model->getVertexArray(), this->model->getVertexCount());
    4242}
    4343
  • trunk/src/world_entities/test_entity.cc

    r5357 r5378  
    3737//   this->md2Model = new MD2Model("models/tris.md2", "models/tris.pcx");
    3838// this->md2Model = new MD2Model("models/goblin.md2", "maps/goblin.bmp");
    39 //  this->obbTree = new OBBTree(4, (sVec3D*)this->md2Model->data->pVertices, this->md2Model->data->numVertices);
     39  this->obbTree = new OBBTree(4, (sVec3D*)this->md2Model->data->pVertices, this->md2Model->data->numVertices);
    4040
    4141  this->md2Model->setAnim(RUN);
  • trunk/src/world_entities/weapons/crosshair.cc

    r5357 r5378  
    6464
    6565  this->setLayer(E2D_TOP);
    66   this->rotation = 0;
    6766  this->setRotationSpeed(5);
    6867  this->setSize(GraphicsEngine::getInstance()->getResolutionX()/10.0);
    6968
    70   this->position2D[0] = 0;
    71   this->position2D[1] = 0;
    72 
     69  this->setBindNode(this);
    7370  this->material = new Material;
    7471
     
    104101void Crosshair::setSize(float size)
    105102{
    106   this->size = size*.5;
    107 };
     103  this->setSize2D(size/2, size/2);
     104}
    108105
    109106/**
     
    124121  if  (event.type == EV_MOUSE_MOTION)
    125122  {
    126     this->position2D[0] = event.x;
    127     this->position2D[1] = event.y;
     123    this->setAbsCoor2D(event.x, event.y);
    128124  }
    129 
    130   /*
    131   GLdouble z;
    132   GLdouble objX, objY, objZ;
    133   glReadPixels (event.x, event.y, 1, 1, GL_DEPTH_COMPONENT, GL_DOUBLE, &z);
    134 
    135 
    136   if (gluUnProject(event.x,
    137       event.y,
    138       10,
    139       GraphicsEngine::modMat,
    140       GraphicsEngine::projMat,
    141       GraphicsEngine::viewPort,
    142       &objX,
    143       &objY,
    144       &objZ ))
    145     PRINT(0)("screen %d %d -> obj(%f/%f/%f)\n", event.x, event.y, objX, objY, objZ);
    146   else
    147     PRINT(0)("shit\n");
    148 */
    149125}
    150126
     
    156132{
    157133  // let the crosshair rotate
    158   this->rotation += dt * rotationSpeed;
     134  this->shiftDir2D(dt * rotationSpeed);
    159135
    160136
    161137  float z = 0.0f;
    162   glReadPixels ((int)position2D[0], GraphicsEngine::getInstance()->getResolutionY()-(int)position2D[1]-1, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &z);
    163   //cout << z << endl;
     138  glReadPixels ((int)this->getAbsCoor2D().x,
     139                 GraphicsEngine::getInstance()->getResolutionY()-(int)this->getAbsCoor2D().y-1,
     140                 1,
     141                 1,
     142                 GL_DEPTH_COMPONENT,
     143                 GL_FLOAT,
     144                 &z);
     145
    164146
    165147  GLdouble objX=.0, objY=.0, objZ=.0;
    166   gluUnProject(position2D[0],
    167                GraphicsEngine::getInstance()->getResolutionY()-position2D[1]-1,
     148  gluUnProject(this->getAbsCoor2D().x,
     149               GraphicsEngine::getInstance()->getResolutionY()-this->getAbsCoor2D().y-1,
    168150               .99,  // z
    169151               GraphicsEngine::modMat,
     
    175157
    176158  this->setAbsCoor(objX, objY, objZ);
    177 
    178   //this->positioning();
    179159}
    180160
     
    184164void Crosshair::draw() const
    185165{
    186 //   glBegin(GL_TRIANGLES);
    187 //   glColor3f(1,0,0);
    188 //   glVertex3f(objX, objY, objZ);
    189 //   glVertex3f(objX, objY+1, objZ);
    190 //   glVertex3f(objX, objY, objZ+1);
    191 //   glEnd();
    192166  glPushMatrix();
    193   GLdouble pos[3] = { 0.0, 0.0, 0.0};
    194   gluProject(this->getAbsCoor().x,
    195              this->getAbsCoor().y,
    196              this->getAbsCoor().z,
    197              GraphicsEngine::modMat,
    198              GraphicsEngine::projMat,
    199              GraphicsEngine::viewPort,
    200              pos, pos+1, pos+2 );
     167  glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0);
    201168
    202 
    203   glTranslatef(position2D[0], position2D[1], 0);
    204   glRotatef(this->rotation, 0,0,1);
     169  glRotatef(this->getAbsDir2D(), 0,0,1);
    205170  this->material->select();
    206171  glBegin(GL_TRIANGLE_STRIP);
    207172  glTexCoord2f(0, 0);
    208   glVertex2f(-size, -size);
     173  glVertex2f(-this->getSizeX2D(), -this->getSizeY2D());
    209174  glTexCoord2f(1, 0);
    210   glVertex2f(size, -size);
     175  glVertex2f(this->getSizeX2D(), -this->getSizeY2D());
    211176  glTexCoord2f(0, 1);
    212   glVertex2f(-size, size);
     177  glVertex2f(-this->getSizeX2D(), this->getSizeY2D());
    213178  glTexCoord2f(1, 1);
    214   glVertex2f(size, size);
     179  glVertex2f(this->getSizeX2D(), this->getSizeY2D());
    215180  glEnd();
    216181  glPopMatrix();
  • trunk/src/world_entities/weapons/crosshair.h

    r5039 r5378  
    4040
    4141 private:
    42    float            position2D[2];        //!< The 2D-position on the screen
    43 
    4442   Material*        material;             //!< a material for the Aim.
    45    float            rotation;             //!< a rotation of the aim.
    4643   float            rotationSpeed;        //!< Speed of the Rotation.
    47    float            size;                 //!< The Size of the Crosshair (in % of screen resolution 1 is fullscreen)
    4844};
    4945
  • trunk/src/world_entities/world_entity.cc

    r5302 r5378  
    9898bool WorldEntity::buildObbTree(unsigned int depth)
    9999{
    100 //   if (this->obbTree)
    101 //     delete this->obbTree;
    102 //
    103 //   if (this->model)
    104 //   {
    105 //     PRINTF(4)("creating obb tree\n");
    106 //     this->obbTree = new OBBTree(depth, (sVec3D*)this->model->getVertexArray(), this->model->getVertexCount());
    107 //     return true;
    108 //   }
    109 //   else
    110 //   {
    111 //     PRINTF(2)("could not create obb-tree, because no model was loaded yet\n");
    112 //     this->obbTree = NULL;
    113 //     return false;
    114 //  }
     100  if (this->obbTree)
     101    delete this->obbTree;
     102
     103  if (this->model)
     104  {
     105    PRINTF(4)("creating obb tree\n");
     106    this->obbTree = new OBBTree(depth, (sVec3D*)this->model->getVertexArray(), this->model->getVertexCount());
     107    return true;
     108  }
     109  else
     110  {
     111    PRINTF(2)("could not create obb-tree, because no model was loaded yet\n");
     112    this->obbTree = NULL;
     113    return false;
     114  }
    115115}
    116116
Note: See TracChangeset for help on using the changeset viewer.