lugre_gfx2D.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef LUGRE_GFX2D_H
00025 #define LUGRE_GFX2D_H
00026
00027 #include <list>
00028 #include <OgrePrerequisites.h>
00029 #include <OgreVector2.h>
00030 #include <OgreVector3.h>
00031 #include <OgreQuaternion.h>
00032 #include "lugre_gfx3D.h"
00033 #include "lugre_listener.h"
00034
00035 using Ogre::Vector2;
00036 using Ogre::Vector3;
00037 using Ogre::Quaternion;
00038 using Ogre::Real;
00039
00040 class lua_State;
00041
00042
00043 namespace Ogre {
00044 class PanelOverlayElement;
00045 class TextAreaOverlayElement;
00046 };
00047
00048 namespace Lugre {
00049
00050 class cGfx3D;
00051 class cCompassOverlay;
00052 class cColourClipPaneOverlay;
00053 class cColourClipTextOverlay;
00054 class cBorderColourClipPaneOverlay;
00055 class cSortedOverlayContainer;
00056 class cRobRenderableOverlay;
00057
00058
00060 class cGfx2D : public cSmartPointable { public :
00061 static unsigned int miCount;
00062
00063 enum {
00064 kGfx2DAlign_Left,
00065 kGfx2DAlign_Top,
00066 kGfx2DAlign_Right,
00067 kGfx2DAlign_Bottom,
00068 kGfx2DAlign_Center,
00070 };
00071
00072 cGfx2D (Ogre::Overlay* pRootOverlay=0,cGfx2D* pDefaultParent=0);
00073 virtual ~cGfx2D ();
00074 void Init ();
00075 void Clear ();
00076
00077 static std::string GetUniqueName ();
00078
00079 static Ogre::Overlay* CreateOverlay (const char* szName,const size_t iZOrder);
00080 static void DestroyOverlay (Ogre::Overlay* pOverlay);
00081
00083 Ogre::Overlay* mpRootOverlay;
00084 cGfx2D* mpDefaultParent;
00085
00087 Ogre::Overlay* mpParent_Overlay;
00088 cSmartPtr<cGfx2D> mpParent_Gfx2D;
00089
00090
00091 Ogre::OverlayElement* mpOverlayElement;
00092 Ogre::OverlayContainer* mpOverlayContainer;
00093
00094
00095 Ogre::PanelOverlayElement* mpPanel;
00096 cColourClipPaneOverlay* mpCCPO;
00097 cColourClipTextOverlay* mpCCTO;
00098 cBorderColourClipPaneOverlay* mpBCCPO;
00099 cSortedOverlayContainer* mpSOC;
00100 cRobRenderableOverlay* mpRROC;
00101 cCompassOverlay* mpCompass;
00102 Ogre::TextAreaOverlayElement* mpText;
00103
00104
00105
00106
00107 cSmartPtr<cGfx3D> mpTrackPosTarget;
00108 Vector2 mvTrackPosOffset;
00109 Vector2 mvTrackPosTargetSizeFactor;
00110 Vector2 mvTrackPosOwnSizeFactor;
00111 Vector2 mvTrackClampMin;
00112 Vector2 mvTrackClampMax;
00113 Vector2 mvTrackSetSizeFactor;
00114 bool mbTrackClamp;
00115 bool mbTrackHideIfClamped;
00116 bool mbTrackHideIfBehindCam;
00117 bool mbTrackClampMaxXIfBehindCam;
00118 bool mbTrackClampMaxYIfBehindCam;
00119 bool mbTrackSetSize;
00120 bool mbTrackMouse;
00121
00122 void InitPanel (cGfx2D* pParent=0);
00123 void InitCCPO (cGfx2D* pParent=0);
00124 void InitCCTO (cGfx2D* pParent=0);
00125 void InitBCCPO (cGfx2D* pParent=0);
00126 void InitSOC (cGfx2D* pParent=0);
00127 void InitRROC (cGfx2D* pParent=0);
00128 void InitText (cGfx2D* pParent=0);
00129 void InitBase (Ogre::OverlayElement* pOverlayElement,cGfx2D* pParent=0);
00130 void InitCompass (cGfx2D* pParent=0);
00131
00132 void SetPrepareFrameStep (const bool bOn);
00133 void SetVisible (const bool bVisible);
00134 bool GetVisible ();
00135 void SetMaterial (const char* szMat);
00136 void SetBorderMaterial (const char* szMat);
00137 void SetPos (const Ogre::Real x,const Ogre::Real y);
00138 void SetDimensions (const Ogre::Real cx,const Ogre::Real cy);
00139 void SetAlignment (const size_t iHAlign,const size_t iVAlign);
00140 void SetTextAlignment (const size_t iTextAlign);
00141 void SetUV (const Ogre::Real u1, const Ogre::Real v1, const Ogre::Real u2, const Ogre::Real v2);
00142 void SetPartUV (const int iPart,const Ogre::Real u1, const Ogre::Real v1, const Ogre::Real u2, const Ogre::Real v2);
00143 void SetClip (const Ogre::Real fCL,const Ogre::Real fCT,const Ogre::Real fCW,const Ogre::Real fCH);
00144 void SetBorder (const Ogre::Real l,const Ogre::Real t,const Ogre::Real r,const Ogre::Real b);
00145 void SetCharHeight (const Ogre::Real fHeight);
00146 void SetFont (const char* szFont);
00147 void SetText (const char* szText);
00148 void SetAutoWrap (const int iMaxW);
00149 void SetColour (const Ogre::ColourValue& col);
00150 void SetColours (const Ogre::ColourValue& colLT,const Ogre::ColourValue& colRT,const Ogre::ColourValue& colLB,const Ogre::ColourValue& colRB);
00151 void SetPartColours (const int iPart,const Ogre::ColourValue& colLT,const Ogre::ColourValue& colRT,const Ogre::ColourValue& colLB,const Ogre::ColourValue& colRB);
00152 void SetRotate (const Ogre::Real radians);
00153
00154 Ogre::Real GetLeft ();
00155 Ogre::Real GetTop ();
00156 Ogre::Real GetDerivedLeft ();
00157 Ogre::Real GetDerivedTop ();
00158 Ogre::Real GetWidth ();
00159 Ogre::Real GetHeight ();
00160
00161 bool IsPointWithin (const size_t x,const size_t y);
00162
00163 void GetTextBounds (Ogre::Real& w,Ogre::Real& h);
00164 int GetGlyphAtPos (const size_t x,const size_t y);
00165 void GetGlyphBounds (const size_t iIndex,Ogre::Real& l,Ogre::Real& t,Ogre::Real& r,Ogre::Real& b);
00166
00167
00168 static void LuaRegister (lua_State *L);
00169
00170 private:
00171
00172 static std::list<cGfx2D*> gPrepareFrameStepper;
00173 std::list<cGfx2D*>::iterator mPrepareFrameItor;
00174 bool mbPrepareFrameStep;
00175 void PrepareFrameStep ();
00176
00177 public:
00178
00179 static void PrepareFrame ();
00180 };
00181
00182 };
00183
00184 #endif