00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <set>
00018
00019 #include "Primitive.h"
00020
00021 #ifndef N_POLYPRIM
00022 #define N_POLYPRIM
00023
00024 namespace Fluxus
00025 {
00026
00029 class PolyPrimitive : public Primitive
00030 {
00031 public:
00032 enum Type{TRISTRIP,QUADS,TRILIST,TRIFAN,POLYGON};
00033
00034 PolyPrimitive(Type t=TRISTRIP);
00035 PolyPrimitive(const PolyPrimitive &other);
00036 virtual ~PolyPrimitive();
00037
00041 virtual PolyPrimitive *Clone() const;
00042 virtual void Render();
00043 virtual dBoundingBox GetBoundingBox();
00044 virtual void RecalculateNormals(bool smooth);
00045 virtual void ApplyTransform(bool ScaleRotOnly=false);
00046 virtual string GetTypeName() { return "PolyPrimitive"; }
00048
00049 Type GetType() { return m_Type; }
00050
00052 virtual void AddVertex(const dVertex &Vert);
00053
00055 void Clear();
00056
00063
00071 const vector<vector<int> > &GetConnectedVerts() { GenerateTopology(); return m_ConnectedVerts; }
00072
00076 const vector<vector<pair<int,int> > > &GetUniqueEdges() { CalculateUniqueEdges(); return m_UniqueEdges; }
00077
00080 const vector<dVector> &GetGeometricNormals() { GenerateTopology(); return m_GeometricNormals; }
00082
00086 void SetIndexMode(bool s) { m_IndexMode=s; }
00087 bool IsIndexed() { return m_IndexMode; }
00088 vector<unsigned int> &GetIndex() { return m_IndexData; }
00091 void ConvertToIndexed();
00093
00094
00095 protected:
00096
00097 virtual void PDataDirty();
00098
00099
00100 void GenerateTopology();
00101 void CalculateConnected();
00102 void CalculateGeometricNormals();
00103 void CalculateUniqueEdges();
00104 void UniqueEdgesFindShared(pair<int,int> edge, set<pair<int,int> > firstpass, set<pair<int,int> > &stored);
00105 void RecalculateNormalsIndexed();
00106
00107 vector<vector<int> > m_ConnectedVerts;
00108 vector<dVector> m_GeometricNormals;
00109 vector<vector<pair<int,int> > > m_UniqueEdges;
00110
00111 bool m_IndexMode;
00112 vector<unsigned int> m_IndexData;
00113
00114 Type m_Type;
00115 vector<dVector> *m_VertData;
00116 vector<dVector> *m_NormData;
00117 vector<dColour> *m_ColData;
00118 vector<dVector> *m_TexData;
00119 };
00120
00121 };
00122
00123 #endif