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_BEAM_H
00025 #define LUGRE_BEAM_H
00026
00027 #include "lugre_robrenderable.h"
00028 #include <OgrePrerequisites.h>
00029 #include <OgreVector3.h>
00030 #include <deque>
00031
00032
00033 namespace Lugre {
00034
00035 class cBeamFilter;
00036 class cBeam;
00037 class cBeamPoint;
00038
00039 class cBeamFilter { public:
00040 cBeamFilter();
00041 virtual ~cBeamFilter();
00042 virtual cBeamPoint& CurPoint (cBeamPoint& p,const int iLine,const int iPoint);
00043 virtual cBeamPoint& NextPoint (cBeamPoint& p,const int iLine,const int iPoint);
00044 virtual cBeamPoint& PrevPoint (cBeamPoint& p,const int iLine,const int iPoint);
00045 static cBeamFilter IDENTITY;
00046 };
00047
00048 class cBeamPoint { public:
00049 Ogre::Vector3 pos;
00050 float h1,h2;
00051 float u1,u2;
00052 float v1,v2;
00053 Ogre::ColourValue col1,col2;
00054 cBeamPoint () : pos(0,0,0), col1(Ogre::ColourValue::White), col2(Ogre::ColourValue::White), h1(1), h2(1), u1(0), u2(0), v1(0), v2(1) {}
00055 cBeamPoint ( const Ogre::Vector3& pos,
00056 const float h1,const float h2,
00057 const float u1,const float u2,
00058 const float v1,const float v2,
00059 const Ogre::ColourValue& col1 = Ogre::ColourValue::White,
00060 const Ogre::ColourValue& col2 = Ogre::ColourValue::White
00061 ) : pos(pos), col1(col1), col2(col2), h1(h1), h2(h2), u1(u1), u2(u2), v1(v1), v2(v2) {}
00062 };
00063
00066 class cBeam { public:
00067 bool mbBoundsDirty;
00068 std::deque<std::deque<cBeamPoint>*> mlBeamLines;
00069
00070 cBeam ();
00071 virtual ~cBeam ();
00072
00073 int CountLines () { return mlBeamLines.size(); }
00074 void ClearLines () { mbBoundsDirty = true; mlBeamLines.clear(); }
00075 int AddLine () { mlBeamLines.push_back(new std::deque<cBeamPoint>()); return mlBeamLines.size()-1; }
00076 void DeleteLine (const int iLine) {
00077 mbBoundsDirty = true;
00078 if (iLine >= 0 && iLine < mlBeamLines.size()) {
00079 std::deque<std::deque<cBeamPoint>*>::iterator itor = mlBeamLines.begin()+iLine;
00080 if (*itor) delete *itor;
00081 mlBeamLines.erase(itor);
00082 }
00083 }
00084
00085
00086 void AddPoint (const int iLine,const cBeamPoint& p) { mbBoundsDirty = true; if (iLine >= 0 && iLine < mlBeamLines.size()) mlBeamLines[iLine]->push_back(p); }
00087 void ClearLine (const int iLine) { mbBoundsDirty = true; if (iLine >= 0 && iLine < mlBeamLines.size()) mlBeamLines[iLine]->clear(); }
00088 int CountLinePoints (const int iLine) { return (iLine >= 0 && iLine < mlBeamLines.size()) ? mlBeamLines[iLine]->size() : 0; }
00089 void PopFront (const int iLine) { mbBoundsDirty = true; if (iLine >= 0 && iLine < mlBeamLines.size()) mlBeamLines[iLine]->pop_front(); }
00090 void PopBack (const int iLine) { mbBoundsDirty = true; if (iLine >= 0 && iLine < mlBeamLines.size()) mlBeamLines[iLine]->pop_back(); }
00091 cBeamPoint* GetPoint (const int iLine,const int iPoint) {
00092 return (iLine >= 0 && iLine < mlBeamLines.size() &&
00093 iPoint >= 0 && iPoint < mlBeamLines[iLine]->size()) ? &(*mlBeamLines[iLine])[iPoint] : 0;
00094 }
00095
00096 void UpdateBeamBounds (cRobRenderOp& pRobRenderOp);
00097
00099 void Draw (cRobRenderOp& pRobRenderOp,Ogre::Vector3 vEyePos,const bool bUseVertexColour,cBeamFilter &filter=cBeamFilter::IDENTITY);
00100 void Draw (cRobRenderOp& pRobRenderOp,Ogre::Camera& pCam,Ogre::SceneNode& pBeamSceneNode,const bool bUseVertexColour,cBeamFilter &filter=cBeamFilter::IDENTITY);
00101
00102 static Ogre::Vector3 CalcEyePos (Ogre::Camera& pCam,Ogre::SceneNode& pBeamSceneNode);
00103 };
00104
00105 class cSimpleBeam : public cBeam, public cRobSimpleRenderable { public :
00106 cBeamFilter* pFilter;
00107 bool mbUseVertexColour;
00108 cSimpleBeam(const bool mbUseVertexColour);
00109 virtual ~cSimpleBeam();
00110 void UpdateBounds ();
00111 virtual const Ogre::AxisAlignedBox& getBoundingBox(void) const;
00112 virtual Ogre::Real getBoundingRadius(void) const;
00113 virtual Ogre::Real getSquaredViewDepth(const Ogre::Camera* cam) const;
00114 virtual void _notifyCurrentCamera (Ogre::Camera* cam);
00115 };
00116
00117 };
00118
00119 #endif