With assistance from Sukender, moved the depreacted osg::Geometry vertex indices and AttributeBinding definitions out into a separated namespace/class so to use

deprecated features you should now use deprecated_osg::Geometry in place of osg::Geometry.
This commit is contained in:
Robert Osfield 2013-06-25 16:10:24 +00:00
parent ceb97fe230
commit 1793466442
26 changed files with 479 additions and 494 deletions

View File

@ -470,8 +470,6 @@ OPTION(OSG_GL_FIXED_FUNCTION_AVAILABLE "Set to OFF to disable use of OpenGL fixe
OPTION(OSG_CPP_EXCEPTIONS_AVAILABLE "Set to OFF to disable compile of OSG components that use C++ exceptions." ON)
OPTION(OSG_USE_DEPRECATED_GEOMETRY_METHODS "Set to ON to enable use of deprecated osg::Geometry functions." ON)
################################################################################
# Set Config file

View File

@ -22,11 +22,6 @@
* exist in the triangulation.
*/
#include <osg/Config>
#ifndef OSG_USE_DEPRECATED_GEOMETRY_METHODS
#define OSG_USE_DEPRECATED_GEOMETRY_METHODS 1
#endif
#include <osgDB/ReadFile>
#include <osgUtil/Optimizer>
#include <osgViewer/Viewer>
@ -118,10 +113,10 @@ public:
/** return a geometry that fills the constraint.
*/
virtual osg::Geometry * makeAreal( osg::Vec3Array *points);
virtual deprecated_osg::Geometry * makeAreal( osg::Vec3Array *points);
/** or create a wall around the constraint area: */
virtual osg::Geometry * makeWallGeometry( osg::Vec3Array *points) ;
virtual deprecated_osg::Geometry * makeWallGeometry( osg::Vec3Array *points) ;
/** for basic purposes, you can call these routines to make simple fill in geometries */
virtual osg::DrawArrays* makeWall(void ) const;
@ -171,7 +166,7 @@ public:
/** return a geometry that fills the constraint.
*/
virtual osg::Geometry *makeGeometry(const osg::Vec3Array *points) ;
virtual deprecated_osg::Geometry *makeGeometry(const osg::Vec3Array *points) ;
/** return normals array - flat shaded */
osg::Vec3Array* getNormals(const osg::Vec3Array *points);
@ -208,7 +203,7 @@ public:
{
// create pyramid geometry. Centre plus points around base
const osg::Vec3Array *_line= dynamic_cast<const osg::Vec3Array*>(getVertexArray());
osg::Geometry *gm=new osg::Geometry;
deprecated_osg::Geometry *gm=new deprecated_osg::Geometry;
osg::Vec3Array *pts=new osg::Vec3Array;
osg::Vec3Array *norms=new osg::Vec3Array;
osg::Vec2Array *tcoords=new osg::Vec2Array;
@ -224,7 +219,7 @@ public:
norms->push_back(nrm);
}
gm->setNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE);
gm->setNormalBinding(deprecated_osg::Geometry::BIND_PER_PRIMITIVE);
gm->setVertexArray(pts);
osg::StateSet *dstate= gm->getOrCreateStateSet( );
dstate->setMode( GL_LIGHTING, osg::StateAttribute::ON );
@ -620,7 +615,7 @@ osg::Group *makedelaunay(const int ndcs)
// Calculate the texture coordinates after triangulation as
//the points may get disordered by the triangulate function
osg::ref_ptr<osg::Geometry> gm=new osg::Geometry;
osg::ref_ptr<deprecated_osg::Geometry> gm=new deprecated_osg::Geometry;
gm->setVertexArray(points); // points may have been modified in order by triangulation.
/** calculate texture coords for terrain points */
if (image) {
@ -634,7 +629,7 @@ osg::Group *makedelaunay(const int ndcs)
}
gm->addPrimitiveSet(trig->getTriangles());
gm->setNormalArray(trig->getOutputNormalArray());
gm->setNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE);
gm->setNormalBinding(deprecated_osg::Geometry::BIND_PER_PRIMITIVE);
geode->addDrawable(gm.get());
if (ndcs>0) {
for ( std::vector < pyramid* >::iterator itr=pyrlist.begin(); itr!=pyrlist.end(); itr++) {
@ -993,10 +988,10 @@ osg::DrawArrays * ArealConstraint::makeWall(void) const
return (new osg::DrawArrays(osg::PrimitiveSet::QUAD_STRIP,0,2+2*_line->size()));
}
osg::Geometry *ArealConstraint::makeWallGeometry( osg::Vec3Array *pt)
deprecated_osg::Geometry *ArealConstraint::makeWallGeometry( osg::Vec3Array *pt)
{
osg::ref_ptr<osg::Geometry> gm=new osg::Geometry; // the wall
osg::ref_ptr<osg::Geometry> edges=new osg::Geometry; // edges of bounds
osg::ref_ptr<deprecated_osg::Geometry> gm=new deprecated_osg::Geometry; // the wall
osg::ref_ptr<deprecated_osg::Geometry> edges=new deprecated_osg::Geometry; // edges of bounds
edges->setVertexArray(pt);
osg::DrawElementsUInt *trgeom=getTriangles();
edges->addPrimitiveSet(trgeom);
@ -1057,16 +1052,16 @@ osg::Geometry *ArealConstraint::makeWallGeometry( osg::Vec3Array *pt)
}
osg::Geometry * ArealConstraint::makeAreal( osg::Vec3Array *points)
deprecated_osg::Geometry * ArealConstraint::makeAreal( osg::Vec3Array *points)
{
osg::ref_ptr<osg::Geometry> gm; // the fill in area
osg::ref_ptr<deprecated_osg::Geometry> gm; // the fill in area
if (_interiorTris.size()>0) {
gm =new osg::Geometry; // the forest roof
gm =new deprecated_osg::Geometry; // the forest roof
gm->setVertexArray(points);
osg::DrawElementsUInt *trgeom=getTriangles();
gm->addPrimitiveSet(trgeom);
gm->setNormalArray(getCanopyNormals(points));
gm->setNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE);
gm->setNormalBinding(deprecated_osg::Geometry::BIND_PER_PRIMITIVE);
gm->setTexCoordArray(0,getCanopyTexcoords(points));
osg::Image* image = osgDB::readImageFile(texture);
if (image)
@ -1238,9 +1233,9 @@ osg::Vec3Array * LinearConstraint::getNormals(const osg::Vec3Array *points)
return norms.release();
}
osg::Geometry * LinearConstraint::makeGeometry(const osg::Vec3Array *points)
deprecated_osg::Geometry * LinearConstraint::makeGeometry(const osg::Vec3Array *points)
{
osg::ref_ptr<osg::Geometry> gm=new osg::Geometry; // the fill in road/railway
osg::ref_ptr<deprecated_osg::Geometry> gm=new deprecated_osg::Geometry; // the fill in road/railway
if (_midline->size()>0) {
osg::ref_ptr<osg::Vec3Array> locpts=getPoints(points);
if (texture!="") {
@ -1263,7 +1258,7 @@ osg::Geometry * LinearConstraint::makeGeometry(const osg::Vec3Array *points)
}
gm->setVertexArray(locpts.get());
gm->setNormalArray(getNormals(locpts.get()));
gm->setNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE);
gm->setNormalBinding(deprecated_osg::Geometry::BIND_PER_PRIMITIVE);
gm->addPrimitiveSet(getTriangles());
}

View File

@ -16,11 +16,6 @@
* THE SOFTWARE.
*/
#include <osg/Config>
#ifndef OSG_USE_DEPRECATED_GEOMETRY_METHODS
#define OSG_USE_DEPRECATED_GEOMETRY_METHODS 1
#endif
#include <osg/Geometry>
#include <osg/Material>
#include <osg/MatrixTransform>
@ -148,7 +143,7 @@ void CreateHouses()
// create geometry
osg::ref_ptr<osg::Geometry> geometry = new osg::Geometry();
osg::ref_ptr<deprecated_osg::Geometry> geometry = new deprecated_osg::Geometry();
geometry->addPrimitiveSet(primitives);
@ -156,10 +151,10 @@ void CreateHouses()
geometry->setVertexIndices(coordIndices.get());
geometry->setColorArray(colors.get());
geometry->setColorBinding(osg::Geometry::BIND_OVERALL);
geometry->setColorBinding(deprecated_osg::Geometry::BIND_OVERALL);
geometry->setNormalArray(normals.get());
geometry->setNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE);
geometry->setNormalBinding(deprecated_osg::Geometry::BIND_PER_PRIMITIVE);
osg::ref_ptr<osg::Geode> geode = new osg::Geode();
geode->addDrawable(geometry.get());

View File

@ -33,12 +33,6 @@
// example uses a NodeVisitor to try to find worthwhile locations
// for OcclusionQueryNodes in your the scene graph.
#include <osg/Config>
#ifndef OSG_USE_DEPRECATED_GEOMETRY_METHODS
#define OSG_USE_DEPRECATED_GEOMETRY_METHODS 1
#endif
#include <osg/NodeVisitor>
#include <osg/Geode>
#include <osg/Geometry>
@ -572,7 +566,7 @@ createBox()
state->setAttributeAndModes( pm,
osg::StateAttribute::ON | osg::StateAttribute::PROTECTED );
osg::ref_ptr<osg::Geometry> geom = new osg::Geometry;
osg::ref_ptr<deprecated_osg::Geometry> geom = new deprecated_osg::Geometry;
osg::ref_ptr<osg::Vec3Array> v = new osg::Vec3Array;
geom->setVertexArray( v.get() );
@ -610,12 +604,12 @@ createBox()
osg::ref_ptr<osg::Vec4Array> c = new osg::Vec4Array;
geom->setColorArray( c.get() );
geom->setColorBinding( osg::Geometry::BIND_OVERALL );
geom->setColorBinding( deprecated_osg::Geometry::BIND_OVERALL );
c->push_back( osg::Vec4( 0.f, 1.f, 1.f, 1.f ) );
osg::ref_ptr<osg::Vec3Array> n = new osg::Vec3Array;
geom->setNormalArray( n.get() );
geom->setNormalBinding( osg::Geometry::BIND_PER_PRIMITIVE );
geom->setNormalBinding( deprecated_osg::Geometry::BIND_PER_PRIMITIVE );
n->push_back( osg::Vec3( -1.f, 0.f, 0.f ) );
n->push_back( osg::Vec3( 1.f, 0.f, 0.f ) );
n->push_back( osg::Vec3( 0.f, 0.f, -1.f ) );
@ -650,7 +644,7 @@ createRandomTriangles( unsigned int num )
ss->setMode( GL_LIGHTING, osg::StateAttribute::OFF |
osg::StateAttribute::PROTECTED);
osg::ref_ptr<osg::Geometry> geom = new osg::Geometry;
osg::ref_ptr<deprecated_osg::Geometry> geom = new deprecated_osg::Geometry;
// Disable display lists to decrease performance.
geom->setUseDisplayList( false );
@ -674,7 +668,7 @@ createRandomTriangles( unsigned int num )
osg::ref_ptr<osg::Vec4Array> c = new osg::Vec4Array;
geom->setColorArray( c.get() );
// Bind per primitive to force slow glBegin/glEnd path.
geom->setColorBinding( osg::Geometry::BIND_PER_PRIMITIVE );
geom->setColorBinding( deprecated_osg::Geometry::BIND_PER_PRIMITIVE );
c->resize( num );
#define RAND_0_TO_1 ( (rand()%10)*.1 )

