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 156 2007-11-26 20:26:57Z natepak $
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(const std::string &name, 
00045                       const Ogre::UTFString &text, 
00046                       const std::string fontName = "Arial", 
00047                       float charHeight = 1.0,
00048                       const Ogre::ColourValue &color = Ogre::ColourValue::White);
00050   public: virtual ~MovableText();
00051 
00053   public: void SetFontName(const std::string &font);
00054           
00056   public: const std::string &GetFont() const;
00057 
00059   public: void SetText(const Ogre::UTFString & caption);
00060 
00062   public: const Ogre::UTFString & GetText() const;
00063 
00065   public: void SetColor(const Ogre::ColourValue & color);
00066 
00068   public: const Ogre::ColourValue & GetColor() const; 
00069 
00071   public: void SetCharHeight(float height);
00072 
00074   public: float GetCharHeight() const;
00075 
00077   public:void SetSpaceWidth(float width);
00078 
00080   public: float GetSpaceWidth() const;
00081 
00083   public: void SetTextAlignment(const HorizAlign &hAlign, 
00084                                 const VertAlign &vAlign); 
00085 
00087   public: void SetBaseline(float height);
00088 
00090   public: float GetBaseline() const;
00091 
00093   public: void SetShowOnTop(bool show);
00094 
00096   public: bool GetShowOnTop() const;
00097 
00099   public: Ogre::AxisAlignedBox GetAABB();
00100 
00102   protected: void _setupGeometry();
00103 
00105   protected: void _updateColors();
00106 
00108   protected: void getWorldTransforms(Ogre::Matrix4 *xform) const;
00109 
00111   protected: float getBoundingRadius() const;
00112 
00114   protected: float getSquaredViewDepth(const Ogre::Camera *cam) const;
00115 
00116   private: float viewportAspectCoef;
00117 
00118   private: std::string fontName;
00119   private: Ogre::UTFString text;
00120 
00121   private: HorizAlign horizAlign;
00122   private: VertAlign vertAlign;
00123 
00124   private: Ogre::ColourValue color;
00125   private: Ogre::RenderOperation renderOp;
00126   private: Ogre::AxisAlignedBox aabb;
00127   private: Ogre::LightList lightList;
00128 
00129   private: float charHeight;
00130   private: float spaceWidth;
00131 
00132   private: bool needUpdate;
00133   private: bool updateColors;
00134   private: bool onTop;
00135 
00136   private: float radius;
00137   private: float baseline;
00138 
00139   private: Ogre::Camera *camera;
00140   private: Ogre::RenderWindow *renderWindow;
00141   private: Ogre::Font *font;
00142   private: Ogre::MaterialPtr material;
00143   private: Ogre::MaterialPtr backgroundMaterial;
00144 
00145   private: const Ogre::Quaternion &getWorldOrientation(void) const;
00146   private: const Ogre::Vector3 &getWorldPosition(void) const;
00147   private: const Ogre::AxisAlignedBox &getBoundingBox(void) const;
00148 
00149   private: const Ogre::String &getMovableType() const;
00150 
00151   private: void _notifyCurrentCamera(Ogre::Camera *cam);
00152   private: void _updateRenderQueue(Ogre::RenderQueue* queue);
00153 
00155   protected: void getRenderOperation(Ogre::RenderOperation &op);
00156 
00158   protected: const Ogre::MaterialPtr &getMaterial(void) const;
00159 
00161   protected: const Ogre::LightList &getLights(void) const; //{return mLList;}; 
00162 
00163 };
00164 
00165 #endif

Last updated Aug 04 2007