00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef VRS_POLYGONSET_H
00021 #define VRS_POLYGONSET_H
00022
00023 #include <vrs/shape.h>
00024 #include <vrs/color.h>
00025 #include <vrs/id.h>
00026 #include <vrs/vector.h>
00027
00028 namespace VRS {
00029
00030 class MappedVertexAttributeShapeGL;
00031 template<class T, class V> class Dictionary;
00032 template<class T> class Iterator;
00033
00035 class VRS_CORE_API PolygonSet :
00036 public Shape
00037 {
00038 public:
00039 VRS_TYPEINFO(PolygonSet, Shape);
00040 VRS_SERIALIZABLE(PolygonSet);
00041
00042 public:
00043 enum PrimitiveType {
00044 FirstPrimitiveType,
00045 Points,
00046 Lines, LineStrip, LineLoop,
00047 Triangles, TriangleStrip, TriangleFan,
00048 Quads, QuadStrip,
00049 ConvexFace,
00050 LinesAdjacency, LineStripAdjacency,
00051 TrianglesAdjacency, TriangleStripAdjacency,
00052 LastPrimitiveType
00053 };
00054 VRS_SERIALIZABLE_CLASS_ENUM(PrimitiveType);
00055
00056 public:
00057 PolygonSet(
00058 PrimitiveType type = PolygonSet::Triangles,
00059 Iterator<Vector>* vertexIter = NULL,
00060 Iterator<Vector>* normalIter = NULL,
00061 Iterator<Color>* colorIter = NULL,
00062 Iterator<Vector>* texture0Iter = NULL,
00063 Iterator<Vector>* texture1Iter = NULL,
00064 Iterator<Vector>* texture2Iter = NULL,
00065 Iterator<Vector>* texture3Iter = NULL,
00066 Iterator<unsigned int>* indexIter = NULL,
00067 Iterator<unsigned int>* rangeIter = NULL,
00068 Iterator<bool>* edgeflagIter = NULL
00069 );
00070 PolygonSet(
00071 Iterator<PrimitiveType>* primitiveIter,
00072 Iterator<Vector>* vertexIter = NULL,
00073 Iterator<Vector>* normalIter = NULL,
00074 Iterator<Color>* colorIter = NULL,
00075 Iterator<Vector>* texture0Iter = NULL,
00076 Iterator<Vector>* texture1Iter = NULL,
00077 Iterator<Vector>* texture2Iter = NULL,
00078 Iterator<Vector>* texture3Iter = NULL,
00079 Iterator<unsigned int>* indexIter = NULL,
00080 Iterator<unsigned int>* rangeIter = NULL,
00081 Iterator<bool>* edgeflagIter = NULL
00082 );
00091 public:
00092 virtual void setType(PolygonSet::PrimitiveType primitiveType);
00093 virtual PolygonSet::PrimitiveType getType() const;
00098 virtual void setVectorIterator(const ID& vertexDataType, Iterator<Vector>* iter);
00100 virtual void setColorIterator (const ID& vertexDataType, Iterator<Color>* iter);
00102
00112 virtual Iterator<ID>* newVertexDataIterator() const;
00114 virtual bool isVectorIterator(const ID& vertexDataType) const;
00116 virtual bool isColorIterator (const ID& vertexDataType) const;
00118
00120 virtual Iterator<Vector>* newVectorIterator(const ID& vertexDataType) const;
00122 virtual Iterator<Color>* newColorIterator (const ID& vertexDataType) const;
00124
00128 virtual void setIndexIterator(Iterator<unsigned int>* iter);
00130 virtual void setRangeIterator(Iterator<unsigned int>* iter);
00131 virtual void setPrimitiveIterator(Iterator<PrimitiveType>* iter);
00137 virtual void setEdgeFlagIterator(Iterator<bool>* iter);
00139
00140 virtual Iterator<unsigned int>* newIndexIterator() const;
00141 virtual Iterator<unsigned int>* newRangeIterator() const;
00142 virtual Iterator<PrimitiveType>* newPrimitiveIterator() const;
00143 virtual Iterator<bool>* newEdgeFlagIterator() const;
00145
00146 virtual void setVertexIterator(Iterator<Vector>* iter);
00147 virtual void setNormalIterator(Iterator<Vector>* iter);
00148 virtual void setTextureIterator(Iterator<Vector>* iter, unsigned int textureUnit = 0);
00149 virtual void setColorIterator(Iterator<Color>* iter);
00151
00152 virtual Iterator<Vector>* newVertexIterator() const;
00153 virtual Iterator<Vector>* newNormalIterator() const;
00154 virtual Iterator<Vector>* newTextureIterator(unsigned int textureUnit = 0) const;
00155 virtual Iterator<Color>* newColorIterator() const;
00157
00161 virtual SO<Iterator<Matrix> > getInstanceTransformationIterator() const;
00165 virtual void setInstanceTransformationIterator(SO<Iterator<Matrix> > instanceTransforms);
00166
00168 virtual SO<Iterator<UINT32> > getIDIterator() const;
00172 virtual void setIDIterator(const SO<Iterator<UINT32> >& idIter);
00173
00174 void setBoundingBox(const Bounds&);
00176
00178 virtual Bounds boundingBox() const;
00180
00181 virtual void modified();
00182
00183 private:
00184 PrimitiveType type_;
00185
00186 SO<Iterator<unsigned int> > indexIter_;
00187 SO<Iterator<unsigned int> > rangeIter_;
00188 SO<Iterator<PrimitiveType> > primitiveIter_;
00189 SO<Iterator<bool> > edgeFlagIter_;
00190 SO<Iterator<Matrix> > m_instanceTransforms;
00191 SO<Iterator<UINT32> > m_idIter;
00192
00193 SO<Dictionary<ID, SO<SharedObj> > > data_;
00194
00195 mutable Bounds bbox_;
00196 mutable TransactionNo bboxValid_;
00197
00198 mutable SO<MappedVertexAttributeShapeGL> cachedShape_;
00199 mutable TransactionNo cacheUpdate_;
00200
00201 friend class PolygonSetSimplifierGL;
00202 };
00203
00204 }
00205
00206 #endif // VRS_POLYGONSET_H