00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef VRS_OPENGL_MAPPEDVERTEXATTRIBUTESHAPEGL_H
00021 #define VRS_OPENGL_MAPPEDVERTEXATTRIBUTESHAPEGL_H
00022
00023 #include <vrs/shape.h>
00024 #include <vrs/opengl/vertexattributebufferobjectgl.h>
00025
00026 namespace VRS {
00027
00028 class EngineGL;
00029 class PolygonSet;
00030 template<typename T, typename V> class Dictionary;
00031
00033 class VRS_CORE_API MappedVertexAttributeShapeGL : public Shape {
00034 public:
00035 VRS_TYPEINFO(MappedVertexAttributeShapeGL, Shape);
00036 VRS_SERIALIZABLE(MappedVertexAttributeShapeGL);
00037
00038 MappedVertexAttributeShapeGL(
00039 const PolygonSet* source,
00040 BufferObjectGL::UsagePattern usage = BufferObjectGL::STATIC_DRAW
00041 );
00048
00049
00050
00051
00052 SO<PolygonSet> convertToPolygonSet() const;
00053
00054 MappedVertexAttributeShapeGL(
00055 const Bounds& bbox = Bounds(),
00056 BaseVertexAttributeBufferObjectGL* vertices = NULL,
00057 BaseVertexAttributeBufferObjectGL* normals = NULL,
00058 BaseVertexAttributeBufferObjectGL* color = NULL,
00059 BaseVertexAttributeBufferObjectGL* tex_coord_0 = NULL,
00060 BaseVertexAttributeBufferObjectGL* index = NULL,
00061 BaseVertexAttributeBufferObjectGL* range = NULL,
00062 BaseVertexAttributeBufferObjectGL* primitive = NULL
00063 );
00064 MappedVertexAttributeShapeGL(
00065 GLenum primitiveType,
00066 const Bounds& bbox = Bounds(),
00067 BaseVertexAttributeBufferObjectGL* vertices = NULL,
00068 BaseVertexAttributeBufferObjectGL* normals = NULL,
00069 BaseVertexAttributeBufferObjectGL* color = NULL,
00070 BaseVertexAttributeBufferObjectGL* tex_coord_0 = NULL,
00071 BaseVertexAttributeBufferObjectGL* index = NULL,
00072 BaseVertexAttributeBufferObjectGL* range = NULL
00073 );
00086 virtual ~MappedVertexAttributeShapeGL();
00087
00088 BaseVertexAttributeBufferObjectGL* getBufferObject(const ID& vertexAttributeName) const;
00089 void setArray(const ID& vertexAttributeName, BaseVertexAttributeBufferObjectGL* content);
00091
00092 BaseVertexAttributeBufferObjectGL* indices() const;
00093 void setIndices(BaseVertexAttributeBufferObjectGL* indices);
00095
00096 BaseVertexAttributeBufferObjectGL* ranges() const;
00097 void setRanges(BaseVertexAttributeBufferObjectGL* ranges);
00099
00100 BaseVertexAttributeBufferObjectGL* primitives() const;
00101 void setPrimitives(BaseVertexAttributeBufferObjectGL* pimitives);
00103
00104 GLenum getPrimitiveType() const;
00105 void setPrimitiveType(GLenum primitiveType);
00107
00108 void clear();
00110
00113 UINT usedMemory() const;
00117 void setBoundingBox(const Bounds&);
00119 virtual Bounds boundingBox() const;
00120
00121
00122 void enableMirroredData(bool yesNo, bool vec4fCompatible = false);
00128 bool mirroredDataEnabled() const;
00131 SO<const VertexAttributeBufferObjectGL<Vector3f> > getMirroredVertices() const;
00140 SO<const BaseVertexAttributeBufferObjectGL> getMirroredIndices() const;
00143
00144 SO<Iterator<ID> > newVertexAttributeNameIterator() const;
00145
00149 virtual SO<Iterator<Matrix> > getInstanceTransformationIterator() const;
00153 virtual void setInstanceTransformationIterator(SO<Iterator<Matrix> > instanceTransforms);
00154
00156 virtual SO<Iterator<UINT32> > getIDIterator() const;
00160 virtual void setIDIterator(const SO<Iterator<UINT32> >& idIter);
00161
00167 virtual bool invertOrientation();
00168
00169 private:
00170 GLenum primitiveType_;
00171
00172 SO<Dictionary<ID, SO<BaseVertexAttributeBufferObjectGL> > > content_;
00173 SO<BaseVertexAttributeBufferObjectGL> indices_;
00174 SO<BaseVertexAttributeBufferObjectGL> ranges_;
00175 SO<BaseVertexAttributeBufferObjectGL> primitives_;
00176 SO<Iterator<Matrix> > m_instanceTransforms;
00177 SO<Iterator<UINT32> > m_idIter;
00178 mutable SO<VertexAttributeBufferObjectGL<Vector3f> > mirroredVertices_;
00179 mutable SO<BaseVertexAttributeBufferObjectGL> mirroredIndices_;
00180 bool mirroredDataEnabled_;
00181 bool vec4fCompatible_;
00182
00183 Bounds bbox_;
00184 };
00185
00186 inline BaseVertexAttributeBufferObjectGL* MappedVertexAttributeShapeGL::indices() const { return indices_; }
00187
00188 inline BaseVertexAttributeBufferObjectGL* MappedVertexAttributeShapeGL::ranges() const { return ranges_; }
00189
00190 inline BaseVertexAttributeBufferObjectGL* MappedVertexAttributeShapeGL::primitives() const { return primitives_; }
00191
00192 inline GLenum MappedVertexAttributeShapeGL::getPrimitiveType() const { return primitiveType_; }
00193
00194 }
00195
00196 #endif // VRS_OPENGL_MAPPEDVERTEXATTRIBUTESHAPEGL_H