Gazebo

MovableText.hh

00001 
00002 /*
00003  *  Gazebo - Outdoor Multi-Robot Simulator
00004  *  Copyright (C) 2003  
00005  *     Nate Koenig & Andrew Howard
00006  *
00007  *  This program is free software; you can redistribute it and/or modify
00008  *  it under the terms of the GNU General Public License as published by
00009  *  the Free Software Foundation; either version 2 of the License, or
00010  *  (at your option) any later version.
00011  *
00012  *  This program is distributed in the hope that it will be useful,
00013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *  GNU General Public License for more details.
00016  *
00017  *  You should have received a copy of the GNU General Public License
00018  *  along with this program; if not, write to the Free Software
00019  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020  *
00021  */
00022 /* Desc: Middleman between OGRE and Gazebo
00023  * Author: indepedentCreations@gmail.com
00024  * Date: 13 Feb 2006
00025  * CVS: $Id: MovableText.hh 240 2008-01-25 06:10:28Z robotos $
00026  */
00027 
00028 #ifndef MOVABLETEXT_HH
00029 #define MOVABLETEXT_HH
00030 
00031 #include <Ogre.h>
00032 #include <string>
00033 
00035 class MovableText : public Ogre::MovableObject, public Ogre::Renderable
00036 {
00038   public: enum HorizAlign {H_LEFT, H_CENTER};
00039 
00041   public: enum VertAlign  {V_BELOW, V_ABOVE};
00042 
00044   public: MovableText();
00045 
00047   public: virtual ~MovableText();
00048 
00050   public: void Load(const std::string &name, 
00051                       const Ogre::UTFString &text, 
00052                       const std::string &fontName = "Arial", 
00053                       float charHeight = 1.0,
00054                       const Ogre::ColourValue &color = Ogre::ColourValue::White);
00055 
00057   public: void SetFontName(const std::string &font);
00058           
00060   public: const std::string &GetFont() const;
00061 
00063   public: void SetText(const Ogre::UTFString & caption);
00064 
00066   public: const Ogre::UTFString & GetText() const;
00067 
00069   public: void SetColor(const Ogre::ColourValue & color);
00070 
00072   public: const Ogre::ColourValue & GetColor() const; 
00073 
00075   public: void SetCharHeight(float height);
00076 
00078   public: float GetCharHeight() const;
00079 
00081   public:void SetSpaceWidth(float width);
00082 
00084   public: float GetSpaceWidth() const;
00085 
00087   public: void SetTextAlignment(const HorizAlign &hAlign, 
00088                                 const VertAlign &vAlign); 
00089 
00091   public: void SetBaseline(float height);
00092 
00094   public: float GetBaseline() const;
00095 
00097   public: void SetShowOnTop(bool show);
00098 
00100   public: bool GetShowOnTop() const;
00101 
00103   public: Ogre::AxisAlignedBox GetAABB();
00104 
00106   protected: void _setupGeometry();
00107 
00109   protected: void _updateColors();
00110 
00112   protected: void getWorldTransforms(Ogre::Matrix4 *xform) const;
00113 
00115   protected: float getBoundingRadius() const;
00116 
00118   protected: float getSquaredViewDepth(const Ogre::Camera *cam) const;
00119 
00120   private: float viewportAspectCoef;
00121 
00122   private: std::string fontName;
00123   private: Ogre::UTFString text;
00124 
00125   private: HorizAlign horizAlign;
00126   private: VertAlign vertAlign;
00127 
00128   private: Ogre::ColourValue color;
00129   private: Ogre::RenderOperation renderOp;
00130   private: Ogre::AxisAlignedBox aabb;
00131   private: Ogre::LightList lightList;
00132 
00133   private: float charHeight;
00134   private: float spaceWidth;
00135 
00136   private: bool needUpdate;
00137   private: bool updateColors;
00138   private: bool onTop;
00139 
00140   private: float radius;
00141   private: float baseline;
00142 
00143   private: Ogre::Camera *camera;
00144   private: Ogre::RenderWindow *renderWindow;
00145   private: Ogre::Font *font;
00146   private: Ogre::MaterialPtr material;
00147   private: Ogre::MaterialPtr backgroundMaterial;
00148 
00149   private: const Ogre::Quaternion &getWorldOrientation(void) const;
00150   private: const Ogre::Vector3 &getWorldPosition(void) const;
00151   private: const Ogre::AxisAlignedBox &getBoundingBox(void) const;
00152 
00153   private: const Ogre::String &getMovableType() const;
00154 
00155   private: void _notifyCurrentCamera(Ogre::Camera *cam);
00156   private: void _updateRenderQueue(Ogre::RenderQueue* queue);
00157 
00159   protected: void getRenderOperation(Ogre::RenderOperation &op);
00160 
00162   protected: const Ogre::MaterialPtr &getMaterial(void) const;
00163 
00165   protected: const Ogre::LightList &getLights(void) const; //{return mLList;}; 
00166 
00167 };
00168 
00169 #endif

Last updated Aug 04 2007