Changeset 7019 in orxonox.OLD for trunk/src/world_entities
- Timestamp:
- Feb 3, 2006, 4:33:45 PM (19 years ago)
- Location:
- trunk/src/world_entities
- Files:
-
- 1 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/Makefile.am
r7016 r7019 63 63 world_entities/environments/model_entity.cc \ 64 64 \ 65 world_entities/elements/image_entity.cc 65 world_entities/elements/image_entity.cc \ 66 world_entities/elements/text_element.cc 66 67 67 68 -
trunk/src/world_entities/elements/text_element.cc
r7016 r7019 16 16 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON 17 17 18 #include " image_entity.h"18 #include "text_element.h" 19 19 20 20 #include "load_param.h" … … 22 22 23 23 #include "graphics_engine.h" 24 #include "material.h"25 #include "glincl.h"26 24 #include "state.h" 27 25 … … 30 28 31 29 32 CREATE_FACTORY( ImageEntity, CL_IMAGE_ENTITY);30 CREATE_FACTORY(TextElement, CL_TEXT_ELEMENT); 33 31 34 32 … … 36 34 * standart constructor 37 35 */ 38 ImageEntity::ImageEntity(const TiXmlElement* root)36 TextElement::TextElement (const TiXmlElement* root) 39 37 { 40 this->init(); 38 this->setClassID(CL_TEXT_ELEMENT, "TextElement"); 39 this->setName("TextElement"); 40 41 this->setLayer(E2D_LAYER_TOP); 42 this->setSize(GraphicsEngine::getInstance()->getResolutionX()/10.0); 43 44 this->setSize(20); 45 this->setFont("fonts/earth.ttf"); 46 41 47 if(root != NULL) 42 48 this->loadParams(root); … … 45 51 46 52 /** 47 * destroys a ImageEntity53 * destroys a TextElement 48 54 */ 49 ImageEntity::~ImageEntity()55 TextElement::~TextElement () 50 56 { 51 if (this->material)52 delete this->material;53 57 } 54 58 55 59 56 /** 57 * initializes the ImageEntity 58 */ 59 void ImageEntity::init() 60 void TextElement::loadParams(const TiXmlElement* root) 60 61 { 61 this->setClassID(CL_IMAGE_ENTITY, "ImageEntity"); 62 this->setName("ImageEntity"); 62 Element2D::loadParams(root); 63 63 64 this->setLayer(E2D_LAYER_TOP); 65 this->setRotationSpeed(5); 66 this->setSize(GraphicsEngine::getInstance()->getResolutionX()/10.0, GraphicsEngine::getInstance()->getResolutionY()/10.0); 64 LoadParam(root, "size", this, Text, setSize); 67 65 68 this->setBindNode(this); 69 this->material = new Material; 70 this->setTexture("pictures/error_texture.png"); 71 this->bBillboarding = false; 66 LoadParam(root, "text", this, TextElement, setText); 67 68 LoadParam(root, "font", this, TextElement, setFont); 72 69 } 73 70 74 75 void ImageEntity::loadParams(const TiXmlElement* root) 71 void TextElement::setText(const char* text) 76 72 { 77 PNode::loadParams(root); 78 Element2D::loadParams(root); 79 80 LoadParam(root, "texture", this, ImageEntity, setTexture) 81 .describe("the texture-file to load onto the ImageEntity"); 82 83 LoadParam(root, "size", this, ImageEntity, setSize) 84 .describe("the size of the ImageEntity in Pixels"); 85 86 LoadParam(root, "rotation-speed", this, ImageEntity, setRotationSpeed) 87 .describe("the Speed with which the ImageEntity should rotate"); 88 89 LoadParam(root, "billboarding", this, ImageEntity, toggleBillboarding) 90 .describe("sets the Billboard to always look in the direction of the Player"); 73 Text::setText(text); 91 74 } 92 75 93 94 /** 95 * sets the size of the ImageEntity. 96 * @param size the size in pixels 97 */ 98 void ImageEntity::setSize(float sizeX, float sizeY) 76 void TextElement::setFont(const char* font) 99 77 { 100 this->setSize2D(sizeX, sizeY);78 Text::setFont(font, (unsigned int)this->getSizeY2D()); 101 79 } 102 103 104 /**105 * sets the material to load106 * @param textureFile The texture-file to load onto the crosshair107 */108 void ImageEntity::setTexture(const char* textureFile)109 {110 this->material->setDiffuseMap(textureFile);111 }112 113 114 /** this turns on/off the billboarding of this WorldEntity115 *116 * This means that the image will always look in the direction of the Player117 */118 void ImageEntity::toggleBillboarding()119 {120 this->bBillboarding = !this->bBillboarding;121 }122 123 124 /**125 * ticks the ImageEntity126 * @param dt the time to ticks127 */128 void ImageEntity::tick(float dt)129 {130 131 }132 133 134 /**135 * draws the crosshair136 */137 void ImageEntity::draw() const138 {139 if( !this->isVisible())140 return;141 142 glPushMatrix();143 glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0);144 145 //glRotatef(this->getAbsDir2D(), 0,0,1);146 this->material->select();147 glBegin(GL_TRIANGLE_STRIP);148 glTexCoord2f(0, 0);149 glVertex2f(-this->getSizeX2D(), -this->getSizeY2D());150 glTexCoord2f(1, 0);151 glVertex2f(this->getSizeX2D(), -this->getSizeY2D());152 glTexCoord2f(0, 1);153 glVertex2f(-this->getSizeX2D(), this->getSizeY2D());154 glTexCoord2f(1, 1);155 glVertex2f(this->getSizeX2D(), this->getSizeY2D());156 glEnd();157 glPopMatrix();158 159 } -
trunk/src/world_entities/elements/text_element.h
r7016 r7019 1 1 /*! 2 * @file image_entity.h3 * Definition of an ImageEntity2 * @file text_element.h 3 * Definition of an TextElement 4 4 */ 5 5 6 #ifndef _ IMAGE_ENTITY_H7 #define _ IMAGE_ENTITY_H6 #ifndef _TEXT_ELEMENT_H 7 #define _TEXT_ELEMENT_H 8 8 9 9 #include "p_node.h" 10 #include " element_2d.h"10 #include "text.h" 11 11 #include "event_listener.h" 12 12 … … 20 20 21 21 //! A class that enables the 22 class ImageEntity : public PNode, public Element2D{22 class TextElement : public Text { 23 23 24 24 public: 25 ImageEntity(const TiXmlElement* root = NULL);26 virtual ~ ImageEntity();25 TextElement(const TiXmlElement* root = NULL); 26 virtual ~TextElement(); 27 27 28 28 void init(); 29 29 virtual void loadParams(const TiXmlElement* root); 30 30 31 void setSize(float sizeX, float sizeY); 32 void setTexture(const char* textureFile); 33 /** @param rotationSpeed the speed at what the crosshair should rotate */ 34 void setRotationSpeed(float rotationSpeed) { this->rotationSpeed = rotationSpeed; }; 35 void toggleBillboarding(); 36 37 virtual void tick(float dt); 38 virtual void draw() const; 31 void setText(const char* text); 32 void setFont(const char* font); 39 33 40 34 private: 41 Material* material; //!< a material for the Aim. 42 float rotationSpeed; //!< Speed of the Rotation. 43 bool bBillboarding; //!< true if billboarding is on 35 44 36 }; 45 37 46 #endif /* _ IMAGE_ENTITY_H */38 #endif /* _TEXT_ELEMENT_H */
Note: See TracChangeset
for help on using the changeset viewer.