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_OGREWRAPPER_H
00025 #define LUGRE_OGREWRAPPER_H
00026 #undef min
00027 #undef max
00028 #include <OgrePrerequisites.h>
00029 #include <OgreVector3.h>
00030 #include <OgreQuaternion.h>
00031 #if OGRE_VERSION < 0x10700
00032 #include <OgreUserDefinedObject.h>
00033 #endif
00035
00036 namespace Ogre {
00037 class TextAreaOverlayElement;
00038 class Skeleton;
00039 class Bone;
00040 }
00041 namespace OIS {
00042 class InputManager;
00043 class Mouse;
00044 class Keyboard;
00045 class JoyStick;
00046 }
00047
00048 namespace Lugre {
00049
00050 #if OGRE_VERSION < 0x10700
00052 class cOgreUserObjectWrapper : public Ogre::UserDefinedObject { public :
00053 Ogre::Entity* mpEntity;
00054 int miType;
00055 int miParam[4];
00056
00057 cOgreUserObjectWrapper();
00058 virtual ~cOgreUserObjectWrapper();
00059 virtual long getTypeID(void) const;
00060 virtual const Ogre::String& getTypeName(void) const;
00061 };
00062 #endif
00063
00064 class cOgreWrapper { public :
00065 Ogre::Root* mRoot;
00066 Ogre::Camera* mCamera;
00067 Ogre::Viewport* mViewport;
00068 Ogre::SceneManager* mSceneMgr;
00069 Ogre::RenderWindow* mWindow;
00070 Ogre::SceneNode* mpCamPosSceneNode;
00071 Ogre::SceneNode* mpCamHolderSceneNode;
00072
00073
00074 std::string msWindowTitle;
00075 float mfLastFPS;
00076 float mfAvgFPS;
00077 float mfBestFPS;
00078 float mfWorstFPS;
00079 unsigned long miBestFrameTime;
00080 unsigned long miWorstFrameTime;
00081 size_t miTriangleCount;
00082 size_t miBatchCount;
00083
00084
00085 OIS::InputManager* mInputManager;
00086 OIS::Mouse* mMouse;
00087 OIS::Keyboard* mKeyboard;
00088 OIS::JoyStick* mJoy;
00089
00090 cOgreWrapper();
00091
00092
00093 inline static cOgreWrapper& GetSingleton () {
00094 static cOgreWrapper* mSingleton = 0;
00095 if (!mSingleton) mSingleton = new cOgreWrapper();
00096 return *mSingleton;
00097 }
00098
00099
00100 Ogre::SceneManager* GetSceneManager (const char* szSceneMgrName="main");
00101
00102
00103 std::vector<std::string> ListRenderSystems ();
00104 void SetRenderSystemByName (std::string sRenderSysName);
00105 std::vector<std::string> ListConfigOptionNames (std::string sRenderSysName);
00106 std::vector<std::string> ListPossibleValuesForConfigOption (std::string sRenderSysName,std::string sConfigOptionName);
00107 void SetConfigOption (std::string sName,std::string sValue);
00108 std::string GetConfigOption (std::string sName);
00109
00111 bool Init (const char* szWindowTitle,const char* szOgrePluginDir,const char* szOgreBaseDir,bool bAutoCreateWindow=true);
00112 bool CreateOgreWindow (bool bConfigRestoreOrDialog=true);
00113 void RenderOneFrame ();
00114 void DeInit ();
00115 void TakeGridScreenshot (const int& pGridSize, const Ogre::String& pFileName, const Ogre::String& pFileExtention, const bool& pStitchGridImages);
00116 void TakeScreenshot (const char* szPrefix="../screenshots/");
00117
00118 void SetSkybox (const char* szMatName,const bool bFlip=false);
00119 void AttachCamera (Ogre::SceneNode* pSceneNode=0);
00120 void SetCameraPos (const Ogre::Vector3 vPos=Ogre::Vector3::ZERO);
00121 void SetCameraRot (const Ogre::Quaternion qRot=Ogre::Quaternion::IDENTITY);
00122 void CameraLookAt (const Ogre::Vector3 vPos=Ogre::Vector3::ZERO);
00123
00124
00125 static std::string GetUniqueName ();
00126 int GetViewportHeight ();
00127 int GetViewportWidth ();
00128
00129
00130 int GetEntityIndexCount (Ogre::Entity* pEntity);
00131 Ogre::Vector3 GetEntityVertex (Ogre::Entity* pEntity,const int iIndexIndex);
00132 bool RayAABBQuery (const Ogre::Vector3& vRayPos,const Ogre::Vector3& vRayDir,const Ogre::AxisAlignedBox &aabb,float* pfHitDist=0, int* pfHitFaceNormalX=0, int* pfHitFaceNormalY=0, int* pfHitFaceNormalZ=0);
00133 int RayEntityQuery (const Ogre::Vector3& vRayPos,const Ogre::Vector3& vRayDir,Ogre::Entity* pEntity,float* pfHitDist=0);
00134 int RayEntityQuery (const Ogre::Vector3& vRayPos,const Ogre::Vector3& vRayDir,Ogre::Entity* pEntity,const Ogre::Vector3& vPos,const Ogre::Quaternion& qRot,const Ogre::Vector3& vScale,float* pfHitDist=0);
00135 void RayEntityQuery (const Ogre::Vector3& vRayPos,const Ogre::Vector3& vRayDir,Ogre::Entity* pEntity,std::vector<std::pair<float,int> > &pHitList);
00136 void RayEntityQuery (const Ogre::Vector3& vRayPos,const Ogre::Vector3& vRayDir,Ogre::Entity* pEntity,const Ogre::Vector3& vPos,const Ogre::Quaternion& qRot,const Ogre::Vector3& vScale,std::vector<std::pair<float,int> > &pHitList);
00137
00138
00139 bool ProjectPos (const Ogre::Vector3& pos,Ogre::Real& x,Ogre::Real& y);
00140 bool ProjectSizeAndPos (const Ogre::Vector3& pos,Ogre::Real& x,Ogre::Real& y,const Ogre::Real rad,Ogre::Real& cx,Ogre::Real& cy);
00141 Ogre::Vector3 ProjectSizeAndPosEx (const Ogre::Vector3& pos,const Ogre::Real rad,Ogre::Vector3& vSize);
00142
00143 static Ogre::Bone* SearchBoneByName (Ogre::Skeleton& pSkeleton,const char* szBoneName);
00144
00145 static void ImageBlit (Ogre::Image& pImageS,Ogre::Image& pImageD,const int tx0,const int ty0);
00146 static void ImageBlitPart (Ogre::Image& pImageS,Ogre::Image& pImageD,int dst_x,int dst_y,int src_x,int src_y,int w,int h);
00147 static void ImageColorReplace (Ogre::Image& pImage,Ogre::ColourValue colSearch,Ogre::ColourValue colReplace);
00148 static void ImageColorKeyToAlpha (Ogre::Image& pImage,Ogre::ColourValue colSearch);
00149 };
00150
00151 };
00152
00153 #endif