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 // Original authors:
00032 /*
00033  * File: MovableText.h
00034  *
00035  * description: This create create a billboarding object that display a text.
00036  *
00037  * @author  2003 by cTh see gavocanov@rambler.ru
00038  * @update  2006 by barraq see nospam@barraquand.com
00039  */
00040 
00041 #ifndef OGRE_TOOLS_MOVABLE_TEXT_H
00042 #define OGRE_TOOLS_MOVABLE_TEXT_H
00043 
00044 #include <OGRE/OgreMovableObject.h>
00045 #include <OGRE/OgreRenderable.h>
00046 #include <OGRE/OgreVector3.h>
00047 #include <OGRE/OgreQuaternion.h>
00048 
00049 namespace Ogre
00050 {
00051 class RenderQueue;
00052 class Camera;
00053 }
00054 
00055 namespace ogre_tools
00056 {
00057 
00058 class MovableText : public Ogre::MovableObject, public Ogre::Renderable
00059 {
00060   /******************************** MovableText data ****************************/
00061 public:
00062   enum HorizontalAlignment
00063   {
00064     H_LEFT, H_CENTER
00065   };
00066   enum VerticalAlignment
00067   {
00068     V_BELOW, V_ABOVE, V_CENTER
00069   };
00070 
00071 protected:
00072   Ogre::String mFontName;
00073   Ogre::String mType;
00074   Ogre::String mName;
00075   Ogre::String mCaption;
00076   HorizontalAlignment mHorizontalAlignment;
00077   VerticalAlignment mVerticalAlignment;
00078 
00079   Ogre::ColourValue mColor;
00080   Ogre::RenderOperation mRenderOp;
00081   Ogre::AxisAlignedBox mAABB;
00082   Ogre::LightList mLList;
00083 
00084   Ogre::Real mCharHeight;
00085   Ogre::Real mLineSpacing;
00086   Ogre::Real mSpaceWidth;
00087 
00088   bool mNeedUpdate;
00089   bool mUpdateColors;
00090   bool mOnTop;
00091 
00092   Ogre::Real mTimeUntilNextToggle;
00093   Ogre::Real mRadius;
00094 
00095   Ogre::Vector3 mGlobalTranslation;
00096   Ogre::Vector3 mLocalTranslation;
00097 
00098   Ogre::Camera *mpCam;
00099   Ogre::RenderWindow *mpWin;
00100   Ogre::Font *mpFont;
00101   Ogre::MaterialPtr mpMaterial;
00102   Ogre::MaterialPtr mpBackgroundMaterial;
00103 
00104   /******************************** public methods ******************************/
00105 public:
00106   MovableText(const Ogre::String &caption, const Ogre::String &fontName = "Arial", Ogre::Real charHeight = 1.0,
00107       const Ogre::ColourValue &color = Ogre::ColourValue::White);
00108   virtual ~MovableText();
00109 
00110 #if (OGRE_VERSION_MAJOR >= 1 && OGRE_VERSION_MINOR >= 6)
00111   virtual void visitRenderables(Ogre::Renderable::Visitor* visitor, bool debugRenderables = false);
00112 #endif
00113 
00114   // Set settings
00115   void setFontName(const Ogre::String &fontName);
00116   void setCaption(const Ogre::String &caption);
00117   void setColor(const Ogre::ColourValue &color);
00118   void setCharacterHeight(Ogre::Real height);
00119   void setLineSpacing(Ogre::Real height);
00120   void setSpaceWidth(Ogre::Real width);
00121   void setTextAlignment(const HorizontalAlignment& horizontalAlignment,
00122       const VerticalAlignment& verticalAlignment);
00123   void setGlobalTranslation(Ogre::Vector3 trans);
00124   void setLocalTranslation(Ogre::Vector3 trans);
00125   void showOnTop(bool show = true);
00126 
00127   // Get settings
00128   const Ogre::String &getFontName() const
00129   {
00130     return mFontName;
00131   }
00132   const Ogre::String &getCaption() const
00133   {
00134     return mCaption;
00135   }
00136   const Ogre::ColourValue &getColor() const
00137   {
00138     return mColor;
00139   }
00140 
00141   Ogre::Real getCharacterHeight() const
00142   {
00143     return mCharHeight;
00144   }
00145   Ogre::Real getSpaceWidth() const
00146   {
00147     return mSpaceWidth;
00148   }
00149   Ogre::Vector3 getGlobalTranslation() const
00150   {
00151     return mGlobalTranslation;
00152   }
00153   Ogre::Vector3 getLocalTranslation() const
00154   {
00155     return mLocalTranslation;
00156   }
00157   bool getShowOnTop() const
00158   {
00159     return mOnTop;
00160   }
00161   Ogre::AxisAlignedBox GetAABB(void)
00162   {
00163     return mAABB;
00164   }
00165 
00166   const Ogre::MaterialPtr &getMaterial(void) const
00167   {
00168     assert(!mpMaterial.isNull());
00169     return mpMaterial;
00170   }
00171   ;
00172 
00173 
00174   /******************************** protected methods and overload **************/
00175 protected:
00176 
00177   // from MovableText, create the object
00178   void _setupGeometry();
00179   void _updateColors();
00180 
00181   // from Ogre::MovableObject
00182   void getWorldTransforms(Ogre::Matrix4 *xform) const;
00183   Ogre::Real getBoundingRadius(void) const
00184   {
00185     return mRadius;
00186   }
00187   ;
00188   Ogre::Real getSquaredViewDepth(const Ogre::Camera *cam) const
00189   {
00190     return 0;
00191   }
00192   ;
00193   const Ogre::Quaternion &getWorldOrientation(void) const;
00194   const Ogre::Vector3 &getWorldPosition(void) const;
00195   const Ogre::AxisAlignedBox &getBoundingBox(void) const
00196   {
00197     return mAABB;
00198   }
00199   ;
00200   const Ogre::String &getName(void) const
00201   {
00202     return mName;
00203   }
00204   ;
00205   const Ogre::String &getMovableType(void) const
00206   {
00207     static Ogre::String movType = "MovableText";
00208     return movType;
00209   }
00210   ;
00211 
00212   void _notifyCurrentCamera(Ogre::Camera *cam);
00213   void _updateRenderQueue(Ogre::RenderQueue* queue);
00214 
00215   // from renderable
00216   void getRenderOperation(Ogre::RenderOperation &op);
00217   const Ogre::LightList &getLights(void) const
00218   {
00219     return mLList;
00220   }
00221   ;
00222 };
00223 
00224 }
00225 
00226 #endif


ogre_tools_qt
Author(s): Josh Faust
autogenerated on Fri Dec 6 2013 20:56:42