lugre_gfx3D.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_GFX3D_H
00025 #define LUGRE_GFX3D_H
00026
00027 #include "lugre_fifo.h"
00028 #include "lugre_smartptr.h"
00029 #include <list>
00030
00031 #undef min
00032 #undef max
00033
00034 #include <OgreFont.h>
00035 #include <OgreVector3.h>
00036 #include <OgreQuaternion.h>
00037 #include <OgreAxisAlignedBox.h>
00038 #include <OgreOverlayElement.h>
00039
00040 class lua_State;
00041 using Ogre::Vector3;
00042 using Ogre::Quaternion;
00043 using Ogre::Real;
00044 using Ogre::ColourValue;
00045 using Ogre::SceneNode;
00046 using Ogre::TagPoint;
00047
00048 namespace Ogre {
00049 class ParticleSystem;
00050 class WireBoundingBox;
00051 class AxisAlignedBox;
00052 class MovableObject;
00053 class Font;
00054 class Camera;
00055 class TagPoint;
00056 };
00057
00058 namespace Lugre {
00059
00060 class cRadar;
00061 class cRadialGrid;
00062 class cSimpleBeam;
00063 class cRobSimpleRenderable;
00064 class cTargetMarker;
00065 class cFastBatch;
00066
00067 void FreeOldUnusedParticleSystems(const unsigned int limit = 100);
00068
00069 class cGfx3D : public cSmartPointable { public :
00070 static unsigned int miCount;
00071
00072
00073 SceneNode* mpSceneNode;
00074 TagPoint* mpTagPoint;
00075 cFastBatch* mpFastBatch;
00076 cRadialGrid* mpRadialGrid;
00077 cRadar* mpRadar;
00078 Ogre::RibbonTrail* mpTrail;
00079 cSimpleBeam* mpBeam;
00080 Ogre::Entity* mpEntity;
00081 Ogre::Entity* mpAttachToEntity;
00082 std::string msAttachToBoneName;
00083 Ogre::AnimationState* mpAnimState;
00084 Ogre::String msPathAnimName;
00085 Ogre::AnimationState* mpPathAnimState;
00086 bool mbHasPath;
00087 Ogre::BillboardSet* mpBillboardSet;
00088 Ogre::ParticleSystem* mpParticleSystem;
00089 Ogre::ManualObject* mpManualObject;
00090 Ogre::FontPtr mpFont;
00091
00092 cRobSimpleRenderable* mpSimpleRenderable;
00093 Ogre::AxisAlignedBox mAABB;
00094 float mfCustomBoundingRadius;
00095 bool mbHasAABB;
00096 Ogre::Camera* mpForcePosCam;
00097 Ogre::Camera* mpForceRotCam;
00098 cSmartPtr<cGfx3D> mpForceLookatTarget;
00099 Ogre::Vector3 mvProjectedPos,mvProjectedSize;
00100 int miLastProjectedFrame;
00101
00102 void UpdateProjected (const int iFrameNum);
00103
00104 static cGfx3D* NewOfSceneNode (Ogre::SceneNode* pParent);
00105 static cGfx3D* NewChildOfSceneNode (Ogre::SceneNode* pParent);
00106 static cGfx3D* NewChildOfGfx3D (cGfx3D* pParent);
00107 static cGfx3D* NewChildOfRoot (Ogre::SceneManager* pSceneMgr);
00108 static cGfx3D* NewFree (Ogre::SceneManager* pSceneMgr);
00109 static cGfx3D* NewTagPoint (cGfx3D* pParent,const char* szBoneName,const Ogre::Vector3& vOffsetPosition=Ogre::Vector3::ZERO,const Ogre::Quaternion& qOffsetOrientation=Ogre::Quaternion::IDENTITY);
00110
00111 private:
00112 cGfx3D (SceneNode* pSceneNode);
00113 public:
00114 virtual ~cGfx3D ();
00115 void Clear ();
00116
00117 bool IsInScene ();
00118 void SetParent (cGfx3D* pParent);
00119 void SetParent (SceneNode* pParent);
00120 Vector3 GetScale ();
00121 Vector3 GetPosition ();
00122 Vector3 GetDerivedPosition ();
00123 Quaternion GetOrientation ();
00124 Quaternion GetDerivedOrientation ();
00125 void SetPosition (const Vector3& vPos);
00126 void SetOrientation (const Quaternion& qRot);
00127 void SetScale (const Vector3& vScale);
00128 void SetNormaliseNormals (const bool bNormalise);
00129 void SetVisible (const bool bVisible, const bool bCascade);
00130 void SetCastShadows (const bool bCastShadows);
00131 void SetMaterial (const char* szMat);
00132 void SetPrepareFrameStep (const bool bOn);
00133
00134 void SetFastBatch ();
00135 void SetParticleSystem (const char* szTemplateName);
00136 const unsigned int GetNumParticles ();
00137 void SetMesh (const char* szMeshName);
00138 void SetManualObject (Ogre::ManualObject* pManualObject);
00139 void SetBillboardSet (Ogre::BillboardSet* pBillboardSet);
00140 void SetAnim (const char* szAnimName,const bool bLoop);
00141 Real GetAnimLength (const char* szAnimName);
00142 void SetPathAnimTimePos (const Real fTimeInSeconds);
00143 Real GetPathAnimTimePos ();
00144 bool IsPathAnimLooped ();
00145 void SetAnimTimePos (const Real fTimeInSeconds);
00146 Real GetAnimTimePos ();
00147 bool IsAnimLooped ();
00148 bool HasBone (const char* szBoneName);
00149 void SetBillboard (const Vector3 vPos,const Real fRadius,const char* szMatName);
00150 void SetExplosion (const Real fRadius,const char* szMatName);
00151 void SetTargetTracker (const Real fDist,const Real fSize,const ColourValue vColor,const char* szMatName);
00152 void SetRadar ();
00153 void SetBeam (const bool bUseVertexColour);
00154 void SetRadialGrid ();
00155 void SetWireBoundingBox (const Ogre::AxisAlignedBox& aabb);
00156 void SetWireBoundingBox (const Vector3& vMin,const Vector3& vMax);
00157 void SetWireBoundingBox (Ogre::MovableObject& mov);
00158 void SetWireBoundingBox (Ogre::Entity& entity);
00159 void SetWireBoundingBox (cGfx3D& gfx3D);
00160 void SetSimpleRenderable ();
00161 void SetTextFont (const char* szFontName);
00162 void SetText (const char* szText,const Real fSize,const ColourValue vColor,const float mfWrapMaxW=0,Ogre::GuiHorizontalAlignment align=Ogre::GHA_LEFT);
00163
00164 void CreateMergedMesh(const char *szMeshname);
00165
00166 void SetTrail (const Vector3 vPos,const Real fLength, const unsigned int iElements, const char* szMatName,
00167 const Real fR,const Real fG,const Real fB, const Real fA,
00168 const Real fDeltaR,const Real fDeltaG,const Real fDeltaB, const Real fDeltaA,
00169 const Real fW,const Real fDeltaW);
00170
00171 void SetStarfield (const size_t numstars,const Real fRad,const Real fColoring,const char* szMatName);
00172
00173
00174 static void LuaRegister (lua_State *L);
00175
00176
00177 void AttachObject (Ogre::MovableObject* pObj);
00178 void DetachObject (Ogre::MovableObject* pObj);
00179
00180 void DestroyPath ();
00181
00182 private:
00183
00184 static std::list<cGfx3D*> gPrepareFrameStepper;
00185 std::list<cGfx3D*>::iterator mPrepareFrameItor;
00186 bool mbPrepareFrameStep;
00187 void PrepareFrameStep ();
00188
00189 public:
00190
00191 static void PrepareFrame ();
00192 };
00193
00194 };
00195
00196 #endif