Changeset 7843 in orxonox.OLD for trunk/src/lib/graphics/render2D
- Timestamp:
- May 24, 2006, 11:17:59 PM (19 years ago)
- Location:
- trunk/src/lib/graphics/render2D
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/render2D/element_2d.cc
r7840 r7843 21 21 #include <algorithm> 22 22 23 // ONLY IF PNODE ENABLED // 24 #include "state.h" 23 25 #include "p_node.h" 26 #include "camera.h" 27 /////////////////////////// 24 28 25 29 #include "graphics_engine.h" … … 45 49 46 50 this->setVisibility(true); 51 this->bCurrentlyVisible = true; 47 52 this->activate2D(); 48 53 this->setAlignment(E2D_ALIGN_NONE); … … 240 245 241 246 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 */ 251 void Element2D::setBindNode(const PNode* bindNode) 252 { 253 this->bindNode = bindNode; 254 if (bindNode == NULL) 255 this->bCurrentlyVisible = true; 256 } 242 257 243 258 /** … … 863 878 else if (unlikely(this->bindNode != NULL)) 864 879 { 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 865 888 GLdouble projectPos[3] = {0.0, 0.0, 0.0}; 866 889 gluProject(this->bindNode->getAbsCoor().x, … … 1011 1034 void Element2D::draw2D(E2D_LAYER from, E2D_LAYER to) const 1012 1035 { 1013 if (this->bVisible )1036 if (this->bVisible && this->bCurrentlyVisible) 1014 1037 this->draw(); 1015 1038 if (this->children.size() > 0) -
trunk/src/lib/graphics/render2D/element_2d.h
r7840 r7843 116 116 inline void setVisibility(bool visible) { this->bVisible = visible; }; 117 117 /** @returns the visibility state */ 118 inline bool isVisible() const { return this->bVisible;};118 inline bool isVisible() const { return (this->bVisible && this->bCurrentlyVisible); }; 119 119 120 120 121 121 // POSITIONAL (E2D-specials) // 122 122 /** @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); 124 124 void setBindNode(const std::string& bindNode); 125 125 inline const PNode* getBindNode() const { return this->bindNode; }; … … 244 244 E2D_ALIGNMENT alignment; //!< How the Element is aligned around its Position 245 245 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. 248 249 E2D_LAYER layer; //!< What layer this Element2D is on. 249 250 -
trunk/src/lib/graphics/render2D/image_plane.cc
r7810 r7843 21 21 22 22 #include "graphics_engine.h" 23 #include "material.h"24 23 #include "glincl.h" 25 #include "state.h"26 24 #include "p_node.h" 27 25 … … 50 48 ImagePlane::~ImagePlane () 51 49 { 52 if (this->material)53 delete this->material;54 50 } 55 51 … … 67 63 68 64 //this->setBindNode(this); 69 this->material = new Material();70 65 this->setTexture("pictures/error_texture.png"); 71 66 } … … 78 73 void ImagePlane::loadParams(const TiXmlElement* root) 79 74 { 80 LoadParam(root, "texture", this->material, Material, setDiffuseMap)75 LoadParam(root, "texture", &this->material, Material, setDiffuseMap) 81 76 .describe("the texture-file to load onto the ImagePlane"); 82 77 … … 102 97 void ImagePlane::setTexture(const std::string& textureFile) 103 98 { 104 this->material ->setDiffuseMap(textureFile);99 this->material.setDiffuseMap(textureFile); 105 100 } 106 101 … … 149 144 void ImagePlane::draw() const 150 145 { 151 if( !this->isVisible())152 return;153 154 146 glPushMatrix(); 155 147 156 148 glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0); 157 this->material ->select();149 this->material.select(); 158 150 159 151 glBegin(GL_TRIANGLE_STRIP); -
trunk/src/lib/graphics/render2D/image_plane.h
r7810 r7843 11 11 12 12 #include "vector.h" 13 #include "material.h" 13 14 14 15 16 class Material;17 class TiXmlElement;18 15 19 16 //! A class that enables the … … 37 34 38 35 private: 39 Material *material; //!< a material for the ImagePlane36 Material material; //!< a material for the ImagePlane 40 37 float rotationSpeed; //!< Speed of the Rotation. 41 38
Note: See TracChangeset
for help on using the changeset viewer.