View File

@ -235,9 +235,6 @@ class OSG_EXPORT Geometry : public Drawable
BIND_OFF=0,
BIND_OVERALL=1,
BIND_PER_PRIMITIVE_SET=2,
#if defined(OSG_USE_DEPRECATED_GEOMETRY_METHODS)
BIND_PER_PRIMITIVE=3, /// no longer supported
#endif
BIND_PER_VERTEX=4
};
@ -264,36 +261,6 @@ class OSG_EXPORT Geometry : public Drawable
/** deprecated, use array->setNormalize(..). */
void setVertexAttribNormalize(unsigned int index,GLboolean norm);
GLboolean getVertexAttribNormalize(unsigned int index) const;
#if defined(OSG_USE_DEPRECATED_GEOMETRY_METHODS)
/** no longer supported.*/
inline void setVertexIndices(IndexArray* array);
inline const IndexArray* getVertexIndices() const;
/** no longer supported.*/
inline void setNormalIndices(IndexArray* array);
inline const IndexArray* getNormalIndices() const;
/** no longer supported.*/
inline void setColorIndices(IndexArray* array);
inline const IndexArray* getColorIndices() const;
/** no longer supported.*/
inline void setSecondaryColorIndices(IndexArray* array);
inline const IndexArray* getSecondaryColorIndices() const;
/** no longer supported.*/
inline void setFogCoordIndices(IndexArray* array);
inline const IndexArray* getFogCoordIndices() const;
/** no longer supported.*/
inline void setTexCoordIndices(unsigned int unit,IndexArray*);
inline const IndexArray* getTexCoordIndices(unsigned int unit) const;
/** no longer supported.*/
inline void setVertexAttribIndices(unsigned int index,IndexArray* array);
inline const IndexArray* getVertexAttribIndices(unsigned int index) const;
#endif
};
/** Convenience function to be used for creating quad geometry with texture coords.
@ -311,92 +278,72 @@ inline Geometry* createTexturedQuadGeometry(const Vec3& corner,const Vec3& width
} // namespace osg
#if defined(OSG_USE_DEPRECATED_GEOMETRY_METHODS)
#include <osg/Notify>
namespace osg {
/** Contains deprecated features of namespace osg. */
namespace deprecated_osg {
inline void Geometry::setVertexIndices(IndexArray* array)
/** Geometry class contaning deprecated features.
* Please note this class is \b not "exported" (OSG_EXPORT) to avoid issues with MSVC, when compiling plugins.
*/
class OSG_EXPORT Geometry : public osg::Geometry
{
if (_vertexArray.valid()) { _vertexArray->setUserData(array); if (array) _containsDeprecatedData = true; }
else { OSG_WARN<<"Geometry::setVertexIndicies(..) function failed as there is no vertex array to associate inidices with."<<std::endl; }
}
public:
Geometry() : osg::Geometry() {}
Geometry(const Geometry& geometry,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) : osg::Geometry(geometry, copyop) {}
inline const IndexArray* Geometry::getVertexIndices() const
{
if (_vertexArray.valid()) return dynamic_cast<IndexArray*>(_vertexArray->getUserData());
else return 0;
}
/** Same values as Array::Binding.*/
enum AttributeBinding
{
BIND_OFF=0,
BIND_OVERALL=1,
BIND_PER_PRIMITIVE_SET=2,
BIND_PER_PRIMITIVE=3,
BIND_PER_VERTEX=4
};
inline void Geometry::setNormalIndices(IndexArray* array)
{
if (_normalArray.valid()) { _normalArray->setUserData(array); if (array) _containsDeprecatedData = true; }
else { OSG_WARN<<"Geometry::setNormalIndicies(..) function failed as there is no normal array to associate inidices with."<<std::endl; }
}
inline const IndexArray* Geometry::getNormalIndices() const
{
if (_normalArray.valid()) return dynamic_cast<IndexArray*>(_normalArray->getUserData());
else return 0;
}
void setNormalBinding(AttributeBinding ab);
AttributeBinding getNormalBinding() const;
inline void Geometry::setColorIndices(IndexArray* array)
{
if (_colorArray.valid()) { _colorArray->setUserData(array); if (array) _containsDeprecatedData = true; }
else { OSG_WARN<<"Geometry::setColorIndicies(..) function failed as there is no color array to associate inidices with."<<std::endl; }
}
inline const IndexArray* Geometry::getColorIndices() const
{
if (_colorArray.valid()) return dynamic_cast<IndexArray*>(_colorArray->getUserData());
else return 0;
}
void setColorBinding(AttributeBinding ab);
AttributeBinding getColorBinding() const;
inline void Geometry::setSecondaryColorIndices(IndexArray* array)
{
if (_secondaryColorArray.valid()) { _secondaryColorArray->setUserData(array); if (array) _containsDeprecatedData = true; }
else { OSG_WARN<<"Geometry::setSecondaryColorArray(..) function failed as there is no secondary color array to associate inidices with."<<std::endl; }
}
inline const IndexArray* Geometry::getSecondaryColorIndices() const
{
if (_secondaryColorArray.valid()) return dynamic_cast<IndexArray*>(_secondaryColorArray->getUserData());
else return 0;
}
void setSecondaryColorBinding(AttributeBinding ab);
AttributeBinding getSecondaryColorBinding() const;
inline void Geometry::setFogCoordIndices(IndexArray* array)
{
if (_fogCoordArray.valid()) { _fogCoordArray->setUserData(array); if (array) _containsDeprecatedData = true; }
else { OSG_WARN<<"Geometry::setFogCoordIndicies(..) function failed as there is no fog coord array to associate inidices with."<<std::endl; }
}
inline const IndexArray* Geometry::getFogCoordIndices() const
{
if (_fogCoordArray.valid()) return dynamic_cast<IndexArray*>(_fogCoordArray->getUserData());
else return 0;
}
void setFogCoordBinding(AttributeBinding ab);
AttributeBinding getFogCoordBinding() const;
inline void Geometry::setTexCoordIndices(unsigned int unit,IndexArray* array)
{
if (unit<_texCoordList.size() && _texCoordList[unit].valid()) { _texCoordList[unit]->setUserData(array); if (array) _containsDeprecatedData = true; }
else { OSG_WARN<<"Geometry::setTexCoordIndices(..) function failed as there is no texcoord array to associate inidices with."<<std::endl; }
}
inline const IndexArray* Geometry::getTexCoordIndices(unsigned int unit) const
{
if (unit<_texCoordList.size() && _texCoordList[unit].valid()) return dynamic_cast<IndexArray*>(_texCoordList[unit]->getUserData());
else return 0;
}
void setVertexAttribBinding(unsigned int index,AttributeBinding ab);
AttributeBinding getVertexAttribBinding(unsigned int index) const;
inline void Geometry::setVertexAttribIndices(unsigned int index,IndexArray* array)
{
if (index<_vertexAttribList.size() && _vertexAttribList[index].valid()) { _vertexAttribList[index]->setUserData(array); if (array) _containsDeprecatedData = true; }
else { OSG_WARN<<"Geometry::setVertexAttribIndices(..) function failed as there is no vertex attrib array to associate inidices with."<<std::endl; }
}
inline const IndexArray* Geometry::getVertexAttribIndices(unsigned int index) const
{
if (index<_vertexAttribList.size() && _vertexAttribList[index].valid()) return dynamic_cast<IndexArray*>(_vertexAttribList[index]->getUserData());
else return 0;
}
void setVertexAttribNormalize(unsigned int index,GLboolean norm);
GLboolean getVertexAttribNormalize(unsigned int index) const;
} // namespace osg
#endif
void setVertexIndices(osg::IndexArray* array);
const osg::IndexArray* getVertexIndices() const;
void setNormalIndices(osg::IndexArray* array);
const osg::IndexArray* getNormalIndices() const;
void setColorIndices(osg::IndexArray* array);
const osg::IndexArray* getColorIndices() const;
void setSecondaryColorIndices(osg::IndexArray* array);
const osg::IndexArray* getSecondaryColorIndices() const;
void setFogCoordIndices(osg::IndexArray* array);
const osg::IndexArray* getFogCoordIndices() const;
void setTexCoordIndices(unsigned int unit,osg::IndexArray* array);
const osg::IndexArray* getTexCoordIndices(unsigned int unit) const;
void setVertexAttribIndices(unsigned int index,osg::IndexArray* array);
const osg::IndexArray* getVertexAttribIndices(unsigned int index) const;
};
} // namespace deprecated_osg
#endif

View File

@ -44,6 +44,4 @@
#cmakedefine OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
#cmakedefine OSG_GL_FIXED_FUNCTION_AVAILABLE
#cmakedefine OSG_USE_DEPRECATED_GEOMETRY_METHODS
#endif

View File

