PolyPrimitive.h

Go to the documentation of this file.
00001 // Copyright (C) 2005 Dave Griffiths
00002 //
00003 // This program is free software; you can redistribute it and/or modify
00004 // it under the terms of the GNU General Public License as published by
00005 // the Free Software Foundation; either version 2 of the License, or
00006 // (at your option) any later version.
00007 //
00008 // This program is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 // GNU General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU General Public License
00014 // along with this program; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
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     // Topology generation commands
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

Generated on Mon Feb 11 06:54:25 2008 for The Fluxus Renderer (libfluxus) by  doxygen 1.5.1