Renamed osg::Primitive to osg::PrimitiveSet which better reflect what it
encapsulates. Added new osg::IndexGeometry implemention, *not* complete yet. Changed the rest of the OSG to handle the renaming og Primitive to PrimitiveSet.
This commit is contained in:
9
NEWS
9
NEWS
@@ -2,6 +2,15 @@
|
||||
OSG News (most significant items from ChangeLog)
|
||||
================================================
|
||||
|
||||
Support added for handling different extensions on different graphics
|
||||
contexts.
|
||||
|
||||
Sort callbacks added to osg::RenderStage.
|
||||
|
||||
Support for multitexturing added to OpenFlight loader.
|
||||
|
||||
Added PolygonStipple class.
|
||||
|
||||
30th August 2002 - OpenSceneGraph-0.9.1.tar.gz
|
||||
|
||||
>>> Support added for 1D & 3D textures, texture env combiners, secondary color and fog coords, DOFTransform and Sequence nodes. Inventor/VRML and LWO2 loaders added and the a port HP-UX!
|
||||
|
||||
@@ -209,6 +209,10 @@ SOURCE=..\..\src\osg\Geometry.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\osg\IndexedGeometry.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\osg\GeoSet.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -557,6 +561,10 @@ SOURCE=..\..\Include\Osg\Geometry
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Include\Osg\IndexedGeometry
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Include\Osg\GeoSet
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -158,6 +158,10 @@ SOURCE=..\..\..\src\osgPlugins\osg\Geometry.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\osg\IndexedGeometry.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\osg\Group.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -19,7 +19,7 @@ class StateAttribute;
|
||||
class Node;
|
||||
class Drawable;
|
||||
class Array;
|
||||
class Primitive;
|
||||
class PrimitiveSet;
|
||||
|
||||
/** Copy Op(erator) used to control the whether shallow or deep copy is used
|
||||
* during copy construction and clone operation.*/
|
||||
@@ -56,8 +56,8 @@ class SG_EXPORT CopyOp
|
||||
virtual StateAttribute* operator() (const StateAttribute* attr) const;
|
||||
virtual Texture* operator() (const Texture* text) const;
|
||||
virtual Image* operator() (const Image* image) const;
|
||||
virtual Array* operator() (const Array* image) const;
|
||||
virtual Primitive* operator() (const Primitive* image) const;
|
||||
virtual Array* operator() (const Array* array) const;
|
||||
virtual PrimitiveSet* operator() (const PrimitiveSet* primitives) const;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <osg/Vec3>
|
||||
#include <osg/Vec4>
|
||||
#include <osg/Array>
|
||||
#include <osg/Primitive>
|
||||
#include <osg/PrimitiveSet>
|
||||
|
||||
namespace osg {
|
||||
|
||||
@@ -90,17 +90,17 @@ class SG_EXPORT Geometry : public Drawable
|
||||
const TexCoordArrayList& getTexCoordArrayList() const { return _texCoordList; }
|
||||
|
||||
|
||||
typedef std::vector< ref_ptr<Primitive> > PrimitiveList;
|
||||
typedef std::vector< ref_ptr<PrimitiveSet> > PrimitiveList;
|
||||
|
||||
void setPrimitiveList(const PrimitiveList& primitives) { _primitives = primitives; dirtyDisplayList(); }
|
||||
PrimitiveList& getPrimitiveList() { return _primitives; }
|
||||
const PrimitiveList& getPrimitiveList() const { return _primitives; }
|
||||
|
||||
unsigned int getNumPrimitives() const { return _primitives.size(); }
|
||||
Primitive* getPrimitive(unsigned int pos) { return _primitives[pos].get(); }
|
||||
const Primitive* getPrimitive(unsigned int pos) const { return _primitives[pos].get(); }
|
||||
PrimitiveSet* getPrimitive(unsigned int pos) { return _primitives[pos].get(); }
|
||||
const PrimitiveSet* getPrimitive(unsigned int pos) const { return _primitives[pos].get(); }
|
||||
|
||||
void addPrimitive(Primitive* primitive) { if (primitive) _primitives.push_back(primitive); dirtyDisplayList(); }
|
||||
void addPrimitive(PrimitiveSet* primitive) { if (primitive) _primitives.push_back(primitive); dirtyDisplayList(); }
|
||||
|
||||
|
||||
bool verifyBindings() const;
|
||||
|
||||
185
include/osg/IndexedGeometry
Normal file
185
include/osg/IndexedGeometry
Normal file
@@ -0,0 +1,185 @@
|
||||
//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_GEOMETRY
|
||||
#define OSG_GEOMETRY 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(Array* array) { _vertexIndices = array; dirtyDisplayList(); dirtyBound(); }
|
||||
Array* getVertexIndices() { return _vertexIndices.get(); }
|
||||
const Array* 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(Array* array) { _normalIndices = array; dirtyDisplayList(); }
|
||||
Array* getNormalIndices() { return _normalIndices.get(); }
|
||||
const Array* 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(Array* array) { _colorIndices = array; dirtyDisplayList(); }
|
||||
Array* getColorIndices() { return _colorIndices.get(); }
|
||||
const Array* 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(Array* array) { _secondaryColorIndices = array; dirtyDisplayList(); }
|
||||
Array* getSecondaryColorIndices() { return _secondaryColorIndices.get(); }
|
||||
const Array* 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(Array* array) { _fogCoordIndices = array; dirtyDisplayList(); }
|
||||
Array* getFogCoordIndices() { return _fogCoordIndices.get(); }
|
||||
const Array* getFogCoordIndices() const { return _fogCoordIndices.get(); }
|
||||
|
||||
|
||||
|
||||
typedef std::pair< ref_ptr<Array>, ref_ptr<Array> > 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,Array*);
|
||||
Array* getTexCoordIndices(unsigned int unit);
|
||||
const Array* 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<Array> _vertexIndices;
|
||||
|
||||
AttributeBinding _normalBinding;
|
||||
ref_ptr<Vec3Array> _normalArray;
|
||||
ref_ptr<Array> _normalIndices;
|
||||
|
||||
AttributeBinding _colorBinding;
|
||||
ref_ptr<Array> _colorArray;
|
||||
ref_ptr<Array> _colorIndices;
|
||||
|
||||
AttributeBinding _secondaryColorBinding;
|
||||
ref_ptr<Array> _secondaryColorArray;
|
||||
ref_ptr<Array> _secondaryColorIndices;
|
||||
|
||||
AttributeBinding _fogCoordBinding;
|
||||
ref_ptr<FloatArray> _fogCoordArray;
|
||||
ref_ptr<Array> _fogCoordIndices;
|
||||
|
||||
TexCoordArrayList _texCoordList;
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -2,8 +2,8 @@
|
||||
//Distributed under the terms of the GNU Library General Public License (LGPL)
|
||||
//as published by the Free Software Foundation.
|
||||
|
||||
#ifndef OSG_PRIMTIVE
|
||||
#define OSG_PRIMTIVE 1
|
||||
#ifndef OSG_PRIMTIVESET
|
||||
#define OSG_PRIMTIVESET 1
|
||||
|
||||
#include <osg/Drawable>
|
||||
|
||||
@@ -75,7 +75,7 @@ public:
|
||||
#endif
|
||||
|
||||
|
||||
class Primitive : public Object
|
||||
class PrimitiveSet : public Object
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -103,18 +103,18 @@ class Primitive : public Object
|
||||
POLYGON = GL_POLYGON
|
||||
};
|
||||
|
||||
Primitive(Type primType=PrimitiveType,GLenum mode=0):
|
||||
PrimitiveSet(Type primType=PrimitiveType,GLenum mode=0):
|
||||
_primitiveType(primType),
|
||||
_mode(mode) {}
|
||||
|
||||
Primitive(const Primitive& prim,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
||||
PrimitiveSet(const PrimitiveSet& prim,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
||||
Object(prim,copyop),
|
||||
_primitiveType(prim._primitiveType),
|
||||
_mode(prim._mode) {}
|
||||
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const Primitive*>(obj)!=NULL; }
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const PrimitiveSet*>(obj)!=NULL; }
|
||||
virtual const char* libraryName() const { return "osg"; }
|
||||
virtual const char* className() const { return "Primitive"; }
|
||||
virtual const char* className() const { return "PrimitiveSet"; }
|
||||
|
||||
Type getType() const { return _primitiveType; }
|
||||
|
||||
@@ -135,22 +135,26 @@ class Primitive : public Object
|
||||
GLenum _mode;
|
||||
};
|
||||
|
||||
class SG_EXPORT DrawArrays : public Primitive
|
||||
// temporary addition for backwards compatiblity.
|
||||
typedef PrimitiveSet Primitive;
|
||||
|
||||
|
||||
class SG_EXPORT DrawArrays : public PrimitiveSet
|
||||
{
|
||||
public:
|
||||
|
||||
DrawArrays(GLenum mode=0):
|
||||
Primitive(DrawArraysPrimitiveType,mode),
|
||||
PrimitiveSet(DrawArraysPrimitiveType,mode),
|
||||
_first(0),
|
||||
_count(0) {}
|
||||
|
||||
DrawArrays(GLenum mode, GLint first, GLsizei count):
|
||||
Primitive(DrawArraysPrimitiveType,mode),
|
||||
PrimitiveSet(DrawArraysPrimitiveType,mode),
|
||||
_first(first),
|
||||
_count(count) {}
|
||||
|
||||
DrawArrays(const DrawArrays& da,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
||||
Primitive(da,copyop),
|
||||
PrimitiveSet(da,copyop),
|
||||
_first(da._first),
|
||||
_count(da._count) {}
|
||||
|
||||
@@ -188,32 +192,32 @@ class SG_EXPORT DrawArrays : public Primitive
|
||||
GLsizei _count;
|
||||
};
|
||||
|
||||
class SG_EXPORT DrawArrayLengths : public Primitive, public VectorSizei
|
||||
class SG_EXPORT DrawArrayLengths : public PrimitiveSet, public VectorSizei
|
||||
{
|
||||
public:
|
||||
|
||||
DrawArrayLengths(GLenum mode=0):
|
||||
Primitive(DrawArrayLengthsPrimitiveType,mode),
|
||||
PrimitiveSet(DrawArrayLengthsPrimitiveType,mode),
|
||||
_first(0) {}
|
||||
|
||||
DrawArrayLengths(const DrawArrayLengths& dal,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
||||
Primitive(dal,copyop),
|
||||
PrimitiveSet(dal,copyop),
|
||||
VectorSizei(dal),
|
||||
_first(dal._first) {}
|
||||
|
||||
DrawArrayLengths(GLenum mode, GLint first, unsigned int no, GLsizei* ptr) :
|
||||
Primitive(DrawArrayLengthsPrimitiveType,mode),
|
||||
PrimitiveSet(DrawArrayLengthsPrimitiveType,mode),
|
||||
VectorSizei(ptr,ptr+no),
|
||||
_first(first) {}
|
||||
|
||||
DrawArrayLengths(GLenum mode,GLint first, unsigned int no) :
|
||||
Primitive(DrawArrayLengthsPrimitiveType,mode),
|
||||
PrimitiveSet(DrawArrayLengthsPrimitiveType,mode),
|
||||
VectorSizei(no),
|
||||
_first(first) {}
|
||||
|
||||
template <class InputIterator>
|
||||
DrawArrayLengths(GLenum mode, GLint first, InputIterator firstItr,InputIterator lastItr) :
|
||||
Primitive(DrawArrayLengthsPrimitiveType,mode),
|
||||
PrimitiveSet(DrawArrayLengthsPrimitiveType,mode),
|
||||
VectorSizei(firstItr,lastItr),
|
||||
_first(first) {}
|
||||
|
||||
@@ -240,28 +244,28 @@ class SG_EXPORT DrawArrayLengths : public Primitive, public VectorSizei
|
||||
GLint _first;
|
||||
};
|
||||
|
||||
class SG_EXPORT DrawElementsUByte : public Primitive, public VectorUByte
|
||||
class SG_EXPORT DrawElementsUByte : public PrimitiveSet, public VectorUByte
|
||||
{
|
||||
public:
|
||||
|
||||
DrawElementsUByte(GLenum mode=0):
|
||||
Primitive(DrawElementsUBytePrimitiveType,mode) {}
|
||||
PrimitiveSet(DrawElementsUBytePrimitiveType,mode) {}
|
||||
|
||||
DrawElementsUByte(const DrawElementsUByte& array,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
||||
Primitive(array,copyop),
|
||||
PrimitiveSet(array,copyop),
|
||||
VectorUByte(array) {}
|
||||
|
||||
DrawElementsUByte(GLenum mode,unsigned int no,GLubyte* ptr) :
|
||||
Primitive(DrawElementsUBytePrimitiveType,mode),
|
||||
PrimitiveSet(DrawElementsUBytePrimitiveType,mode),
|
||||
VectorUByte(ptr,ptr+no) {}
|
||||
|
||||
DrawElementsUByte(GLenum mode,unsigned int no) :
|
||||
Primitive(DrawElementsUBytePrimitiveType,mode),
|
||||
PrimitiveSet(DrawElementsUBytePrimitiveType,mode),
|
||||
VectorUByte(no) {}
|
||||
|
||||
template <class InputIterator>
|
||||
DrawElementsUByte(GLenum mode, InputIterator first,InputIterator last) :
|
||||
Primitive(DrawElementsUBytePrimitiveType,mode),
|
||||
PrimitiveSet(DrawElementsUBytePrimitiveType,mode),
|
||||
VectorUByte(first,last) {}
|
||||
|
||||
virtual Object* cloneType() const { return osgNew DrawElementsUByte(); }
|
||||
@@ -280,28 +284,28 @@ class SG_EXPORT DrawElementsUByte : public Primitive, public VectorUByte
|
||||
};
|
||||
|
||||
|
||||
class SG_EXPORT DrawElementsUShort : public Primitive, public VectorUShort
|
||||
class SG_EXPORT DrawElementsUShort : public PrimitiveSet, public VectorUShort
|
||||
{
|
||||
public:
|
||||
|
||||
DrawElementsUShort(GLenum mode=0):
|
||||
Primitive(DrawElementsUShortPrimitiveType,mode) {}
|
||||
PrimitiveSet(DrawElementsUShortPrimitiveType,mode) {}
|
||||
|
||||
DrawElementsUShort(const DrawElementsUShort& array,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
||||
Primitive(array,copyop),
|
||||
PrimitiveSet(array,copyop),
|
||||
VectorUShort(array) {}
|
||||
|
||||
DrawElementsUShort(GLenum mode,unsigned int no,GLushort* ptr) :
|
||||
Primitive(DrawElementsUShortPrimitiveType,mode),
|
||||
PrimitiveSet(DrawElementsUShortPrimitiveType,mode),
|
||||
VectorUShort(ptr,ptr+no) {}
|
||||
|
||||
DrawElementsUShort(GLenum mode,unsigned int no) :
|
||||
Primitive(DrawElementsUShortPrimitiveType,mode),
|
||||
PrimitiveSet(DrawElementsUShortPrimitiveType,mode),
|
||||
VectorUShort(no) {}
|
||||
|
||||
template <class InputIterator>
|
||||
DrawElementsUShort(GLenum mode, InputIterator first,InputIterator last) :
|
||||
Primitive(DrawElementsUShortPrimitiveType,mode),
|
||||
PrimitiveSet(DrawElementsUShortPrimitiveType,mode),
|
||||
VectorUShort(first,last) {}
|
||||
|
||||
virtual Object* cloneType() const { return osgNew DrawElementsUShort(); }
|
||||
@@ -319,28 +323,28 @@ class SG_EXPORT DrawElementsUShort : public Primitive, public VectorUShort
|
||||
virtual unsigned int getNumIndices() { return size(); }
|
||||
};
|
||||
|
||||
class SG_EXPORT DrawElementsUInt : public Primitive, public VectorUInt
|
||||
class SG_EXPORT DrawElementsUInt : public PrimitiveSet, public VectorUInt
|
||||
{
|
||||
public:
|
||||
|
||||
DrawElementsUInt(GLenum mode=0):
|
||||
Primitive(DrawElementsUIntPrimitiveType,mode) {}
|
||||
PrimitiveSet(DrawElementsUIntPrimitiveType,mode) {}
|
||||
|
||||
DrawElementsUInt(const DrawElementsUInt& array,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
||||
Primitive(array,copyop),
|
||||
PrimitiveSet(array,copyop),
|
||||
VectorUInt(array) {}
|
||||
|
||||
DrawElementsUInt(GLenum mode,unsigned int no,GLuint* ptr) :
|
||||
Primitive(DrawElementsUIntPrimitiveType,mode),
|
||||
PrimitiveSet(DrawElementsUIntPrimitiveType,mode),
|
||||
VectorUInt(ptr,ptr+no) {}
|
||||
|
||||
DrawElementsUInt(GLenum mode,unsigned int no) :
|
||||
Primitive(DrawElementsUIntPrimitiveType,mode),
|
||||
PrimitiveSet(DrawElementsUIntPrimitiveType,mode),
|
||||
VectorUInt(no) {}
|
||||
|
||||
template <class InputIterator>
|
||||
DrawElementsUInt(GLenum mode, InputIterator first,InputIterator last) :
|
||||
Primitive(DrawElementsUIntPrimitiveType,mode),
|
||||
PrimitiveSet(DrawElementsUIntPrimitiveType,mode),
|
||||
VectorUInt(first,last) {}
|
||||
|
||||
virtual Object* cloneType() const { return osgNew DrawElementsUInt(); }
|
||||
@@ -358,11 +362,6 @@ class SG_EXPORT DrawElementsUInt : public Primitive, public VectorUInt
|
||||
virtual unsigned int getNumIndices() { return size(); }
|
||||
};
|
||||
|
||||
// backwards compatibility with first incarnation of DrawElements nameing convention.
|
||||
typedef DrawElementsUByte UByteDrawElements;
|
||||
typedef DrawElementsUShort UShortDrawElements;
|
||||
typedef DrawElementsUInt UIntDrawElements;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -190,7 +190,7 @@ class SG_EXPORT StateSet : public Object
|
||||
void setRenderBinDetails(int binNum,const std::string& binName,RenderBinMode mode=USE_RENDERBIN_DETAILS);
|
||||
|
||||
/** set the render bin details to inherit.*/
|
||||
void setRendingBinToInherit();
|
||||
void setRenderBinToInherit();
|
||||
|
||||
/** get the render bin mode.*/
|
||||
inline RenderBinMode getRenderBinMode() const { return _binMode; }
|
||||
|
||||
@@ -57,87 +57,87 @@ requests, translating them into calls to the windowing API.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
|
||||
\namespace osgGA::CmdLineArgs
|
||||
|
||||
A collection of utilities for processing command line arguments.
|
||||
|
||||
An osgGA::CmdLineArgs::Processor class is provided, which implements a chain
|
||||
of responsibilty for handline command line arguments. Each item in the chain
|
||||
is a subclass of the abstract osgGA::CmdLineArgs::ArgHandler. A number
|
||||
of ArgHandlers are provided, though the user if free to implement their
|
||||
own subclasses for specific needs (e.g. to validate an argument which
|
||||
takes an integer which must be in a specific range).
|
||||
|
||||
Let's look at an example...
|
||||
|
||||
<h2>Example</h2>
|
||||
|
||||
\code
|
||||
|
||||
#include <osgGA/CmdLineArgs>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
using namespace osg;
|
||||
using namespace osgGA::CmdLineArgs;
|
||||
|
||||
// Create some handlers
|
||||
ref_ptr<BoolHandler> helpSwitch(new BoolHandler("[-h]","\t\tPrint this help and exit","-h"));
|
||||
ref_ptr<BoolHandler> verboseSwitch(new BoolHandler("[-v]","\t\tActivate verbose output","-v"));
|
||||
ref_ptr<SwitchStringHandler> configFile(
|
||||
new SwitchStringHandler("[-config <configfile>",
|
||||
"\t\tSpecify a config file to load"), "-config");
|
||||
|
||||
Processor clp;
|
||||
clp.push_back(helpSwitch.get());
|
||||
clp.push_back(verboseSwitch.get());
|
||||
clp.push_back(configFile.get());
|
||||
|
||||
try{
|
||||
clp.process(argc,argv);
|
||||
}
|
||||
catch(ArgHandlerX& e){
|
||||
cerr<<e.what()<<endl;
|
||||
clp.printUsage(cerr);
|
||||
exit(1);
|
||||
}
|
||||
catch(...){
|
||||
cerr<<"Unknown exception caught while processing command line arguments."<<endl;
|
||||
clp.printUsage(cerr);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if(helpSwitch->wasSpecified()){
|
||||
clp.printHelp(cerr);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if(verboseSwitch->wasSpecified()){
|
||||
// Activate verbosity...
|
||||
}
|
||||
|
||||
if(configFile->wasSpecified()){
|
||||
loadConfigFile(configFile->getString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
\endcode
|
||||
|
||||
The processor takes each argument on the command line in turn, and passes it
|
||||
to the ArgHandler chain. Each ArgHandler is given the opportunity to handle
|
||||
an argument and - if it requires - any subsequent arguments until the
|
||||
end of the argument list (it can do this by incrementing the ArgIterator
|
||||
passed to it. If an ArgHandler handles an argument (e.g. it's looking for
|
||||
and recognises the argument '-h'), it returns true and further processing of
|
||||
the argument stops. If an argument is not handled it is passed to the next
|
||||
handler in the chain, and so on, until it is either handled, or it drops off
|
||||
the end of the chain.
|
||||
|
||||
A number of pre-written ArgHandlers are supplied. User's may use these
|
||||
directly, may write their own, or may extend a pre-written ArgHandler to
|
||||
customise it for their specific needs.
|
||||
|
||||
*/
|
||||
// /**
|
||||
//
|
||||
// \namespace osgGA::CmdLineArgs
|
||||
//
|
||||
// A collection of utilities for processing command line arguments.
|
||||
//
|
||||
// An osgGA::CmdLineArgs::Processor class is provided, which implements a chain
|
||||
// of responsibilty for handline command line arguments. Each item in the chain
|
||||
// is a subclass of the abstract osgGA::CmdLineArgs::ArgHandler. A number
|
||||
// of ArgHandlers are provided, though the user if free to implement their
|
||||
// own subclasses for specific needs (e.g. to validate an argument which
|
||||
// takes an integer which must be in a specific range).
|
||||
//
|
||||
// Let's look at an example...
|
||||
//
|
||||
// <h2>Example</h2>
|
||||
//
|
||||
// \code
|
||||
//
|
||||
// #include <osgGA/CmdLineArgs>
|
||||
//
|
||||
// int main(int argc, char* argv[])
|
||||
// {
|
||||
// using namespace osg;
|
||||
// using namespace osgGA::CmdLineArgs;
|
||||
//
|
||||
// // Create some handlers
|
||||
// ref_ptr<BoolHandler> helpSwitch(new BoolHandler("[-h]","\t\tPrint this help and exit","-h"));
|
||||
// ref_ptr<BoolHandler> verboseSwitch(new BoolHandler("[-v]","\t\tActivate verbose output","-v"));
|
||||
// ref_ptr<SwitchStringHandler> configFile(
|
||||
// new SwitchStringHandler("[-config <configfile>",
|
||||
// "\t\tSpecify a config file to load"), "-config");
|
||||
//
|
||||
// Processor clp;
|
||||
// clp.push_back(helpSwitch.get());
|
||||
// clp.push_back(verboseSwitch.get());
|
||||
// clp.push_back(configFile.get());
|
||||
//
|
||||
// try{
|
||||
// clp.process(argc,argv);
|
||||
// }
|
||||
// catch(ArgHandlerX& e){
|
||||
// cerr<<e.what()<<endl;
|
||||
// clp.printUsage(cerr);
|
||||
// exit(1);
|
||||
// }
|
||||
// catch(...){
|
||||
// cerr<<"Unknown exception caught while processing command line arguments."<<endl;
|
||||
// clp.printUsage(cerr);
|
||||
// exit(1);
|
||||
// }
|
||||
//
|
||||
// if(helpSwitch->wasSpecified()){
|
||||
// clp.printHelp(cerr);
|
||||
// exit(0);
|
||||
// }
|
||||
//
|
||||
// if(verboseSwitch->wasSpecified()){
|
||||
// // Activate verbosity...
|
||||
// }
|
||||
//
|
||||
// if(configFile->wasSpecified()){
|
||||
// loadConfigFile(configFile->getString());
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// \endcode
|
||||
//
|
||||
// The processor takes each argument on the command line in turn, and passes it
|
||||
// to the ArgHandler chain. Each ArgHandler is given the opportunity to handle
|
||||
// an argument and - if it requires - any subsequent arguments until the
|
||||
// end of the argument list (it can do this by incrementing the ArgIterator
|
||||
// passed to it. If an ArgHandler handles an argument (e.g. it's looking for
|
||||
// and recognises the argument '-h'), it returns true and further processing of
|
||||
// the argument stops. If an argument is not handled it is passed to the next
|
||||
// handler in the chain, and so on, until it is either handled, or it drops off
|
||||
// the end of the chain.
|
||||
//
|
||||
// A number of pre-written ArgHandlers are supplied. User's may use these
|
||||
// directly, may write their own, or may extend a pre-written ArgHandler to
|
||||
// customise it for their specific needs.
|
||||
//
|
||||
// */
|
||||
|
||||
@@ -54,7 +54,7 @@ osg::Drawable* createSquare(const osg::Vec3& corner,const osg::Vec3& width,const
|
||||
(*tcoords)[3].set(0.0f,1.0f);
|
||||
geom->setTexCoordArray(0,tcoords);
|
||||
|
||||
geom->addPrimitive(osgNew osg::DrawArrays(osg::Primitive::QUADS,0,4));
|
||||
geom->addPrimitive(osgNew osg::DrawArrays(osg::PrimitiveSet::QUADS,0,4));
|
||||
|
||||
if (image)
|
||||
{
|
||||
@@ -98,7 +98,7 @@ osg::Drawable* createAxis(const osg::Vec3& corner,const osg::Vec3& xdir,const os
|
||||
geom->setColorArray(color);
|
||||
geom->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
|
||||
|
||||
geom->addPrimitive(osgNew osg::DrawArrays(osg::Primitive::LINES,0,6));
|
||||
geom->addPrimitive(osgNew osg::DrawArrays(osg::PrimitiveSet::LINES,0,6));
|
||||
|
||||
osg::StateSet* stateset = new osg::StateSet;
|
||||
osg::LineWidth* linewidth = new osg::LineWidth();
|
||||
|
||||
@@ -82,12 +82,12 @@ osg::Geode* createGeometryCube()
|
||||
|
||||
// set up the primitives
|
||||
|
||||
cube->addPrimitive(osgNew osg::DrawArrays(osg::Primitive::POLYGON,0,4));
|
||||
cube->addPrimitive(osgNew osg::DrawArrays(osg::Primitive::POLYGON,4,4));
|
||||
cube->addPrimitive(osgNew osg::DrawArrays(osg::Primitive::POLYGON,8,4));
|
||||
cube->addPrimitive(osgNew osg::DrawArrays(osg::Primitive::POLYGON,12,4));
|
||||
cube->addPrimitive(osgNew osg::DrawArrays(osg::Primitive::POLYGON,16,4));
|
||||
cube->addPrimitive(osgNew osg::DrawArrays(osg::Primitive::POLYGON,20,4));
|
||||
cube->addPrimitive(osgNew osg::DrawArrays(osg::PrimitiveSet::POLYGON,0,4));
|
||||
cube->addPrimitive(osgNew osg::DrawArrays(osg::PrimitiveSet::POLYGON,4,4));
|
||||
cube->addPrimitive(osgNew osg::DrawArrays(osg::PrimitiveSet::POLYGON,8,4));
|
||||
cube->addPrimitive(osgNew osg::DrawArrays(osg::PrimitiveSet::POLYGON,12,4));
|
||||
cube->addPrimitive(osgNew osg::DrawArrays(osg::PrimitiveSet::POLYGON,16,4));
|
||||
cube->addPrimitive(osgNew osg::DrawArrays(osg::PrimitiveSet::POLYGON,20,4));
|
||||
|
||||
|
||||
// set up coords.
|
||||
|
||||
@@ -116,7 +116,7 @@ osg::Node* createScene()
|
||||
// in this case is POINTS (which has the same value GL_POINTS), the second
|
||||
// parameter is the index position into the vertex array of the first point
|
||||
// to draw, and the third parameter is the number of points to draw.
|
||||
pointsGeom->addPrimitive(new osg::DrawArrays(osg::Primitive::POINTS,0,vertices->size()));
|
||||
pointsGeom->addPrimitive(new osg::DrawArrays(osg::PrimitiveSet::POINTS,0,vertices->size()));
|
||||
|
||||
|
||||
// add the points geomtry to the geode.
|
||||
@@ -161,7 +161,7 @@ osg::Node* createScene()
|
||||
|
||||
// This time we simply use primitive, and hardwire the number of coords to use
|
||||
// since we know up front,
|
||||
linesGeom->addPrimitive(new osg::DrawArrays(osg::Primitive::LINES,0,8));
|
||||
linesGeom->addPrimitive(new osg::DrawArrays(osg::PrimitiveSet::LINES,0,8));
|
||||
|
||||
|
||||
// add the points geomtry to the geode.
|
||||
@@ -203,7 +203,7 @@ osg::Node* createScene()
|
||||
|
||||
// This time we simply use primitive, and hardwire the number of coords to use
|
||||
// since we know up front,
|
||||
linesGeom->addPrimitive(new osg::DrawArrays(osg::Primitive::LINE_STRIP,0,5));
|
||||
linesGeom->addPrimitive(new osg::DrawArrays(osg::PrimitiveSet::LINE_STRIP,0,5));
|
||||
|
||||
|
||||
// add the points geomtry to the geode.
|
||||
@@ -250,7 +250,7 @@ osg::Node* createScene()
|
||||
|
||||
// This time we simply use primitive, and hardwire the number of coords to use
|
||||
// since we know up front,
|
||||
linesGeom->addPrimitive(new osg::DrawArrays(osg::Primitive::LINE_LOOP,0,numCoords));
|
||||
linesGeom->addPrimitive(new osg::DrawArrays(osg::PrimitiveSet::LINE_LOOP,0,numCoords));
|
||||
|
||||
|
||||
// add the points geomtry to the geode.
|
||||
@@ -322,7 +322,7 @@ osg::Node* createScene()
|
||||
|
||||
// This time we simply use primitive, and hardwire the number of coords to use
|
||||
// since we know up front,
|
||||
polyGeom->addPrimitive(new osg::DrawArrays(osg::Primitive::POLYGON,0,numCoords));
|
||||
polyGeom->addPrimitive(new osg::DrawArrays(osg::PrimitiveSet::POLYGON,0,numCoords));
|
||||
|
||||
printTriangles("Polygon",*polyGeom);
|
||||
|
||||
@@ -369,7 +369,7 @@ osg::Node* createScene()
|
||||
|
||||
// This time we simply use primitive, and hardwire the number of coords to use
|
||||
// since we know up front,
|
||||
polyGeom->addPrimitive(new osg::DrawArrays(osg::Primitive::QUADS,0,numCoords));
|
||||
polyGeom->addPrimitive(new osg::DrawArrays(osg::PrimitiveSet::QUADS,0,numCoords));
|
||||
|
||||
|
||||
printTriangles("Quads",*polyGeom);
|
||||
@@ -418,7 +418,7 @@ osg::Node* createScene()
|
||||
|
||||
// This time we simply use primitive, and hardwire the number of coords to use
|
||||
// since we know up front,
|
||||
polyGeom->addPrimitive(new osg::DrawArrays(osg::Primitive::QUAD_STRIP,0,numCoords));
|
||||
polyGeom->addPrimitive(new osg::DrawArrays(osg::PrimitiveSet::QUAD_STRIP,0,numCoords));
|
||||
|
||||
|
||||
printTriangles("Quads strip",*polyGeom);
|
||||
@@ -486,9 +486,9 @@ osg::Node* createScene()
|
||||
|
||||
// This time we simply use primitive, and hardwire the number of coords to use
|
||||
// since we know up front,
|
||||
polyGeom->addPrimitive(new osg::DrawArrays(osg::Primitive::TRIANGLES,0,6));
|
||||
polyGeom->addPrimitive(new osg::DrawArrays(osg::Primitive::TRIANGLE_STRIP,6,6));
|
||||
polyGeom->addPrimitive(new osg::DrawArrays(osg::Primitive::TRIANGLE_FAN,12,5));
|
||||
polyGeom->addPrimitive(new osg::DrawArrays(osg::PrimitiveSet::TRIANGLES,0,6));
|
||||
polyGeom->addPrimitive(new osg::DrawArrays(osg::PrimitiveSet::TRIANGLE_STRIP,6,6));
|
||||
polyGeom->addPrimitive(new osg::DrawArrays(osg::PrimitiveSet::TRIANGLE_FAN,12,5));
|
||||
|
||||
// polygon stipple
|
||||
osg::StateSet* stateSet = new osg::StateSet();
|
||||
@@ -604,7 +604,7 @@ osg::Node* createBackground()
|
||||
// contains unsigned char indicies, UShortDrawElements which contains unsigned short indices,
|
||||
// and UIntDrawElements whcih contains ... unsigned int indices.
|
||||
// The first parameter to DrawElements is
|
||||
polyGeom->addPrimitive(new osg::UShortDrawElements(osg::Primitive::QUADS,numIndices,myIndices));
|
||||
polyGeom->addPrimitive(new osg::DrawElementsUShort(osg::PrimitiveSet::QUADS,numIndices,myIndices));
|
||||
|
||||
// new we need to add the texture to the Drawable, we do so by creating a
|
||||
// StateSet to contain the Texture2D StateAttribute.
|
||||
|
||||
@@ -46,7 +46,7 @@ Node *makeBase( void )
|
||||
geom->setColorArray( colors );
|
||||
geom->setColorBinding( Geometry::BIND_OVERALL );
|
||||
|
||||
geom->addPrimitive( new DrawArrays(Primitive::TRIANGLE_FAN,0,19) );
|
||||
geom->addPrimitive( new DrawArrays(PrimitiveSet::TRIANGLE_FAN,0,19) );
|
||||
|
||||
Texture2D *tex = new Texture2D;
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ Node *makeSky( void )
|
||||
|
||||
for( i = 0; i < nlev-1; i++ )
|
||||
{
|
||||
UShortDrawElements* drawElements = new UShortDrawElements(Primitive::TRIANGLE_STRIP);
|
||||
DrawElementsUShort* drawElements = new DrawElementsUShort(PrimitiveSet::TRIANGLE_STRIP);
|
||||
drawElements->reserve(38);
|
||||
|
||||
for( j = 0; j <= 18; j++ )
|
||||
|
||||
@@ -102,7 +102,7 @@ Node *makeTank( void )
|
||||
c++;
|
||||
}
|
||||
|
||||
gset->addPrimitive( new DrawArrays(Primitive::TRIANGLE_STRIP,0,c) );
|
||||
gset->addPrimitive( new DrawArrays(PrimitiveSet::TRIANGLE_STRIP,0,c) );
|
||||
|
||||
// create the top of the tank.
|
||||
|
||||
@@ -144,7 +144,7 @@ Node *makeTank( void )
|
||||
for( i = 0; i < c; i++ )
|
||||
conv( vc[i], *mat, vc[i] );
|
||||
|
||||
gset->addPrimitive(new DrawArrays(Primitive::TRIANGLE_FAN,prev_c,c-prev_c));
|
||||
gset->addPrimitive(new DrawArrays(PrimitiveSet::TRIANGLE_FAN,prev_c,c-prev_c));
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ Node *makeTerrain( void )
|
||||
|
||||
for( i = 0; i < m-2; i++ )
|
||||
{
|
||||
UShortDrawElements* elements = new UShortDrawElements(Primitive::TRIANGLE_STRIP);
|
||||
DrawElementsUShort* elements = new DrawElementsUShort(PrimitiveSet::TRIANGLE_STRIP);
|
||||
elements->reserve(39*2);
|
||||
for( j = 0; j < n; j++ )
|
||||
{
|
||||
|
||||
@@ -183,7 +183,7 @@ static Geometry *makeTree( _tree *tree, StateSet *dstate )
|
||||
geom->setColorArray( &l );
|
||||
geom->setColorBinding( Geometry::BIND_OVERALL );
|
||||
|
||||
geom->addPrimitive( new DrawArrays(Primitive::QUADS,0,4) );
|
||||
geom->addPrimitive( new DrawArrays(PrimitiveSet::QUADS,0,4) );
|
||||
|
||||
geom->setStateSet( dstate );
|
||||
|
||||
|
||||
@@ -193,7 +193,7 @@ osg::Geometry* createWall(const osg::Vec3& v1,const osg::Vec3& v2,const osg::Vec
|
||||
|
||||
for(row=0;row<noYSteps-1;++row)
|
||||
{
|
||||
osg::DrawElementsUShort* quadstrip = new osg::DrawElementsUShort(osg::Primitive::QUAD_STRIP);
|
||||
osg::DrawElementsUShort* quadstrip = new osg::DrawElementsUShort(osg::PrimitiveSet::QUAD_STRIP);
|
||||
quadstrip->reserve(noXSteps*2);
|
||||
for(unsigned int col=0;col<noXSteps;++col)
|
||||
{
|
||||
|
||||
@@ -250,7 +250,7 @@ osg::Node* createOccluder(const osg::Vec3& v1,const osg::Vec3& v2,const osg::Vec
|
||||
geom->setColorArray(colors);
|
||||
geom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||
|
||||
geom->addPrimitive(osgNew osg::DrawArrays(osg::Primitive::QUADS,0,4));
|
||||
geom->addPrimitive(osgNew osg::DrawArrays(osg::PrimitiveSet::QUADS,0,4));
|
||||
|
||||
osg::Geode* geode = osgNew osg::Geode;
|
||||
geode->addDrawable(geom);
|
||||
@@ -390,7 +390,7 @@ int main( int argc, char **argv )
|
||||
|
||||
if (manuallyCreateImpostors)
|
||||
{
|
||||
viewer.setEventHandler(new OccluderEventHandler(viewer.getViewportSceneView(0),rootnode));
|
||||
viewer.addEventHandler(new OccluderEventHandler(viewer.getViewportSceneView(0),rootnode));
|
||||
}
|
||||
|
||||
// open the viewer window.
|
||||
|
||||
@@ -518,7 +518,7 @@ osg::Node* createPreRenderSubGraph(osg::Node* subgraph)
|
||||
polyGeom->setColorArray(colors);
|
||||
polyGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||
|
||||
polyGeom->addPrimitive(new osg::DrawArrays(osg::Primitive::QUAD_STRIP,0,vertices->size()));
|
||||
polyGeom->addPrimitive(new osg::DrawArrays(osg::PrimitiveSet::QUAD_STRIP,0,vertices->size()));
|
||||
|
||||
// new we need to add the texture to the Drawable, we do so by creating a
|
||||
// StateSet to contain the Texture StateAttribute.
|
||||
|
||||
@@ -92,7 +92,7 @@ osg::Drawable* createMirrorSurface(float xMin,float xMax,float yMin,float yMax,f
|
||||
geom->setColorArray(colours);
|
||||
geom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||
|
||||
geom->addPrimitive(osgNew osg::DrawArrays(osg::Primitive::QUADS,0,4));
|
||||
geom->addPrimitive(osgNew osg::DrawArrays(osg::PrimitiveSet::QUADS,0,4));
|
||||
|
||||
return geom;
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ int main( int argc, char **argv )
|
||||
viewer.addViewport(rootNode);
|
||||
|
||||
// register additional event handler
|
||||
viewer.setEventHandler(osgNew MyEventHandler(&seq), 0);
|
||||
viewer.addEventHandler(osgNew MyEventHandler(&seq), 0);
|
||||
|
||||
// register trackball, flight and drive.
|
||||
viewer.registerCameraManipulator(new osgGA::TrackballManipulator);
|
||||
|
||||
@@ -122,7 +122,7 @@ osg::Drawable* createSquare(float textureCoordMax=1.0f)
|
||||
(*tcoords)[3].set(textureCoordMax,textureCoordMax);
|
||||
geom->setTexCoordArray(0,tcoords);
|
||||
|
||||
geom->addPrimitive(osgNew osg::DrawArrays(osg::Primitive::QUADS,0,4));
|
||||
geom->addPrimitive(osgNew osg::DrawArrays(osg::PrimitiveSet::QUADS,0,4));
|
||||
|
||||
return geom;
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ osg::Drawable* createSquare(float textureCoordMax=1.0f)
|
||||
(*tcoords)[3].set(textureCoordMax,textureCoordMax);
|
||||
geom->setTexCoordArray(0,tcoords);
|
||||
|
||||
geom->addPrimitive(osgNew osg::DrawArrays(osg::Primitive::QUADS,0,4));
|
||||
geom->addPrimitive(osgNew osg::DrawArrays(osg::PrimitiveSet::QUADS,0,4));
|
||||
|
||||
return geom;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <osg/Texture>
|
||||
#include <osg/Drawable>
|
||||
#include <osg/Array>
|
||||
#include <osg/Primitive>
|
||||
#include <osg/PrimitiveSet>
|
||||
|
||||
using namespace osg;
|
||||
|
||||
@@ -85,10 +85,10 @@ Array* CopyOp::operator() (const Array* array) const
|
||||
return const_cast<Array*>(array);
|
||||
}
|
||||
|
||||
Primitive* CopyOp::operator() (const Primitive* primitive) const
|
||||
PrimitiveSet* CopyOp::operator() (const PrimitiveSet* primitive) const
|
||||
{
|
||||
if (primitive && _flags&DEEP_COPY_PRIMITIVES)
|
||||
return dynamic_cast<Primitive*>(primitive->clone(*this));
|
||||
return dynamic_cast<PrimitiveSet*>(primitive->clone(*this));
|
||||
else
|
||||
return const_cast<Primitive*>(primitive);
|
||||
return const_cast<PrimitiveSet*>(primitive);
|
||||
}
|
||||
|
||||
@@ -1025,13 +1025,13 @@ Geometry* GeoSet::convertToGeometry()
|
||||
|
||||
for( int i = 0; i < _numprims; i++ )
|
||||
{
|
||||
UShortDrawElements* n = new UShortDrawElements;
|
||||
DrawElementsUShort* n = new DrawElementsUShort;
|
||||
geom->addPrimitive(n);
|
||||
|
||||
if (_cindex._is_ushort)
|
||||
geom->addPrimitive(osgNew UShortDrawElements( (GLenum)_oglprimtype, _primLengths[i],&_cindex._ptr._ushort[index] ));
|
||||
geom->addPrimitive(osgNew DrawElementsUShort( (GLenum)_oglprimtype, _primLengths[i],&_cindex._ptr._ushort[index] ));
|
||||
else
|
||||
geom->addPrimitive(osgNew UIntDrawElements( (GLenum)_oglprimtype, _primLengths[i], &_cindex._ptr._uint[index] ));
|
||||
geom->addPrimitive(osgNew DrawElementsUInt( (GLenum)_oglprimtype, _primLengths[i], &_cindex._ptr._uint[index] ));
|
||||
|
||||
index += _primLengths[i];
|
||||
}
|
||||
@@ -1062,9 +1062,9 @@ Geometry* GeoSet::convertToGeometry()
|
||||
if( _cindex.valid())
|
||||
{
|
||||
if (_cindex._is_ushort)
|
||||
geom->addPrimitive(osgNew UShortDrawElements( (GLenum)_oglprimtype, _cindex._size, _cindex._ptr._ushort ));
|
||||
geom->addPrimitive(osgNew DrawElementsUShort( (GLenum)_oglprimtype, _cindex._size, _cindex._ptr._ushort ));
|
||||
else
|
||||
geom->addPrimitive(osgNew UIntDrawElements( (GLenum)_oglprimtype, _cindex._size, _cindex._ptr._uint ));
|
||||
geom->addPrimitive(osgNew DrawElementsUInt( (GLenum)_oglprimtype, _cindex._size, _cindex._ptr._uint ));
|
||||
}
|
||||
else
|
||||
geom->addPrimitive(new DrawArrays( (GLenum)_oglprimtype, 0, _numcoords ));
|
||||
|
||||
@@ -28,7 +28,7 @@ Geometry::Geometry(const Geometry& geometry,const CopyOp& copyop):
|
||||
pitr!=geometry._primitives.end();
|
||||
++pitr)
|
||||
{
|
||||
Primitive* primitive = copyop(pitr->get());
|
||||
PrimitiveSet* primitive = copyop(pitr->get());
|
||||
if (primitive) _primitives.push_back(primitive);
|
||||
}
|
||||
|
||||
|
||||
@@ -527,7 +527,7 @@ Geode* osg::createGeodeForImage(osg::Image* image,float s,float t)
|
||||
geom->setColorArray(colours);
|
||||
geom->setColorBinding(Geometry::BIND_OVERALL);
|
||||
|
||||
geom->addPrimitive(osgNew DrawArrays(Primitive::QUADS,0,4));
|
||||
geom->addPrimitive(osgNew DrawArrays(PrimitiveSet::QUADS,0,4));
|
||||
|
||||
// set up the geode.
|
||||
osg::Geode* geode = osgNew osg::Geode;
|
||||
|
||||
612
src/osg/IndexedGeometry.cpp
Normal file
612
src/osg/IndexedGeometry.cpp
Normal file
@@ -0,0 +1,612 @@
|
||||
#include <osg/GLExtensions>
|
||||
#include <osg/IndexedGeometry>
|
||||
#include <osg/Notify>
|
||||
|
||||
using namespace osg;
|
||||
|
||||
IndexedGeometry::IndexedGeometry()
|
||||
{
|
||||
_normalBinding = BIND_OFF;
|
||||
_colorBinding = BIND_OFF;
|
||||
_secondaryColorBinding = BIND_OFF;
|
||||
_fogCoordBinding = BIND_OFF;
|
||||
}
|
||||
|
||||
IndexedGeometry::IndexedGeometry(const IndexedGeometry& geometry,const CopyOp& copyop):
|
||||
Drawable(geometry,copyop),
|
||||
_vertexArray(dynamic_cast<Vec3Array*>(copyop(geometry._vertexArray.get()))),
|
||||
_normalBinding(geometry._normalBinding),
|
||||
_normalArray(dynamic_cast<Vec3Array*>(copyop(geometry._normalArray.get()))),
|
||||
_colorBinding(geometry._colorBinding),
|
||||
_colorArray(copyop(geometry._colorArray.get())),
|
||||
_secondaryColorBinding(geometry._secondaryColorBinding),
|
||||
_secondaryColorArray(copyop(geometry._secondaryColorArray.get())),
|
||||
_fogCoordBinding(geometry._fogCoordBinding),
|
||||
_fogCoordArray(dynamic_cast<FloatArray*>(copyop(geometry._fogCoordArray.get())))
|
||||
{
|
||||
for(PrimitiveSetList::const_iterator pitr=geometry._primitives.begin();
|
||||
pitr!=geometry._primitives.end();
|
||||
++pitr)
|
||||
{
|
||||
PrimitiveSet* primitive = copyop(pitr->get());
|
||||
if (primitive) _primitives.push_back(primitive);
|
||||
}
|
||||
|
||||
for(TexCoordArrayList::const_iterator titr=geometry._texCoordList.begin();
|
||||
titr!=geometry._texCoordList.end();
|
||||
++titr)
|
||||
{
|
||||
_texCoordList.push_back(*titr);
|
||||
}
|
||||
}
|
||||
|
||||
IndexedGeometry::~IndexedGeometry()
|
||||
{
|
||||
// no need to delete, all automatically handled by ref_ptr :-)
|
||||
}
|
||||
|
||||
void IndexedGeometry::setTexCoordArray(unsigned int unit,Array* array)
|
||||
{
|
||||
if (_texCoordList.size()<=unit)
|
||||
_texCoordList.resize(unit+1);
|
||||
|
||||
_texCoordList[unit].first = array;
|
||||
|
||||
dirtyDisplayList();
|
||||
}
|
||||
|
||||
Array* IndexedGeometry::getTexCoordArray(unsigned int unit)
|
||||
{
|
||||
if (unit<_texCoordList.size()) return _texCoordList[unit].first.get();
|
||||
else return 0;
|
||||
}
|
||||
|
||||
const Array* IndexedGeometry::getTexCoordArray(unsigned int unit) const
|
||||
{
|
||||
if (unit<_texCoordList.size()) return _texCoordList[unit].first.get();
|
||||
else return 0;
|
||||
}
|
||||
|
||||
typedef void (APIENTRY * FogCoordProc) (const GLfloat* coord);
|
||||
typedef void (APIENTRY * SecondaryColor3ubvProc) (const GLubyte* coord);
|
||||
typedef void (APIENTRY * SecondaryColor3fvProc) (const GLfloat* coord);
|
||||
|
||||
void IndexedGeometry::drawImmediateMode(State& state)
|
||||
{
|
||||
if (!_vertexArray.valid()) return;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// set up the vertex arrays.
|
||||
//
|
||||
state.setVertexPointer(3,GL_FLOAT,0,_vertexArray->getDataPointer());
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// set up texture coordinates.
|
||||
//
|
||||
unsigned int i;
|
||||
for(i=0;i<_texCoordList.size();++i)
|
||||
{
|
||||
Array* array = _texCoordList[i].first.get();
|
||||
if (array)
|
||||
state.setTexCoordPointer(i,array->getDataSize(),array->getDataType(),0,array->getDataPointer());
|
||||
else
|
||||
state.disableTexCoordPointer(i);
|
||||
}
|
||||
state.disableTexCoordPointersAboveAndIncluding(i);
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
; // set up normals if required.
|
||||
//
|
||||
Vec3* normalPointer = 0;
|
||||
if (_normalArray.valid() && !_normalArray->empty()) normalPointer = &(_normalArray->front());
|
||||
|
||||
AttributeBinding normalBinding = _normalBinding;
|
||||
if (normalBinding!=BIND_OFF && !normalPointer)
|
||||
{
|
||||
// switch off if not supported or have a valid data.
|
||||
normalBinding = BIND_OFF;
|
||||
}
|
||||
|
||||
switch (normalBinding)
|
||||
{
|
||||
case(BIND_OFF):
|
||||
state.disableNormalPointer();
|
||||
break;
|
||||
case(BIND_OVERALL):
|
||||
state.disableNormalPointer();
|
||||
glNormal3fv(reinterpret_cast<const GLfloat*>(normalPointer));
|
||||
break;
|
||||
case(BIND_PER_PRIMITIVE):
|
||||
state.disableNormalPointer();
|
||||
break;
|
||||
case(BIND_PER_VERTEX):
|
||||
state.setNormalPointer(GL_FLOAT,0,normalPointer);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Set up color if required.
|
||||
//
|
||||
// set up colors, complicated by the fact that the color array
|
||||
// might be bound in 4 different ways, and be represented as 3 different data types -
|
||||
// Vec3, Vec4 or UByte4 Arrays.
|
||||
//
|
||||
const unsigned char* colorPointer = 0;
|
||||
unsigned int colorStride = 0;
|
||||
Array::Type colorType = Array::ArrayType;
|
||||
if (_colorArray.valid())
|
||||
{
|
||||
colorType = _colorArray->getType();
|
||||
switch(colorType)
|
||||
{
|
||||
case(Array::UByte4ArrayType):
|
||||
{
|
||||
colorPointer = reinterpret_cast<const unsigned char*>(_colorArray->getDataPointer());
|
||||
colorStride = 4;
|
||||
break;
|
||||
}
|
||||
case(Array::Vec3ArrayType):
|
||||
{
|
||||
colorPointer = reinterpret_cast<const unsigned char*>(_colorArray->getDataPointer());
|
||||
colorStride = 12;
|
||||
break;
|
||||
}
|
||||
case(Array::Vec4ArrayType):
|
||||
{
|
||||
colorPointer = reinterpret_cast<const unsigned char*>(_colorArray->getDataPointer());
|
||||
colorStride = 16;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
AttributeBinding colorBinding = _colorBinding;
|
||||
if (colorBinding!=BIND_OFF && !colorPointer)
|
||||
{
|
||||
// switch off if not supported or have a valid data.
|
||||
colorBinding = BIND_OFF;
|
||||
}
|
||||
|
||||
switch (colorBinding)
|
||||
{
|
||||
case(BIND_OFF):
|
||||
state.disableColorPointer();
|
||||
break;
|
||||
case(BIND_OVERALL):
|
||||
state.disableColorPointer();
|
||||
if (colorPointer)
|
||||
{
|
||||
switch(colorType)
|
||||
{
|
||||
case(Array::UByte4ArrayType):
|
||||
glColor4ubv(reinterpret_cast<const GLubyte*>(colorPointer));
|
||||
break;
|
||||
case(Array::Vec3ArrayType):
|
||||
glColor3fv(reinterpret_cast<const GLfloat*>(colorPointer));
|
||||
break;
|
||||
case(Array::Vec4ArrayType):
|
||||
glColor4fv(reinterpret_cast<const GLfloat*>(colorPointer));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case(BIND_PER_PRIMITIVE):
|
||||
state.disableColorPointer();
|
||||
break;
|
||||
case(BIND_PER_VERTEX):
|
||||
state.setColorPointer(_colorArray->getDataSize(),_colorArray->getDataType(),0,colorPointer);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Set up secondary color if required.
|
||||
//
|
||||
// set up colors, complicated by the fact that the color array
|
||||
// might be bound in 4 different ways, and be represented as 3 different data types -
|
||||
// Vec3, Vec4 or UByte4 Arrays.
|
||||
const unsigned char* secondaryColorPointer = 0;
|
||||
unsigned int secondaryColorStride = 0;
|
||||
Array::Type secondaryColorType = Array::ArrayType;
|
||||
if (_secondaryColorArray.valid())
|
||||
{
|
||||
secondaryColorType = _secondaryColorArray->getType();
|
||||
switch(secondaryColorType)
|
||||
{
|
||||
case(Array::UByte4ArrayType):
|
||||
{
|
||||
secondaryColorPointer = reinterpret_cast<const unsigned char*>(_secondaryColorArray->getDataPointer());
|
||||
secondaryColorStride = 4;
|
||||
break;
|
||||
}
|
||||
case(Array::Vec3ArrayType):
|
||||
{
|
||||
secondaryColorPointer = reinterpret_cast<const unsigned char*>(_secondaryColorArray->getDataPointer());
|
||||
secondaryColorStride = 12;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static SecondaryColor3ubvProc s_glSecondaryColor3ubv =
|
||||
(SecondaryColor3ubvProc) osg::getGLExtensionFuncPtr("glSecondaryColor3ubv","glSecondaryColor3ubvEXT");
|
||||
static SecondaryColor3fvProc s_glSecondaryColor3fv =
|
||||
(SecondaryColor3fvProc) osg::getGLExtensionFuncPtr("glSecondaryColor3fv","glSecondaryColor3fvEXT");
|
||||
|
||||
AttributeBinding secondaryColorBinding = _secondaryColorBinding;
|
||||
if (secondaryColorBinding!=BIND_OFF && (!secondaryColorPointer || !s_glSecondaryColor3ubv || !s_glSecondaryColor3fv))
|
||||
{
|
||||
// switch off if not supported or have a valid data.
|
||||
secondaryColorBinding = BIND_OFF;
|
||||
}
|
||||
|
||||
|
||||
switch (secondaryColorBinding)
|
||||
{
|
||||
case(BIND_OFF):
|
||||
state.disableSecondaryColorPointer();
|
||||
break;
|
||||
case(BIND_OVERALL):
|
||||
state.disableSecondaryColorPointer();
|
||||
if (secondaryColorPointer)
|
||||
{
|
||||
switch(secondaryColorType)
|
||||
{
|
||||
case(Array::UByte4ArrayType):
|
||||
s_glSecondaryColor3ubv(reinterpret_cast<const GLubyte*>(secondaryColorPointer));
|
||||
break;
|
||||
case(Array::Vec3ArrayType):
|
||||
s_glSecondaryColor3fv(reinterpret_cast<const GLfloat*>(secondaryColorPointer));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case(BIND_PER_PRIMITIVE):
|
||||
state.disableSecondaryColorPointer();
|
||||
break;
|
||||
case(BIND_PER_VERTEX):
|
||||
state.setSecondaryColorPointer(_secondaryColorArray->getDataSize(),_secondaryColorArray->getDataType(),0,secondaryColorPointer);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Set up fog coord if required.
|
||||
//
|
||||
|
||||
GLfloat* fogCoordPointer = 0;
|
||||
if (_fogCoordArray.valid() && !_fogCoordArray->empty()) fogCoordPointer = &(_fogCoordArray->front());
|
||||
|
||||
static FogCoordProc s_glFogCoordfv =
|
||||
(FogCoordProc) osg::getGLExtensionFuncPtr("glFogCoordfv","glFogCoordfvEXT");
|
||||
|
||||
|
||||
AttributeBinding fogCoordBinding = _fogCoordBinding;
|
||||
if (fogCoordBinding!=BIND_OFF && (!fogCoordPointer || !s_glFogCoordfv))
|
||||
{
|
||||
// swithc off if not supported or have a valid data.
|
||||
fogCoordBinding = BIND_OFF;
|
||||
}
|
||||
|
||||
switch (fogCoordBinding)
|
||||
{
|
||||
case(BIND_OFF):
|
||||
state.disableFogCoordPointer();
|
||||
break;
|
||||
case(BIND_OVERALL):
|
||||
state.disableFogCoordPointer();
|
||||
s_glFogCoordfv(fogCoordPointer);
|
||||
break;
|
||||
case(BIND_PER_PRIMITIVE):
|
||||
state.disableFogCoordPointer();
|
||||
break;
|
||||
case(BIND_PER_VERTEX):
|
||||
state.setFogCoordPointer(GL_FLOAT,0,fogCoordPointer);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// draw the primitives themselves.
|
||||
//
|
||||
|
||||
for(PrimitiveSetList::iterator itr=_primitives.begin();
|
||||
itr!=_primitives.end();
|
||||
++itr)
|
||||
{
|
||||
if (normalBinding==BIND_PER_PRIMITIVE_SET)
|
||||
{
|
||||
glNormal3fv((const GLfloat *)normalPointer++);
|
||||
}
|
||||
|
||||
if (colorBinding==BIND_PER_PRIMITIVE_SET)
|
||||
{
|
||||
switch(colorType)
|
||||
{
|
||||
case(Array::UByte4ArrayType):
|
||||
glColor4ubv(reinterpret_cast<const GLubyte*>(colorPointer));
|
||||
break;
|
||||
case(Array::Vec3ArrayType):
|
||||
glColor3fv(reinterpret_cast<const GLfloat*>(colorPointer));
|
||||
break;
|
||||
case(Array::Vec4ArrayType):
|
||||
glColor4fv(reinterpret_cast<const GLfloat*>(colorPointer));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
colorPointer += colorStride;
|
||||
}
|
||||
|
||||
if (secondaryColorBinding==BIND_PER_PRIMITIVE_SET)
|
||||
{
|
||||
switch(secondaryColorType)
|
||||
{
|
||||
case(Array::UByte4ArrayType):
|
||||
s_glSecondaryColor3ubv(reinterpret_cast<const GLubyte*>(secondaryColorPointer));
|
||||
break;
|
||||
case(Array::Vec3ArrayType):
|
||||
s_glSecondaryColor3fv(reinterpret_cast<const GLfloat*>(secondaryColorPointer));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
secondaryColorPointer += secondaryColorStride;
|
||||
}
|
||||
|
||||
if (fogCoordBinding==BIND_PER_PRIMITIVE_SET)
|
||||
{
|
||||
s_glFogCoordfv(fogCoordPointer++);
|
||||
}
|
||||
|
||||
//(*itr)->draw();
|
||||
|
||||
PrimitiveSet* primitiveset = itr->get();
|
||||
switch(primitiveset->getType())
|
||||
{
|
||||
case(PrimitiveSet::DrawArraysPrimitiveType):
|
||||
{
|
||||
DrawArrays* drawArray = static_cast<DrawArrays*>(primitiveset);
|
||||
glBegin(primitiveset->getMode());
|
||||
|
||||
Vec3* vertices = &(_vertexArray->front()) + drawArray->getFirst();
|
||||
int count = drawArray->getCount();
|
||||
for(GLsizei ci=0;ci<count;++ci)
|
||||
{
|
||||
glVertex3fv(vertices->ptr());
|
||||
++vertices;
|
||||
}
|
||||
|
||||
glEnd();
|
||||
break;
|
||||
}
|
||||
case(PrimitiveSet::DrawArrayLengthsPrimitiveType):
|
||||
{
|
||||
//* drawArray = static_cast<*>(primitiveset);
|
||||
glBegin(primitiveset->getMode());
|
||||
glEnd();
|
||||
break;
|
||||
}
|
||||
case(PrimitiveSet::DrawElementsUBytePrimitiveType):
|
||||
{
|
||||
//* drawArray = static_cast<*>(primitiveset);
|
||||
glBegin(primitiveset->getMode());
|
||||
glEnd();
|
||||
break;
|
||||
}
|
||||
case(PrimitiveSet::DrawElementsUShortPrimitiveType):
|
||||
{
|
||||
//* drawArray = static_cast<*>(primitiveset);
|
||||
glBegin(primitiveset->getMode());
|
||||
glEnd();
|
||||
break;
|
||||
}
|
||||
case(PrimitiveSet::DrawElementsUIntPrimitiveType):
|
||||
{
|
||||
//* drawArray = static_cast<*>(primitiveset);
|
||||
glBegin(primitiveset->getMode());
|
||||
glEnd();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void IndexedGeometry::accept(AttributeFunctor& af)
|
||||
{
|
||||
if (_vertexArray.valid() && !_vertexArray->empty())
|
||||
{
|
||||
af.apply(VERTICES,_vertexArray->size(),&(_vertexArray->front()));
|
||||
}
|
||||
|
||||
if (_normalArray.valid() && !_normalArray->empty())
|
||||
{
|
||||
af.apply(NORMALS,_normalArray->size(),&(_normalArray->front()));
|
||||
}
|
||||
// need to add other attriubtes
|
||||
}
|
||||
|
||||
void IndexedGeometry::accept(PrimitiveFunctor& functor)
|
||||
{
|
||||
if (!_vertexArray.valid() || _vertexArray->empty()) return;
|
||||
|
||||
functor.setVertexArray(_vertexArray->size(),&(_vertexArray->front()));
|
||||
|
||||
for(PrimitiveSetList::iterator itr=_primitives.begin();
|
||||
itr!=_primitives.end();
|
||||
++itr)
|
||||
{
|
||||
(*itr)->accept(functor);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool IndexedGeometry::verifyBindings() const
|
||||
{
|
||||
switch(_normalBinding)
|
||||
{
|
||||
case(BIND_OFF):
|
||||
if (_normalArray.valid() && _normalArray->getNumElements()>0) return false;
|
||||
break;
|
||||
case(BIND_OVERALL):
|
||||
if (!_normalArray.valid()) return false;
|
||||
if (_normalArray->getNumElements()!=1) return false;
|
||||
break;
|
||||
case(BIND_PER_PRIMITIVE_SET):
|
||||
if (!_normalArray.valid()) return false;
|
||||
if (_normalArray->getNumElements()!=_primitives.size()) return false;
|
||||
break;
|
||||
case(BIND_PER_VERTEX):
|
||||
if (_vertexArray.valid())
|
||||
{
|
||||
if (!_normalArray.valid()) return false;
|
||||
if (_normalArray->getNumElements()!=_vertexArray->getNumElements()) return false;
|
||||
}
|
||||
else if (_normalArray.valid() && _normalArray->getNumElements()>0) return false;
|
||||
break;
|
||||
}
|
||||
|
||||
switch(_colorBinding)
|
||||
{
|
||||
case(BIND_OFF):
|
||||
if (_colorArray.valid() && _colorArray->getNumElements()>0) return false;
|
||||
break;
|
||||
case(BIND_OVERALL):
|
||||
if (!_colorArray.valid()) return false;
|
||||
if (_colorArray->getNumElements()!=1) return false;
|
||||
break;
|
||||
case(BIND_PER_PRIMITIVE_SET):
|
||||
if (!_colorArray.valid()) return false;
|
||||
if (_colorArray->getNumElements()!=_primitives.size()) return false;
|
||||
break;
|
||||
case(BIND_PER_VERTEX):
|
||||
if (_vertexArray.valid())
|
||||
{
|
||||
if (!_colorArray.valid()) return false;
|
||||
if (_colorArray->getNumElements()!=_vertexArray->getNumElements()) return false;
|
||||
}
|
||||
else if (_colorArray.valid() && _colorArray->getNumElements()>0) return false;
|
||||
break;
|
||||
}
|
||||
|
||||
for(TexCoordArrayList::const_iterator itr=_texCoordList.begin();
|
||||
itr!=_texCoordList.end();
|
||||
++itr)
|
||||
{
|
||||
const Array* array = itr->first.get();
|
||||
if (_vertexArray.valid())
|
||||
{
|
||||
if (array && array->getNumElements()!=_vertexArray->getNumElements()) return false;
|
||||
}
|
||||
else if (array && array->getNumElements()>0) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void IndexedGeometry::computeCorrectBindingsAndArraySizes()
|
||||
{
|
||||
if (verifyBindings()) return;
|
||||
|
||||
if (!_vertexArray.valid() || _vertexArray->empty())
|
||||
{
|
||||
// no vertex array so switch everything off.
|
||||
|
||||
_vertexArray = 0;
|
||||
|
||||
_colorArray = 0;
|
||||
_colorBinding = BIND_OFF;
|
||||
|
||||
_normalArray = 0;
|
||||
_normalBinding = BIND_OFF;
|
||||
|
||||
_texCoordList.clear();
|
||||
|
||||
notify(INFO)<<"Info: remove redundent attribute arrays from empty osg::IndexedGeometry"<<std::endl;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
switch(_normalBinding)
|
||||
{
|
||||
case(BIND_OFF):
|
||||
if (_normalArray.valid()) _normalArray = 0;
|
||||
break;
|
||||
case(BIND_OVERALL):
|
||||
if (!_normalArray.valid())
|
||||
{
|
||||
_normalBinding = BIND_OFF;
|
||||
}
|
||||
else if (_normalArray->getNumElements()==0)
|
||||
{
|
||||
_normalArray = 0;
|
||||
_normalBinding = BIND_OFF;
|
||||
}
|
||||
else if (_normalArray->getNumElements()>1)
|
||||
{
|
||||
// trim the array down to 1 element long.
|
||||
_normalArray->erase(_normalArray->begin()+1,_normalArray->end());
|
||||
}
|
||||
break;
|
||||
case(BIND_PER_PRIMITIVE):
|
||||
if (!_normalArray.valid())
|
||||
{
|
||||
_normalBinding = BIND_OFF;
|
||||
}
|
||||
else if (_normalArray->getNumElements()<_primitives.size())
|
||||
{
|
||||
_normalArray = 0;
|
||||
_normalBinding = BIND_OFF;
|
||||
}
|
||||
else if (_normalArray->getNumElements()>_primitives.size())
|
||||
{
|
||||
// trim the array down to size of the number of primitives.
|
||||
_normalArray->erase(_normalArray->begin()+_primitives.size(),_normalArray->end());
|
||||
}
|
||||
break;
|
||||
case(BIND_PER_VERTEX):
|
||||
if (!_normalArray.valid())
|
||||
{
|
||||
_normalBinding = BIND_OFF;
|
||||
}
|
||||
else if (_normalArray->getNumElements()<_vertexArray->getNumElements())
|
||||
{
|
||||
_normalArray = 0;
|
||||
_normalBinding = BIND_OFF;
|
||||
}
|
||||
else if (_normalArray->getNumElements()>_vertexArray->getNumElements())
|
||||
{
|
||||
// trim the array down to size of the number of primitives.
|
||||
_normalArray->erase(_normalArray->begin()+_vertexArray->getNumElements(),_normalArray->end());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// TODO colours and tex coords.
|
||||
|
||||
}
|
||||
@@ -39,6 +39,7 @@ CXXFILES =\
|
||||
Image.cpp\
|
||||
Impostor.cpp\
|
||||
ImpostorSprite.cpp\
|
||||
IndexedGeometry.cpp\
|
||||
LOD.cpp\
|
||||
Light.cpp\
|
||||
LightModel.cpp\
|
||||
@@ -61,7 +62,7 @@ CXXFILES =\
|
||||
PolygonOffset.cpp\
|
||||
PolygonStipple.cpp\
|
||||
PositionAttitudeTransform.cpp\
|
||||
Primitive.cpp\
|
||||
PrimitiveSet.cpp\
|
||||
Projection.cpp\
|
||||
Quat.cpp\
|
||||
Sequence.cpp\
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <osg/Primitive>
|
||||
#include <osg/PrimitiveSet>
|
||||
|
||||
using namespace osg;
|
||||
|
||||
@@ -60,7 +60,7 @@ StateSet::StateSet()
|
||||
|
||||
_renderingHint = DEFAULT_BIN;
|
||||
|
||||
setRendingBinToInherit();
|
||||
setRenderBinToInherit();
|
||||
}
|
||||
|
||||
StateSet::StateSet(const StateSet& rhs,const CopyOp& copyop):Object(rhs,copyop)
|
||||
@@ -341,7 +341,7 @@ void StateSet::setGlobalDefaults()
|
||||
{
|
||||
_renderingHint = DEFAULT_BIN;
|
||||
|
||||
setRendingBinToInherit();
|
||||
setRenderBinToInherit();
|
||||
|
||||
|
||||
setMode(GL_DEPTH_TEST,StateAttribute::ON);
|
||||
@@ -358,7 +358,7 @@ void StateSet::setAllToInherit()
|
||||
{
|
||||
_renderingHint = DEFAULT_BIN;
|
||||
|
||||
setRendingBinToInherit();
|
||||
setRenderBinToInherit();
|
||||
|
||||
_modeList.clear();
|
||||
_attributeList.clear();
|
||||
@@ -775,12 +775,27 @@ void StateSet::setRenderingHint(const int hint)
|
||||
{
|
||||
_renderingHint = hint;
|
||||
// temporary hack to get new render bins working.
|
||||
if (_renderingHint==TRANSPARENT_BIN)
|
||||
switch(_renderingHint)
|
||||
{
|
||||
_binMode = USE_RENDERBIN_DETAILS;
|
||||
_binNum = 1;
|
||||
_binName = "DepthSortedBin";
|
||||
// _binName = "RenderBin";
|
||||
case(TRANSPARENT_BIN):
|
||||
{
|
||||
_binMode = USE_RENDERBIN_DETAILS;
|
||||
_binNum = 1;
|
||||
_binName = "DepthSortedBin";
|
||||
break;
|
||||
}
|
||||
case(OPAQUE_BIN):
|
||||
{
|
||||
_binMode = USE_RENDERBIN_DETAILS;
|
||||
_binNum = 0;
|
||||
_binName = "RenderBin";
|
||||
break;
|
||||
}
|
||||
default: // DEFAULT_BIN
|
||||
{
|
||||
setRenderBinToInherit();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -791,7 +806,7 @@ void StateSet::setRenderBinDetails(const int binNum,const std::string& binName,c
|
||||
_binName = binName;
|
||||
}
|
||||
|
||||
void StateSet::setRendingBinToInherit()
|
||||
void StateSet::setRenderBinToInherit()
|
||||
{
|
||||
_binMode = INHERIT_RENDERBIN_DETAILS;
|
||||
_binNum = 0;
|
||||
|
||||
@@ -558,7 +558,7 @@ void Texture::Extensions::glCompressedTexImage2D(GLenum target, GLint level, GLe
|
||||
if (_glCompressedTexImage2D)
|
||||
{
|
||||
typedef void (APIENTRY * CompressedTexImage2DArbProc) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
|
||||
(*((CompressedTexImage2DArbProc)_glCompressedTexImage2D))(target, level, internalformat, width, height, border, imageSize, data);
|
||||
((CompressedTexImage2DArbProc)_glCompressedTexImage2D)(target, level, internalformat, width, height, border, imageSize, data);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -345,7 +345,7 @@ void Texture3D::Extensions::glTexImage3D( GLenum target, GLint level, GLenum int
|
||||
if (_glTexImage3D)
|
||||
{
|
||||
typedef void (APIENTRY * GLTexImage3DProc) ( GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
|
||||
(*((GLTexImage3DProc)_glTexImage3D))( target, level, internalFormat, width, height, depth, border, format, type, pixels);
|
||||
((GLTexImage3DProc)_glTexImage3D)( target, level, internalFormat, width, height, depth, border, format, type, pixels);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -358,7 +358,7 @@ void Texture3D::Extensions::glTexSubImage3D( GLenum target, GLint level, GLint x
|
||||
if (_glTexSubImage3D)
|
||||
{
|
||||
typedef void (APIENTRY * GLTexSubImage3DProc) ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
|
||||
(*((GLTexSubImage3DProc)_glTexSubImage3D))( target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
|
||||
((GLTexSubImage3DProc)_glTexSubImage3D)( target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -371,7 +371,7 @@ void Texture3D::Extensions::glCopyTexSubImage3D( GLenum target, GLint level, GLi
|
||||
if (_glCopyTexSubImage3D)
|
||||
{
|
||||
typedef void (APIENTRY * GLCopyTexSubImageProc) ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height );
|
||||
(*((GLCopyTexSubImageProc)_glCopyTexSubImage3D))(target, level, xoffset, yoffset, zoffset, x, y, width, height);
|
||||
((GLCopyTexSubImageProc)_glCopyTexSubImage3D)(target, level, xoffset, yoffset, zoffset, x, y, width, height);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -384,7 +384,7 @@ void Texture3D::Extensions::gluBuild3DMipmaps( GLenum target, GLint internalForm
|
||||
if (_gluBuild3DMipmaps)
|
||||
{
|
||||
typedef void (APIENTRY * GLUBuild3DMipMapsProc) ( GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *data);
|
||||
(*((GLUBuild3DMipMapsProc)_gluBuild3DMipmaps))(target, internalFormat, width, height, depth, format, type, data);
|
||||
((GLUBuild3DMipMapsProc)_gluBuild3DMipmaps)(target, internalFormat, width, height, depth, format, type, data);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -76,11 +76,15 @@ void DynGeoSet::append(DynGeoSet* source)
|
||||
break; \
|
||||
}
|
||||
|
||||
const osg::Primitive::Mode NO_PRIMITIVE_TYPE = (osg::Primitive::Mode)0xffff;
|
||||
const osg::PrimitiveSet::Mode NO_PRIMITIVE_TYPE = (osg::PrimitiveSet::Mode)0xffff;
|
||||
|
||||
DynGeoSet::DynGeoSet()
|
||||
{
|
||||
_primtype=NO_PRIMITIVE_TYPE;
|
||||
_primtype = NO_PRIMITIVE_TYPE;
|
||||
_normal_binding = osg::Geometry::BIND_OFF;
|
||||
_color_binding = osg::Geometry::BIND_OFF;
|
||||
_texture_binding = osg::Geometry::BIND_OFF;
|
||||
|
||||
_geom = new osg::Geometry;
|
||||
}
|
||||
|
||||
@@ -181,7 +185,7 @@ void DynGeoSet::addToGeometry(osg::Geometry* geom)
|
||||
}
|
||||
}
|
||||
|
||||
if (_primtype!=osg::Primitive::POLYGON)
|
||||
if (_primtype!=osg::PrimitiveSet::POLYGON)
|
||||
{
|
||||
geom->addPrimitive(new osg::DrawArrays(_primtype,indexBase,_coordList.size()));
|
||||
}
|
||||
@@ -308,17 +312,17 @@ DynGeoSet* GeoSetBuilder::findMatchingGeoSet()
|
||||
}
|
||||
|
||||
|
||||
osg::Primitive::Mode GeoSetBuilder::findPrimType(const int nVertices)
|
||||
osg::PrimitiveSet::Mode GeoSetBuilder::findPrimType(const int nVertices)
|
||||
{
|
||||
switch (nVertices)
|
||||
{
|
||||
case 1: return osg::Primitive::POINTS;
|
||||
case 2: return osg::Primitive::LINES;
|
||||
case 3: return osg::Primitive::TRIANGLES;
|
||||
case 4: return osg::Primitive::QUADS;
|
||||
case 1: return osg::PrimitiveSet::POINTS;
|
||||
case 2: return osg::PrimitiveSet::LINES;
|
||||
case 3: return osg::PrimitiveSet::TRIANGLES;
|
||||
case 4: return osg::PrimitiveSet::QUADS;
|
||||
}
|
||||
|
||||
if (nVertices>=5) return osg::Primitive::POLYGON;
|
||||
if (nVertices>=5) return osg::PrimitiveSet::POLYGON;
|
||||
|
||||
return NO_PRIMITIVE_TYPE;
|
||||
}
|
||||
|
||||
@@ -111,8 +111,8 @@ class DynGeoSet : public osg::Referenced
|
||||
osg::Geometry::AttributeBinding getNormalBinding() const { return _normal_binding; }
|
||||
osg::Geometry::AttributeBinding getTextureBinding() const { return _texture_binding; }
|
||||
|
||||
void setPrimType(osg::Primitive::Mode type) { _primtype=type; }
|
||||
osg::Primitive::Mode getPrimType() const { return _primtype; }
|
||||
void setPrimType(osg::PrimitiveSet::Mode type) { _primtype=type; }
|
||||
osg::PrimitiveSet::Mode getPrimType() const { return _primtype; }
|
||||
|
||||
inline void addPrimLen(const int len) { _primLenList.push_back(len); }
|
||||
inline void addCoord(const osg::Vec3& coord) { _coordList.push_back(coord); }
|
||||
@@ -150,7 +150,7 @@ class DynGeoSet : public osg::Referenced
|
||||
osg::ref_ptr<osg::StateSet> _stateset;
|
||||
|
||||
|
||||
osg::Primitive::Mode _primtype;
|
||||
osg::PrimitiveSet::Mode _primtype;
|
||||
PrimLenList _primLenList;
|
||||
|
||||
CoordList _coordList;
|
||||
@@ -194,7 +194,7 @@ class GeoSetBuilder
|
||||
|
||||
void initPrimData();
|
||||
DynGeoSet* findMatchingGeoSet();
|
||||
osg::Primitive::Mode findPrimType(const int nVertices);
|
||||
osg::PrimitiveSet::Mode findPrimType(const int nVertices);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -37,8 +37,8 @@ Record* Registry::getPrototype(const int opcode)
|
||||
if (itr != _recordProtoMap.end()) {
|
||||
return (*itr).second.get();
|
||||
}
|
||||
osg::notify( osg::WARN )
|
||||
<< "flt::Registry::addPrototype: Unkown opcode: " << opcode << "\n";
|
||||
osg::notify( osg::NOTICE )
|
||||
<< "flt::Registry::getPrototype: Unkown opcode: " << opcode << "\n";
|
||||
|
||||
return NULL;
|
||||
|
||||
|
||||
@@ -959,17 +959,17 @@ void ConvertFromFLT::setCullFaceAndWireframe ( const SFace *pSFace, osg::StateSe
|
||||
break;
|
||||
|
||||
case FaceRecord::WIREFRAME_NOT_CLOSED:
|
||||
dgset->setPrimType(osg::Primitive::LINE_STRIP);
|
||||
dgset->setPrimType(osg::PrimitiveSet::LINE_STRIP);
|
||||
break;
|
||||
|
||||
case FaceRecord::WIREFRAME_CLOSED:
|
||||
dgset->setPrimType(osg::Primitive::LINE_LOOP);
|
||||
dgset->setPrimType(osg::PrimitiveSet::LINE_LOOP);
|
||||
break;
|
||||
|
||||
case FaceRecord::OMNIDIRECTIONAL_LIGHT:
|
||||
case FaceRecord::UNIDIRECTIONAL_LIGHT:
|
||||
case FaceRecord::BIDIRECTIONAL_LIGHT:
|
||||
dgset->setPrimType(osg::Primitive::POINTS);
|
||||
dgset->setPrimType(osg::PrimitiveSet::POINTS);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1440,7 +1440,7 @@ int ConvertFromFLT::addVertices(GeoSetBuilder* pBuilder, PrimNodeRecord* primRec
|
||||
|
||||
if (vertices > 0)
|
||||
{
|
||||
if (dgset->getPrimType() == osg::Primitive::POINTS)
|
||||
if (dgset->getPrimType() == osg::PrimitiveSet::POINTS)
|
||||
{
|
||||
for (i=0; i < vertices; i++)
|
||||
dgset->addPrimLen(1);
|
||||
@@ -1672,7 +1672,7 @@ void ConvertFromFLT::visitLightPoint(GeoSetBuilder* pBuilder, LightPointRecord*
|
||||
osg::StateSet* stateSet = dgset->getStateSet();
|
||||
SLightPoint *pSLightPoint = (SLightPoint*)rec->getData();
|
||||
|
||||
dgset->setPrimType(osg::Primitive::POINTS);
|
||||
dgset->setPrimType(osg::PrimitiveSet::POINTS);
|
||||
stateSet->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
|
||||
stateSet->setMode(GL_POINT_SMOOTH, osg::StateAttribute::ON);
|
||||
dgset->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
|
||||
@@ -1796,16 +1796,16 @@ void ConvertFromFLT::visitMeshPrimitive ( osg::Group &parent, MeshPrimitiveRecor
|
||||
switch ( mesh->getData()->primitiveType )
|
||||
{
|
||||
case MeshPrimitiveRecord::TRIANGLE_STRIP:
|
||||
geometry->addPrimitive ( new osg::DrawArrays(osg::Primitive::TRIANGLE_STRIP,0,mesh->getNumVertices()) );
|
||||
geometry->addPrimitive ( new osg::DrawArrays(osg::PrimitiveSet::TRIANGLE_STRIP,0,mesh->getNumVertices()) );
|
||||
break;
|
||||
case MeshPrimitiveRecord::TRIANGLE_FAN:
|
||||
geometry->addPrimitive ( new osg::DrawArrays(osg::Primitive::TRIANGLE_FAN,0,mesh->getNumVertices()) );
|
||||
geometry->addPrimitive ( new osg::DrawArrays(osg::PrimitiveSet::TRIANGLE_FAN,0,mesh->getNumVertices()) );
|
||||
break;
|
||||
case MeshPrimitiveRecord::QUADRILATERAL_STRIP:
|
||||
geometry->addPrimitive ( new osg::DrawArrays(osg::Primitive::QUAD_STRIP,0,mesh->getNumVertices()) );
|
||||
geometry->addPrimitive ( new osg::DrawArrays(osg::PrimitiveSet::QUAD_STRIP,0,mesh->getNumVertices()) );
|
||||
break;
|
||||
case MeshPrimitiveRecord::INDEXED_POLYGON:
|
||||
geometry->addPrimitive ( new osg::DrawArrays(osg::Primitive::POLYGON,0,mesh->getNumVertices()) );
|
||||
geometry->addPrimitive ( new osg::DrawArrays(osg::PrimitiveSet::POLYGON,0,mesh->getNumVertices()) );
|
||||
break;
|
||||
default:
|
||||
assert ( 0 ); // What type is this?
|
||||
|
||||
@@ -163,9 +163,9 @@ void OSGVisitor::applySeparator(Separator *sep)
|
||||
}
|
||||
}
|
||||
|
||||
osg::Primitive *generatePrimitive(PolygonList &polys, unsigned primsize) {
|
||||
osg::PrimitiveSet *generatePrimitive(PolygonList &polys, unsigned primsize) {
|
||||
unsigned i,j;
|
||||
osg::Primitive *p=0;
|
||||
osg::PrimitiveSet *p=0;
|
||||
// Fisrt of all count the number of polygons
|
||||
unsigned count=0;
|
||||
for (i=0;i<polys.size();i++) {
|
||||
@@ -177,13 +177,13 @@ osg::Primitive *generatePrimitive(PolygonList &polys, unsigned primsize) {
|
||||
if (count==0) return 0; ///If no polys, no primitive :)
|
||||
|
||||
// The type of primitive
|
||||
osg::Primitive::Mode mode;
|
||||
osg::PrimitiveSet::Mode mode;
|
||||
switch (primsize) {
|
||||
case 1: mode=osg::Primitive::POINTS;break;
|
||||
case 2: mode=osg::Primitive::LINES;break;
|
||||
case 3: mode=osg::Primitive::TRIANGLES;break;
|
||||
case 4: mode=osg::Primitive::QUADS;break;
|
||||
default: mode=osg::Primitive::QUADS;
|
||||
case 1: mode=osg::PrimitiveSet::POINTS;break;
|
||||
case 2: mode=osg::PrimitiveSet::LINES;break;
|
||||
case 3: mode=osg::PrimitiveSet::TRIANGLES;break;
|
||||
case 4: mode=osg::PrimitiveSet::QUADS;break;
|
||||
default: mode=osg::PrimitiveSet::QUADS;
|
||||
}
|
||||
// Now will generate the indices and the primitive
|
||||
if (count < 65536) {
|
||||
@@ -289,7 +289,7 @@ void OSGVisitor::applyIndexedFaceSet(IndexedFaceSet *ifs) {
|
||||
/* Converting list of polys */
|
||||
PolygonList polys=ifs->getPolygons();
|
||||
for (i=1;i<=4;i++) {
|
||||
osg::Primitive *p=generatePrimitive(polys,i);
|
||||
osg::PrimitiveSet *p=generatePrimitive(polys,i);
|
||||
if (p!=0) {
|
||||
geometry->addPrimitive(p);
|
||||
}
|
||||
@@ -348,7 +348,7 @@ void OSGVisitor::applyIndexedTriStripSet(IndexedTriStripSet *its) {
|
||||
for (j=0;j<vindex.size();j++) {
|
||||
indices[j]=vindex[j];
|
||||
}
|
||||
geometry->addPrimitive(new osg::DrawElementsUShort(osg::Primitive::TRIANGLE_STRIP,vindex.size(),indices));
|
||||
geometry->addPrimitive(new osg::DrawElementsUShort(osg::PrimitiveSet::TRIANGLE_STRIP,vindex.size(),indices));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -589,8 +589,8 @@ osg::Drawable* ReaderWriter3DS::createDrawable(Lib3dsMesh *m,FaceList& faceLis
|
||||
|
||||
// create primitives
|
||||
int numIndices = faceList.size()*3;
|
||||
UShortDrawElements* elements = new osg::UShortDrawElements(osg::Primitive::TRIANGLES,numIndices);
|
||||
UShortDrawElements::iterator index_itr = elements->begin();
|
||||
DrawElementsUShort* elements = new osg::DrawElementsUShort(osg::PrimitiveSet::TRIANGLES,numIndices);
|
||||
DrawElementsUShort::iterator index_itr = elements->begin();
|
||||
|
||||
for (fitr=faceList.begin();
|
||||
fitr!=faceList.end();
|
||||
|
||||
@@ -157,7 +157,7 @@ Lwo2Layer::GenerateGeode( Geode& geode, short tags_count )
|
||||
(*texcoords).push_back(uv);
|
||||
}
|
||||
}
|
||||
geometry->addPrimitive(osgNew DrawArrays(Primitive::POLYGON,
|
||||
geometry->addPrimitive(osgNew DrawArrays(PrimitiveSet::POLYGON,
|
||||
(*coords).size() - (*pol_itr)->size(),
|
||||
(*pol_itr)->size()));
|
||||
}
|
||||
|
||||
@@ -198,26 +198,26 @@ osgDB::ReaderWriter::ReadResult ReaderWriterLWO::readNode_LWO1(const std::string
|
||||
{
|
||||
GeometryCollection& gc = mtgcm[face.material];
|
||||
|
||||
osg::Primitive::Mode mode;
|
||||
osg::PrimitiveSet::Mode mode;
|
||||
switch(face.index_cnt)
|
||||
{
|
||||
case(0):
|
||||
mode = osg::Primitive::POINTS;
|
||||
mode = osg::PrimitiveSet::POINTS;
|
||||
break;
|
||||
case(1):
|
||||
mode = osg::Primitive::POINTS;
|
||||
mode = osg::PrimitiveSet::POINTS;
|
||||
break;
|
||||
case(2):
|
||||
mode = osg::Primitive::LINES;
|
||||
mode = osg::PrimitiveSet::LINES;
|
||||
break;
|
||||
case(3):
|
||||
mode = osg::Primitive::TRIANGLES;
|
||||
mode = osg::PrimitiveSet::TRIANGLES;
|
||||
break;
|
||||
case(4):
|
||||
mode = osg::Primitive::QUADS;
|
||||
mode = osg::PrimitiveSet::QUADS;
|
||||
break;
|
||||
default:
|
||||
mode = osg::Primitive::POLYGON;
|
||||
mode = osg::PrimitiveSet::POLYGON;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -207,7 +207,7 @@ osg::Drawable* ReaderWriterOBJ::makeDrawable(GLMmodel* obj,
|
||||
osg::Geometry* geom = new osg::Geometry;
|
||||
|
||||
// primitives are only triangles
|
||||
geom->addPrimitive(new osg::DrawArrays(osg::Primitive::TRIANGLES,0,ntris*3));
|
||||
geom->addPrimitive(new osg::DrawArrays(osg::PrimitiveSet::TRIANGLES,0,ntris*3));
|
||||
|
||||
// the following code for mapping the coords, normals and texcoords
|
||||
// is complicated greatly by the need to create separate out the
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#if 1
|
||||
|
||||
#include <osg/Geometry>
|
||||
|
||||
#include <osgDB/Registry>
|
||||
@@ -19,7 +21,7 @@ const char* Geometry_getPrimitiveModeStr(GLenum mode);
|
||||
|
||||
Array* Array_readLocalData(Input& fr);
|
||||
|
||||
bool Primitve_readLocalData(Input& fr,osg::Geometry& geom);
|
||||
bool Primitive_readLocalData(Input& fr,osg::Geometry& geom);
|
||||
|
||||
// register the read and write functions with the osgDB::Registry.
|
||||
RegisterDotOsgWrapperProxy g_GeometryFuncProxy
|
||||
@@ -54,7 +56,7 @@ bool Geometry_readLocalData(Object& obj, Input& fr)
|
||||
|
||||
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
|
||||
{
|
||||
if (!Primitve_readLocalData(fr,geom)) ++fr;
|
||||
if (!Primitive_readLocalData(fr,geom)) ++fr;
|
||||
}
|
||||
|
||||
++fr;
|
||||
@@ -577,7 +579,7 @@ bool Array_writeLocalData(const Array& array,Output& fw)
|
||||
}
|
||||
|
||||
|
||||
bool Primitve_readLocalData(Input& fr,osg::Geometry& geom)
|
||||
bool Primitive_readLocalData(Input& fr,osg::Geometry& geom)
|
||||
{
|
||||
bool iteratorAdvanced = false;
|
||||
if (fr.matchSequence("DrawArrays %w %i %i"))
|
||||
@@ -731,19 +733,19 @@ bool Primitve_readLocalData(Input& fr,osg::Geometry& geom)
|
||||
return iteratorAdvanced;
|
||||
}
|
||||
|
||||
bool Primitve_writeLocalData(const Primitive& prim,Output& fw)
|
||||
bool Primitive_writeLocalData(const PrimitiveSet& prim,Output& fw)
|
||||
{
|
||||
|
||||
switch(prim.getType())
|
||||
{
|
||||
case(Primitive::DrawArraysPrimitiveType):
|
||||
case(PrimitiveSet::DrawArraysPrimitiveType):
|
||||
{
|
||||
const DrawArrays& cprim = static_cast<const DrawArrays&>(prim);
|
||||
fw<<cprim.className()<<" "<<Geometry_getPrimitiveModeStr(cprim.getMode())<<" "<<cprim.getFirst()<<" "<<cprim.getCount()<<std::endl;
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(Primitive::DrawArrayLengthsPrimitiveType):
|
||||
case(PrimitiveSet::DrawArrayLengthsPrimitiveType):
|
||||
{
|
||||
const DrawArrayLengths& cprim = static_cast<const DrawArrayLengths&>(prim);
|
||||
fw<<cprim.className()<<" "<<Geometry_getPrimitiveModeStr(cprim.getMode())<<" "<<cprim.getFirst()<<" "<<cprim.size()<<std::endl;
|
||||
@@ -751,7 +753,7 @@ bool Primitve_writeLocalData(const Primitive& prim,Output& fw)
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(Primitive::DrawElementsUBytePrimitiveType):
|
||||
case(PrimitiveSet::DrawElementsUBytePrimitiveType):
|
||||
{
|
||||
const DrawElementsUByte& cprim = static_cast<const DrawElementsUByte&>(prim);
|
||||
fw<<cprim.className()<<" "<<Geometry_getPrimitiveModeStr(cprim.getMode())<<" "<<cprim.size()<<std::endl;
|
||||
@@ -759,7 +761,7 @@ bool Primitve_writeLocalData(const Primitive& prim,Output& fw)
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(Primitive::DrawElementsUShortPrimitiveType):
|
||||
case(PrimitiveSet::DrawElementsUShortPrimitiveType):
|
||||
{
|
||||
const DrawElementsUShort& cprim = static_cast<const DrawElementsUShort&>(prim);
|
||||
fw<<cprim.className()<<" "<<Geometry_getPrimitiveModeStr(cprim.getMode())<<" "<<cprim.size()<<std::endl;
|
||||
@@ -767,7 +769,7 @@ bool Primitve_writeLocalData(const Primitive& prim,Output& fw)
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(Primitive::DrawElementsUIntPrimitiveType):
|
||||
case(PrimitiveSet::DrawElementsUIntPrimitiveType):
|
||||
{
|
||||
const DrawElementsUInt& cprim = static_cast<const DrawElementsUInt&>(prim);
|
||||
fw<<cprim.className()<<" "<<Geometry_getPrimitiveModeStr(cprim.getMode())<<" "<<cprim.size()<<std::endl;
|
||||
@@ -795,7 +797,7 @@ bool Geometry_writeLocalData(const Object& obj, Output& fw)
|
||||
++itr)
|
||||
{
|
||||
fw.indent();
|
||||
Primitve_writeLocalData(**itr,fw);
|
||||
Primitive_writeLocalData(**itr,fw);
|
||||
}
|
||||
fw.moveOut();
|
||||
fw.indent() << "}"<<std::endl;
|
||||
@@ -885,16 +887,16 @@ const char* Geometry_getBindingTypeStr(Geometry::AttributeBinding mode)
|
||||
|
||||
bool Geometry_matchPrimitiveModeStr(const char* str,GLenum& mode)
|
||||
{
|
||||
if (strcmp(str,"POINTS")==0) mode = Primitive::POINTS;
|
||||
else if (strcmp(str,"LINES")==0) mode = Primitive::LINES;
|
||||
else if (strcmp(str,"LINE_STRIP")==0) mode = Primitive::LINE_STRIP;
|
||||
else if (strcmp(str,"LINE_LOOP")==0) mode = Primitive::LINE_LOOP;
|
||||
else if (strcmp(str,"TRIANGLES")==0) mode = Primitive::TRIANGLES;
|
||||
else if (strcmp(str,"TRIANGLE_STRIP")==0) mode = Primitive::TRIANGLE_STRIP;
|
||||
else if (strcmp(str,"TRIANGLE_FAN")==0) mode = Primitive::TRIANGLE_FAN;
|
||||
else if (strcmp(str,"QUADS")==0) mode = Primitive::QUADS;
|
||||
else if (strcmp(str,"QUAD_STRIP")==0) mode = Primitive::QUAD_STRIP;
|
||||
else if (strcmp(str,"POLYGON")==0) mode = Primitive::POLYGON;
|
||||
if (strcmp(str,"POINTS")==0) mode = PrimitiveSet::POINTS;
|
||||
else if (strcmp(str,"LINES")==0) mode = PrimitiveSet::LINES;
|
||||
else if (strcmp(str,"LINE_STRIP")==0) mode = PrimitiveSet::LINE_STRIP;
|
||||
else if (strcmp(str,"LINE_LOOP")==0) mode = PrimitiveSet::LINE_LOOP;
|
||||
else if (strcmp(str,"TRIANGLES")==0) mode = PrimitiveSet::TRIANGLES;
|
||||
else if (strcmp(str,"TRIANGLE_STRIP")==0) mode = PrimitiveSet::TRIANGLE_STRIP;
|
||||
else if (strcmp(str,"TRIANGLE_FAN")==0) mode = PrimitiveSet::TRIANGLE_FAN;
|
||||
else if (strcmp(str,"QUADS")==0) mode = PrimitiveSet::QUADS;
|
||||
else if (strcmp(str,"QUAD_STRIP")==0) mode = PrimitiveSet::QUAD_STRIP;
|
||||
else if (strcmp(str,"POLYGON")==0) mode = PrimitiveSet::POLYGON;
|
||||
else return false;
|
||||
return true;
|
||||
}
|
||||
@@ -904,16 +906,17 @@ const char* Geometry_getPrimitiveModeStr(GLenum mode)
|
||||
{
|
||||
switch(mode)
|
||||
{
|
||||
case (Primitive::POINTS) : return "POINTS";
|
||||
case (Primitive::LINES) : return "LINES";
|
||||
case (Primitive::LINE_STRIP) : return "LINE_STRIP";
|
||||
case (Primitive::LINE_LOOP) : return "LINE_LOOP";
|
||||
case (Primitive::TRIANGLES) : return "TRIANGLES";
|
||||
case (Primitive::TRIANGLE_STRIP) : return "TRIANGLE_STRIP";
|
||||
case (Primitive::TRIANGLE_FAN) : return "TRIANGLE_FAN";
|
||||
case (Primitive::QUADS) : return "QUADS";
|
||||
case (Primitive::QUAD_STRIP) : return "QUAD_STRIP";
|
||||
case (Primitive::POLYGON) : return "POLYGON";
|
||||
default : return "UnknownPrimitveType";
|
||||
case (PrimitiveSet::POINTS) : return "POINTS";
|
||||
case (PrimitiveSet::LINES) : return "LINES";
|
||||
case (PrimitiveSet::LINE_STRIP) : return "LINE_STRIP";
|
||||
case (PrimitiveSet::LINE_LOOP) : return "LINE_LOOP";
|
||||
case (PrimitiveSet::TRIANGLES) : return "TRIANGLES";
|
||||
case (PrimitiveSet::TRIANGLE_STRIP) : return "TRIANGLE_STRIP";
|
||||
case (PrimitiveSet::TRIANGLE_FAN) : return "TRIANGLE_FAN";
|
||||
case (PrimitiveSet::QUADS) : return "QUADS";
|
||||
case (PrimitiveSet::QUAD_STRIP) : return "QUAD_STRIP";
|
||||
case (PrimitiveSet::POLYGON) : return "POLYGON";
|
||||
default : return "UnknownPrimitveType";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
930
src/osgPlugins/osg/IndexedGeometry.cpp
Normal file
930
src/osgPlugins/osg/IndexedGeometry.cpp
Normal file
@@ -0,0 +1,930 @@
|
||||
#include <osg/IndexedGeometry>
|
||||
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/Input>
|
||||
#include <osgDB/Output>
|
||||
|
||||
using namespace osg;
|
||||
using namespace osgDB;
|
||||
|
||||
// forward declare functions to use later.
|
||||
bool IndexedGeometry_readLocalData(Object& obj, Input& fr);
|
||||
bool IndexedGeometry_writeLocalData(const Object& obj, Output& fw);
|
||||
|
||||
bool IndexedGeometry_matchBindingTypeStr(const char* str,IndexedGeometry::AttributeBinding& mode);
|
||||
const char* IndexedGeometry_getBindingTypeStr(IndexedGeometry::AttributeBinding mode);
|
||||
|
||||
bool IndexedGeometry_matchPrimitiveModeStr(const char* str,GLenum& mode);
|
||||
const char* IndexedGeometry_getPrimitiveModeStr(GLenum mode);
|
||||
|
||||
Array* IG_Array_readLocalData(Input& fr);
|
||||
|
||||
bool IG_Primitive_readLocalData(Input& fr,osg::IndexedGeometry& geom);
|
||||
|
||||
// register the read and write functions with the osgDB::Registry.
|
||||
// RegisterDotOsgWrapperProxy g_GeometryFuncProxy
|
||||
// (
|
||||
// osgNew osg::IndexedGeometry,
|
||||
// "Geometry",
|
||||
// "Object Drawable Geometry",
|
||||
// &IndexedGeometry_readLocalData,
|
||||
// &IndexedGeometry_writeLocalData,
|
||||
// DotOsgWrapper::READ_AND_WRITE
|
||||
// );
|
||||
|
||||
RegisterDotOsgWrapperProxy g_IndexedGeometryFuncProxy
|
||||
(
|
||||
osgNew osg::IndexedGeometry,
|
||||
"IndexedGeometry",
|
||||
"Object Drawable IndexedGeometry",
|
||||
&IndexedGeometry_readLocalData,
|
||||
&IndexedGeometry_writeLocalData,
|
||||
DotOsgWrapper::READ_AND_WRITE
|
||||
);
|
||||
|
||||
bool IndexedGeometry_readLocalData(Object& obj, Input& fr)
|
||||
{
|
||||
bool iteratorAdvanced = false;
|
||||
|
||||
IndexedGeometry& geom = static_cast<IndexedGeometry&>(obj);
|
||||
|
||||
bool matchedFirst = false;
|
||||
if ((matchedFirst=fr.matchSequence("Primitives %i {")) || fr.matchSequence("PrimitivesSet %i {") )
|
||||
{
|
||||
int entry = fr[1].getNoNestedBrackets();
|
||||
|
||||
int capacity;
|
||||
fr[1].getInt(capacity);
|
||||
|
||||
IndexedGeometry::PrimitiveSetList& primitives = geom.getPrimitiveSetList();
|
||||
if (capacity>0) primitives.reserve(capacity);
|
||||
|
||||
|
||||
fr += 3;
|
||||
|
||||
|
||||
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
|
||||
{
|
||||
if (!IG_Primitive_readLocalData(fr,geom)) ++fr;
|
||||
}
|
||||
|
||||
++fr;
|
||||
|
||||
iteratorAdvanced = true;
|
||||
|
||||
}
|
||||
|
||||
if (fr.matchSequence("VertexArray %i {"))
|
||||
{
|
||||
|
||||
int entry = fr[0].getNoNestedBrackets();
|
||||
|
||||
int capacity;
|
||||
fr[1].getInt(capacity);
|
||||
|
||||
Vec3Array* vertices = osgNew Vec3Array;
|
||||
vertices->reserve(capacity);
|
||||
|
||||
fr += 3;
|
||||
|
||||
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
|
||||
{
|
||||
Vec3 v;
|
||||
if (fr[0].getFloat(v.x()) && fr[1].getFloat(v.y()) && fr[2].getFloat(v.z()))
|
||||
{
|
||||
fr += 3;
|
||||
vertices->push_back(v);
|
||||
}
|
||||
else
|
||||
{
|
||||
++fr;
|
||||
}
|
||||
}
|
||||
|
||||
geom.setVertexArray(vertices);
|
||||
|
||||
iteratorAdvanced = true;
|
||||
++fr;
|
||||
|
||||
|
||||
}
|
||||
|
||||
IndexedGeometry::AttributeBinding normalBinding=IndexedGeometry::BIND_OFF;
|
||||
if (fr[0].matchWord("NormalBinding") && IndexedGeometry_matchBindingTypeStr(fr[1].getStr(),normalBinding))
|
||||
{
|
||||
geom.setNormalBinding(normalBinding);
|
||||
fr+=2;
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
if (fr.matchSequence("NormalArray %i {"))
|
||||
{
|
||||
int entry = fr[0].getNoNestedBrackets();
|
||||
|
||||
int capacity;
|
||||
fr[1].getInt(capacity);
|
||||
|
||||
Vec3Array* normals = osgNew Vec3Array;
|
||||
normals->reserve(capacity);
|
||||
|
||||
fr += 3;
|
||||
|
||||
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
|
||||
{
|
||||
Vec3 v;
|
||||
if (fr[0].getFloat(v.x()) && fr[1].getFloat(v.y()) && fr[2].getFloat(v.z()))
|
||||
{
|
||||
fr += 3;
|
||||
normals->push_back(v);
|
||||
}
|
||||
else
|
||||
{
|
||||
++fr;
|
||||
}
|
||||
}
|
||||
|
||||
geom.setNormalArray(normals);
|
||||
|
||||
iteratorAdvanced = true;
|
||||
++fr;
|
||||
}
|
||||
|
||||
IndexedGeometry::AttributeBinding colorBinding=IndexedGeometry::BIND_OFF;
|
||||
if (fr[0].matchWord("ColorBinding") && IndexedGeometry_matchBindingTypeStr(fr[1].getStr(),colorBinding))
|
||||
{
|
||||
geom.setColorBinding(colorBinding);
|
||||
fr+=2;
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
if (fr.matchSequence("ColorArray %w %i {"))
|
||||
{
|
||||
++fr;
|
||||
Array* colors = IG_Array_readLocalData(fr);
|
||||
if (colors)
|
||||
{
|
||||
geom.setColorArray(colors);
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
IndexedGeometry::AttributeBinding secondaryColorBinding=IndexedGeometry::BIND_OFF;
|
||||
if (fr[0].matchWord("SecondaryColorBinding") && IndexedGeometry_matchBindingTypeStr(fr[1].getStr(),secondaryColorBinding))
|
||||
{
|
||||
geom.setSecondaryColorBinding(secondaryColorBinding);
|
||||
fr+=2;
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
if (fr.matchSequence("SecondaryColorArray %w %i {"))
|
||||
{
|
||||
++fr;
|
||||
Array* colors = IG_Array_readLocalData(fr);
|
||||
if (colors)
|
||||
{
|
||||
geom.setSecondaryColorArray(colors);
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
IndexedGeometry::AttributeBinding fogCoordBinding=IndexedGeometry::BIND_OFF;
|
||||
if (fr[0].matchWord("FogCoordBinding") && IndexedGeometry_matchBindingTypeStr(fr[1].getStr(),fogCoordBinding))
|
||||
{
|
||||
geom.setFogCoordBinding(fogCoordBinding);
|
||||
fr+=2;
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
if (fr.matchSequence("FogCoordArray %i {"))
|
||||
{
|
||||
int entry = fr[0].getNoNestedBrackets();
|
||||
|
||||
int capacity;
|
||||
fr[1].getInt(capacity);
|
||||
|
||||
FloatArray* fogcoords = osgNew FloatArray;
|
||||
fogcoords->reserve(capacity);
|
||||
|
||||
fr += 3;
|
||||
|
||||
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
|
||||
{
|
||||
float fc;
|
||||
if (fr[0].getFloat(fc))
|
||||
{
|
||||
++fr;
|
||||
fogcoords->push_back(fc);
|
||||
}
|
||||
else
|
||||
{
|
||||
++fr;
|
||||
}
|
||||
}
|
||||
|
||||
geom.setFogCoordArray(fogcoords);
|
||||
|
||||
iteratorAdvanced = true;
|
||||
++fr;
|
||||
}
|
||||
|
||||
if (fr.matchSequence("TexCoordArray %i %w %i {"))
|
||||
{
|
||||
int unit=0;
|
||||
fr[1].getInt(unit);
|
||||
|
||||
fr+=2;
|
||||
Array* texcoords = IG_Array_readLocalData(fr);
|
||||
if (texcoords)
|
||||
{
|
||||
geom.setTexCoordArray(unit,texcoords);
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return iteratorAdvanced;
|
||||
}
|
||||
|
||||
|
||||
Array* IG_Array_readLocalData(Input& fr)
|
||||
{
|
||||
int entry = fr[0].getNoNestedBrackets();
|
||||
|
||||
const char* arrayName = fr[0].getStr();
|
||||
|
||||
unsigned int capacity = 0;
|
||||
fr[1].getUInt(capacity);
|
||||
++fr;
|
||||
|
||||
fr += 2;
|
||||
|
||||
if (strcmp(arrayName,"ByteArray")==0)
|
||||
{
|
||||
ByteArray* array = osgNew ByteArray;
|
||||
array->reserve(capacity);
|
||||
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
|
||||
{
|
||||
int int_value;
|
||||
if (fr[0].getInt(int_value))
|
||||
{
|
||||
++fr;
|
||||
array->push_back(int_value);
|
||||
}
|
||||
else ++fr;
|
||||
}
|
||||
++fr;
|
||||
return array;
|
||||
}
|
||||
else if (strcmp(arrayName,"ShortArray")==0)
|
||||
{
|
||||
ShortArray* array = osgNew ShortArray;
|
||||
array->reserve(capacity);
|
||||
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
|
||||
{
|
||||
int int_value;
|
||||
if (fr[0].getInt(int_value))
|
||||
{
|
||||
++fr;
|
||||
array->push_back(int_value);
|
||||
}
|
||||
else ++fr;
|
||||
}
|
||||
++fr;
|
||||
return array;
|
||||
}
|
||||
else if (strcmp(arrayName,"IntArray")==0)
|
||||
{
|
||||
IntArray* array = osgNew IntArray;
|
||||
array->reserve(capacity);
|
||||
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
|
||||
{
|
||||
int int_value;
|
||||
if (fr[0].getInt(int_value))
|
||||
{
|
||||
++fr;
|
||||
array->push_back(int_value);
|
||||
}
|
||||
else ++fr;
|
||||
}
|
||||
++fr;
|
||||
return array;
|
||||
}
|
||||
else if (strcmp(arrayName,"UByteArray")==0)
|
||||
{
|
||||
UByteArray* array = osgNew UByteArray;
|
||||
array->reserve(capacity);
|
||||
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
|
||||
{
|
||||
unsigned int uint_value;
|
||||
if (fr[0].getUInt(uint_value))
|
||||
{
|
||||
++fr;
|
||||
array->push_back(uint_value);
|
||||
}
|
||||
else ++fr;
|
||||
}
|
||||
++fr;
|
||||
return array;
|
||||
}
|
||||
else if (strcmp(arrayName,"UShortArray")==0)
|
||||
{
|
||||
UShortArray* array = osgNew UShortArray;
|
||||
array->reserve(capacity);
|
||||
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
|
||||
{
|
||||
unsigned int uint_value;
|
||||
if (fr[0].getUInt(uint_value))
|
||||
{
|
||||
++fr;
|
||||
array->push_back(uint_value);
|
||||
}
|
||||
else ++fr;
|
||||
}
|
||||
++fr;
|
||||
return array;
|
||||
}
|
||||
else if (strcmp(arrayName,"UIntArray")==0)
|
||||
{
|
||||
UIntArray* array = osgNew UIntArray;
|
||||
array->reserve(capacity);
|
||||
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
|
||||
{
|
||||
unsigned int uint_value;
|
||||
if (fr[0].getUInt(uint_value))
|
||||
{
|
||||
++fr;
|
||||
array->push_back(uint_value);
|
||||
}
|
||||
else ++fr;
|
||||
}
|
||||
++fr;
|
||||
return array;
|
||||
}
|
||||
else if (strcmp(arrayName,"UByte4Array")==0)
|
||||
{
|
||||
UByte4Array* array = osgNew UByte4Array;
|
||||
array->reserve(capacity);
|
||||
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
|
||||
{
|
||||
unsigned int r,g,b,a;
|
||||
if (fr[0].getUInt(r) &&
|
||||
fr[1].getUInt(g) &&
|
||||
fr[2].getUInt(b) &&
|
||||
fr[3].getUInt(a))
|
||||
{
|
||||
++fr;
|
||||
array->push_back(osg::UByte4(r,g,b,a));
|
||||
}
|
||||
else ++fr;
|
||||
}
|
||||
++fr;
|
||||
return array;
|
||||
}
|
||||
else if (strcmp(arrayName,"FloatArray")==0)
|
||||
{
|
||||
FloatArray* array = osgNew FloatArray;
|
||||
array->reserve(capacity);
|
||||
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
|
||||
{
|
||||
float float_value;
|
||||
if (fr[0].getFloat(float_value))
|
||||
{
|
||||
++fr;
|
||||
array->push_back(float_value);
|
||||
}
|
||||
else ++fr;
|
||||
}
|
||||
++fr;
|
||||
return array;
|
||||
}
|
||||
else if (strcmp(arrayName,"Vec2Array")==0)
|
||||
{
|
||||
Vec2Array* array = osgNew Vec2Array;
|
||||
array->reserve(capacity);
|
||||
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
|
||||
{
|
||||
Vec2 v;
|
||||
if (fr[0].getFloat(v.x()) && fr[1].getFloat(v.y()))
|
||||
{
|
||||
fr += 2;
|
||||
array->push_back(v);
|
||||
}
|
||||
else ++fr;
|
||||
}
|
||||
++fr;
|
||||
return array;
|
||||
}
|
||||
else if (strcmp(arrayName,"Vec3Array")==0)
|
||||
{
|
||||
Vec3Array* array = osgNew Vec3Array;
|
||||
array->reserve(capacity);
|
||||
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
|
||||
{
|
||||
Vec3 v;
|
||||
if (fr[0].getFloat(v.x()) && fr[1].getFloat(v.y()) && fr[2].getFloat(v.z()))
|
||||
{
|
||||
fr += 3;
|
||||
array->push_back(v);
|
||||
}
|
||||
else ++fr;
|
||||
}
|
||||
++fr;
|
||||
return array;
|
||||
}
|
||||
else if (strcmp(arrayName,"Vec4Array")==0)
|
||||
{
|
||||
Vec4Array* array = osgNew Vec4Array;
|
||||
array->reserve(capacity);
|
||||
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
|
||||
{
|
||||
Vec4 v;
|
||||
if (fr[0].getFloat(v.x()) && fr[1].getFloat(v.y()) && fr[2].getFloat(v.z()) && fr[3].getFloat(v.w()))
|
||||
{
|
||||
fr += 4;
|
||||
array->push_back(v);
|
||||
}
|
||||
else ++fr;
|
||||
}
|
||||
++fr;
|
||||
return array;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
template<class Iterator>
|
||||
void IG_Array_writeLocalData(Output& fw, Iterator first, Iterator last,int noItemsPerLine=8)
|
||||
{
|
||||
fw.indent() << "{"<<std::endl;
|
||||
fw.moveIn();
|
||||
|
||||
int column=0;
|
||||
|
||||
for(Iterator itr=first;
|
||||
itr!=last;
|
||||
++itr)
|
||||
{
|
||||
if (column==0) fw.indent();
|
||||
|
||||
fw << *itr;
|
||||
|
||||
++column;
|
||||
if (column==noItemsPerLine)
|
||||
{
|
||||
fw << std::endl;
|
||||
column = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
fw << " ";
|
||||
}
|
||||
}
|
||||
if (column!=0) fw << std::endl;
|
||||
|
||||
fw.moveOut();
|
||||
fw.indent()<<"}"<<std::endl;
|
||||
|
||||
}
|
||||
|
||||
bool IG_Array_writeLocalData(const Array& array,Output& fw)
|
||||
{
|
||||
switch(array.getType())
|
||||
{
|
||||
case(Array::ByteArrayType):
|
||||
{
|
||||
const ByteArray& carray = static_cast<const ByteArray&>(array);
|
||||
fw<<array.className()<<" "<<carray.size()<<std::endl;
|
||||
IG_Array_writeLocalData(fw,carray.begin(),carray.end());
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(Array::ShortArrayType):
|
||||
{
|
||||
const ShortArray& carray = static_cast<const ShortArray&>(array);
|
||||
fw<<array.className()<<" "<<carray.size()<<std::endl;
|
||||
IG_Array_writeLocalData(fw,carray.begin(),carray.end());
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(Array::IntArrayType):
|
||||
{
|
||||
const IntArray& carray = static_cast<const IntArray&>(array);
|
||||
fw<<array.className()<<" "<<carray.size()<<std::endl;
|
||||
IG_Array_writeLocalData(fw,carray.begin(),carray.end());
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(Array::UByteArrayType):
|
||||
{
|
||||
const UByteArray& carray = static_cast<const UByteArray&>(array);
|
||||
fw<<array.className()<<" "<<carray.size()<<std::endl;
|
||||
IG_Array_writeLocalData(fw,carray.begin(),carray.end());
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(Array::UShortArrayType):
|
||||
{
|
||||
const UShortArray& carray = static_cast<const UShortArray&>(array);
|
||||
fw<<array.className()<<" "<<carray.size()<<std::endl;
|
||||
IG_Array_writeLocalData(fw,carray.begin(),carray.end());
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(Array::UIntArrayType):
|
||||
{
|
||||
const UIntArray& carray = static_cast<const UIntArray&>(array);
|
||||
fw<<array.className()<<" "<<carray.size()<<" ";
|
||||
IG_Array_writeLocalData(fw,carray.begin(),carray.end());
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(Array::UByte4ArrayType):
|
||||
{
|
||||
const UByte4Array& carray = static_cast<const UByte4Array&>(array);
|
||||
fw<<array.className()<<" "<<carray.size()<<" ";
|
||||
IG_Array_writeLocalData(fw,carray.begin(),carray.end(),1);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(Array::FloatArrayType):
|
||||
{
|
||||
const FloatArray& carray = static_cast<const FloatArray&>(array);
|
||||
fw<<array.className()<<" "<<carray.size()<<std::endl;
|
||||
IG_Array_writeLocalData(fw,carray.begin(),carray.end());
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(Array::Vec2ArrayType):
|
||||
{
|
||||
const Vec2Array& carray = static_cast<const Vec2Array&>(array);
|
||||
fw<<array.className()<<" "<<carray.size()<<std::endl;
|
||||
IG_Array_writeLocalData(fw,carray.begin(),carray.end(),1);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(Array::Vec3ArrayType):
|
||||
{
|
||||
const Vec3Array& carray = static_cast<const Vec3Array&>(array);
|
||||
fw<<array.className()<<" "<<carray.size()<<std::endl;
|
||||
IG_Array_writeLocalData(fw,carray.begin(),carray.end(),1);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(Array::Vec4ArrayType):
|
||||
{
|
||||
const Vec4Array& carray = static_cast<const Vec4Array&>(array);
|
||||
fw<<array.className()<<" "<<carray.size()<<std::endl;
|
||||
IG_Array_writeLocalData(fw,carray.begin(),carray.end(),1);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(Array::ArrayType):
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool IG_Primitive_readLocalData(Input& fr,osg::IndexedGeometry& geom)
|
||||
{
|
||||
bool iteratorAdvanced = false;
|
||||
if (fr.matchSequence("DrawArrays %w %i %i"))
|
||||
{
|
||||
|
||||
GLenum mode;
|
||||
IndexedGeometry_matchPrimitiveModeStr(fr[1].getStr(),mode);
|
||||
|
||||
int first;
|
||||
fr[2].getInt(first);
|
||||
|
||||
int count;
|
||||
fr[3].getInt(count);
|
||||
|
||||
geom.addPrimitiveSet(osgNew DrawArrays(mode,first,count));
|
||||
|
||||
fr += 4;
|
||||
|
||||
iteratorAdvanced = true;
|
||||
|
||||
}
|
||||
else if (fr.matchSequence("DrawArrayLengths %w %i %i {"))
|
||||
{
|
||||
int entry = fr[1].getNoNestedBrackets();
|
||||
|
||||
GLenum mode;
|
||||
IndexedGeometry_matchPrimitiveModeStr(fr[1].getStr(),mode);
|
||||
|
||||
int first;
|
||||
fr[2].getInt(first);
|
||||
|
||||
int capacity;
|
||||
fr[3].getInt(capacity);
|
||||
|
||||
fr += 5;
|
||||
|
||||
DrawArrayLengths* prim = osgNew DrawArrayLengths;
|
||||
prim->setMode(mode);
|
||||
prim->setFirst(first);
|
||||
prim->reserve(capacity);
|
||||
|
||||
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
|
||||
{
|
||||
unsigned int i;
|
||||
if (fr[0].getUInt(i))
|
||||
{
|
||||
prim->push_back(i);
|
||||
++fr;
|
||||
}
|
||||
}
|
||||
++fr;
|
||||
|
||||
geom.addPrimitiveSet(prim);
|
||||
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
else if (fr.matchSequence("DrawElementsUByte %w %i {"))
|
||||
{
|
||||
int entry = fr[1].getNoNestedBrackets();
|
||||
|
||||
GLenum mode;
|
||||
IndexedGeometry_matchPrimitiveModeStr(fr[1].getStr(),mode);
|
||||
|
||||
int capacity;
|
||||
fr[2].getInt(capacity);
|
||||
|
||||
fr += 4;
|
||||
|
||||
DrawElementsUByte* prim = osgNew DrawElementsUByte;
|
||||
prim->setMode(mode);
|
||||
prim->reserve(capacity);
|
||||
|
||||
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
|
||||
{
|
||||
unsigned int i;
|
||||
if (fr[0].getUInt(i))
|
||||
{
|
||||
prim->push_back(i);
|
||||
++fr;
|
||||
}
|
||||
}
|
||||
++fr;
|
||||
|
||||
geom.addPrimitiveSet(prim);
|
||||
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
else if (fr.matchSequence("DrawElementsUShort %w %i {"))
|
||||
{
|
||||
int entry = fr[1].getNoNestedBrackets();
|
||||
|
||||
GLenum mode;
|
||||
IndexedGeometry_matchPrimitiveModeStr(fr[1].getStr(),mode);
|
||||
|
||||
int capacity;
|
||||
fr[2].getInt(capacity);
|
||||
|
||||
fr += 4;
|
||||
|
||||
DrawElementsUShort* prim = osgNew DrawElementsUShort;
|
||||
prim->setMode(mode);
|
||||
prim->reserve(capacity);
|
||||
|
||||
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
|
||||
{
|
||||
unsigned int i;
|
||||
if (fr[0].getUInt(i))
|
||||
{
|
||||
prim->push_back(i);
|
||||
++fr;
|
||||
}
|
||||
}
|
||||
++fr;
|
||||
|
||||
geom.addPrimitiveSet(prim);
|
||||
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
else if (fr.matchSequence("DrawElementsUInt %w %i {"))
|
||||
{
|
||||
int entry = fr[1].getNoNestedBrackets();
|
||||
|
||||
GLenum mode;
|
||||
IndexedGeometry_matchPrimitiveModeStr(fr[1].getStr(),mode);
|
||||
|
||||
int capacity;
|
||||
fr[2].getInt(capacity);
|
||||
|
||||
fr += 4;
|
||||
|
||||
DrawElementsUInt* prim = osgNew DrawElementsUInt;
|
||||
prim->setMode(mode);
|
||||
prim->reserve(capacity);
|
||||
|
||||
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
|
||||
{
|
||||
unsigned int i;
|
||||
if (fr[0].getUInt(i))
|
||||
{
|
||||
prim->push_back(i);
|
||||
++fr;
|
||||
}
|
||||
}
|
||||
++fr;
|
||||
|
||||
geom.addPrimitiveSet(prim);
|
||||
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
return iteratorAdvanced;
|
||||
}
|
||||
|
||||
bool IG_Primitive_writeLocalData(const PrimitiveSet& prim,Output& fw)
|
||||
{
|
||||
|
||||
switch(prim.getType())
|
||||
{
|
||||
case(PrimitiveSet::DrawArraysPrimitiveType):
|
||||
{
|
||||
const DrawArrays& cprim = static_cast<const DrawArrays&>(prim);
|
||||
fw<<cprim.className()<<" "<<IndexedGeometry_getPrimitiveModeStr(cprim.getMode())<<" "<<cprim.getFirst()<<" "<<cprim.getCount()<<std::endl;
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(PrimitiveSet::DrawArrayLengthsPrimitiveType):
|
||||
{
|
||||
const DrawArrayLengths& cprim = static_cast<const DrawArrayLengths&>(prim);
|
||||
fw<<cprim.className()<<" "<<IndexedGeometry_getPrimitiveModeStr(cprim.getMode())<<" "<<cprim.getFirst()<<" "<<cprim.size()<<std::endl;
|
||||
IG_Array_writeLocalData(fw,cprim.begin(),cprim.end());
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(PrimitiveSet::DrawElementsUBytePrimitiveType):
|
||||
{
|
||||
const DrawElementsUByte& cprim = static_cast<const DrawElementsUByte&>(prim);
|
||||
fw<<cprim.className()<<" "<<IndexedGeometry_getPrimitiveModeStr(cprim.getMode())<<" "<<cprim.size()<<std::endl;
|
||||
IG_Array_writeLocalData(fw,cprim.begin(),cprim.end());
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(PrimitiveSet::DrawElementsUShortPrimitiveType):
|
||||
{
|
||||
const DrawElementsUShort& cprim = static_cast<const DrawElementsUShort&>(prim);
|
||||
fw<<cprim.className()<<" "<<IndexedGeometry_getPrimitiveModeStr(cprim.getMode())<<" "<<cprim.size()<<std::endl;
|
||||
IG_Array_writeLocalData(fw,cprim.begin(),cprim.end());
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case(PrimitiveSet::DrawElementsUIntPrimitiveType):
|
||||
{
|
||||
const DrawElementsUInt& cprim = static_cast<const DrawElementsUInt&>(prim);
|
||||
fw<<cprim.className()<<" "<<IndexedGeometry_getPrimitiveModeStr(cprim.getMode())<<" "<<cprim.size()<<std::endl;
|
||||
IG_Array_writeLocalData(fw,cprim.begin(),cprim.end());
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool IndexedGeometry_writeLocalData(const Object& obj, Output& fw)
|
||||
{
|
||||
const IndexedGeometry& geom = static_cast<const IndexedGeometry&>(obj);
|
||||
|
||||
const IndexedGeometry::PrimitiveSetList& primitives = geom.getPrimitiveSetList();
|
||||
if (!primitives.empty())
|
||||
{
|
||||
fw.indent() << "PrimitiveSets "<<primitives.size()<<std::endl;
|
||||
fw.indent() << "{"<<std::endl;
|
||||
fw.moveIn();
|
||||
for(IndexedGeometry::PrimitiveSetList::const_iterator itr=primitives.begin();
|
||||
itr!=primitives.end();
|
||||
++itr)
|
||||
{
|
||||
fw.indent();
|
||||
IG_Primitive_writeLocalData(**itr,fw);
|
||||
}
|
||||
fw.moveOut();
|
||||
fw.indent() << "}"<<std::endl;
|
||||
}
|
||||
|
||||
if (geom.getVertexArray())
|
||||
{
|
||||
const Vec3Array& vertices = *geom.getVertexArray();
|
||||
fw.indent()<<"VertexArray "<<vertices.size()<<std::endl;
|
||||
|
||||
IG_Array_writeLocalData(fw,vertices.begin(),vertices.end(),1);
|
||||
|
||||
}
|
||||
|
||||
if (geom.getNormalArray())
|
||||
{
|
||||
|
||||
fw.indent()<<"NormalBinding "<<IndexedGeometry_getBindingTypeStr(geom.getNormalBinding())<<std::endl;
|
||||
|
||||
const Vec3Array& normals = *geom.getNormalArray();
|
||||
fw.indent()<<"NormalArray "<<normals.size()<<std::endl;
|
||||
|
||||
IG_Array_writeLocalData(fw,normals.begin(),normals.end(),1);
|
||||
|
||||
}
|
||||
|
||||
if (geom.getColorArray())
|
||||
{
|
||||
fw.indent()<<"ColorBinding "<<IndexedGeometry_getBindingTypeStr(geom.getColorBinding())<<std::endl;
|
||||
fw.indent()<<"ColorArray ";
|
||||
IG_Array_writeLocalData(*geom.getColorArray(),fw);
|
||||
}
|
||||
|
||||
if (geom.getSecondaryColorArray())
|
||||
{
|
||||
fw.indent()<<"SecondaryColorBinding "<<IndexedGeometry_getBindingTypeStr(geom.getSecondaryColorBinding())<<std::endl;
|
||||
fw.indent()<<"SecondaryColorArray ";
|
||||
IG_Array_writeLocalData(*geom.getSecondaryColorArray(),fw);
|
||||
}
|
||||
|
||||
if (geom.getFogCoordArray())
|
||||
{
|
||||
fw.indent()<<"FogCoordBinding "<<IndexedGeometry_getBindingTypeStr(geom.getFogCoordBinding())<<std::endl;
|
||||
|
||||
const FloatArray& fogcoords = *geom.getFogCoordArray();
|
||||
fw.indent()<<"FogCoordArray "<<fogcoords.size()<<std::endl;
|
||||
|
||||
IG_Array_writeLocalData(fw,fogcoords.begin(),fogcoords.end());
|
||||
}
|
||||
|
||||
const IndexedGeometry::TexCoordArrayList& tcal=geom.getTexCoordArrayList();
|
||||
for(unsigned int i=0;i<tcal.size();++i)
|
||||
{
|
||||
if (tcal[i].first.valid())
|
||||
{
|
||||
fw.indent()<<"TexCoordArray "<<i<<" ";
|
||||
IG_Array_writeLocalData(*(tcal[i].first),fw);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IndexedGeometry_matchBindingTypeStr(const char* str,IndexedGeometry::AttributeBinding& mode)
|
||||
{
|
||||
if (strcmp(str,"OFF")==0) mode = IndexedGeometry::BIND_OFF;
|
||||
else if (strcmp(str,"OVERALL")==0) mode = IndexedGeometry::BIND_OVERALL;
|
||||
else if (strcmp(str,"PER_PRIMITIVE")==0) mode = IndexedGeometry::BIND_PER_PRIMITIVE;
|
||||
else if (strcmp(str,"PER_VERTEX")==0) mode = IndexedGeometry::BIND_PER_VERTEX;
|
||||
else return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
const char* IndexedGeometry_getBindingTypeStr(IndexedGeometry::AttributeBinding mode)
|
||||
{
|
||||
switch(mode)
|
||||
{
|
||||
case (IndexedGeometry::BIND_OVERALL) : return "OVERALL";
|
||||
case (IndexedGeometry::BIND_PER_PRIMITIVE) : return "PER_PRIMITIVE";
|
||||
case (IndexedGeometry::BIND_PER_VERTEX) : return "PER_VERTEX";
|
||||
case (IndexedGeometry::BIND_OFF) :
|
||||
default : return "OFF";
|
||||
}
|
||||
}
|
||||
|
||||
bool IndexedGeometry_matchPrimitiveModeStr(const char* str,GLenum& mode)
|
||||
{
|
||||
if (strcmp(str,"POINTS")==0) mode = PrimitiveSet::POINTS;
|
||||
else if (strcmp(str,"LINES")==0) mode = PrimitiveSet::LINES;
|
||||
else if (strcmp(str,"LINE_STRIP")==0) mode = PrimitiveSet::LINE_STRIP;
|
||||
else if (strcmp(str,"LINE_LOOP")==0) mode = PrimitiveSet::LINE_LOOP;
|
||||
else if (strcmp(str,"TRIANGLES")==0) mode = PrimitiveSet::TRIANGLES;
|
||||
else if (strcmp(str,"TRIANGLE_STRIP")==0) mode = PrimitiveSet::TRIANGLE_STRIP;
|
||||
else if (strcmp(str,"TRIANGLE_FAN")==0) mode = PrimitiveSet::TRIANGLE_FAN;
|
||||
else if (strcmp(str,"QUADS")==0) mode = PrimitiveSet::QUADS;
|
||||
else if (strcmp(str,"QUAD_STRIP")==0) mode = PrimitiveSet::QUAD_STRIP;
|
||||
else if (strcmp(str,"POLYGON")==0) mode = PrimitiveSet::POLYGON;
|
||||
else return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
const char* IndexedGeometry_getPrimitiveModeStr(GLenum mode)
|
||||
{
|
||||
switch(mode)
|
||||
{
|
||||
case (PrimitiveSet::POINTS) : return "POINTS";
|
||||
case (PrimitiveSet::LINES) : return "LINES";
|
||||
case (PrimitiveSet::LINE_STRIP) : return "LINE_STRIP";
|
||||
case (PrimitiveSet::LINE_LOOP) : return "LINE_LOOP";
|
||||
case (PrimitiveSet::TRIANGLES) : return "TRIANGLES";
|
||||
case (PrimitiveSet::TRIANGLE_STRIP) : return "TRIANGLE_STRIP";
|
||||
case (PrimitiveSet::TRIANGLE_FAN) : return "TRIANGLE_FAN";
|
||||
case (PrimitiveSet::QUADS) : return "QUADS";
|
||||
case (PrimitiveSet::QUAD_STRIP) : return "QUAD_STRIP";
|
||||
case (PrimitiveSet::POLYGON) : return "POLYGON";
|
||||
default : return "UnknownPrimitveType";
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@ CXXFILES =\
|
||||
Group.cpp\
|
||||
Image.cpp\
|
||||
Impostor.cpp\
|
||||
IndexedGeometry.cpp\
|
||||
Light.cpp\
|
||||
LightModel.cpp\
|
||||
LightSource.cpp\
|
||||
|
||||
@@ -253,7 +253,7 @@ void* geomRead::Parse(trpgToken /*tok*/,trpgReadBuffer &buf)
|
||||
case trpgGeometry::Triangles:
|
||||
{
|
||||
geometry = new Geometry;
|
||||
geometry->addPrimitive(new DrawArrays(Primitive::TRIANGLES,0,numPrims*3));
|
||||
geometry->addPrimitive(new DrawArrays(PrimitiveSet::TRIANGLES,0,numPrims*3));
|
||||
}
|
||||
break;
|
||||
case trpgGeometry::TriStrips:
|
||||
@@ -267,7 +267,7 @@ void* geomRead::Parse(trpgToken /*tok*/,trpgReadBuffer &buf)
|
||||
int first=0;
|
||||
for(int i=0;i<numPrims;++i)
|
||||
{
|
||||
geometry->addPrimitive(new DrawArrays(Primitive::TRIANGLE_STRIP,first,primitives[i]));
|
||||
geometry->addPrimitive(new DrawArrays(PrimitiveSet::TRIANGLE_STRIP,first,primitives[i]));
|
||||
first += primitives[i];
|
||||
|
||||
}
|
||||
@@ -286,7 +286,7 @@ void* geomRead::Parse(trpgToken /*tok*/,trpgReadBuffer &buf)
|
||||
int i;
|
||||
for(i=0;i<numPrims;++i)
|
||||
{
|
||||
geometry->addPrimitive(new DrawArrays(Primitive::TRIANGLE_FAN,first,primitives[i]));
|
||||
geometry->addPrimitive(new DrawArrays(PrimitiveSet::TRIANGLE_FAN,first,primitives[i]));
|
||||
first += primitives[i];
|
||||
}
|
||||
|
||||
|
||||
@@ -181,6 +181,10 @@ void Text::drawImmediateMode(State& state)
|
||||
|
||||
if(!_initAlignment)
|
||||
initAlignment();
|
||||
|
||||
// we must disable all the vertex arrays to prevent any state
|
||||
// propagating into text.
|
||||
state.disableAllVertexArrays();
|
||||
|
||||
// draw boundingBox
|
||||
if(_drawMode & BOUNDINGBOX)
|
||||
|
||||
@@ -1189,16 +1189,16 @@ bool Optimizer::MergeGeometryVisitor::mergeGeode(osg::Geode& geode)
|
||||
itr!=primitives.end();
|
||||
++itr)
|
||||
{
|
||||
osg::Primitive* prim = itr->get();
|
||||
if (prim->getMode()==osg::Primitive::POLYGON)
|
||||
osg::PrimitiveSet* prim = itr->get();
|
||||
if (prim->getMode()==osg::PrimitiveSet::POLYGON)
|
||||
{
|
||||
if (prim->getNumIndices()==3)
|
||||
{
|
||||
prim->setMode(osg::Primitive::TRIANGLES);
|
||||
prim->setMode(osg::PrimitiveSet::TRIANGLES);
|
||||
}
|
||||
else if (prim->getNumIndices()==4)
|
||||
{
|
||||
prim->setMode(osg::Primitive::QUADS);
|
||||
prim->setMode(osg::PrimitiveSet::QUADS);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1218,8 +1218,8 @@ bool Optimizer::MergeGeometryVisitor::mergeGeode(osg::Geode& geode)
|
||||
unsigned int primNo=0;
|
||||
while(primNo+1<primitives.size())
|
||||
{
|
||||
osg::Primitive* lhs = primitives[primNo].get();
|
||||
osg::Primitive* rhs = primitives[primNo+1].get();
|
||||
osg::PrimitiveSet* lhs = primitives[primNo].get();
|
||||
osg::PrimitiveSet* rhs = primitives[primNo+1].get();
|
||||
|
||||
bool combine = false;
|
||||
|
||||
@@ -1229,10 +1229,10 @@ bool Optimizer::MergeGeometryVisitor::mergeGeode(osg::Geode& geode)
|
||||
|
||||
switch(lhs->getMode())
|
||||
{
|
||||
case(osg::Primitive::POINTS):
|
||||
case(osg::Primitive::LINES):
|
||||
case(osg::Primitive::TRIANGLES):
|
||||
case(osg::Primitive::QUADS):
|
||||
case(osg::PrimitiveSet::POINTS):
|
||||
case(osg::PrimitiveSet::LINES):
|
||||
case(osg::PrimitiveSet::TRIANGLES):
|
||||
case(osg::PrimitiveSet::QUADS):
|
||||
combine = true;
|
||||
break;
|
||||
}
|
||||
@@ -1244,19 +1244,19 @@ bool Optimizer::MergeGeometryVisitor::mergeGeode(osg::Geode& geode)
|
||||
|
||||
switch(lhs->getType())
|
||||
{
|
||||
case(osg::Primitive::DrawArraysPrimitiveType):
|
||||
case(osg::PrimitiveSet::DrawArraysPrimitiveType):
|
||||
combine = mergePrimitive(*(static_cast<osg::DrawArrays*>(lhs)),*(static_cast<osg::DrawArrays*>(rhs)));
|
||||
break;
|
||||
case(osg::Primitive::DrawArrayLengthsPrimitiveType):
|
||||
case(osg::PrimitiveSet::DrawArrayLengthsPrimitiveType):
|
||||
combine = mergePrimitive(*(static_cast<osg::DrawArrayLengths*>(lhs)),*(static_cast<osg::DrawArrayLengths*>(rhs)));
|
||||
break;
|
||||
case(osg::Primitive::DrawElementsUBytePrimitiveType):
|
||||
case(osg::PrimitiveSet::DrawElementsUBytePrimitiveType):
|
||||
combine = mergePrimitive(*(static_cast<osg::DrawElementsUByte*>(lhs)),*(static_cast<osg::DrawElementsUByte*>(rhs)));
|
||||
break;
|
||||
case(osg::Primitive::DrawElementsUShortPrimitiveType):
|
||||
case(osg::PrimitiveSet::DrawElementsUShortPrimitiveType):
|
||||
combine = mergePrimitive(*(static_cast<osg::DrawElementsUShort*>(lhs)),*(static_cast<osg::DrawElementsUShort*>(rhs)));
|
||||
break;
|
||||
case(osg::Primitive::DrawElementsUIntPrimitiveType):
|
||||
case(osg::PrimitiveSet::DrawElementsUIntPrimitiveType):
|
||||
combine = mergePrimitive(*(static_cast<osg::DrawElementsUInt*>(lhs)),*(static_cast<osg::DrawElementsUInt*>(rhs)));
|
||||
break;
|
||||
default:
|
||||
@@ -1336,7 +1336,7 @@ bool Optimizer::MergeGeometryVisitor::mergeGeometry(osg::Geometry& lhs,osg::Geom
|
||||
primItr!=rhs.getPrimitiveList().end();
|
||||
++primItr)
|
||||
{
|
||||
osg::Primitive* primitive = primItr->get();
|
||||
osg::PrimitiveSet* primitive = primItr->get();
|
||||
primitive->offsetIndices(base);
|
||||
}
|
||||
|
||||
|
||||
@@ -80,12 +80,12 @@ void SmoothingVisitor::smooth(osg::Geometry& geom)
|
||||
{
|
||||
switch((*itr)->getMode())
|
||||
{
|
||||
case(Primitive::TRIANGLES):
|
||||
case(Primitive::TRIANGLE_STRIP):
|
||||
case(Primitive::TRIANGLE_FAN):
|
||||
case(Primitive::QUADS):
|
||||
case(Primitive::QUAD_STRIP):
|
||||
case(Primitive::POLYGON):
|
||||
case(PrimitiveSet::TRIANGLES):
|
||||
case(PrimitiveSet::TRIANGLE_STRIP):
|
||||
case(PrimitiveSet::TRIANGLE_FAN):
|
||||
case(PrimitiveSet::QUADS):
|
||||
case(PrimitiveSet::QUAD_STRIP):
|
||||
case(PrimitiveSet::POLYGON):
|
||||
++numSurfacePrimitives;
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -140,15 +140,15 @@ void Tesselator::retesselatePolygons(osg::Geometry& geom)
|
||||
int noPrimitiveAtStart = geom.getPrimitiveList().size();
|
||||
for(int primNo=0;primNo<noPrimitiveAtStart;++primNo)
|
||||
{
|
||||
osg::Primitive* primitive = geom.getPrimitiveList()[primNo].get();
|
||||
if (primitive->getMode()==osg::Primitive::POLYGON)
|
||||
osg::PrimitiveSet* primitive = geom.getPrimitiveList()[primNo].get();
|
||||
if (primitive->getMode()==osg::PrimitiveSet::POLYGON)
|
||||
{
|
||||
beginTesselation();
|
||||
beginContour();
|
||||
|
||||
switch(primitive->getType())
|
||||
{
|
||||
case(osg::Primitive::DrawArraysPrimitiveType):
|
||||
case(osg::PrimitiveSet::DrawArraysPrimitiveType):
|
||||
{
|
||||
osg::DrawArrays* drawArray = static_cast<osg::DrawArrays*>(primitive);
|
||||
unsigned int first = drawArray->getFirst();
|
||||
@@ -159,7 +159,7 @@ void Tesselator::retesselatePolygons(osg::Geometry& geom)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case(osg::Primitive::DrawElementsUBytePrimitiveType):
|
||||
case(osg::PrimitiveSet::DrawElementsUBytePrimitiveType):
|
||||
{
|
||||
osg::DrawElementsUByte* drawElements = static_cast<osg::DrawElementsUByte*>(primitive);
|
||||
for(osg::DrawElementsUByte::iterator indexItr=drawElements->begin();
|
||||
@@ -170,7 +170,7 @@ void Tesselator::retesselatePolygons(osg::Geometry& geom)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case(osg::Primitive::DrawElementsUShortPrimitiveType):
|
||||
case(osg::PrimitiveSet::DrawElementsUShortPrimitiveType):
|
||||
{
|
||||
osg::DrawElementsUShort* drawElements = static_cast<osg::DrawElementsUShort*>(primitive);
|
||||
for(osg::DrawElementsUShort::iterator indexItr=drawElements->begin();
|
||||
@@ -181,7 +181,7 @@ void Tesselator::retesselatePolygons(osg::Geometry& geom)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case(osg::Primitive::DrawElementsUIntPrimitiveType):
|
||||
case(osg::PrimitiveSet::DrawElementsUIntPrimitiveType):
|
||||
{
|
||||
osg::DrawElementsUInt* drawElements = static_cast<osg::DrawElementsUInt*>(primitive);
|
||||
for(osg::DrawElementsUInt::iterator indexItr=drawElements->begin();
|
||||
|
||||
@@ -48,12 +48,12 @@ void TriStripVisitor::stripify(Geometry& geom)
|
||||
{
|
||||
switch((*itr)->getMode())
|
||||
{
|
||||
case(Primitive::TRIANGLES):
|
||||
case(Primitive::TRIANGLE_STRIP):
|
||||
case(Primitive::TRIANGLE_FAN):
|
||||
case(Primitive::QUADS):
|
||||
case(Primitive::QUAD_STRIP):
|
||||
case(Primitive::POLYGON):
|
||||
case(PrimitiveSet::TRIANGLES):
|
||||
case(PrimitiveSet::TRIANGLE_STRIP):
|
||||
case(PrimitiveSet::TRIANGLE_FAN):
|
||||
case(PrimitiveSet::QUADS):
|
||||
case(PrimitiveSet::QUAD_STRIP):
|
||||
case(PrimitiveSet::POLYGON):
|
||||
++numSurfacePrimitives;
|
||||
break;
|
||||
default:
|
||||
@@ -76,12 +76,12 @@ void TriStripVisitor::stripify(Geometry& geom)
|
||||
{
|
||||
switch((*itr)->getMode())
|
||||
{
|
||||
case(Primitive::TRIANGLES):
|
||||
case(Primitive::TRIANGLE_STRIP):
|
||||
case(Primitive::TRIANGLE_FAN):
|
||||
case(Primitive::QUADS):
|
||||
case(Primitive::QUAD_STRIP):
|
||||
case(Primitive::POLYGON):
|
||||
case(PrimitiveSet::TRIANGLES):
|
||||
case(PrimitiveSet::TRIANGLE_STRIP):
|
||||
case(PrimitiveSet::TRIANGLE_FAN):
|
||||
case(PrimitiveSet::QUADS):
|
||||
case(PrimitiveSet::QUAD_STRIP):
|
||||
case(PrimitiveSet::POLYGON):
|
||||
(*itr)->accept(taf);
|
||||
break;
|
||||
default:
|
||||
@@ -124,7 +124,7 @@ void TriStripVisitor::stripify(Geometry& geom)
|
||||
NvStripInfo *strip = strips[i];
|
||||
int nStripFaceCount = strip->m_faces.size();
|
||||
|
||||
osg::UShortDrawElements* elements = osgNew osg::UShortDrawElements(osg::Primitive::TRIANGLE_STRIP);
|
||||
osg::DrawElementsUShort* elements = osgNew osg::DrawElementsUShort(osg::PrimitiveSet::TRIANGLE_STRIP);
|
||||
elements->reserve(nStripFaceCount+2);
|
||||
new_primitives.push_back(elements);
|
||||
|
||||
@@ -187,7 +187,7 @@ void TriStripVisitor::stripify(Geometry& geom)
|
||||
if (leftoverFaces.size())
|
||||
{
|
||||
|
||||
osg::UShortDrawElements* triangles = osgNew osg::UShortDrawElements(osg::Primitive::TRIANGLES);
|
||||
osg::DrawElementsUShort* triangles = osgNew osg::DrawElementsUShort(osg::PrimitiveSet::TRIANGLES);
|
||||
triangles->reserve(leftoverFaces.size()*3);
|
||||
new_primitives.push_back(triangles);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user