movable_text.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2008, Willow Garage, Inc.
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are met:
00007  *
00008  *     * Redistributions of source code must retain the above copyright
00009  *       notice, this list of conditions and the following disclaimer.
00010  *     * Redistributions in binary form must reproduce the above copyright
00011  *       notice, this list of conditions and the following disclaimer in the
00012  *       documentation and/or other materials provided with the distribution.
00013  *     * Neither the name of the Willow Garage, Inc. nor the names of its
00014  *       contributors may be used to endorse or promote products derived from
00015  *       this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00021  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027  * POSSIBILITY OF SUCH DAMAGE.
00028  */
00029 
00030 // Adapted from: http://www.ogre3d.org/wiki/index.php/MovableText
00031 //          now: http://www.ogre3d.org/tikiwiki/tiki-index.php?page=MovableText
00032 // Original authors:
00033 /*
00034  * File: MovableText.h
00035  *
00036  * description: This create create a billboarding object that display a text.
00037  *
00038  * @author  2003 by cTh see gavocanov@rambler.ru
00039  * @update  2006 by barraq see nospam@barraquand.com
00040  */
00041 
00042 #ifndef OGRE_TOOLS_MOVABLE_TEXT_H
00043 #define OGRE_TOOLS_MOVABLE_TEXT_H
00044 
00045 #include <OgreMovableObject.h>
00046 #include <OgreRenderable.h>
00047 #include <OgreVector3.h>
00048 #include <OgreQuaternion.h>
00049 #include <OgreSharedPtr.h>
00050 
00051 
00052 namespace Ogre
00053 {
00054 class RenderQueue;
00055 class Camera;
00056 class Font;
00057 }
00058 
00059 namespace rviz
00060 {
00061 
00062 class MovableText : public Ogre::MovableObject, public Ogre::Renderable
00063 {
00064   /******************************** MovableText data ****************************/
00065 public:
00066   enum HorizontalAlignment
00067   {
00068     H_LEFT, H_CENTER
00069   };
00070   enum VerticalAlignment
00071   {
00072     V_BELOW, V_ABOVE, V_CENTER
00073   };
00074 
00075 protected:
00076   Ogre::String mFontName;
00077   Ogre::String mType;
00078   Ogre::String mName;
00079   Ogre::String mCaption;
00080   HorizontalAlignment mHorizontalAlignment;
00081   VerticalAlignment mVerticalAlignment;
00082 
00083   Ogre::ColourValue mColor;
00084   Ogre::RenderOperation mRenderOp;
00085   Ogre::AxisAlignedBox mAABB;
00086   Ogre::LightList mLList;
00087 
00088   Ogre::Real mCharHeight;
00089   Ogre::Real mLineSpacing;
00090   Ogre::Real mSpaceWidth;
00091 
00092   bool mNeedUpdate;
00093   bool mUpdateColors;
00094   bool mOnTop;
00095 
00096   Ogre::Real mTimeUntilNextToggle;
00097   Ogre::Real mRadius;
00098 
00099   Ogre::Vector3 mGlobalTranslation;
00100   Ogre::Vector3 mLocalTranslation;
00101 
00102   Ogre::Camera *mpCam;
00103   Ogre::RenderWindow *mpWin;
00104   Ogre::Font *mpFont;
00105   Ogre::MaterialPtr mpMaterial;
00106   Ogre::MaterialPtr mpBackgroundMaterial;
00107 
00108   /******************************** public methods ******************************/
00109 public:
00110   MovableText(
00111     const Ogre::String &caption,
00112     const Ogre::String &fontName = "Liberation Sans",
00113     Ogre::Real charHeight = 1.0,
00114     const Ogre::ColourValue &color = Ogre::ColourValue::White);
00115   virtual ~MovableText();
00116 
00117 #if (OGRE_VERSION_MAJOR >= 1 && OGRE_VERSION_MINOR >= 6)
00118   virtual void visitRenderables(Ogre::Renderable::Visitor* visitor, bool debugRenderables = false);
00119 #endif
00120 
00121   // Set settings
00122   void setFontName(const Ogre::String &fontName);
00123   void setCaption(const Ogre::String &caption);
00124   void setColor(const Ogre::ColourValue &color);
00125   void setCharacterHeight(Ogre::Real height);
00126   void setLineSpacing(Ogre::Real height);
00127   void setSpaceWidth(Ogre::Real width);
00128   void setTextAlignment(const HorizontalAlignment& horizontalAlignment,
00129       const VerticalAlignment& verticalAlignment);
00130   void setGlobalTranslation(Ogre::Vector3 trans);
00131   void setLocalTranslation(Ogre::Vector3 trans);
00132   void showOnTop(bool show = true);
00133 
00134   // Get settings
00135   const Ogre::String &getFontName() const
00136   {
00137     return mFontName;
00138   }
00139   const Ogre::String &getCaption() const
00140   {
00141     return mCaption;
00142   }
00143   const Ogre::ColourValue &getColor() const
00144   {
00145     return mColor;
00146   }
00147 
00148   Ogre::Real getCharacterHeight() const
00149   {
00150     return mCharHeight;
00151   }
00152   Ogre::Real getSpaceWidth() const
00153   {
00154     return mSpaceWidth;
00155   }
00156   Ogre::Vector3 getGlobalTranslation() const
00157   {
00158     return mGlobalTranslation;
00159   }
00160   Ogre::Vector3 getLocalTranslation() const
00161   {
00162     return mLocalTranslation;
00163   }
00164   bool getShowOnTop() const
00165   {
00166     return mOnTop;
00167   }
00168   Ogre::AxisAlignedBox GetAABB(void)
00169   {
00170     return mAABB;
00171   }
00172 
00173   const Ogre::MaterialPtr &getMaterial(void) const
00174   {
00175     assert(!mpMaterial.isNull());
00176     return mpMaterial;
00177   }
00178   ;
00179 
00180 
00181   /******************************** protected methods and overload **************/
00182 protected:
00183 
00184   // from MovableText, create the object
00185   void _setupGeometry();
00186   void _updateColors();
00187 
00188   // from Ogre::MovableObject
00189   void getWorldTransforms(Ogre::Matrix4 *xform) const;
00190   Ogre::Real getBoundingRadius(void) const
00191   {
00192     return mRadius;
00193   }
00194   ;
00195   Ogre::Real getSquaredViewDepth(const Ogre::Camera *cam) const
00196   {
00197     return 0;
00198   }
00199   ;
00200   const Ogre::Quaternion &getWorldOrientation(void) const;
00201   const Ogre::Vector3 &getWorldPosition(void) const;
00202   const Ogre::AxisAlignedBox &getBoundingBox(void) const
00203   {
00204     return mAABB;
00205   }
00206   ;
00207   const Ogre::String &getName(void) const
00208   {
00209     return mName;
00210   }
00211   ;
00212   const Ogre::String &getMovableType(void) const
00213   {
00214     static Ogre::String movType = "MovableText";
00215     return movType;
00216   }
00217   ;
00218 
00219   void _notifyCurrentCamera(Ogre::Camera *cam);
00220   void _updateRenderQueue(Ogre::RenderQueue* queue);
00221 
00222   // from renderable
00223   void getRenderOperation(Ogre::RenderOperation &op);
00224   const Ogre::LightList &getLights(void) const
00225   {
00226     return mLList;
00227   }
00228   ;
00229 };
00230 
00231 }
00232 
00233 #endif


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Tue Oct 3 2017 03:19:31