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     virtual void AddVertex(const dVertex &Vert);    
00051 
00058 
00066     const vector<vector<int> > &GetConnectedVerts() { GenerateTopology(); return m_ConnectedVerts; }
00067     
00071     const vector<vector<pair<int,int> > > &GetUniqueEdges() { CalculateUniqueEdges(); return m_UniqueEdges; }
00072     
00075     const vector<dVector> &GetGeometricNormals() { GenerateTopology(); return m_GeometricNormals; }
00077 
00081     void SetIndexMode(bool s) { m_IndexMode=s; }
00082     bool IsIndexed() { return m_IndexMode; }
00083     vector<unsigned int> &GetIndex() { return m_IndexData; }
00086     void ConvertToIndexed();
00088     
00089     
00090 protected:
00091 
00092     virtual void PDataDirty();
00093     
00094     // Topology generation commands
00095     void GenerateTopology();
00096     void CalculateConnected();
00097     void CalculateGeometricNormals();
00098     void CalculateUniqueEdges();
00099     void UniqueEdgesFindShared(pair<int,int> edge, set<pair<int,int> > firstpass, set<pair<int,int> > &stored);
00100     void RecalculateNormalsIndexed();
00101     
00102     vector<vector<int> > m_ConnectedVerts;
00103     vector<dVector> m_GeometricNormals;
00104     vector<vector<pair<int,int> > > m_UniqueEdges;
00105     
00106     bool m_IndexMode;
00107     vector<unsigned int> m_IndexData;
00108     
00109     Type m_Type;
00110     vector<dVector> *m_VertData;
00111     vector<dVector> *m_NormData;
00112     vector<dColour> *m_ColData;
00113     vector<dVector> *m_TexData;
00114 };
00115 
00116 };
00117 
00118 #endif

Generated on Tue Sep 4 23:22:18 2007 for The Fluxus Renderer (libfluxus) by  doxygen 1.5.1