@ -1789,3 +1789,115 @@ void Geometry::fixDeprecatedData()
_containsDeprecatedData = false;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// deprecated_osg
void deprecated_osg::Geometry::setNormalBinding(AttributeBinding ab) { osg::Geometry::setNormalBinding(static_cast<osg::Geometry::AttributeBinding>(ab)); }
deprecated_osg::Geometry::AttributeBinding deprecated_osg::Geometry::getNormalBinding() const { return static_cast<AttributeBinding>(osg::Geometry::getNormalBinding()); }
void deprecated_osg::Geometry::setColorBinding(deprecated_osg::Geometry::AttributeBinding ab) { osg::Geometry::setColorBinding(static_cast<osg::Geometry::AttributeBinding>(ab)); }
deprecated_osg::Geometry::AttributeBinding deprecated_osg::Geometry::getColorBinding() const { return static_cast<AttributeBinding>(osg::Geometry::getColorBinding()); }
void deprecated_osg::Geometry::setSecondaryColorBinding(deprecated_osg::Geometry::AttributeBinding ab) { osg::Geometry::setSecondaryColorBinding(static_cast<osg::Geometry::AttributeBinding>(ab)); }
deprecated_osg::Geometry::AttributeBinding deprecated_osg::Geometry::getSecondaryColorBinding() const { return static_cast<AttributeBinding>(osg::Geometry::getSecondaryColorBinding()); }
void deprecated_osg::Geometry::setFogCoordBinding(deprecated_osg::Geometry::AttributeBinding ab) { osg::Geometry::setFogCoordBinding(static_cast<osg::Geometry::AttributeBinding>(ab)); }
deprecated_osg::Geometry::AttributeBinding deprecated_osg::Geometry::getFogCoordBinding() const { return static_cast<AttributeBinding>(osg::Geometry::getFogCoordBinding()); }
void deprecated_osg::Geometry::setVertexAttribBinding(unsigned int index,deprecated_osg::Geometry::AttributeBinding ab) { osg::Geometry::setVertexAttribBinding(index, static_cast<osg::Geometry::AttributeBinding>(ab)); }
deprecated_osg::Geometry::AttributeBinding deprecated_osg::Geometry::getVertexAttribBinding(unsigned int index) const { return static_cast<AttributeBinding>(osg::Geometry::getVertexAttribBinding(index)); }
void deprecated_osg::Geometry::setVertexAttribNormalize(unsigned int index,GLboolean norm) { osg::Geometry::setVertexAttribNormalize(index, norm); }
GLboolean deprecated_osg::Geometry::getVertexAttribNormalize(unsigned int index) const { return osg::Geometry::getVertexAttribNormalize(index); }
void deprecated_osg::Geometry::setVertexIndices(osg::IndexArray* array)
{
if (_vertexArray.valid()) { _vertexArray->setUserData(array); if (array) _containsDeprecatedData = true; }
else { OSG_WARN<<"Geometry::setVertexIndicies(..) function failed as there is no vertex array to associate inidices with."<<std::endl; }
}
const osg::IndexArray* deprecated_osg::Geometry::getVertexIndices() const
{
if (_vertexArray.valid()) return dynamic_cast<osg::IndexArray*>(_vertexArray->getUserData());
else return 0;
}
void deprecated_osg::Geometry::setNormalIndices(osg::IndexArray* array)
{
if (_normalArray.valid()) { _normalArray->setUserData(array); if (array) _containsDeprecatedData = true; }
else { OSG_WARN<<"Geometry::setNormalIndicies(..) function failed as there is no normal array to associate inidices with."<<std::endl; }
}
const osg::IndexArray* deprecated_osg::Geometry::getNormalIndices() const
{
if (_normalArray.valid()) return dynamic_cast<osg::IndexArray*>(_normalArray->getUserData());
else return 0;
}
void deprecated_osg::Geometry::setColorIndices(osg::IndexArray* array)
{
if (_colorArray.valid()) { _colorArray->setUserData(array); if (array) _containsDeprecatedData = true; }
else { OSG_WARN<<"Geometry::setColorIndicies(..) function failed as there is no color array to associate inidices with."<<std::endl; }
}
const osg::IndexArray* deprecated_osg::Geometry::getColorIndices() const
{
if (_colorArray.valid()) return dynamic_cast<osg::IndexArray*>(_colorArray->getUserData());
else return 0;
}
void deprecated_osg::Geometry::setSecondaryColorIndices(osg::IndexArray* array)
{
if (_secondaryColorArray.valid()) { _secondaryColorArray->setUserData(array); if (array) _containsDeprecatedData = true; }
else { OSG_WARN<<"Geometry::setSecondaryColorArray(..) function failed as there is no secondary color array to associate inidices with."<<std::endl; }
}
const osg::IndexArray* deprecated_osg::Geometry::getSecondaryColorIndices() const
{
if (_secondaryColorArray.valid()) return dynamic_cast<osg::IndexArray*>(_secondaryColorArray->getUserData());
else return 0;
}
void deprecated_osg::Geometry::setFogCoordIndices(osg::IndexArray* array)
{
if (_fogCoordArray.valid()) { _fogCoordArray->setUserData(array); if (array) _containsDeprecatedData = true; }
else { OSG_WARN<<"Geometry::setFogCoordIndicies(..) function failed as there is no fog coord array to associate inidices with."<<std::endl; }
}
const osg::IndexArray* deprecated_osg::Geometry::getFogCoordIndices() const
{
if (_fogCoordArray.valid()) return dynamic_cast<osg::IndexArray*>(_fogCoordArray->getUserData());
else return 0;
}
void deprecated_osg::Geometry::setTexCoordIndices(unsigned int unit,osg::IndexArray* array)
{
if (unit<_texCoordList.size() && _texCoordList[unit].valid()) { _texCoordList[unit]->setUserData(array); if (array) _containsDeprecatedData = true; }
else { OSG_WARN<<"Geometry::setTexCoordIndices(..) function failed as there is no texcoord array to associate inidices with."<<std::endl; }
}
const osg::IndexArray* deprecated_osg::Geometry::getTexCoordIndices(unsigned int unit) const
{
if (unit<_texCoordList.size() && _texCoordList[unit].valid()) return dynamic_cast<osg::IndexArray*>(_texCoordList[unit]->getUserData());
else return 0;
}
void deprecated_osg::Geometry::setVertexAttribIndices(unsigned int index,osg::IndexArray* array)
{
if (index<_vertexAttribList.size() && _vertexAttribList[index].valid()) { _vertexAttribList[index]->setUserData(array); if (array) _containsDeprecatedData = true; }
else { OSG_WARN<<"Geometry::setVertexAttribIndices(..) function failed as there is no vertex attrib array to associate inidices with."<<std::endl; }
}
const osg::IndexArray* deprecated_osg::Geometry::getVertexAttribIndices(unsigned int index) const
{
if (index<_vertexAttribList.size() && _vertexAttribList[index].valid()) return dynamic_cast<osg::IndexArray*>(_vertexAttribList[index]->getUserData());
else return 0;
}

View File

