Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7843 in orxonox.OLD for trunk/src/lib/graphics/render2D


Ignore:
Timestamp:
May 24, 2006, 11:17:59 PM (19 years ago)
Author:
bensch
Message:

compiles

Location:
trunk/src/lib/graphics/render2D
Files:
4 edited

Legend:

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

    r7840 r7843  
    2121#include <algorithm>
    2222
     23// ONLY IF PNODE ENABLED //
     24#include "state.h"
    2325#include "p_node.h"
     26#include "camera.h"
     27///////////////////////////
    2428
    2529#include "graphics_engine.h"
     
    4549
    4650  this->setVisibility(true);
     51  this->bCurrentlyVisible = true;
    4752  this->activate2D();
    4853  this->setAlignment(E2D_ALIGN_NONE);
     
    240245
    241246
     247/**
     248 * @brief sets a node, this 2D-Element should be shown upon
     249 * @param bindNode the Node of the Node. (if NULL it will be unset).
     250 */
     251void Element2D::setBindNode(const PNode* bindNode)
     252{
     253  this->bindNode = bindNode;
     254  if (bindNode == NULL)
     255    this->bCurrentlyVisible = true;
     256}
    242257
    243258/**
     
    863878    else if (unlikely(this->bindNode != NULL))
    864879    {
     880      if (State::getCamera()->distance(this->bindNode) < 0)
     881        this->bCurrentlyVisible = false;
     882      else
     883      {
     884        this->bCurrentlyVisible = true;
     885        printf("OK \n");
     886      }
     887
    865888      GLdouble projectPos[3] = {0.0, 0.0, 0.0};
    866889      gluProject(this->bindNode->getAbsCoor().x,
     
    10111034void Element2D::draw2D(E2D_LAYER from, E2D_LAYER to) const
    10121035{
    1013   if (this->bVisible)
     1036  if (this->bVisible && this->bCurrentlyVisible)
    10141037    this->draw();
    10151038  if (this->children.size() > 0)
  • trunk/src/lib/graphics/render2D/element_2d.h

    r7840 r7843  
    116116    inline void setVisibility(bool visible) { this->bVisible = visible; };
    117117    /** @returns the visibility state */
    118     inline bool isVisible() const { return this->bVisible; };
     118    inline bool isVisible() const { return (this->bVisible && this->bCurrentlyVisible); };
    119119
    120120
    121121    // POSITIONAL (E2D-specials) //
    122122    /** @param bindNode the Node this 2D-element should follow. if NULL the Element will not follow anything */
    123     inline void setBindNode(const PNode* bindNode) { this->bindNode = bindNode; };
     123    void setBindNode(const PNode* bindNode);
    124124    void setBindNode(const std::string& bindNode);
    125125    inline const PNode* getBindNode() const { return this->bindNode; };
     
    244244    E2D_ALIGNMENT           alignment;          //!< How the Element is aligned around its Position
    245245
    246     bool                    bVisible;            //!< If the given Element2D is visible.
    247     bool                    bActive;             //!< If the given Element2D is active.
     246    bool                    bVisible;           //!< If the given Element2D is visible.
     247    bool                    bCurrentlyVisible;  //!< Evaluated in the TICK process, to see if the Element is Currently visible.
     248    bool                    bActive;            //!< If the given Element2D is active.
    248249    E2D_LAYER               layer;              //!< What layer this Element2D is on.
    249250
  • trunk/src/lib/graphics/render2D/image_plane.cc

    r7810 r7843  
    2121
    2222#include "graphics_engine.h"
    23 #include "material.h"
    2423#include "glincl.h"
    25 #include "state.h"
    2624#include "p_node.h"
    2725
     
    5048ImagePlane::~ImagePlane ()
    5149{
    52   if (this->material)
    53     delete this->material;
    5450}
    5551
     
    6763
    6864  //this->setBindNode(this);
    69   this->material = new Material();
    7065  this->setTexture("pictures/error_texture.png");
    7166}
     
    7873void ImagePlane::loadParams(const TiXmlElement* root)
    7974{
    80   LoadParam(root, "texture", this->material, Material, setDiffuseMap)
     75  LoadParam(root, "texture", &this->material, Material, setDiffuseMap)
    8176      .describe("the texture-file to load onto the ImagePlane");
    8277
     
    10297void ImagePlane::setTexture(const std::string& textureFile)
    10398{
    104   this->material->setDiffuseMap(textureFile);
     99  this->material.setDiffuseMap(textureFile);
    105100}
    106101
     
    149144void ImagePlane::draw() const
    150145{
    151   if( !this->isVisible())
    152     return;
    153 
    154146  glPushMatrix();
    155147
    156148  glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0);
    157   this->material->select();
     149  this->material.select();
    158150
    159151  glBegin(GL_TRIANGLE_STRIP);
  • trunk/src/lib/graphics/render2D/image_plane.h

    r7810 r7843  
    1111
    1212#include "vector.h"
     13#include "material.h"
    1314
    14 
    15 
    16 class Material;
    17 class TiXmlElement;
    1815
    1916//! A class that enables the
     
    3734
    3835  private:
    39     Material*        material;             //!< a material for the ImagePlane
     36    Material         material;             //!< a material for the ImagePlane
    4037    float            rotationSpeed;        //!< Speed of the Rotation.
    4138
Note: See TracChangeset for help on using the changeset viewer.