Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/elements/image_entity.cc @ 7730

Last change on this file since 7730 was 7730, checked in by bensch, 18 years ago

orxonox/trunk: testing if it works on WIndows like this

File size: 3.3 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   ### File Specific:
12   main-programmer: Patrick Boenzli
13   co-programmer: ...
14*/
15
16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON
17
18#include "image_entity.h"
19
20#include "util/loading/load_param.h"
21#include "util/loading/factory.h"
22
23#include "graphics_engine.h"
24#include "material.h"
25#include "glincl.h"
26#include "state.h"
27
28
29using namespace std;
30
31
32CREATE_FACTORY(ImageEntity, CL_IMAGE_ENTITY);
33
34
35/**
36 * standart constructor
37 */
38ImageEntity::ImageEntity (const TiXmlElement* root)
39{
40  this->init();
41  if(root != NULL)
42    this->loadParams(root);
43}
44
45
46/**
47 * destroys a ImageEntity
48*/
49ImageEntity::~ImageEntity ()
50{
51}
52
53/**
54 * initializes the ImageEntity
55 */
56void ImageEntity::init()
57{
58  this->setClassID(CL_IMAGE_ENTITY, "ImageEntity");
59  this->setName("ImageEntity");
60
61  this->setLayer(E2D_LAYER_TOP);
62  this->setRotationSpeed(5);
63  this->setSize(GraphicsEngine::getInstance()->getResolutionX()/10.0, GraphicsEngine::getInstance()->getResolutionY()/10.0);
64
65  this->setBindNode(this);
66  //this->setTexture("pictures/error_texture.png");
67  this->bBillboarding = false;
68}
69
70
71void ImageEntity::loadParams(const TiXmlElement* root)
72{
73  PNode::loadParams(root);
74  Element2D::loadParams(root);
75
76//   LoadParam(root, "texture", this, ImageEntity, setTexture)
77//       .describe("the texture-file to load onto the ImageEntity");
78
79  LoadParam(root, "size", this, ImageEntity, setSize)
80      .describe("the size of the ImageEntity in Pixels");
81
82  LoadParam(root, "rotation-speed", this, ImageEntity, setRotationSpeed)
83      .describe("the Speed with which the ImageEntity should rotate");
84
85  LoadParam(root, "billboarding", this, ImageEntity, toggleBillboarding)
86      .describe("sets the Billboard to always look in the direction of the Player");
87}
88
89
90/**
91 * sets the size of the ImageEntity.
92 * @param size the size in pixels
93 */
94void ImageEntity::setSize(float sizeX, float sizeY)
95{
96  this->setSize2D(sizeX, sizeY);
97}
98
99
100/**
101 * sets the material to load
102 * @param textureFile The texture-file to load onto the crosshair
103 */
104void ImageEntity::setTexture(const std::string& textureFile)
105{
106 //   this->material.setDiffuseMap(textureFile);
107}
108
109
110/** this turns on/off the billboarding of this WorldEntity
111 *
112 * This means that the image will always look in the direction of the Player
113 */
114void ImageEntity::toggleBillboarding()
115{
116  this->bBillboarding = !this->bBillboarding;
117}
118
119
120/**
121 * ticks the ImageEntity
122 * @param dt the time to ticks
123 */
124void ImageEntity::tick(float dt)
125{
126
127}
128
129
130/**
131 * draws the crosshair
132 */
133void ImageEntity::draw() const
134{
135  if( !this->isVisible())
136    return;
137
138  glPushMatrix();
139  glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0);
140
141  //glRotatef(this->getAbsDir2D(), 0,0,1);
142  this->material.select();
143  glBegin(GL_TRIANGLE_STRIP);
144  glTexCoord2f(0, 0);
145  glVertex2f(-this->getSizeX2D(), -this->getSizeY2D());
146  glTexCoord2f(1, 0);
147  glVertex2f(this->getSizeX2D(), -this->getSizeY2D());
148  glTexCoord2f(0, 1);
149  glVertex2f(-this->getSizeX2D(), this->getSizeY2D());
150  glTexCoord2f(1, 1);
151  glVertex2f(this->getSizeX2D(), this->getSizeY2D());
152  glEnd();
153  glPopMatrix();
154
155}
Note: See TracBrowser for help on using the repository browser.