00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef OST_GFX_PRIM_LIST_HH
00020 #define OST_GFX_PRIM_LIST_HH
00021
00022
00023
00024
00025
00026 #include <boost/shared_ptr.hpp>
00027
00028 #include <ost/geom/geom.hh>
00029
00030 #include "gfx_object.hh"
00031 #include "gfx_prim.hh"
00032
00033 namespace ost { namespace gfx {
00034
00038 class DLLEXPORT_OST_GFX PrimList: public GfxObj
00039 {
00040 struct PointEntry {
00041 PointEntry(const geom::Vec3& p, float r, const Color& c):
00042 pos(p), rad(r), col(c) {}
00043 geom::Vec3 pos;
00044 float rad;
00045 Color col;
00046 };
00047
00048 typedef std::vector<PointEntry> PointEntryList;
00049
00050 struct LineEntry {
00051 LineEntry(const geom::Vec3& p1, const geom::Vec3& p2, float r1, float r2, const Color& c1, const Color& c2):
00052 pos1(p1), pos2(p2), radius_1(r1), radius_2(r2), col1(c1), col2(c2) {}
00053 geom::Vec3 pos1, pos2;
00054 float radius_1, radius_2;
00055 Color col1, col2;
00056 };
00057
00058 typedef std::vector<LineEntry> LineEntryList;
00059
00060 public:
00062 PrimList(const String& name);
00063
00064 virtual geom::AlignedCuboid GetBoundingBox(bool use_tf=true) const;
00065
00066 virtual void ProcessLimits(geom::Vec3& minc, geom::Vec3& maxc,
00067 const geom::Transform& tf) const;
00069 virtual geom::Vec3 GetCenter() const;
00070
00071 virtual void CustomRenderPov(PovState& pov);
00072
00073 virtual void CustomRenderGL(RenderPass pass);
00074
00075 virtual void OnRenderModeChange();
00076
00077 virtual void SetLineWidth(float w);
00079 void Clear();
00080
00088 void AddPoint(const geom::Vec3& p, const Color& col);
00089
00097 void AddLine(const geom::Vec3& p1, const geom::Vec3& p2, const Color& col1, const Color& col2);
00098
00106 void AddSphere(const geom::Vec3& cen, float rad, const Color& col);
00107
00115 void AddCyl(const geom::Vec3& p0, const geom::Vec3& p1, float r1, float r2, const Color& col1, const Color& col2);
00116
00124 void AddText(const std::string& text, const geom::Vec3& pos, const Color& col, float point_size);
00125
00127 void SetDiameter(float d);
00128
00130 void SetRadius(float r);
00131
00133 void SetColor(const Color& c);
00134
00135 void SetSphereDetail(unsigned int d);
00136 unsigned int GetSphereDetail() const {return sphere_detail_;}
00137
00138 void SetArcDetail(unsigned int d);
00139 unsigned int GetArcDetail() const {return arc_detail_;}
00140
00141
00142
00159 void AddMesh(float* v, float* n, float* c, size_t nv, unsigned int* i, size_t ni);
00160
00161 protected:
00162 virtual void CustomPreRenderGL(bool flag);
00163
00164 private:
00165 SpherePrimList points_;
00166 CylinderPrimList lines_;
00167 SpherePrimList spheres_;
00168 CylinderPrimList cyls_;
00169 TextPrimList texts_;
00170 unsigned int sphere_detail_;
00171 unsigned int arc_detail_;
00172
00173 IndexedVertexArray simple_va_;
00174
00175 std::vector<IndexedVertexArray> vas_;
00176
00177 void prep_simple_va();
00178 void prep_va();
00179 void render_text();
00180 };
00181
00187
00192 }}
00193
00194 #endif