lugre_robrenderable.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_ROBRENDERABLE_H
00025 #define LUGRE_ROBRENDERABLE_H
00026 #undef min
00027 #undef max
00028 #include <OgrePrerequisites.h>
00029
00030
00031 #include <OgreSimpleRenderable.h>
00032 #include <OgreCamera.h>
00033 #include <OgreVector3.h>
00034
00035 namespace Lugre {
00036
00037 class cRobRenderOp { public :
00038
00039
00040
00041
00042
00044 enum eVertexFormat {
00045 kVertexFormat_none,
00046 kVertexFormat_p,
00047 kVertexFormat_puv,
00048 kVertexFormat_pn,
00049 kVertexFormat_pnuv,
00050 kVertexFormat_pc,
00051 kVertexFormat_puvc,
00052 kVertexFormat_pnc,
00053 kVertexFormat_pnuvc,
00054 };
00055 Ogre::Vector3 mvAABMin;
00056 Ogre::Vector3 mvAABMax;
00057 bool mbBoundingBoxEmpty;
00058 Ogre::Real mfBoundingRadius;
00059 Ogre::RenderOperation* mpRenderOp;
00060 Ogre::AxisAlignedBox* mpBox;
00061 size_t miVertexCapacity;
00062 size_t miIndexCapacity;
00063 size_t miVertexCount;
00064 size_t miIndexCount;
00065 size_t miVertexSize;
00066 bool mbBufferIsDynamic;
00067 bool mbBufferIsReadable;
00068 bool mbDynamic;
00069 bool mbReadable;
00070 bool mbKeepOldIndices;
00071 eVertexFormat miVertexFormat;
00072 size_t miReceivedVertices;
00073 size_t miReceivedIndices;
00074 Ogre::RenderSystem* mpRenderSys;
00075
00076 char* mVertexWritePtr;
00077 unsigned short* mIndexWritePtr;
00078 Ogre::HardwareVertexBufferSharedPtr mHWVBuf;
00079 Ogre::HardwareIndexBufferSharedPtr mHWIBuf;
00080
00081 cRobRenderOp(Ogre::RenderOperation* pRenderOp=0,Ogre::AxisAlignedBox* pBox=0);
00082 virtual ~cRobRenderOp();
00083
00084 void Begin (const size_t iVertexCount,const size_t iIndexCount=0,const bool bDynamic=false,const bool bKeepOldIndices=false,
00085 const Ogre::RenderOperation::OperationType opType=Ogre::RenderOperation::OT_TRIANGLE_LIST,const bool bReadable=false);
00086 void Vertex (const Ogre::Vector3& p);
00087 void Vertex (const Ogre::Vector3& p,const Ogre::Real u,const Ogre::Real v);
00088 void Vertex (const Ogre::Vector3& p,const Ogre::Vector3& n);
00089 void Vertex (const Ogre::Vector3& p,const Ogre::Vector3& n,const Ogre::Real u,const Ogre::Real v);
00090 void Vertex (const Ogre::Vector3& p,const Ogre::ColourValue& c);
00091 void Vertex (const Ogre::Vector3& p,const Ogre::Real u,const Ogre::Real v,const Ogre::ColourValue& c);
00092 void Vertex (const Ogre::Vector3& p,const Ogre::Vector3& n,const Ogre::ColourValue& c);
00093 void Vertex (const Ogre::Vector3& p,const Ogre::Vector3& n,const Ogre::Real u,const Ogre::Real v,const Ogre::ColourValue& c);
00094 void Index (const int i);
00095 void Index (const int i,const int j,const int k);
00096 void End ();
00097 void SkipVertices (const size_t iNum=1);
00098 void SkipIndices (const size_t iNum=1);
00099 void AddToMesh (Ogre::MeshPtr pMesh, const std::string& sMatName);
00100 void ConvertToMesh (const std::string& sMeshName,const std::string& sMatName);
00101
00102
00109 Ogre::Real* StartCustomWriter (const Ogre::Vector3& vBoundsMin,const Ogre::Vector3& vBoundsMax);
00110
00114 void SetVertexFormatFromEnum (const eVertexFormat miVertexFormat,const int iNumTexCoordsSets=1);
00115
00120 Ogre::VertexDeclaration* GetVertexDecl ();
00121
00123 void _StartWrite (const bool bVertexFormatChanged);
00124 void _AllocateIndexBufferIfNeeded ();
00126 Ogre::Real* PrepareAddVertex (const eVertexFormat miVertexFormat,const Ogre::Vector3& p);
00127
00128 static Ogre::Real GetMaxZ ();
00129 };
00130
00131 class cRobSimpleRenderable : public cRobRenderOp, public Ogre::SimpleRenderable { public :
00132 cRobSimpleRenderable();
00133 virtual ~cRobSimpleRenderable();
00134
00135 void ConvertToMesh (const std::string& sMeshName);
00136 void AddToMesh (const std::string& sMeshName);
00137 void AddToMesh (Ogre::MeshPtr pMesh);
00138 virtual Ogre::Real getBoundingRadius(void) const;
00139 virtual Ogre::Real getSquaredViewDepth(const Ogre::Camera* cam) const;
00140 };
00141
00142
00143 };
00144
00145 #endif