Changeset 4847 in orxonox.OLD for orxonox/trunk/src/lib/graphics/render2D/element_2d.cc
- Timestamp:
- Jul 13, 2005, 6:25:44 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/graphics/render2D/element_2d.cc
r4843 r4847 31 31 Element2D::Element2D () 32 32 { 33 this->setClassID(CL_ELEMENT_2D, "Element2D"); 34 35 Render2D::getInstance()->registerElement2D(this); 33 this->init(); 36 34 } 37 35 … … 46 44 47 45 46 void Element2D::init() 47 { 48 this->setClassID(CL_ELEMENT_2D, "Element2D"); 49 50 Render2D::getInstance()->registerElement2D(this); 51 52 } 53 48 54 /** 49 55 * this sets the position of the Element on the screen. 56 * Use this in the your tick function, if you want the element to be automatically positioned. 50 57 */ 51 58 void Element2D::positioning() 52 59 { 53 60 // setting the Position of this ELEM2D. 54 Vector pos;55 61 if (this->bindNode) 56 62 { 57 GLdouble x = this->bindNode->getAbsCoor().x;58 GLdouble y = this->bindNode->getAbsCoor().y;59 GLdouble z = this->bindNode->getAbsCoor().z;60 63 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]; 64 gluProject(this->bindNode->getAbsCoor().x, 65 this->bindNode->getAbsCoor().y, 66 this->bindNode->getAbsCoor().z, 67 GraphicsEngine::modMat, 68 GraphicsEngine::projMat, 69 GraphicsEngine::viewPort, 70 projectPos, 71 projectPos+1, 72 projectPos+2); 73 absPos2D.x = projectPos[0] + this->relPos2D[0]; 74 absPos2D.y = GraphicsEngine::getInstance()->getResolutionY() - projectPos[1] + this->relPos2D[1]; 75 absPos2D.depth = projectPos[2]; 65 76 } 66 77 else 67 78 { 68 pos.x = this->position2D[0];69 pos.y = this->position2D[1];70 pos.z= 0;79 absPos2D.x = this->relPos2D[0]; 80 absPos2D.y = this->relPos2D[1]; 81 absPos2D.depth = 0; 71 82 } 72 73 glPushMatrix();74 83 } 75 84 85 /** 86 * ticks the 2d-Element 87 * @param dt the time elapsed since the last tick 88 */ 89 void Element2D::tick(float dt) 90 { 91 this->positioning(); 92 }
Note: See TracChangeset
for help on using the changeset viewer.