@ -1,8 +1,3 @@
#include <osg/Config>
#ifndef OSG_USE_DEPRECATED_GEOMETRY_METHODS
#define OSG_USE_DEPRECATED_GEOMETRY_METHODS 1
#endif
#include "ConvertFromInventor.h"
#include "PendulumCallback.h"
@ -774,42 +769,42 @@ ConvertFromInventor::preShape(void* data, SoCallbackAction* action,
ConvertFromInventor* thisPtr = (ConvertFromInventor *) (data);
// Normal and color binding map from Inventor to OSG
static std::map<SoNormalBinding::Binding, osg::Geometry::AttributeBinding>
static std::map<SoNormalBinding::Binding, deprecated_osg::Geometry::AttributeBinding>
normBindingMap;
static std::map<SoMaterialBinding::Binding, osg::Geometry::AttributeBinding>
static std::map<SoMaterialBinding::Binding, deprecated_osg::Geometry::AttributeBinding>
colBindingMap;
static bool firstTime = true;
if (firstTime)
{
normBindingMap[SoNormalBinding::OVERALL]
= osg::Geometry::BIND_OVERALL;
= deprecated_osg::Geometry::BIND_OVERALL;
normBindingMap[SoNormalBinding::PER_PART]
= osg::Geometry::BIND_PER_PRIMITIVE;
= deprecated_osg::Geometry::BIND_PER_PRIMITIVE;
normBindingMap[SoNormalBinding::PER_PART_INDEXED]
= osg::Geometry::BIND_PER_PRIMITIVE;
= deprecated_osg::Geometry::BIND_PER_PRIMITIVE;
normBindingMap[SoNormalBinding::PER_FACE]
= osg::Geometry::BIND_PER_PRIMITIVE;
= deprecated_osg::Geometry::BIND_PER_PRIMITIVE;
normBindingMap[SoNormalBinding::PER_FACE_INDEXED]
= osg::Geometry::BIND_PER_PRIMITIVE;
= deprecated_osg::Geometry::BIND_PER_PRIMITIVE;
normBindingMap[SoNormalBinding::PER_VERTEX]
= osg::Geometry::BIND_PER_VERTEX;
= deprecated_osg::Geometry::BIND_PER_VERTEX;
normBindingMap[SoNormalBinding::PER_VERTEX_INDEXED]
= osg::Geometry::BIND_PER_VERTEX;
= deprecated_osg::Geometry::BIND_PER_VERTEX;
colBindingMap[SoMaterialBinding::OVERALL]
= osg::Geometry::BIND_OVERALL;
= deprecated_osg::Geometry::BIND_OVERALL;
colBindingMap[SoMaterialBinding::PER_PART]
= osg::Geometry::BIND_PER_PRIMITIVE;
= deprecated_osg::Geometry::BIND_PER_PRIMITIVE;
colBindingMap[SoMaterialBinding::PER_PART_INDEXED]
= osg::Geometry::BIND_PER_PRIMITIVE;
= deprecated_osg::Geometry::BIND_PER_PRIMITIVE;
colBindingMap[SoMaterialBinding::PER_FACE]
= osg::Geometry::BIND_PER_PRIMITIVE;
= deprecated_osg::Geometry::BIND_PER_PRIMITIVE;
colBindingMap[SoMaterialBinding::PER_FACE_INDEXED]
= osg::Geometry::BIND_PER_PRIMITIVE;
= deprecated_osg::Geometry::BIND_PER_PRIMITIVE;
colBindingMap[SoMaterialBinding::PER_VERTEX]
= osg::Geometry::BIND_PER_VERTEX;
= deprecated_osg::Geometry::BIND_PER_VERTEX;
colBindingMap[SoMaterialBinding::PER_VERTEX_INDEXED]
= osg::Geometry::BIND_PER_VERTEX;
= deprecated_osg::Geometry::BIND_PER_VERTEX;
firstTime = false;
}
@ -822,8 +817,8 @@ ConvertFromInventor::preShape(void* data, SoCallbackAction* action,
}
else
{
thisPtr->normalBinding = osg::Geometry::BIND_PER_VERTEX;
thisPtr->colorBinding = osg::Geometry::BIND_PER_VERTEX;
thisPtr->normalBinding = deprecated_osg::Geometry::BIND_PER_VERTEX;
thisPtr->colorBinding = deprecated_osg::Geometry::BIND_PER_VERTEX;
}
// Check vertex ordering
@ -874,7 +869,7 @@ ConvertFromInventor::postShape(void* data, SoCallbackAction* action,
// Create a new Geometry
osg::ref_ptr<osg::Geometry> geometry = new osg::Geometry;
osg::ref_ptr<deprecated_osg::Geometry> geometry = new deprecated_osg::Geometry;
osg::ref_ptr<osg::Vec3Array> coords = new osg::Vec3Array(thisPtr->vertices.size());
@ -883,7 +878,7 @@ ConvertFromInventor::postShape(void* data, SoCallbackAction* action,
geometry->setVertexArray(coords.get());
osg::ref_ptr<osg::Vec3Array> norms = NULL;
if (thisPtr->normalBinding == osg::Geometry::BIND_OVERALL)
if (thisPtr->normalBinding == deprecated_osg::Geometry::BIND_OVERALL)
{
norms = new osg::Vec3Array(1);
const SbVec3f &norm = action->getNormal(0);
@ -902,7 +897,7 @@ ConvertFromInventor::postShape(void* data, SoCallbackAction* action,
// Set the colors
osg::ref_ptr<osg::Vec4Array> cols;
if (thisPtr->colorBinding == osg::Geometry::BIND_OVERALL)
if (thisPtr->colorBinding == deprecated_osg::Geometry::BIND_OVERALL)
{
cols = new osg::Vec4Array(1);
SbColor ambient, diffuse, specular, emission;
@ -2162,8 +2157,8 @@ void ConvertFromInventor::addVertex(SoCallbackAction* action,
// Get the normal of the vertex
SbVec3f norm = v->getNormal();
if ((normalBinding == osg::Geometry::BIND_PER_VERTEX) ||
(normalBinding == osg::Geometry::BIND_PER_PRIMITIVE && index == 0))
if ((normalBinding == deprecated_osg::Geometry::BIND_PER_VERTEX) ||
(normalBinding == deprecated_osg::Geometry::BIND_PER_PRIMITIVE && index == 0))
{
// What is this? Why to invert normals at CLOCKWISE vertex ordering?
// PCJohn 2009-12-13
@ -2173,18 +2168,18 @@ void ConvertFromInventor::addVertex(SoCallbackAction* action,
normals.push_back(osg::Vec3(norm[0], norm[1], norm[2]));
}
if (colorBinding == osg::Geometry::BIND_PER_VERTEX ||
colorBinding == osg::Geometry::BIND_PER_PRIMITIVE)
if (colorBinding == deprecated_osg::Geometry::BIND_PER_VERTEX ||
colorBinding == deprecated_osg::Geometry::BIND_PER_PRIMITIVE)
{
// Get the material/color
SbColor ambient, diffuse, specular, emission;
float transparency, shininess;
action->getMaterial(ambient, diffuse, specular, emission, shininess,
transparency, v->getMaterialIndex());
if (colorBinding == osg::Geometry::BIND_PER_VERTEX)
if (colorBinding == deprecated_osg::Geometry::BIND_PER_VERTEX)
colors.push_back(osg::Vec4(diffuse[0], diffuse[1], diffuse[2],
1.0 - transparency));
else if (colorBinding == osg::Geometry::BIND_PER_PRIMITIVE && index == 0)
else if (colorBinding == deprecated_osg::Geometry::BIND_PER_PRIMITIVE && index == 0)
colors.push_back(osg::Vec4(diffuse[0], diffuse[1], diffuse[2],
1.0 - transparency));
}

View File

@ -109,8 +109,8 @@ class ConvertFromInventor
private:
// Normal and color binding
osg::Geometry::AttributeBinding normalBinding;
osg::Geometry::AttributeBinding colorBinding;
deprecated_osg::Geometry::AttributeBinding normalBinding;
deprecated_osg::Geometry::AttributeBinding colorBinding;
// List of vertices, normals, colors and texture coordinates
std::vector<osg::Vec3> vertices;

View File

@ -25,11 +25,6 @@
// but you are not forced to do so.
//
#include <osg/Config>
#ifndef OSG_USE_DEPRECATED_GEOMETRY_METHODS
#define OSG_USE_DEPRECATED_GEOMETRY_METHODS 1
#endif
#include <osg/BlendFunc>
#include <osg/Billboard>
#include <osg/Geode>
@ -470,27 +465,18 @@ bool ivDeindex(variableType *dest, const variableType *src, const int srcNum,
template<typename variableType, typename fieldType>
bool ivProcessArray(const osg::Array *indices, const osg::Array *drawElemIndices,
bool ivProcessArray(const osg::Array *drawElemIndices,
fieldType *destField, const fieldType *srcField,
int startIndex, int numToProcess)
{
bool ok = true;
if (indices || drawElemIndices) {
if (drawElemIndices) {
// "deindex" original data
if (indices && !drawElemIndices)
ok = ivDeindex<variableType>(destField->startEditing(),
srcField->getValues(startIndex),
srcField->getNum(), indices, numToProcess); else
if (!indices && drawElemIndices)
ok = ivDeindex<variableType>(destField->startEditing(),
srcField->getValues(startIndex),
srcField->getNum(), drawElemIndices, numToProcess);
else {
OSG_WARN << "IvWriter: NOT IMPLEMENTED" << std::endl;
assert(0); // FIXME:
}
destField->finishEditing();
if (!ok)
@ -511,21 +497,16 @@ bool ivProcessArray(const osg::Array *indices, const osg::Array *drawElemIndices
}
static void processIndices(const osg::Array *indices, const osg::Array *drawElemIndices,
static void processIndices(const osg::Array *drawElemIndices,
SoMFInt32 &ivIndices,
int startIndex, int stopIndex, int numItemsUntilMinusOne)
{
if (indices || drawElemIndices) {
if (indices && !drawElemIndices)
osgArray2ivMField(indices, ivIndices, startIndex, stopIndex, numItemsUntilMinusOne); else
if (!indices && drawElemIndices)
if (drawElemIndices) {
osgArray2ivMField(drawElemIndices, ivIndices, startIndex, stopIndex, numItemsUntilMinusOne);
else {
OSG_WARN << "IvWriter: NOT IMPLEMENTED" << std::endl;
assert(0); // FIXME:
}
} else {
int num = stopIndex-startIndex;
if (numItemsUntilMinusOne != 0 && num >= 1)
num += (num-1)/numItemsUntilMinusOne;
@ -572,10 +553,10 @@ static void postProcessDrawArrayLengths(const osg::DrawArrayLengths *drawArrayLe
static void postProcessField(const SbIntList &runLengths, osg::PrimitiveSet::Mode primType,
SoMFInt32 *field, osg::Geometry::AttributeBinding binding)
SoMFInt32 *field, deprecated_osg::Geometry::AttributeBinding binding)
{
if (binding==osg::Geometry::BIND_OFF || binding==osg::Geometry::BIND_OVERALL ||
binding==osg::Geometry::BIND_PER_PRIMITIVE_SET)
if (binding==deprecated_osg::Geometry::BIND_OFF || binding==deprecated_osg::Geometry::BIND_OVERALL ||
binding==deprecated_osg::Geometry::BIND_PER_PRIMITIVE_SET)
return;
// make copy of array
@ -588,11 +569,11 @@ static void postProcessField(const SbIntList &runLengths, osg::PrimitiveSet::Mod
int newNum = origNum;
const int l = runLengths.getLength();
switch (binding) {
case osg::Geometry::BIND_PER_VERTEX:
case deprecated_osg::Geometry::BIND_PER_VERTEX:
for (int i=0; i<l; i++)
newNum += (runLengths[i]-3)*3;
break;
case osg::Geometry::BIND_PER_PRIMITIVE:
case deprecated_osg::Geometry::BIND_PER_PRIMITIVE:
for (int i=0; i<l; i++)
newNum += runLengths[i]-3;
break;
@ -606,7 +587,7 @@ static void postProcessField(const SbIntList &runLengths, osg::PrimitiveSet::Mod
int32_t *dst = field->startEditing();
// int32_t *dst2 = dst;
switch (binding) {
case osg::Geometry::BIND_PER_VERTEX:
case deprecated_osg::Geometry::BIND_PER_VERTEX:
for (int i=0; i<l; i++) {
int c = runLengths[i];
*(dst++) = *(src++);
@ -642,7 +623,7 @@ static void postProcessField(const SbIntList &runLengths, osg::PrimitiveSet::Mod
}
break;
case osg::Geometry::BIND_PER_PRIMITIVE:
case deprecated_osg::Geometry::BIND_PER_PRIMITIVE:
for (int i=0; i<l; i++,src++) {
int c = runLengths[i];
*(dst++) = *(src);
@ -662,8 +643,8 @@ static void postProcessField(const SbIntList &runLengths, osg::PrimitiveSet::Mod
static void postProcessTriangleSeparation(SoIndexedShape *shape, osg::PrimitiveSet::Mode primType,
osg::Geometry::AttributeBinding normalBinding,
osg::Geometry::AttributeBinding colorBinding)
deprecated_osg::Geometry::AttributeBinding normalBinding,
deprecated_osg::Geometry::AttributeBinding colorBinding)
{
// compute runLengths
SbIntList runLengths;
@ -680,42 +661,42 @@ static void postProcessTriangleSeparation(SoIndexedShape *shape, osg::PrimitiveS
if (l != 0) // append final l if field is not finished by -1
runLengths.append(l);
postProcessField(runLengths, primType, &shape->coordIndex, osg::Geometry::BIND_PER_VERTEX);
postProcessField(runLengths, primType, &shape->coordIndex, deprecated_osg::Geometry::BIND_PER_VERTEX);
postProcessField(runLengths, primType, &shape->normalIndex, normalBinding);
postProcessField(runLengths, primType, &shape->materialIndex, colorBinding);
bool notUseTexCoords = shape->textureCoordIndex.getNum()==0 ||
(shape->textureCoordIndex.getNum()==1 && shape->textureCoordIndex[0] == -1);
if (!notUseTexCoords)
postProcessField(runLengths, primType, &shape->textureCoordIndex, osg::Geometry::BIND_PER_VERTEX);
postProcessField(runLengths, primType, &shape->textureCoordIndex, deprecated_osg::Geometry::BIND_PER_VERTEX);
}
static SoMaterialBinding* createMaterialBinding(const osg::Geometry *g, bool isMaterialIndexed)
static SoMaterialBinding* createMaterialBinding(const deprecated_osg::Geometry *g, bool isMaterialIndexed)
{
SoMaterialBinding *materialBinding = new SoMaterialBinding;
switch (g->getColorBinding()) {
case osg::Geometry::BIND_OFF: // OFF means use material from state set (if any) for whole geometry
case osg::Geometry::BIND_OVERALL:
case osg::Geometry::BIND_PER_PRIMITIVE_SET: materialBinding->value = SoMaterialBinding::OVERALL; break;
case osg::Geometry::BIND_PER_PRIMITIVE: materialBinding->value = (isMaterialIndexed) ? SoMaterialBinding::PER_PART_INDEXED : SoMaterialBinding::PER_PART; break;
case osg::Geometry::BIND_PER_VERTEX: materialBinding->value = (isMaterialIndexed) ? SoMaterialBinding::PER_VERTEX_INDEXED : SoMaterialBinding::PER_VERTEX; break;
case deprecated_osg::Geometry::BIND_OFF: // OFF means use material from state set (if any) for whole geometry
case deprecated_osg::Geometry::BIND_OVERALL:
case deprecated_osg::Geometry::BIND_PER_PRIMITIVE_SET: materialBinding->value = SoMaterialBinding::OVERALL; break;
case deprecated_osg::Geometry::BIND_PER_PRIMITIVE: materialBinding->value = (isMaterialIndexed) ? SoMaterialBinding::PER_PART_INDEXED : SoMaterialBinding::PER_PART; break;
case deprecated_osg::Geometry::BIND_PER_VERTEX: materialBinding->value = (isMaterialIndexed) ? SoMaterialBinding::PER_VERTEX_INDEXED : SoMaterialBinding::PER_VERTEX; break;
default: assert(0);
}
return materialBinding;
}
static SoNormalBinding* createNormalBinding(const osg::Geometry *g, bool areNormalsIndexed)
static SoNormalBinding* createNormalBinding(const deprecated_osg::Geometry *g, bool areNormalsIndexed)
{
// Convert normal binding
SoNormalBinding *normalBinding = new SoNormalBinding;
switch (g->getNormalBinding()) {
case osg::Geometry::BIND_OFF: // FIXME: what to do with BIND_OFF value?
case osg::Geometry::BIND_OVERALL:
case osg::Geometry::BIND_PER_PRIMITIVE_SET: normalBinding->value = SoNormalBinding::OVERALL; break;
case osg::Geometry::BIND_PER_PRIMITIVE: normalBinding->value = (areNormalsIndexed) ? SoNormalBinding::PER_PART_INDEXED : SoNormalBinding::PER_PART; break;
case osg::Geometry::BIND_PER_VERTEX: normalBinding->value = (areNormalsIndexed) ? SoNormalBinding::PER_VERTEX_INDEXED : SoNormalBinding::PER_VERTEX; break;
case deprecated_osg::Geometry::BIND_OFF: // FIXME: what to do with BIND_OFF value?
case deprecated_osg::Geometry::BIND_OVERALL:
case deprecated_osg::Geometry::BIND_PER_PRIMITIVE_SET: normalBinding->value = SoNormalBinding::OVERALL; break;
case deprecated_osg::Geometry::BIND_PER_PRIMITIVE: normalBinding->value = (areNormalsIndexed) ? SoNormalBinding::PER_PART_INDEXED : SoNormalBinding::PER_PART; break;
case deprecated_osg::Geometry::BIND_PER_VERTEX: normalBinding->value = (areNormalsIndexed) ? SoNormalBinding::PER_VERTEX_INDEXED : SoNormalBinding::PER_VERTEX; break;
default: assert(0);
}
return normalBinding;
@ -1101,7 +1082,7 @@ void ConvertToInventor::popInventorState()
}
static bool processPrimitiveSet(const osg::Geometry *g, const osg::PrimitiveSet *pset,
static bool processPrimitiveSet(const deprecated_osg::Geometry *g, const osg::PrimitiveSet *pset,
osg::UIntArray *drawElemIndices, bool needSeparateTriangles,
int elementsCount, int primSize, const int startIndex, int stopIndex,
int &normalIndex, int &colorIndex,
@ -1136,49 +1117,49 @@ static bool processPrimitiveSet(const osg::Geometry *g, const osg::PrimitiveSet
SoNode *nonIndexedMaterial = NULL;
// Normal indexing
int normalStart = g->getNormalBinding() == osg::Geometry::BIND_PER_VERTEX ? startIndex : normalIndex;
int normalStart = (g->getNormalBinding() == deprecated_osg::Geometry::BIND_PER_VERTEX) ? startIndex : normalIndex;
int numNormalsUsed = 0;
switch (g->getNormalBinding()) {
case osg::Geometry::BIND_OFF: // FIXME: what is meaning of OFF value?
case osg::Geometry::BIND_OVERALL: numNormalsUsed = 0; break;
case osg::Geometry::BIND_PER_PRIMITIVE_SET: numNormalsUsed = 1; break;
case osg::Geometry::BIND_PER_PRIMITIVE: numNormalsUsed = primSize!=0 ? (stopIndex-startIndex)/primSize :
case deprecated_osg::Geometry::BIND_OFF: // FIXME: what is meaning of OFF value?
case deprecated_osg::Geometry::BIND_OVERALL: numNormalsUsed = 0; break;
case deprecated_osg::Geometry::BIND_PER_PRIMITIVE_SET: numNormalsUsed = 1; break;
case deprecated_osg::Geometry::BIND_PER_PRIMITIVE: numNormalsUsed = primSize!=0 ? (stopIndex-startIndex)/primSize :
(drawArrayLengths ? drawArrayLengths->size() : 1); break;
case osg::Geometry::BIND_PER_VERTEX: numNormalsUsed = stopIndex-startIndex; break;
case deprecated_osg::Geometry::BIND_PER_VERTEX: numNormalsUsed = stopIndex-startIndex; break;
}
normalIndex += numNormalsUsed;
// Color indexing
int colorStart = g->getColorBinding() == osg::Geometry::BIND_PER_VERTEX ? startIndex : colorIndex;
int colorStart = g->getColorBinding() == deprecated_osg::Geometry::BIND_PER_VERTEX ? startIndex : colorIndex;
int numColorsUsed = 0;
switch (g->getColorBinding()) {
case osg::Geometry::BIND_OFF:
case osg::Geometry::BIND_OVERALL: numColorsUsed = 0; break;
case osg::Geometry::BIND_PER_PRIMITIVE_SET: numColorsUsed = 1; break;
case osg::Geometry::BIND_PER_PRIMITIVE: numColorsUsed = primSize!=0 ? (stopIndex-startIndex)/primSize :
case deprecated_osg::Geometry::BIND_OFF:
case deprecated_osg::Geometry::BIND_OVERALL: numColorsUsed = 0; break;
case deprecated_osg::Geometry::BIND_PER_PRIMITIVE_SET: numColorsUsed = 1; break;
case deprecated_osg::Geometry::BIND_PER_PRIMITIVE: numColorsUsed = primSize!=0 ? (stopIndex-startIndex)/primSize :
(drawArrayLengths ? drawArrayLengths->size() : 1); break;
case osg::Geometry::BIND_PER_VERTEX: numColorsUsed = stopIndex-startIndex; break;
case deprecated_osg::Geometry::BIND_PER_VERTEX: numColorsUsed = stopIndex-startIndex; break;
}
colorIndex += numColorsUsed;
if (shape->isOfType(SoIndexedShape::getClassTypeId())) {
// Convert to SoIndexedShape
processIndices(g->getVertexIndices(), drawElemIndices, ((SoIndexedShape*)shape)->coordIndex,
processIndices(drawElemIndices, ((SoIndexedShape*)shape)->coordIndex,
startIndex, stopIndex, primSize);
if (ivNormals)
processIndices(g->getNormalIndices(), drawElemIndices, ((SoIndexedShape*)shape)->normalIndex,
processIndices(drawElemIndices, ((SoIndexedShape*)shape)->normalIndex,
normalStart, normalStart+(numNormalsUsed==0 ? 1 : numNormalsUsed),
g->getNormalBinding()==osg::Geometry::BIND_PER_VERTEX ? primSize : 0);
g->getNormalBinding()==deprecated_osg::Geometry::BIND_PER_VERTEX ? primSize : 0);
if (ivMaterial)
processIndices(g->getColorIndices(), drawElemIndices, ((SoIndexedShape*)shape)->materialIndex,
processIndices(drawElemIndices, ((SoIndexedShape*)shape)->materialIndex,
colorStart, colorStart+(numColorsUsed==0 ? 1 : numColorsUsed),
g->getColorBinding()==osg::Geometry::BIND_PER_VERTEX ? primSize : 0);
g->getColorBinding()==deprecated_osg::Geometry::BIND_PER_VERTEX ? primSize : 0);
if (ivTexCoords && !ivTexCoords->isOfType(SoTextureCoordinateFunction::getClassTypeId()))
processIndices(g->getTexCoordIndices(0), drawElemIndices, ((SoIndexedShape*)shape)->textureCoordIndex,
processIndices(drawElemIndices, ((SoIndexedShape*)shape)->textureCoordIndex,
startIndex, stopIndex, primSize);
// Post-processing for DrawArrayLengths
@ -1186,10 +1167,10 @@ static bool processPrimitiveSet(const osg::Geometry *g, const osg::PrimitiveSet
postProcessDrawArrayLengths(drawArrayLengths, &((SoIndexedShape*)shape)->coordIndex);
if (ivNormals && g->getNormalBinding()==osg::Geometry::BIND_PER_VERTEX)
if (ivNormals && g->getNormalBinding()==deprecated_osg::Geometry::BIND_PER_VERTEX)
postProcessDrawArrayLengths(drawArrayLengths, &((SoIndexedShape*)shape)->normalIndex);
if (ivMaterial && g->getColorBinding()==osg::Geometry::BIND_PER_VERTEX)
if (ivMaterial && g->getColorBinding()==deprecated_osg::Geometry::BIND_PER_VERTEX)
postProcessDrawArrayLengths(drawArrayLengths, &((SoIndexedShape*)shape)->materialIndex);
if (ivTexCoords && !ivTexCoords->isOfType(SoTextureCoordinateFunction::getClassTypeId()))
@ -1214,8 +1195,7 @@ static bool processPrimitiveSet(const osg::Geometry *g, const osg::PrimitiveSet
nonIndexedCoords = new SoCoordinate4;
if (ok) {
((SoCoordinate4*)nonIndexedCoords)->point.setNum(n);
ok = ivProcessArray<SbVec4f,SoMFVec4f>(g->getVertexIndices(),
drawElemIndices,
ok = ivProcessArray<SbVec4f,SoMFVec4f>(drawElemIndices,
&((SoCoordinate4*)nonIndexedCoords)->point,
&((SoCoordinate4*)ivCoords)->point,
startIndex, n);
@ -1224,8 +1204,7 @@ static bool processPrimitiveSet(const osg::Geometry *g, const osg::PrimitiveSet
nonIndexedCoords = new SoCoordinate3;
if (ok) {
((SoCoordinate3*)nonIndexedCoords)->point.setNum(n);
ok = ivProcessArray<SbVec3f,SoMFVec3f>(g->getVertexIndices(),
drawElemIndices,
ok = ivProcessArray<SbVec3f,SoMFVec3f>(drawElemIndices,
&((SoCoordinate3*)nonIndexedCoords)->point,
&((SoCoordinate3*)ivCoords)->point,
startIndex, n);
@ -1241,8 +1220,7 @@ static bool processPrimitiveSet(const osg::Geometry *g, const osg::PrimitiveSet
if (ok)
{
((SoTextureCoordinate2*)nonIndexedTexCoords)->point.setNum(n);
ok = ivProcessArray<SbVec2f,SoMFVec2f>(g->getTexCoordIndices(0),
drawElemIndices,
ok = ivProcessArray<SbVec2f,SoMFVec2f>(drawElemIndices,
&((SoTextureCoordinate2*)nonIndexedTexCoords)->point,
&((SoTextureCoordinate2*)ivTexCoords)->point,
startIndex, n);
@ -1255,8 +1233,7 @@ static bool processPrimitiveSet(const osg::Geometry *g, const osg::PrimitiveSet
if (ok)
{
((SoTextureCoordinate3*)nonIndexedTexCoords)->point.setNum(n);
ok = ivProcessArray<SbVec3f,SoMFVec3f>(g->getTexCoordIndices(0),
drawElemIndices,
ok = ivProcessArray<SbVec3f,SoMFVec3f>(drawElemIndices,
&((SoTextureCoordinate3*)nonIndexedTexCoords)->point,
&((SoTextureCoordinate3*)ivCoords)->point,
startIndex, n);
@ -1272,8 +1249,7 @@ static bool processPrimitiveSet(const osg::Geometry *g, const osg::PrimitiveSet
nonIndexedNormals = new SoNormal;
if (ok) {
nonIndexedNormals->vector.setNum(numNormalsUsed==0 ? 1 : numNormalsUsed);
ok = ivProcessArray<SbVec3f,SoMFVec3f>(g->getNormalIndices(),
g->getNormalBinding()==osg::Geometry::BIND_PER_VERTEX ? drawElemIndices : NULL,
ok = ivProcessArray<SbVec3f,SoMFVec3f>(g->getNormalBinding()==deprecated_osg::Geometry::BIND_PER_VERTEX ? drawElemIndices : NULL,
&nonIndexedNormals->vector, &ivNormals->vector,
normalStart, numNormalsUsed==0 ? 1 : numNormalsUsed);
}
@ -1295,8 +1271,7 @@ static bool processPrimitiveSet(const osg::Geometry *g, const osg::PrimitiveSet
&((SoMaterial*)ivMaterial)->diffuseColor :
&((SoBaseColor*)ivMaterial)->rgb;
dstColorField->setNum(numColorsUsed==0 ? 1 : numColorsUsed);
ok = ivProcessArray<SbColor,SoMFColor>(g->getColorIndices(),
g->getColorBinding()==osg::Geometry::BIND_PER_VERTEX ? drawElemIndices : NULL,
ok = ivProcessArray<SbColor,SoMFColor>(g->getColorBinding()==deprecated_osg::Geometry::BIND_PER_VERTEX ? drawElemIndices : NULL,
dstColorField, srcColorField,
colorStart, numColorsUsed==0 ? 1 : numColorsUsed);
}
@ -1471,7 +1446,7 @@ static bool processPrimitiveSet(const osg::Geometry *g, const osg::PrimitiveSet
}
void ConvertToInventor::processGeometry(const osg::Geometry *g, InventorState *ivState)
void ConvertToInventor::processGeometry(const deprecated_osg::Geometry *g, InventorState *ivState)
{
int normalIndex = 0;
int colorIndex = 0;
@ -1598,7 +1573,7 @@ void ConvertToInventor::processGeometry(const osg::Geometry *g, InventorState *i
GLenum mode = pset->getMode();
// Create appropriate SoShape
bool useIndices = g->getVertexIndices() != NULL || vrml1Conversion;
bool useIndices = vrml1Conversion;
bool needSeparateTriangles = false;
SoVertexShape *shape = NULL;
switch (mode) {
@ -1834,8 +1809,8 @@ void ConvertToInventor::processShapeDrawable(const osg::ShapeDrawable *d, Invent
void ConvertToInventor::processDrawable(osg::Drawable *d)
{
osg::Geometry *g = d->asGeometry(); // FIXME: other drawables have to be handled also
osg::ShapeDrawable *sd;
deprecated_osg::Geometry *g = dynamic_cast<deprecated_osg::Geometry*>(d); // FIXME: other drawables have to be handled also
osg::ShapeDrawable *sd = 0;
// Create SoSeparator and convert StateSet for Drawable
InventorState *ivDrawableState = createInventorState(d->getStateSet());

View File

@ -128,7 +128,7 @@ protected:
int uniqueIdGenerator;
void processDrawable(osg::Drawable *d);
void processGeometry(const osg::Geometry *g, InventorState *ivState);
void processGeometry(const deprecated_osg::Geometry *g, InventorState *ivState);
void processShapeDrawable(const osg::ShapeDrawable *d, InventorState *ivState);
virtual InventorState* createInventorState(const osg::StateSet *ss);

View File

@ -550,7 +550,7 @@ bool daeWriter::processGeometry( osg::Geometry *geom, domGeometry *geo, const st
domPolygons *polys = NULL;
domPolylist *polylist = NULL;
// make sure no deprecated indices or BIND_PER_PRIMITIVE remain
// make sure no deprecated indices or binding exist
if (geom->containsDeprecatedData()) geom->fixDeprecatedData();
ArrayNIndices verts( geom->getVertexArray(), 0 );

View File

@ -46,9 +46,12 @@ public:
_lastFaceIndex(0),
_material(material),
_curNormalIndex(0),
_normalBinding(geo->getNormalBinding()),
_normalBinding(osg::Geometry::BIND_OFF),
_mesh(0)
{
if (geo->containsDeprecatedData()) geom->fixDeprecatedData();
_normalBinding = geo->getNormalBinding();
if (!geo->getNormalArray() || geo->getNormalArray()->getNumElements()==0)
{
_normalBinding = osg::Geometry::BIND_OFF; // Turn off binding if there is no normal data
@ -144,7 +147,6 @@ protected:
for (IndexPointer iptr = indices; iptr < ilast; iptr+=3)
{
writeTriangle(iptr[0], iptr[1], iptr[2]);
if (_normalBinding == osg::Geometry::BIND_PER_PRIMITIVE) ++_curNormalIndex;
}
break;
}
@ -156,7 +158,6 @@ protected:
if (i & 1) writeTriangle(iptr[0], iptr[2], iptr[1]);
else writeTriangle(iptr[0], iptr[1], iptr[2]);
}
if (_normalBinding == osg::Geometry::BIND_PER_PRIMITIVE) ++_curNormalIndex;
break;
}
case GL_QUADS:
@ -166,7 +167,6 @@ protected:
{
writeTriangle(iptr[0], iptr[1], iptr[2]);
writeTriangle(iptr[0], iptr[2], iptr[3]);
if (_normalBinding == osg::Geometry::BIND_PER_PRIMITIVE) ++_curNormalIndex;
}
break;
}
@ -178,7 +178,6 @@ protected:
writeTriangle(iptr[0], iptr[1], iptr[2]);
writeTriangle(iptr[1], iptr[3], iptr[2]);
}
if (_normalBinding == osg::Geometry::BIND_PER_PRIMITIVE) ++_curNormalIndex;
break;
}
case GL_POLYGON: // treat polygons as GL_TRIANGLE_FAN
@ -191,7 +190,6 @@ protected:
{
writeTriangle(first, iptr[0], iptr[1]);
}
if (_normalBinding == osg::Geometry::BIND_PER_PRIMITIVE) ++_curNormalIndex;
break;
}
case GL_POINTS:
@ -232,7 +230,6 @@ void PrimitiveIndexWriter::drawArrays(GLenum mode,GLint first,GLsizei count)
for (GLsizei i = 2; i < count; i += 3, pos += 3)
{
writeTriangle(pos, pos + 1, pos + 2);
if (_normalBinding == osg::Geometry::BIND_PER_PRIMITIVE) ++_curNormalIndex;
}
break;
case GL_TRIANGLE_STRIP:
@ -241,14 +238,12 @@ void PrimitiveIndexWriter::drawArrays(GLenum mode,GLint first,GLsizei count)
if (i & 1) writeTriangle(pos, pos + 2, pos + 1);
else writeTriangle(pos, pos + 1, pos + 2);
}
if (_normalBinding == osg::Geometry::BIND_PER_PRIMITIVE) ++_curNormalIndex;
break;
case GL_QUADS:
for (GLsizei i = 3; i < count; i += 4, pos += 4)
{
writeTriangle(pos, pos + 1, pos + 2);
writeTriangle(pos, pos + 2, pos + 3);
if (_normalBinding == osg::Geometry::BIND_PER_PRIMITIVE) ++_curNormalIndex;
}
break;
case GL_QUAD_STRIP:
@ -257,7 +252,6 @@ void PrimitiveIndexWriter::drawArrays(GLenum mode,GLint first,GLsizei count)
writeTriangle(pos, pos + 1, pos + 2);
writeTriangle(pos + 1, pos + 3, pos + 2);
}
if (_normalBinding == osg::Geometry::BIND_PER_PRIMITIVE) ++_curNormalIndex;
break;
case GL_POLYGON: // treat polygons as GL_TRIANGLE_FAN
case GL_TRIANGLE_FAN:
@ -266,7 +260,6 @@ void PrimitiveIndexWriter::drawArrays(GLenum mode,GLint first,GLsizei count)
{
writeTriangle(first, pos, pos+1);
}
if (_normalBinding == osg::Geometry::BIND_PER_PRIMITIVE) ++_curNormalIndex;
break;
case GL_POINTS:
case GL_LINES:
@ -535,7 +528,6 @@ WriterNodeVisitor::setControlPointAndNormalsAndUV(const osg::Geode& geo,
//switch (pGeometry->getNormalBinding())
//{
//case osg::Geometry::BIND_PER_PRIMITIVE_SET:
//case osg::Geometry::BIND_PER_PRIMITIVE:
//case osg::Geometry::BIND_PER_VERTEX:
// break;
//}
@ -615,7 +607,6 @@ void WriterNodeVisitor::createListTriangle(const osg::Geometry* geo,
unsigned int& drawable_n)
{
unsigned int nbVertices = 0;
texcoords = false;
{
const osg::Array * vecs = geo->getVertexArray();
if (vecs)

View File

@ -584,20 +584,20 @@ osg::Quat DataInputStream::readQuat(){
osg::Geometry::AttributeBinding DataInputStream::readBinding(){
deprecated_osg::Geometry::AttributeBinding DataInputStream::readBinding(){
char c = readChar();
if (_verboseOutput) std::cout<<"readBinding() ["<<(int)c<<"]"<<std::endl;
switch((int)c){
case 0: return osg::Geometry::BIND_OFF;
case 1: return osg::Geometry::BIND_OVERALL;
case 2: return static_cast<osg::Geometry::AttributeBinding>(3) /*osg::Geometry::BIND_PER_PRIMITIVE*/;
case 3: return osg::Geometry::BIND_PER_PRIMITIVE_SET;
case 4: return osg::Geometry::BIND_PER_VERTEX;
case 0: return deprecated_osg::Geometry::BIND_OFF;
case 1: return deprecated_osg::Geometry::BIND_OVERALL;
case 2: return deprecated_osg::Geometry::BIND_PER_PRIMITIVE;
case 3: return deprecated_osg::Geometry::BIND_PER_PRIMITIVE_SET;
case 4: return deprecated_osg::Geometry::BIND_PER_VERTEX;
default:
throwException("Unknown binding type in DataInputStream::readBinding()");
return osg::Geometry::BIND_OFF;
return deprecated_osg::Geometry::BIND_OFF;
}
}

View File

@ -6,6 +6,9 @@
#include <string>
#include <map>
#include <vector>
#include <osg/Vec2>
#include <osg/Vec3>
#include <osg/Vec4>
@ -15,8 +18,8 @@
#include <osg/Quat>
#include <osg/Array>
#include <osg/Matrix>
#include <osg/Geometry>
#include <osg/Image>
#include <osg/Geometry>
#include <osg/StateSet>
#include <osg/Uniform>
#include <osg/ref_ptr>
@ -68,7 +71,7 @@ public:
osg::Quat readQuat();
osg::Matrixf readMatrixf();
osg::Matrixd readMatrixd();
osg::Geometry::AttributeBinding readBinding();
deprecated_osg::Geometry::AttributeBinding readBinding();
osg::Array* readArray();
osg::IntArray* readIntArray();
osg::UByteArray* readUByteArray();

View File

@ -507,13 +507,13 @@ void DataOutputStream::writeQuat(const osg::Quat& q){
if (_verboseOutput) std::cout<<"read/writeQuat() ["<<q<<"]"<<std::endl;
}
void DataOutputStream::writeBinding(osg::Geometry::AttributeBinding b){
void DataOutputStream::writeBinding(deprecated_osg::Geometry::AttributeBinding b){
switch(b){
case osg::Geometry::BIND_OFF: writeChar((char) 0); break;
case osg::Geometry::BIND_OVERALL: writeChar((char) 1); break;
case static_cast<osg::Geometry::AttributeBinding>(3): writeChar((char) 2); break; /*osg::Geometry::BIND_PER_PRIMITIVE*/
case osg::Geometry::BIND_PER_PRIMITIVE_SET: writeChar((char) 3); break;
case osg::Geometry::BIND_PER_VERTEX: writeChar((char) 4); break;
case deprecated_osg::Geometry::BIND_OFF: writeChar((char) 0); break;
case deprecated_osg::Geometry::BIND_OVERALL: writeChar((char) 1); break;
case deprecated_osg::Geometry::BIND_PER_PRIMITIVE: writeChar((char) 2); break;
case deprecated_osg::Geometry::BIND_PER_PRIMITIVE_SET: writeChar((char) 3); break;
case deprecated_osg::Geometry::BIND_PER_VERTEX: writeChar((char) 4); break;
default: throwException("Unknown binding in DataOutputStream::writeBinding()");
}

View File

@ -62,7 +62,7 @@ public:
void writePlane(const osg::Plane& v);
void writeVec4ub(const osg::Vec4ub& v);
void writeQuat(const osg::Quat& q);
void writeBinding(osg::Geometry::AttributeBinding b);
void writeBinding(deprecated_osg::Geometry::AttributeBinding b);
void writeArray(const osg::Array* a);
void writeIntArray(const osg::IntArray* a);
void writeUByteArray(const osg::UByteArray* a);

View File

@ -12,13 +12,9 @@
* Copyright 2003 VR-C
**********************************************************************/
#include <osg/Config>
#ifndef OSG_USE_DEPRECATED_GEOMETRY_METHODS
#define OSG_USE_DEPRECATED_GEOMETRY_METHODS 1
#endif
#include "Geometry.h"
#include "Exception.h"
#include "Geometry.h"
#include "Drawable.h"
#include "DrawArrays.h"
#include "DrawArrayLengths.h"
@ -162,7 +158,7 @@ void Geometry::write(DataOutputStream* out){
const osg::Array* array = vaal[j].get();
if (array)
{
out->writeBinding(static_cast<osg::Geometry::AttributeBinding>(array->getBinding()));
out->writeBinding(static_cast<deprecated_osg::Geometry::AttributeBinding>(array->getBinding()));
out->writeBool(array->getNormalize());
out->writeBool(true);
out->writeArray(array);
@ -253,7 +249,7 @@ void Geometry::read(DataInputStream* in){
{
bool na =in->readBool();
if(na){
osg::Geometry::AttributeBinding binding = in->readBinding();
deprecated_osg::Geometry::AttributeBinding binding = in->readBinding();
setNormalArray(in->readVec3Array());
setNormalBinding(binding);
}
@ -262,7 +258,7 @@ void Geometry::read(DataInputStream* in){
{
bool na =in->readBool();
if(na){
osg::Geometry::AttributeBinding binding = in->readBinding();
deprecated_osg::Geometry::AttributeBinding binding = in->readBinding();
setNormalArray(in->readArray());
setNormalBinding(binding);
}
@ -275,7 +271,7 @@ void Geometry::read(DataInputStream* in){
}
// Read color array if any.
if(in->readBool()){
osg::Geometry::AttributeBinding binding = in->readBinding();
deprecated_osg::Geometry::AttributeBinding binding = in->readBinding();
setColorArray(in->readArray());
setColorBinding(binding);
}
@ -285,7 +281,7 @@ void Geometry::read(DataInputStream* in){
}
// Read secondary color array if any
if(in->readBool()){
osg::Geometry::AttributeBinding binding = in->readBinding();
deprecated_osg::Geometry::AttributeBinding binding = in->readBinding();
setSecondaryColorArray(in->readArray());
setSecondaryColorBinding(binding);
}
@ -295,7 +291,7 @@ void Geometry::read(DataInputStream* in){
}
// Read fog coord array if any
if(in->readBool()){
osg::Geometry::AttributeBinding binding = in->readBinding();
deprecated_osg::Geometry::AttributeBinding binding = in->readBinding();
setFogCoordArray(in->readArray());
setFogCoordBinding(binding);
}
@ -321,7 +317,7 @@ void Geometry::read(DataInputStream* in){
size = in->readInt();
for(i =0;i<size;i++)
{
osg::Geometry::AttributeBinding binding = in->readBinding();
deprecated_osg::Geometry::AttributeBinding binding = in->readBinding();
bool normalize = in->readBool();
// Read coords if valid

View File

@ -5,7 +5,7 @@
#include "ReadWrite.h"
namespace ive{
class Geometry : public ReadWrite, public osg::Geometry{
class Geometry : public ReadWrite, public deprecated_osg::Geometry {
public:
void write(DataOutputStream* out);
void read(DataInputStream* in);

View File

@ -6,10 +6,6 @@
* Author(s): Vladimir Vukicevic <vladimir@pobox.com>
*
*/
#include <osg/Config>
#ifndef OSG_USE_DEPRECATED_GEOMETRY_METHODS
#define OSG_USE_DEPRECATED_GEOMETRY_METHODS 1
#endif
#include <osg/TexEnv>
#include <osg/CullFace>
@ -379,7 +375,7 @@ load_md2 (const char *filename, const osgDB::ReaderWriter::Options* options)
}
}
osg::Geometry *geom = new osg::Geometry;
deprecated_osg::Geometry *geom = new deprecated_osg::Geometry;
geom->setVertexArray (vertexCoords);
geom->setVertexIndices (vertexIndices);
@ -389,7 +385,7 @@ load_md2 (const char *filename, const osgDB::ReaderWriter::Options* options)
geom->setNormalArray (normalCoords);
geom->setNormalIndices (normalIndices);
geom->setNormalBinding (osg::Geometry::BIND_PER_VERTEX);
geom->setNormalBinding (deprecated_osg::Geometry::BIND_PER_VERTEX);
geom->addPrimitiveSet (new osg::DrawArrays (osg::PrimitiveSet::TRIANGLES, 0, vertexIndices->size ()));

View File

@ -1,10 +1,5 @@
// -*-c++-*-
#include <osg/Config>
#ifndef OSG_USE_DEPRECATED_GEOMETRY_METHODS
#define OSG_USE_DEPRECATED_GEOMETRY_METHODS 1
#endif
#include "ConvertFromPerformer.h"
#include <osg/Group>
@ -84,10 +79,10 @@ ConvertFromPerformer::ConvertFromPerformer()
{
_osgRoot = NULL;
_gsetBindMap[PFGS_OFF] = osg::Geometry::BIND_OFF;
_gsetBindMap[PFGS_OVERALL] = osg::Geometry::BIND_OVERALL;
_gsetBindMap[PFGS_PER_PRIM] = osg::Geometry::BIND_PER_PRIMITIVE;
_gsetBindMap[PFGS_PER_VERTEX] = osg::Geometry::BIND_PER_VERTEX;
_gsetBindMap[PFGS_OFF] = deprecated_osg::Geometry::BIND_OFF;
_gsetBindMap[PFGS_OVERALL] = deprecated_osg::Geometry::BIND_OVERALL;
_gsetBindMap[PFGS_PER_PRIM] = deprecated_osg::Geometry::BIND_PER_PRIMITIVE;
_gsetBindMap[PFGS_PER_VERTEX] = deprecated_osg::Geometry::BIND_PER_VERTEX;
_saveImagesAsRGB = false;
_saveAbsoluteImagePath = false;
@ -546,9 +541,9 @@ osg::Drawable* ConvertFromPerformer::visitGeoSet(osg::Geode* osgGeode,pfGeoSet*
}
// we'll make it easy to convert by using the Performer style osg::GeoSet,
// and then convert back to a osg::Geometry afterwards.
// and then convert back to a deprecated_osg::Geometry afterwards.
//osg::ref_ptr<osg::GeoSet> geom = new osg::GeoSet;
osg::Geometry* geom = new osg::Geometry;
deprecated_osg::Geometry* geom = new deprecated_osg::Geometry;
int i;

View File

@ -53,7 +53,7 @@ class ConvertFromPerformer {
osg::Material* visitMaterial(osg::StateSet* osgStateSet,pfMaterial* front_mat,pfMaterial* back_mat);
osg::Texture2D* visitTexture(osg::StateSet* osgStateSet,pfTexture* tex);
typedef std::map<int,osg::Geometry::AttributeBinding> GSetBindingMap;
typedef std::map<int,deprecated_osg::Geometry::AttributeBinding> GSetBindingMap;
GSetBindingMap _gsetBindMap;

View File

@ -15,7 +15,7 @@
osg::ref_ptr<osg::Geometry> ReaderWriterVRML2::convertVRML97IndexedFaceSet(openvrml::node *vrml_ifs) const
{
osg::ref_ptr<osg::Geometry> osg_geom = new osg::Geometry();
osg::ref_ptr<deprecated_osg::Geometry> osg_geom = new deprecated_osg::Geometry();
osg_geom->addPrimitiveSet(new osg::DrawArrayLengths(osg::PrimitiveSet::POLYGON));
@ -160,10 +160,10 @@ osg::ref_ptr<osg::Geometry> ReaderWriterVRML2::convertVRML97IndexedFaceSet(openv
if (vrml_norm_per_vertex->value())
{
osg_geom->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
osg_geom->setNormalBinding(deprecated_osg::Geometry::BIND_PER_VERTEX);
} else
{
osg_geom->setNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE);
osg_geom->setNormalBinding(deprecated_osg::Geometry::BIND_PER_PRIMITIVE);
}
}
}
@ -214,10 +214,10 @@ osg::ref_ptr<osg::Geometry> ReaderWriterVRML2::convertVRML97IndexedFaceSet(openv
if (vrml_color_per_vertex->value())
{
osg_geom->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
osg_geom->setColorBinding(deprecated_osg::Geometry::BIND_PER_VERTEX);
} else
{
osg_geom->setColorBinding(osg::Geometry::BIND_PER_PRIMITIVE);
osg_geom->setColorBinding(deprecated_osg::Geometry::BIND_PER_PRIMITIVE);
}
}
}
@ -281,7 +281,7 @@ osg::ref_ptr<osg::Geometry> ReaderWriterVRML2::convertVRML97IndexedFaceSet(openv
osg_geom->setNormalArray(normals);
osg_geom->setNormalIndices(const_cast<osg::IndexArray*>(osg_geom->getVertexIndices()));
osg_geom->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
osg_geom->setNormalBinding(deprecated_osg::Geometry::BIND_PER_VERTEX);
#endif
}

View File

@ -16,7 +16,7 @@
osg::ref_ptr<osg::Geometry> ReaderWriterVRML2::convertVRML97IndexedLineSet(openvrml::node *vrml_ifs) const
{
osg::ref_ptr<osg::Geometry> osg_geom = new osg::Geometry();
osg::ref_ptr<deprecated_osg::Geometry> osg_geom = new deprecated_osg::Geometry();
osg_geom->addPrimitiveSet(new osg::DrawArrayLengths(osg::PrimitiveSet::LINE_STRIP));
@ -117,10 +117,10 @@ osg::ref_ptr<osg::Geometry> ReaderWriterVRML2::convertVRML97IndexedLineSet(openv
if (vrml_color_per_vertex->value())
{
osg_geom->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
osg_geom->setColorBinding(deprecated_osg::Geometry::BIND_PER_VERTEX);
} else
{
osg_geom->setColorBinding(osg::Geometry::BIND_PER_PRIMITIVE);
osg_geom->setColorBinding(deprecated_osg::Geometry::BIND_PER_PRIMITIVE);
}
}
}
@ -143,7 +143,7 @@ osg::ref_ptr<osg::Geometry> ReaderWriterVRML2::convertVRML97Box(openvrml::node*
return (*it).second.get();
}
osg::ref_ptr<osg::Geometry> osg_geom = new osg::Geometry();
osg::ref_ptr<deprecated_osg::Geometry> osg_geom = new deprecated_osg::Geometry();
osg::ref_ptr<osg::Vec3Array> osg_vertices = new osg::Vec3Array();
osg::ref_ptr<osg::Vec2Array> osg_texcoords = new osg::Vec2Array();
osg::ref_ptr<osg::Vec3Array> osg_normals = new osg::Vec3Array();
@ -202,7 +202,7 @@ osg::ref_ptr<osg::Geometry> ReaderWriterVRML2::convertVRML97Box(openvrml::node*
osg_geom->setVertexArray(osg_vertices.get());
osg_geom->setTexCoordArray(0, osg_texcoords.get());
osg_geom->setNormalArray(osg_normals.get());
osg_geom->setNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE);
osg_geom->setNormalBinding(deprecated_osg::Geometry::BIND_PER_PRIMITIVE);
osg_geom->getOrCreateStateSet()->setAttributeAndModes(new osg::CullFace(osg::CullFace::BACK));

View File

@ -1,8 +1,3 @@
#include <osg/Config>
#ifndef OSG_USE_DEPRECATED_GEOMETRY_METHODS
#define OSG_USE_DEPRECATED_GEOMETRY_METHODS 1
#endif
#include <osgSim/ScalarBar>
#include <osgText/Text>
#include <osg/Geometry>
@ -142,7 +137,7 @@ void ScalarBar::createDrawables()
// 1. First the bar
// =================
osg::ref_ptr<osg::Geometry> bar = new osg::Geometry();
osg::ref_ptr<deprecated_osg::Geometry> bar = new deprecated_osg::Geometry();
// Create the bar - created in 'real' coordinate space the moment,
// with xyz values reflecting those of the actual scalar values in play.
@ -177,13 +172,13 @@ void ScalarBar::createDrawables()
cs->push_back(_stc->getColor(_stc->getMin() + (i*incr) + halfIncr));
}
bar->setColorArray(cs.get());
bar->setColorBinding(osg::Geometry::BIND_PER_PRIMITIVE);
bar->setColorBinding(deprecated_osg::Geometry::BIND_PER_PRIMITIVE);
// Normal
osg::ref_ptr<osg::Vec3Array> ns(new osg::Vec3Array);
ns->push_back(osg::Matrix::transform3x3(osg::Vec3(0.0f,0.0f,1.0f),matrix));
bar->setNormalArray(ns.get());
bar->setNormalBinding(osg::Geometry::BIND_OVERALL);
bar->setNormalBinding(deprecated_osg::Geometry::BIND_OVERALL);
// The Quad strip that represents the bar
bar->addPrimitiveSet(new osg::DrawArrays(GL_QUADS,0,vs->size()));

View File

@ -20,8 +20,8 @@ using namespace osgDB;
bool Geometry_readLocalData(Object& obj, Input& fr);
bool Geometry_writeLocalData(const Object& obj, Output& fw);
bool Geometry_matchBindingTypeStr(const char* str,Geometry::AttributeBinding& mode);
const char* Geometry_getBindingTypeStr(Geometry::AttributeBinding mode);
bool Geometry_matchBindingTypeStr(const char* str,deprecated_osg::Geometry::AttributeBinding& mode);
const char* Geometry_getBindingTypeStr(deprecated_osg::Geometry::AttributeBinding mode);
bool Geometry_matchPrimitiveModeStr(const char* str,GLenum& mode);
const char* Geometry_getPrimitiveModeStr(GLenum mode);
@ -45,7 +45,7 @@ bool Geometry_readLocalData(Object& obj, Input& fr)
{
bool iteratorAdvanced = false;
Geometry& geom = static_cast<Geometry&>(obj);
deprecated_osg::Geometry& geom = static_cast<deprecated_osg::Geometry&>(obj);
if (fr.matchSequence("Primitives %i {") || fr.matchSequence("PrimitiveSets %i {") )
{
@ -134,7 +134,7 @@ bool Geometry_readLocalData(Object& obj, Input& fr)
}
Geometry::AttributeBinding normalBinding=Geometry::BIND_OFF;
deprecated_osg::Geometry::AttributeBinding normalBinding = deprecated_osg::Geometry::BIND_OFF;
if (fr[0].matchWord("NormalBinding") && Geometry_matchBindingTypeStr(fr[1].getStr(),normalBinding))
{
fr+=2;
@ -200,7 +200,7 @@ bool Geometry_readLocalData(Object& obj, Input& fr)
iteratorAdvanced = true;
}
Geometry::AttributeBinding colorBinding=Geometry::BIND_OFF;
deprecated_osg::Geometry::AttributeBinding colorBinding = deprecated_osg::Geometry::BIND_OFF;
if (fr[0].matchWord("ColorBinding") && Geometry_matchBindingTypeStr(fr[1].getStr(),colorBinding))
{
fr+=2;
@ -231,7 +231,7 @@ bool Geometry_readLocalData(Object& obj, Input& fr)
}
Geometry::AttributeBinding secondaryColorBinding=Geometry::BIND_OFF;
deprecated_osg::Geometry::AttributeBinding secondaryColorBinding = deprecated_osg::Geometry::BIND_OFF;
if (fr[0].matchWord("SecondaryColorBinding") && Geometry_matchBindingTypeStr(fr[1].getStr(),secondaryColorBinding))
{
fr+=2;
@ -262,7 +262,7 @@ bool Geometry_readLocalData(Object& obj, Input& fr)
}
Geometry::AttributeBinding fogCoordBinding=Geometry::BIND_OFF;
deprecated_osg::Geometry::AttributeBinding fogCoordBinding = deprecated_osg::Geometry::BIND_OFF;
if (fr[0].matchWord("FogCoordBinding") && Geometry_matchBindingTypeStr(fr[1].getStr(),fogCoordBinding))
{
fr+=2;
@ -322,7 +322,7 @@ bool Geometry_readLocalData(Object& obj, Input& fr)
iteratorAdvanced = true;
}
Geometry::AttributeBinding vertexAttribBinding=Geometry::BIND_OFF;
deprecated_osg::Geometry::AttributeBinding vertexAttribBinding = deprecated_osg::Geometry::BIND_OFF;
if (fr.matchSequence("VertexAttribBinding %i %w") && Geometry_matchBindingTypeStr(fr[2].getStr(),vertexAttribBinding))
{
int unit=0;
@ -1277,7 +1277,7 @@ bool Primitive_writeLocalData(const PrimitiveSet& prim,Output& fw)
bool Geometry_writeLocalData(const Object& obj, Output& fw)
{
const Geometry& geom = static_cast<const Geometry&>(obj);
const deprecated_osg::Geometry& geom = static_cast<const deprecated_osg::Geometry&>(obj);
const Geometry::PrimitiveSetList& primitives = geom.getPrimitiveSetList();
if (!primitives.empty())
@ -1393,7 +1393,7 @@ bool Geometry_writeLocalData(const Object& obj, Output& fw)
if (array)
{
fw.indent()<<"VertexAttribBinding "<<i<<" "<<Geometry_getBindingTypeStr(static_cast<osg::Geometry::AttributeBinding>(array->getBinding()))<<std::endl;
fw.indent()<<"VertexAttribBinding "<<i<<" "<<Geometry_getBindingTypeStr(static_cast<deprecated_osg::Geometry::AttributeBinding>(array->getBinding()))<<std::endl;
if (array->getNormalize())
fw.indent()<<"VertexAttribNormalize "<<i<<" TRUE"<<std::endl;
@ -1415,27 +1415,27 @@ bool Geometry_writeLocalData(const Object& obj, Output& fw)
return true;
}
bool Geometry_matchBindingTypeStr(const char* str,Geometry::AttributeBinding& mode)
bool Geometry_matchBindingTypeStr(const char* str,deprecated_osg::Geometry::AttributeBinding& mode)
{
if (strcmp(str,"OFF")==0) mode = Geometry::BIND_OFF;
else if (strcmp(str,"OVERALL")==0) mode = Geometry::BIND_OVERALL;
else if (strcmp(str,"PER_PRIMITIVE")==0) mode = Geometry::BIND_PER_PRIMITIVE;
else if (strcmp(str,"PER_PRIMITIVE_SET")==0) mode = Geometry::BIND_PER_PRIMITIVE_SET;
else if (strcmp(str,"PER_VERTEX")==0) mode = Geometry::BIND_PER_VERTEX;
if (strcmp(str,"OFF")==0) mode = deprecated_osg::Geometry::BIND_OFF;
else if (strcmp(str,"OVERALL")==0) mode = deprecated_osg::Geometry::BIND_OVERALL;
else if (strcmp(str,"PER_PRIMITIVE")==0) mode = deprecated_osg::Geometry::BIND_PER_PRIMITIVE;
else if (strcmp(str,"PER_PRIMITIVE_SET")==0) mode = deprecated_osg::Geometry::BIND_PER_PRIMITIVE_SET;
else if (strcmp(str,"PER_VERTEX")==0) mode = deprecated_osg::Geometry::BIND_PER_VERTEX;
else return false;
return true;
}
const char* Geometry_getBindingTypeStr(Geometry::AttributeBinding mode)
const char* Geometry_getBindingTypeStr(deprecated_osg::Geometry::AttributeBinding mode)
{
switch(mode)
{
case (Geometry::BIND_OVERALL) : return "OVERALL";
case (Geometry::BIND_PER_PRIMITIVE) : return "PER_PRIMITIVE";
case (Geometry::BIND_PER_PRIMITIVE_SET) : return "PER_PRIMITIVE_SET";
case (Geometry::BIND_PER_VERTEX) : return "PER_VERTEX";
case (Geometry::BIND_OFF) :
case (deprecated_osg::Geometry::BIND_OVERALL) : return "OVERALL";
case (deprecated_osg::Geometry::BIND_PER_PRIMITIVE) : return "PER_PRIMITIVE";
case (deprecated_osg::Geometry::BIND_PER_PRIMITIVE_SET) : return "PER_PRIMITIVE_SET";
case (deprecated_osg::Geometry::BIND_PER_VERTEX) : return "PER_VERTEX";
case (deprecated_osg::Geometry::BIND_OFF) :
default : return "OFF";
}
}