Moved the new osg::IndexedGeometry class over the top of the the existing
osg::Geometry class, and removed the temporary IndexedGeometry. Port the rest of the OSG across to account for the change in method calls - osg::Geometry::addPrimitive(..) becomes osg::addPrimitiveSet(..)
This commit is contained in:
@@ -15,7 +15,6 @@ namespace osg {
|
||||
|
||||
// forward declare so that we don't need to include the header.
|
||||
class Geometry;
|
||||
class IndexedGeometry;
|
||||
|
||||
/** Note, osg::GeoSet is now deprecated, please use osg::Geometry instead.
|
||||
osg::GeoSet will be kept through to the beta release for
|
||||
@@ -339,9 +338,6 @@ class SG_EXPORT GeoSet : public Drawable
|
||||
/** convinience function for converting GeoSet's to equivilant Geometry nodes.*/
|
||||
Geometry* convertToGeometry();
|
||||
|
||||
/** convinience function for converting GeoSet's to equivilant IndexedGeometry nodes.*/
|
||||
IndexedGeometry* convertToIndexedGeometry();
|
||||
|
||||
protected:
|
||||
|
||||
GeoSet& operator = (const GeoSet&) { return *this;}
|
||||
|
||||
@@ -37,6 +37,7 @@ class SG_EXPORT Geometry : public Drawable
|
||||
{
|
||||
BIND_OFF=0,
|
||||
BIND_OVERALL,
|
||||
BIND_PER_PRIMITIVE_SET,
|
||||
BIND_PER_PRIMITIVE,
|
||||
BIND_PER_VERTEX
|
||||
};
|
||||
@@ -45,32 +46,48 @@ class SG_EXPORT Geometry : public Drawable
|
||||
Vec3Array* getVertexArray() { return _vertexArray.get(); }
|
||||
const Vec3Array* getVertexArray() const { return _vertexArray.get(); }
|
||||
|
||||
void setVertexIndices(IndexArray* array) { _vertexIndices = array; _fastPathComputed=false; dirtyDisplayList(); dirtyBound(); }
|
||||
IndexArray* getVertexIndices() { return _vertexIndices.get(); }
|
||||
const IndexArray* getVertexIndices() const { return _vertexIndices.get(); }
|
||||
|
||||
void setNormalBinding(AttributeBinding ab) { _normalBinding = ab; dirtyDisplayList(); }
|
||||
|
||||
void setNormalBinding(AttributeBinding ab) { _normalBinding = ab; dirtyDisplayList(); _fastPathComputed=false; }
|
||||
AttributeBinding getNormalBinding() const { return _normalBinding; }
|
||||
|
||||
void setNormalArray(Vec3Array* array) { _normalArray = array; if (!_normalArray.valid()) _normalBinding=BIND_OFF; dirtyDisplayList(); }
|
||||
void setNormalArray(Vec3Array* array) { _normalArray = array; if (!_normalArray.valid()) _normalBinding=BIND_OFF; _fastPathComputed=false; dirtyDisplayList(); }
|
||||
Vec3Array* getNormalArray() { return _normalArray.get(); }
|
||||
const Vec3Array* getNormalArray() const { return _normalArray.get(); }
|
||||
|
||||
void setNormalIndices(IndexArray* array) { _normalIndices = array; _fastPathComputed=false; dirtyDisplayList(); }
|
||||
IndexArray* getNormalIndices() { return _normalIndices.get(); }
|
||||
const IndexArray* getNormalIndices() const { return _normalIndices.get(); }
|
||||
|
||||
void setColorBinding(AttributeBinding ab) { _colorBinding = ab; }
|
||||
|
||||
void setColorBinding(AttributeBinding ab) { _colorBinding = ab; _fastPathComputed=false;}
|
||||
AttributeBinding getColorBinding() const { return _colorBinding; }
|
||||
|
||||
void setColorArray(Array* array) { _colorArray = array; if (!_colorArray.valid()) _colorBinding=BIND_OFF; dirtyDisplayList(); }
|
||||
void setColorArray(Array* array) { _colorArray = array; if (!_colorArray.valid()) _colorBinding=BIND_OFF; _fastPathComputed=false; dirtyDisplayList(); }
|
||||
Array* getColorArray() { return _colorArray.get(); }
|
||||
const Array* getColorArray() const { return _colorArray.get(); }
|
||||
|
||||
void setColorIndices(IndexArray* array) { _colorIndices = array; _fastPathComputed=false; dirtyDisplayList(); }
|
||||
IndexArray* getColorIndices() { return _colorIndices.get(); }
|
||||
const IndexArray* getColorIndices() const { return _colorIndices.get(); }
|
||||
|
||||
void setSecondaryColorBinding(AttributeBinding ab) { _secondaryColorBinding = ab; }
|
||||
|
||||
void setSecondaryColorBinding(AttributeBinding ab) { _secondaryColorBinding = ab; _fastPathComputed=false;}
|
||||
AttributeBinding getSecondaryColorBinding() const { return _secondaryColorBinding; }
|
||||
|
||||
void setSecondaryColorArray(Array* array) { _secondaryColorArray = array; if (!_secondaryColorArray.valid()) _secondaryColorBinding=BIND_OFF; dirtyDisplayList(); }
|
||||
void setSecondaryColorArray(Array* array) { _secondaryColorArray = array; if (!_secondaryColorArray.valid()) _secondaryColorBinding=BIND_OFF; _fastPathComputed=false; dirtyDisplayList(); }
|
||||
Array* getSecondaryColorArray() { return _secondaryColorArray.get(); }
|
||||
const Array* getSecondaryColorArray() const { return _secondaryColorArray.get(); }
|
||||
|
||||
void setSecondaryColorIndices(IndexArray* array) { _secondaryColorIndices = array; _fastPathComputed=false; dirtyDisplayList(); }
|
||||
IndexArray* getSecondaryColorIndices() { return _secondaryColorIndices.get(); }
|
||||
const IndexArray* getSecondaryColorIndices() const { return _secondaryColorIndices.get(); }
|
||||
|
||||
void setFogCoordBinding(AttributeBinding ab) { _fogCoordBinding = ab; }
|
||||
|
||||
void setFogCoordBinding(AttributeBinding ab) { _fogCoordBinding = ab; _fastPathComputed=false;}
|
||||
AttributeBinding getFogCoordBinding() const { return _fogCoordBinding; }
|
||||
|
||||
void setFogCoordArray(FloatArray* array) { _fogCoordArray = array; if (!_fogCoordArray.valid()) _fogCoordBinding=BIND_OFF; dirtyDisplayList(); }
|
||||
@@ -78,33 +95,49 @@ class SG_EXPORT Geometry : public Drawable
|
||||
const FloatArray* getFogCoordArray() const { return _fogCoordArray.get(); }
|
||||
|
||||
|
||||
typedef std::vector< ref_ptr<Array> > TexCoordArrayList;
|
||||
void setFogCoordIndices(IndexArray* array) { _fogCoordIndices = array; dirtyDisplayList(); }
|
||||
IndexArray* getFogCoordIndices() { return _fogCoordIndices.get(); }
|
||||
const IndexArray* getFogCoordIndices() const { return _fogCoordIndices.get(); }
|
||||
|
||||
|
||||
|
||||
typedef std::pair< ref_ptr<Array>, ref_ptr<IndexArray> > TexCoordArrayPair;
|
||||
typedef std::vector< TexCoordArrayPair > TexCoordArrayList;
|
||||
|
||||
|
||||
void setTexCoordArray(unsigned int unit,Array*);
|
||||
Array* getTexCoordArray(unsigned int unit);
|
||||
const Array* getTexCoordArray(unsigned int unit) const;
|
||||
|
||||
void setTexCoordIndices(unsigned int unit,IndexArray*);
|
||||
IndexArray* getTexCoordIndices(unsigned int unit);
|
||||
const IndexArray* getTexCoordIndices(unsigned int unit) const;
|
||||
|
||||
unsigned int getNumTexCoordArrays() const { return _texCoordList.size(); }
|
||||
TexCoordArrayList& getTexCoordArrayList() { return _texCoordList; }
|
||||
const TexCoordArrayList& getTexCoordArrayList() const { return _texCoordList; }
|
||||
|
||||
|
||||
typedef std::vector< ref_ptr<PrimitiveSet> > PrimitiveList;
|
||||
typedef std::vector< ref_ptr<PrimitiveSet> > PrimitiveSetList;
|
||||
|
||||
void setPrimitiveList(const PrimitiveList& primitives) { _primitives = primitives; dirtyDisplayList(); }
|
||||
PrimitiveList& getPrimitiveList() { return _primitives; }
|
||||
const PrimitiveList& getPrimitiveList() const { return _primitives; }
|
||||
void setPrimitiveSetList(const PrimitiveSetList& primitives) { _primitives = primitives; dirtyDisplayList(); dirtyBound(); }
|
||||
PrimitiveSetList& getPrimitiveSetList() { return _primitives; }
|
||||
const PrimitiveSetList& getPrimitiveSetList() const { return _primitives; }
|
||||
|
||||
unsigned int getNumPrimitives() const { return _primitives.size(); }
|
||||
PrimitiveSet* getPrimitive(unsigned int pos) { return _primitives[pos].get(); }
|
||||
const PrimitiveSet* getPrimitive(unsigned int pos) const { return _primitives[pos].get(); }
|
||||
unsigned int getNumPrimitiveSets() const { return _primitives.size(); }
|
||||
PrimitiveSet* getPrimitiveSet(unsigned int pos) { return _primitives[pos].get(); }
|
||||
const PrimitiveSet* getPrimitiveSet(unsigned int pos) const { return _primitives[pos].get(); }
|
||||
|
||||
void addPrimitive(PrimitiveSet* primitive) { if (primitive) _primitives.push_back(primitive); dirtyDisplayList(); }
|
||||
void addPrimitiveSet(PrimitiveSet* primitive) { if (primitive) _primitives.push_back(primitive); dirtyDisplayList(); dirtyBound(); }
|
||||
|
||||
/** return true if OpenGL fast paths will be used with drawing this Geometry.
|
||||
* Fast paths use vertex arrays, and glDrawArrays/glDrawElements. Slow paths
|
||||
* use glBegin()/glVertex.../glEnd(). Use of per primtive bindings or per vertex indexed
|
||||
* arrays will drop the rendering path off the fast path.*/
|
||||
bool areFastPathsUsed() const;
|
||||
|
||||
|
||||
bool verifyBindings() const;
|
||||
|
||||
void computeCorrectBindingsAndArraySizes();
|
||||
|
||||
|
||||
@@ -126,23 +159,31 @@ class SG_EXPORT Geometry : public Drawable
|
||||
|
||||
virtual ~Geometry();
|
||||
|
||||
PrimitiveList _primitives;
|
||||
PrimitiveSetList _primitives;
|
||||
|
||||
ref_ptr<Vec3Array> _vertexArray;
|
||||
ref_ptr<IndexArray> _vertexIndices;
|
||||
|
||||
AttributeBinding _normalBinding;
|
||||
mutable AttributeBinding _normalBinding;
|
||||
ref_ptr<Vec3Array> _normalArray;
|
||||
ref_ptr<IndexArray> _normalIndices;
|
||||
|
||||
AttributeBinding _colorBinding;
|
||||
mutable AttributeBinding _colorBinding;
|
||||
ref_ptr<Array> _colorArray;
|
||||
ref_ptr<IndexArray> _colorIndices;
|
||||
|
||||
AttributeBinding _secondaryColorBinding;
|
||||
mutable AttributeBinding _secondaryColorBinding;
|
||||
ref_ptr<Array> _secondaryColorArray;
|
||||
ref_ptr<IndexArray> _secondaryColorIndices;
|
||||
|
||||
AttributeBinding _fogCoordBinding;
|
||||
mutable AttributeBinding _fogCoordBinding;
|
||||
ref_ptr<FloatArray> _fogCoordArray;
|
||||
ref_ptr<IndexArray> _fogCoordIndices;
|
||||
|
||||
TexCoordArrayList _texCoordList;
|
||||
|
||||
mutable bool _fastPathComputed;
|
||||
mutable bool _fastPath;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -1,185 +0,0 @@
|
||||
//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield
|
||||
//Distributed under the terms of the GNU Library General Public License (LGPL)
|
||||
//as published by the Free Software Foundation.
|
||||
|
||||
#ifndef OSG_INDEXEDGEOMETRY
|
||||
#define OSG_INDEXEDGEOMETRY 1
|
||||
|
||||
#include <osg/Drawable>
|
||||
#include <osg/Vec2>
|
||||
#include <osg/Vec3>
|
||||
#include <osg/Vec4>
|
||||
#include <osg/Array>
|
||||
#include <osg/PrimitiveSet>
|
||||
|
||||
namespace osg {
|
||||
|
||||
|
||||
class SG_EXPORT IndexedGeometry : public Drawable
|
||||
{
|
||||
public:
|
||||
|
||||
IndexedGeometry();
|
||||
|
||||
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
|
||||
IndexedGeometry(const IndexedGeometry& geometry,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
|
||||
|
||||
virtual Object* cloneType() const { return osgNew IndexedGeometry(); }
|
||||
virtual Object* clone(const CopyOp& copyop) const { return osgNew IndexedGeometry(*this,copyop); }
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const IndexedGeometry*>(obj)!=NULL; }
|
||||
virtual const char* libraryName() const { return "osg"; }
|
||||
virtual const char* className() const { return "IndexedGeometry"; }
|
||||
|
||||
virtual IndexedGeometry* asIndexedGeometry() { return this; }
|
||||
virtual const IndexedGeometry* asIndexedGeometry() const { return this; }
|
||||
|
||||
enum AttributeBinding
|
||||
{
|
||||
BIND_OFF=0,
|
||||
BIND_OVERALL,
|
||||
BIND_PER_PRIMITIVE_SET,
|
||||
BIND_PER_PRIMITIVE,
|
||||
BIND_PER_VERTEX
|
||||
};
|
||||
|
||||
void setVertexArray(Vec3Array* array) { _vertexArray = array; dirtyDisplayList(); dirtyBound(); }
|
||||
Vec3Array* getVertexArray() { return _vertexArray.get(); }
|
||||
const Vec3Array* getVertexArray() const { return _vertexArray.get(); }
|
||||
|
||||
void setVertexIndices(IndexArray* array) { _vertexIndices = array; dirtyDisplayList(); dirtyBound(); }
|
||||
IndexArray* getVertexIndices() { return _vertexIndices.get(); }
|
||||
const IndexArray* getVertexIndices() const { return _vertexIndices.get(); }
|
||||
|
||||
|
||||
void setNormalBinding(AttributeBinding ab) { _normalBinding = ab; dirtyDisplayList(); }
|
||||
AttributeBinding getNormalBinding() const { return _normalBinding; }
|
||||
|
||||
void setNormalArray(Vec3Array* array) { _normalArray = array; if (!_normalArray.valid()) _normalBinding=BIND_OFF; dirtyDisplayList(); }
|
||||
Vec3Array* getNormalArray() { return _normalArray.get(); }
|
||||
const Vec3Array* getNormalArray() const { return _normalArray.get(); }
|
||||
|
||||
void setNormalIndices(IndexArray* array) { _normalIndices = array; dirtyDisplayList(); }
|
||||
IndexArray* getNormalIndices() { return _normalIndices.get(); }
|
||||
const IndexArray* getNormalIndices() const { return _normalIndices.get(); }
|
||||
|
||||
|
||||
void setColorBinding(AttributeBinding ab) { _colorBinding = ab; }
|
||||
AttributeBinding getColorBinding() const { return _colorBinding; }
|
||||
|
||||
void setColorArray(Array* array) { _colorArray = array; if (!_colorArray.valid()) _colorBinding=BIND_OFF; dirtyDisplayList(); }
|
||||
Array* getColorArray() { return _colorArray.get(); }
|
||||
const Array* getColorArray() const { return _colorArray.get(); }
|
||||
|
||||
void setColorIndices(IndexArray* array) { _colorIndices = array; dirtyDisplayList(); }
|
||||
IndexArray* getColorIndices() { return _colorIndices.get(); }
|
||||
const IndexArray* getColorIndices() const { return _colorIndices.get(); }
|
||||
|
||||
|
||||
void setSecondaryColorBinding(AttributeBinding ab) { _secondaryColorBinding = ab; }
|
||||
AttributeBinding getSecondaryColorBinding() const { return _secondaryColorBinding; }
|
||||
|
||||
void setSecondaryColorArray(Array* array) { _secondaryColorArray = array; if (!_secondaryColorArray.valid()) _secondaryColorBinding=BIND_OFF; dirtyDisplayList(); }
|
||||
Array* getSecondaryColorArray() { return _secondaryColorArray.get(); }
|
||||
const Array* getSecondaryColorArray() const { return _secondaryColorArray.get(); }
|
||||
|
||||
void setSecondaryColorIndices(IndexArray* array) { _secondaryColorIndices = array; dirtyDisplayList(); }
|
||||
IndexArray* getSecondaryColorIndices() { return _secondaryColorIndices.get(); }
|
||||
const IndexArray* getSecondaryColorIndices() const { return _secondaryColorIndices.get(); }
|
||||
|
||||
|
||||
void setFogCoordBinding(AttributeBinding ab) { _fogCoordBinding = ab; }
|
||||
AttributeBinding getFogCoordBinding() const { return _fogCoordBinding; }
|
||||
|
||||
void setFogCoordArray(FloatArray* array) { _fogCoordArray = array; if (!_fogCoordArray.valid()) _fogCoordBinding=BIND_OFF; dirtyDisplayList(); }
|
||||
FloatArray* getFogCoordArray() { return _fogCoordArray.get(); }
|
||||
const FloatArray* getFogCoordArray() const { return _fogCoordArray.get(); }
|
||||
|
||||
|
||||
void setFogCoordIndices(IndexArray* array) { _fogCoordIndices = array; dirtyDisplayList(); }
|
||||
IndexArray* getFogCoordIndices() { return _fogCoordIndices.get(); }
|
||||
const IndexArray* getFogCoordIndices() const { return _fogCoordIndices.get(); }
|
||||
|
||||
|
||||
|
||||
typedef std::pair< ref_ptr<Array>, ref_ptr<IndexArray> > TexCoordArrayPair;
|
||||
typedef std::vector< TexCoordArrayPair > TexCoordArrayList;
|
||||
|
||||
|
||||
void setTexCoordArray(unsigned int unit,Array*);
|
||||
Array* getTexCoordArray(unsigned int unit);
|
||||
const Array* getTexCoordArray(unsigned int unit) const;
|
||||
|
||||
void setTexCoordIndices(unsigned int unit,IndexArray*);
|
||||
IndexArray* getTexCoordIndices(unsigned int unit);
|
||||
const IndexArray* getTexCoordIndices(unsigned int unit) const;
|
||||
|
||||
unsigned int getNumTexCoordArrays() const { return _texCoordList.size(); }
|
||||
TexCoordArrayList& getTexCoordArrayList() { return _texCoordList; }
|
||||
const TexCoordArrayList& getTexCoordArrayList() const { return _texCoordList; }
|
||||
|
||||
|
||||
typedef std::vector< ref_ptr<PrimitiveSet> > PrimitiveSetList;
|
||||
|
||||
void setPrimitiveSetList(const PrimitiveSetList& primitives) { _primitives = primitives; dirtyDisplayList(); dirtyBound(); }
|
||||
PrimitiveSetList& getPrimitiveSetList() { return _primitives; }
|
||||
const PrimitiveSetList& getPrimitiveSetList() const { return _primitives; }
|
||||
|
||||
unsigned int getNumPrimitiveSet() const { return _primitives.size(); }
|
||||
PrimitiveSet* getPrimitiveSet(unsigned int pos) { return _primitives[pos].get(); }
|
||||
const PrimitiveSet* getPrimitiveSet(unsigned int pos) const { return _primitives[pos].get(); }
|
||||
|
||||
void addPrimitiveSet(PrimitiveSet* primitive) { if (primitive) _primitives.push_back(primitive); dirtyDisplayList(); dirtyBound(); }
|
||||
|
||||
|
||||
bool verifyBindings() const;
|
||||
|
||||
void computeCorrectBindingsAndArraySizes();
|
||||
|
||||
|
||||
/** draw IndexedGeometry directly ignoring an OpenGL display list which could be attached.
|
||||
* This is the internal draw method which does the drawing itself,
|
||||
* and is the method to override when deriving from IndexedGeometry for user-drawn objects.
|
||||
*/
|
||||
virtual void drawImmediateMode(State& state);
|
||||
|
||||
/** accept an AttributeFunctor and call its methods to tell it about the interal attributes that this Drawable has.*/
|
||||
virtual void accept(AttributeFunctor& af);
|
||||
|
||||
/** accept a PrimtiveFunctor and call its methods to tell it about the interal primtives that this Drawable has.*/
|
||||
virtual void accept(PrimitiveFunctor& pf);
|
||||
|
||||
protected:
|
||||
|
||||
IndexedGeometry& operator = (const IndexedGeometry&) { return *this;}
|
||||
|
||||
virtual ~IndexedGeometry();
|
||||
|
||||
PrimitiveSetList _primitives;
|
||||
|
||||
ref_ptr<Vec3Array> _vertexArray;
|
||||
ref_ptr<IndexArray> _vertexIndices;
|
||||
|
||||
AttributeBinding _normalBinding;
|
||||
ref_ptr<Vec3Array> _normalArray;
|
||||
ref_ptr<IndexArray> _normalIndices;
|
||||
|
||||
AttributeBinding _colorBinding;
|
||||
ref_ptr<Array> _colorArray;
|
||||
ref_ptr<IndexArray> _colorIndices;
|
||||
|
||||
AttributeBinding _secondaryColorBinding;
|
||||
ref_ptr<Array> _secondaryColorArray;
|
||||
ref_ptr<IndexArray> _secondaryColorIndices;
|
||||
|
||||
AttributeBinding _fogCoordBinding;
|
||||
ref_ptr<FloatArray> _fogCoordArray;
|
||||
ref_ptr<IndexArray> _fogCoordIndices;
|
||||
|
||||
TexCoordArrayList _texCoordList;
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user