| 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: Benjamin Grauer | 
|---|
| 13 |    co-programmer: ... | 
|---|
| 14 | */ | 
|---|
| 15 |  | 
|---|
| 16 | //#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_ | 
|---|
| 17 |  | 
|---|
| 18 | #include "element_2d.h" | 
|---|
| 19 | #include "render_2d.h" | 
|---|
| 20 |  | 
|---|
| 21 | #include "graphics_engine.h" | 
|---|
| 22 | #include "p_node.h" | 
|---|
| 23 |  | 
|---|
| 24 | using namespace std; | 
|---|
| 25 |  | 
|---|
| 26 |  | 
|---|
| 27 | /** | 
|---|
| 28 |  * standard constructor | 
|---|
| 29 |  * @todo this constructor is not jet implemented - do it | 
|---|
| 30 | */ | 
|---|
| 31 | Element2D::Element2D () | 
|---|
| 32 | { | 
|---|
| 33 |    this->setClassID(CL_ELEMENT_2D, "Element2D"); | 
|---|
| 34 |  | 
|---|
| 35 |    Render2D::getInstance()->registerElement2D(this); | 
|---|
| 36 | } | 
|---|
| 37 |  | 
|---|
| 38 | /** | 
|---|
| 39 |  * standard deconstructor | 
|---|
| 40 | */ | 
|---|
| 41 | Element2D::~Element2D () | 
|---|
| 42 | { | 
|---|
| 43 |   // delete what has to be deleted here | 
|---|
| 44 |   Render2D::getInstance()->unregisterElement2D(this); | 
|---|
| 45 | } | 
|---|
| 46 |  | 
|---|
| 47 |  | 
|---|
| 48 | /** | 
|---|
| 49 |  * this sets the position of the Element on the screen. | 
|---|
| 50 |  */ | 
|---|
| 51 | void Element2D::positioning() | 
|---|
| 52 | { | 
|---|
| 53 |   // setting the Position of this ELEM2D. | 
|---|
| 54 |   Vector pos; | 
|---|
| 55 |   if (this->bindNode) | 
|---|
| 56 |   { | 
|---|
| 57 |     GLdouble x = this->bindNode->getAbsCoor().x; | 
|---|
| 58 |     GLdouble y = this->bindNode->getAbsCoor().y; | 
|---|
| 59 |     GLdouble z = this->bindNode->getAbsCoor().z; | 
|---|
| 60 |     GLdouble projectPos[3]; | 
|---|
| 61 |     gluProject(x, y, z, GraphicsEngine::modMat, GraphicsEngine::projMat, GraphicsEngine::viewPort, projectPos, projectPos+1, projectPos+2); | 
|---|
| 62 |     pos.x = projectPos[0] + this->position2D[0]; | 
|---|
| 63 |     pos.y = GraphicsEngine::getInstance()->getResolutionY() - projectPos[1] + this->position2D[1]; | 
|---|
| 64 |     pos.z = projectPos[2]; | 
|---|
| 65 |   } | 
|---|
| 66 |   else | 
|---|
| 67 |   { | 
|---|
| 68 |     pos.x = this->position2D[0]; | 
|---|
| 69 |     pos.y = this->position2D[1]; | 
|---|
| 70 |     pos.z = 0; | 
|---|
| 71 |   } | 
|---|
| 72 |  | 
|---|
| 73 |   glPushMatrix(); | 
|---|
| 74 | } | 
|---|
| 75 |  | 
|---|