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 #include "PolyEvaluator.h"
00021 
00022 #ifndef N_POLYPRIM
00023 #define N_POLYPRIM
00024 
00025 namespace Fluxus
00026 {
00027 
00030 class PolyPrimitive : public Primitive
00031 {
00032 public:
00033     // Todo: sort out these silly names, add quadstrip
00034     enum Type{TRISTRIP,QUADS,TRILIST,TRIFAN,POLYGON};
00035     
00036     PolyPrimitive(Type t=TRISTRIP);
00037     PolyPrimitive(const PolyPrimitive &other);
00038     virtual ~PolyPrimitive();
00039     
00043     virtual PolyPrimitive *Clone() const;
00044     virtual void Render();
00045     virtual dBoundingBox GetBoundingBox();
00046     virtual void RecalculateNormals(bool smooth);
00047     virtual void ApplyTransform(bool ScaleRotOnly=false);
00048     virtual string GetTypeName() { return "PolyPrimitive"; }
00049     virtual Evaluator *MakeEvaluator() { return new PolyEvaluator(this); }
00051     
00052     Type GetType() const { return m_Type; }
00053     
00055     virtual void AddVertex(const dVertex &Vert);
00056         
00058     void Clear();
00059 
00066 
00074     const vector<vector<int> > &GetConnectedVerts() { GenerateTopology(); return m_ConnectedVerts; }
00075     
00079     const vector<vector<pair<int,int> > > &GetUniqueEdges() { CalculateUniqueEdges(); return m_UniqueEdges; }
00080     
00083     const vector<dVector> &GetGeometricNormals() { GenerateTopology(); return m_GeometricNormals; }
00085 
00089     void SetIndexMode(bool s) { m_IndexMode=s; }
00090     bool IsIndexed() const { return m_IndexMode; }
00091     vector<unsigned int> &GetIndex() { return m_IndexData; }
00092     const vector<unsigned int> &GetIndexConst() const { return m_IndexData; }
00095     void ConvertToIndexed();
00097     
00098     
00099 protected:
00100 
00101     virtual void PDataDirty();
00102     
00103     // Topology generation commands
00104     void GenerateTopology();
00105     void CalculateConnected();
00106     void CalculateGeometricNormals();
00107     void CalculateUniqueEdges();
00108     void UniqueEdgesFindShared(pair<int,int> edge, set<pair<int,int> > firstpass, set<pair<int,int> > &stored);
00109     void RecalculateNormalsIndexed();
00110     
00111     vector<vector<int> > m_ConnectedVerts;
00112     vector<dVector> m_GeometricNormals;
00113     vector<vector<pair<int,int> > > m_UniqueEdges;
00114     
00115     bool m_IndexMode;
00116     vector<unsigned int> m_IndexData;
00117     
00118     Type m_Type;
00119     vector<dVector> *m_VertData;
00120     vector<dVector> *m_NormData;
00121     vector<dColour> *m_ColData;
00122     vector<dVector> *m_TexData;
00123 };
00124 
00125 };
00126 
00127 #endif

Generated on Wed Sep 17 21:16:30 2008 for The Fluxus Renderer (libfluxus) by  doxygen 1.5.1