Replaced deprecatated osg::Geometry::get*Binding() calls.

This commit is contained in:
Robert Osfield
2013-06-27 14:46:16 +00:00
parent dfc1a899db
commit 90ceb88c12
14 changed files with 163 additions and 135 deletions

View File

@@ -154,21 +154,6 @@ void Geometry::setFogCoordArray(Array* array, osg::Array::Binding binding)
if (_useVertexBufferObjects && array) addVertexBufferObjectIfRequired(array);
}
#define SET_BINDING(array, ab)\
if (!array) \
{ \
if (ab==BIND_OFF) return; \
OSG_NOTICE<<"Warning, can't assign attribute binding as no has been array assigned to set binding for."<<std::endl; \
return; \
} \
if (array->getBinding() == static_cast<osg::Array::Binding>(ab)) return; \
array->setBinding(static_cast<osg::Array::Binding>(ab));\
if (ab==3 /*osg::Geometry::BIND_PER_PRIMITIVE*/) _containsDeprecatedData = true;
#define GET_BINDING(array) (array!=0 ? static_cast<AttributeBinding>(array->getBinding()) : BIND_OFF)
void Geometry::setTexCoordArray(unsigned int index,Array* array, osg::Array::Binding binding)
@@ -736,7 +721,7 @@ void Geometry::drawImplementation(RenderInfo& renderInfo) const
}
// dispatch any attributes that are bound overall
arrayDispatchers.dispatch(BIND_OVERALL,0);
arrayDispatchers.dispatch(osg::Array::BIND_OVERALL,0);
state.lazyDisablingOfVertexAttributes();
@@ -779,7 +764,7 @@ void Geometry::drawImplementation(RenderInfo& renderInfo) const
state.applyDisablingOfVertexAttributes();
bool bindPerPrimitiveSetActive = arrayDispatchers.active(BIND_PER_PRIMITIVE_SET);
bool bindPerPrimitiveSetActive = arrayDispatchers.active(osg::Array::BIND_PER_PRIMITIVE_SET);
if (checkForGLErrors) state.checkGLErrors("Geometry::drawImplementation() after vertex arrays setup.");
@@ -790,7 +775,7 @@ void Geometry::drawImplementation(RenderInfo& renderInfo) const
for(unsigned int primitiveSetNum=0; primitiveSetNum!=_primitives.size(); ++primitiveSetNum)
{
// dispatch any attributes that are bound per primitive
if (bindPerPrimitiveSetActive) arrayDispatchers.dispatch(BIND_PER_PRIMITIVE_SET, primitiveSetNum);
if (bindPerPrimitiveSetActive) arrayDispatchers.dispatch(osg::Array::BIND_PER_PRIMITIVE_SET, primitiveSetNum);
const PrimitiveSet* primitiveset = _primitives[primitiveSetNum].get();
@@ -1102,52 +1087,42 @@ Geometry* osg::createTexturedQuadGeometry(const Vec3& corner,const Vec3& widthVe
//
// Deprecated methods.
//
#define SET_BINDING(array, ab)\
if (!array) \
{ \
if (ab==BIND_OFF) return; \
OSG_NOTICE<<"Warning, can't assign attribute binding as no has been array assigned to set binding for."<<std::endl; \
return; \
} \
if (array->getBinding() == static_cast<osg::Array::Binding>(ab)) return; \
array->setBinding(static_cast<osg::Array::Binding>(ab));\
if (ab==3 /*osg::Geometry::BIND_PER_PRIMITIVE*/) _containsDeprecatedData = true; \
dirtyDisplayList();
#define GET_BINDING(array) (array!=0 ? static_cast<AttributeBinding>(array->getBinding()) : BIND_OFF)
#if defined(OSG_DEPRECATED_GEOMETRY_BINDING)
void Geometry::setNormalBinding(AttributeBinding ab)
{
SET_BINDING(_normalArray.get(), ab)
dirtyDisplayList();
}
Geometry::AttributeBinding Geometry::getNormalBinding() const
{
return GET_BINDING(_normalArray.get());
}
void Geometry::setColorBinding(AttributeBinding ab)
{
SET_BINDING(_colorArray.get(), ab)
dirtyDisplayList();
}
Geometry::AttributeBinding Geometry::getColorBinding() const
{
return GET_BINDING(_colorArray.get());
}
void Geometry::setSecondaryColorBinding(AttributeBinding ab)
{
SET_BINDING(_secondaryColorArray.get(), ab)
dirtyDisplayList();
}
Geometry::AttributeBinding Geometry::getSecondaryColorBinding() const
{
return GET_BINDING(_secondaryColorArray.get());
}
void Geometry::setFogCoordBinding(AttributeBinding ab)
{
SET_BINDING(_fogCoordArray.get(), ab)
dirtyDisplayList();
}
Geometry::AttributeBinding Geometry::getFogCoordBinding() const
{
return GET_BINDING(_fogCoordArray.get());
}
void Geometry::setVertexAttribBinding(unsigned int index,AttributeBinding ab)
@@ -1166,12 +1141,6 @@ void Geometry::setVertexAttribBinding(unsigned int index,AttributeBinding ab)
}
}
Geometry::AttributeBinding Geometry::getVertexAttribBinding(unsigned int index) const
{
if (index<_vertexAttribList.size() && _vertexAttribList[index].valid()) return static_cast<AttributeBinding>(_vertexAttribList[index]->getBinding());
else return BIND_OFF;
}
void Geometry::setVertexAttribNormalize(unsigned int index,GLboolean norm)
{
if (index<_vertexAttribList.size() && _vertexAttribList[index].valid())
@@ -1182,12 +1151,38 @@ void Geometry::setVertexAttribNormalize(unsigned int index,GLboolean norm)
}
}
Geometry::AttributeBinding Geometry::getNormalBinding() const
{
return GET_BINDING(_normalArray.get());
}
Geometry::AttributeBinding Geometry::getColorBinding() const
{
return GET_BINDING(_colorArray.get());
}
Geometry::AttributeBinding Geometry::getSecondaryColorBinding() const
{
return GET_BINDING(_secondaryColorArray.get());
}
Geometry::AttributeBinding Geometry::getFogCoordBinding() const
{
return GET_BINDING(_fogCoordArray.get());
}
Geometry::AttributeBinding Geometry::getVertexAttribBinding(unsigned int index) const
{
if (index<_vertexAttribList.size() && _vertexAttribList[index].valid()) return static_cast<AttributeBinding>(_vertexAttribList[index]->getBinding());
else return BIND_OFF;
}
GLboolean Geometry::getVertexAttribNormalize(unsigned int index) const
{
if (index<_vertexAttribList.size() && _vertexAttribList[index].valid()) return _vertexAttribList[index]->getNormalize();
else return GL_FALSE;
}
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Helper methods
@@ -1363,25 +1358,24 @@ void Geometry::fixDeprecatedData()
bool containsBindPerPrimitive = false;
OSG_NOTICE<<"Geometry::fixDeprecatedData()"<<std::endl;
// copy over attribute arrays.
osg::IndexArray* indices = GeometryUtilFunctions::getIndexArray(_vertexArray.get());
if (indices) setVertexArray(GeometryUtilFunctions::expandIndexArray(_vertexArray.get(), indices));
if (getNormalBinding()==3 /*osg::Geometry::BIND_PER_PRIMITIVE*/) containsBindPerPrimitive = true;
if (osg::getBinding(_normalArray.get())==3 /*osg::Geometry::BIND_PER_PRIMITIVE*/) containsBindPerPrimitive = true;
indices = GeometryUtilFunctions::getIndexArray(_normalArray.get());
if (indices) setNormalArray(GeometryUtilFunctions::expandIndexArray(getNormalArray(), indices));
if (getColorBinding()==3 /*osg::Geometry::BIND_PER_PRIMITIVE*/) containsBindPerPrimitive = true;
if (osg::getBinding(getColorArray())==3 /*osg::Geometry::BIND_PER_PRIMITIVE*/) containsBindPerPrimitive = true;
indices = GeometryUtilFunctions::getIndexArray(_colorArray.get());
if (indices) setColorArray(GeometryUtilFunctions::expandIndexArray(getColorArray(), indices));
if (getSecondaryColorBinding()==3 /*osg::Geometry::BIND_PER_PRIMITIVE*/) containsBindPerPrimitive = true;
if (osg::getBinding(getSecondaryColorArray())==3 /*osg::Geometry::BIND_PER_PRIMITIVE*/) containsBindPerPrimitive = true;
indices = GeometryUtilFunctions::getIndexArray(_secondaryColorArray.get());
if (indices) setSecondaryColorArray(GeometryUtilFunctions::expandIndexArray(getSecondaryColorArray(), indices));
if (getFogCoordBinding()==3 /*osg::Geometry::BIND_PER_PRIMITIVE*/) containsBindPerPrimitive = true;
if (osg::getBinding(getFogCoordArray())==3 /*osg::Geometry::BIND_PER_PRIMITIVE*/) containsBindPerPrimitive = true;
indices = GeometryUtilFunctions::getIndexArray(_fogCoordArray.get());
if (indices) setFogCoordArray(GeometryUtilFunctions::expandIndexArray(getFogCoordArray(), indices));
@@ -1393,7 +1387,7 @@ void Geometry::fixDeprecatedData()
for(unsigned int vi=0;vi<_vertexAttribList.size();++vi)
{
if (getVertexAttribBinding(vi)==3 /*osg::Geometry::BIND_PER_PRIMITIVE*/) containsBindPerPrimitive = true;
if (osg::getBinding(getVertexAttribArray(vi))==3 /*osg::Geometry::BIND_PER_PRIMITIVE*/) containsBindPerPrimitive = true;
indices = GeometryUtilFunctions::getIndexArray(_vertexAttribList[vi].get());
if (indices) setVertexAttribArray(vi, GeometryUtilFunctions::expandIndexArray(getVertexAttribArray(vi), indices));
}
@@ -1793,23 +1787,48 @@ void Geometry::fixDeprecatedData()
//
// 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::setNormalBinding(AttributeBinding ab) { SET_BINDING(_normalArray.get(), ab) }
deprecated_osg::Geometry::AttributeBinding deprecated_osg::Geometry::getNormalBinding() const { return static_cast<AttributeBinding>(osg::getBinding(getNormalArray())); }
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::setColorBinding(deprecated_osg::Geometry::AttributeBinding ab) { SET_BINDING(_colorArray.get(), ab) }
deprecated_osg::Geometry::AttributeBinding deprecated_osg::Geometry::getColorBinding() const { return static_cast<AttributeBinding>(osg::getBinding(getColorArray())); }
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::setSecondaryColorBinding(deprecated_osg::Geometry::AttributeBinding ab) { SET_BINDING(_secondaryColorArray.get(), ab) }
deprecated_osg::Geometry::AttributeBinding deprecated_osg::Geometry::getSecondaryColorBinding() const { return static_cast<AttributeBinding>(osg::getBinding(getSecondaryColorArray())); }
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::setFogCoordBinding(deprecated_osg::Geometry::AttributeBinding ab) { SET_BINDING(_fogCoordArray.get(), ab) }
deprecated_osg::Geometry::AttributeBinding deprecated_osg::Geometry::getFogCoordBinding() const { return static_cast<AttributeBinding>(osg::getBinding(getFogCoordArray())); }
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::setVertexAttribBinding(unsigned int index,AttributeBinding ab)
{
if (index<_vertexAttribList.size() && _vertexAttribList[index].valid())
{
if (_vertexAttribList[index]->getBinding()==static_cast<osg::Array::Binding>(ab)) return;
_vertexAttribList[index]->setBinding(static_cast<osg::Array::Binding>(ab));
dirtyDisplayList();
}
else
{
OSG_NOTICE<<"Warning, can't assign attribute binding as no has been array assigned to set binding for."<<std::endl;
}
}
deprecated_osg::Geometry::AttributeBinding deprecated_osg::Geometry::getVertexAttribBinding(unsigned int index) const { return static_cast<AttributeBinding>(osg::getBinding(getVertexAttribArray(index))); }
void deprecated_osg::Geometry::setVertexAttribNormalize(unsigned int index,GLboolean norm)
{
if (index<_vertexAttribList.size() && _vertexAttribList[index].valid())
{
_vertexAttribList[index]->setNormalize(norm);
dirtyDisplayList();
}
}
GLboolean deprecated_osg::Geometry::getVertexAttribNormalize(unsigned int index) const { return osg::getNormalize(getVertexAttribArray(index)); }
void deprecated_osg::Geometry::setVertexIndices(osg::IndexArray* array)
{

View File

@@ -90,7 +90,7 @@ void addDrawableAndReverseWindingOrder( osg::Geode* geode )
reverseWindingOrder( vertices, drawarray->getMode(), first, last );
}
if( geom->getNormalBinding( ) == osg::Geometry::BIND_PER_VERTEX )
if( osg::getBinding(geom->getNormalArray()) == osg::Array::BIND_PER_VERTEX )
{
osg::Vec3Array* normals = dynamic_cast<osg::Vec3Array*>(geom->getNormalArray());
if( normals )
@@ -104,7 +104,7 @@ void addDrawableAndReverseWindingOrder( osg::Geode* geode )
}
}
if( geom->getColorBinding( ) == osg::Geometry::BIND_PER_VERTEX )
if( osg::getBinding(geom->getColorArray()) == osg::Array::BIND_PER_VERTEX )
{
osg::Vec4Array* colors = dynamic_cast<osg::Vec4Array*>(geom->getColorArray());
if( colors )

View File

@@ -79,8 +79,8 @@ VertexPaletteManager::add( const osg::Geometry& geom )
if (t && !t2)
return;
const bool cpv =( geom.getColorBinding() == osg::Geometry::BIND_PER_VERTEX );
const bool npv =( geom.getNormalBinding() == osg::Geometry::BIND_PER_VERTEX );
const bool cpv =( osg::getBinding(geom.getColorArray()) == osg::Array::BIND_PER_VERTEX );
const bool npv =( osg::getBinding(geom.getNormalArray()) == osg::Array::BIND_PER_VERTEX );
add( v, v3.get(), c4.get(), n3.get(), t2.get(), cpv, npv );
}
void

View File

@@ -56,7 +56,7 @@ FltExportVisitor::isLit( const osg::Geometry& geom ) const
if ( ss->getMode( GL_LIGHTING ) & osg::StateAttribute::ON )
return true;
else
return false; //( geom.getNormalBinding() == osg::Geometry::BIND_PER_VERTEX );
return false; //( geom.getNormalBinding() == osg::Array::BIND_PER_VERTEX );
}
bool
@@ -151,7 +151,7 @@ FltExportVisitor::writeFace( const osg::Geode& geode, const osg::Geometry& geom,
int8 lightMode;
osg::Vec4 packedColorRaw( 1., 1., 1., 1. );
uint16 transparency( 0 );
if (geom.getColorBinding() == osg::Geometry::BIND_PER_VERTEX)
if (osg::getBinding(geom.getColorArray()) == osg::Array::BIND_PER_VERTEX)
{
if( isLit( geom ) )
lightMode = VERTEX_COLOR_LIGHTING;
@@ -357,7 +357,7 @@ FltExportVisitor::writeMesh( const osg::Geode& geode, const osg::Geometry& geom
int8 lightMode;
osg::Vec4 packedColorRaw( 1., 1., 1., 1. );
uint16 transparency( 0 );
if (geom.getColorBinding() == osg::Geometry::BIND_PER_VERTEX)
if (osg::getBinding(geom.getColorArray()) == osg::Array::BIND_PER_VERTEX)
{
if (isLit( geom ))
lightMode = VERTEX_COLOR_LIGHTING;
@@ -608,12 +608,12 @@ FltExportVisitor::writeLocalVertexPool( const osg::Geometry& geom )
uint32 attr( HAS_POSITION );
unsigned int vertSize( sizeof( float64 ) * 3 );
if ( ( c4 != NULL ) && ( geom.getColorBinding() == osg::Geometry::BIND_PER_VERTEX) )
if ( ( c4 != NULL ) && ( osg::getBinding(geom.getColorArray()) == osg::Array::BIND_PER_VERTEX) )
{
attr |= HAS_RGBA_COLOR;
vertSize += sizeof( unsigned int );
}
if ( ( n3 != NULL ) && ( geom.getNormalBinding() == osg::Geometry::BIND_PER_VERTEX) )
if ( ( n3 != NULL ) && ( osg::getBinding(geom.getNormalArray()) == osg::Array::BIND_PER_VERTEX) )
{
attr |= HAS_NORMAL;
vertSize += ( sizeof( float32 ) * 3 );

View File

@@ -801,7 +801,7 @@ template <class ArrayType, int Value>
ArrayType* createGeometryArray(domSourceReader & sourceReader, const VertexIndicesIndexMap & vertexIndicesIndexMap, int texcoordNum=-1) {
const ArrayType * source = sourceReader.getArray<ArrayType>();
if (!source) return 0;
ArrayType * pArray = new ArrayType(osg::Geometry::BIND_PER_VERTEX);
ArrayType * pArray = new ArrayType(osg::Array::BIND_PER_VERTEX);
for (VertexIndicesIndexMap::const_iterator it = vertexIndicesIndexMap.begin(), end = vertexIndicesIndexMap.end(); it != end; ++it) {
int index = texcoordNum>=0 ? it->first.texcoord_indices[texcoordNum] : it->first.get<Value>();
if (index>=0 && static_cast<unsigned int>(index)<source->size()) pArray->push_back(source->at(index));

View File

@@ -511,7 +511,7 @@ void daeWriter::appendGeometryIndices(osg::Geometry *geom,
if ( norm != NULL )
{
if ( geom->getNormalBinding() == osg::Geometry::BIND_PER_VERTEX )
if ( osg::getBinding(geom->getNormalArray()) == osg::Array::BIND_PER_VERTEX )
p->getValue().append( normals.inds!=NULL?normals.inds->index( vindex ):vindex );
else
p->getValue().append( normals.inds!=NULL?normals.inds->index( ncount ):ncount );
@@ -519,7 +519,7 @@ void daeWriter::appendGeometryIndices(osg::Geometry *geom,
if ( color != NULL )
{
if ( geom->getColorBinding() == osg::Geometry::BIND_PER_VERTEX )
if ( osg::getBinding(geom->getColorArray()) == osg::Array::BIND_PER_VERTEX )
p->getValue().append( colors.inds!=NULL?colors.inds->index( vindex ):vindex );
else
p->getValue().append( colors.inds!=NULL?colors.inds->index( ccount ):ccount );
@@ -1292,11 +1292,11 @@ bool daeWriter::processGeometry( osg::Geometry *geom, domGeometry *geo, const st
break;
}
if ( geom->getNormalBinding() == osg::Geometry::BIND_PER_PRIMITIVE_SET )
if ( osg::getBinding(geom->getNormalArray()) == osg::Array::BIND_PER_PRIMITIVE_SET )
{
ncount++;
}
if ( geom->getColorBinding() == osg::Geometry::BIND_PER_PRIMITIVE_SET )
if ( osg::getBinding(geom->getColorArray()) == osg::Array::BIND_PER_PRIMITIVE_SET )
{
ccount++;
}

View File

@@ -502,9 +502,10 @@ void DXFWriterNodeVisitor::processGeometry(osg::Geometry* geo, osg::Matrix& m)
OSG_DEBUG << "adding Layer " << _layer._name << std::endl;
// if single colour include in header
if ( osg::Geometry::BIND_OVERALL == geo->getColorBinding() ) {
osg::Array::Binding colorBinding = osg::getBinding(geo->getColorArray());
if ( osg::Array::BIND_OVERALL == colorBinding ) {
_layer._color = _acadColor.findColor(getNodeRGB(geo)); // per layer color
} else if ( osg::Geometry::BIND_OFF== geo->getColorBinding() ) {
} else if ( osg::Array::BIND_OFF== colorBinding ) {
_layer._color = 0xff; // use white - or can we easily lookup in texture?
} else {
_layer._color = 0; // per point color
@@ -514,7 +515,7 @@ void DXFWriterNodeVisitor::processGeometry(osg::Geometry* geo, osg::Matrix& m)
} else {
_layer = _layers[_count++];
OSG_DEBUG << "writing Layer " << _layer._name << std::endl;
processStateSet(_currentStateSet.get());
if ( geo->getNumPrimitiveSets() ) {

View File

@@ -68,11 +68,11 @@ void Normals::MakeNormalsVisitor::apply( Geode &geode )
if( normals == 0L )
continue;
Geometry::AttributeBinding binding = geom->getNormalBinding();
if( binding == Geometry::BIND_OFF )
Array::Binding binding = osg::getBinding(geom->getNormalArray());
if( binding == Array::BIND_OFF )
continue;
if( binding == Geometry::BIND_OVERALL )
if( binding == Array::BIND_OVERALL )
{
Vec3 v(0,0,0);
Vec3 n = normals->front();
@@ -99,7 +99,7 @@ void Normals::MakeNormalsVisitor::apply( Geode &geode )
#ifdef DEBUG
_printPrimitiveType( (*itr).get() );
#endif
if( binding == Geometry::BIND_PER_PRIMITIVE_SET )
if( binding == Array::BIND_PER_PRIMITIVE_SET )
{
Vec3 v(0,0,0);
Vec3 n = *(normals_index++);
@@ -135,7 +135,7 @@ void Normals::MakeNormalsVisitor::apply( Geode &geode )
normals_index++;
}
coord_index += 2;
if( binding == Geometry::BIND_PER_VERTEX )
if( binding == Array::BIND_PER_VERTEX )
normals_index += 2;
break;
}
@@ -185,13 +185,13 @@ void Normals::MakeNormalsVisitor::apply( Geode &geode )
void Normals::MakeNormalsVisitor::_processPrimitive( unsigned int nv,
Vec3Array::iterator coords,
Vec3Array::iterator normals,
Geometry::AttributeBinding binding )
Array::Binding binding )
{
Vec3 v(0,0,0);
Vec3 n(0,0,0);
if( _mode == SurfaceNormals )
{
if( binding == Geometry::BIND_PER_VERTEX )
if( binding == Array::BIND_PER_VERTEX )
{
for( unsigned int i = 0; i < nv; i++ )
n += *(normals++);

View File

@@ -50,7 +50,7 @@ class Normals: public osg::Geode
void _processPrimitive( unsigned int nv,
osg::Vec3Array::iterator coords,
osg::Vec3Array::iterator normals,
osg::Geometry::AttributeBinding binding );
osg::Array::Binding binding );
};
#ifdef DEBUG

View File

@@ -119,7 +119,7 @@ class ObjPrimitiveIndexWriter : public osg::PrimitiveIndexFunctor {
_fout << "/";
if (_hasNormalCoords)
{
if (_geo->getNormalBinding() == osg::Geometry::BIND_PER_VERTEX)
if (osg::getBinding(_geo->getNormalArray()) == osg::Array::BIND_PER_VERTEX)
_fout << (i+_lastNormalIndex);
else
_fout << (_normalIndex + _lastNormalIndex);
@@ -519,7 +519,7 @@ void OBJWriterNodeVisitor::processGeometry(osg::Geometry* geo, osg::Matrix& m) {
_fout << "o " << getUniqueName( geo->getName().empty() ? geo->className() : geo->getName() ) << std::endl;
if (geo->containsDeprecatedData()) geo->fixDeprecatedData();
processStateSet(_currentStateSet.get());
processArray("v", geo->getVertexArray(), m, false);
@@ -533,7 +533,7 @@ void OBJWriterNodeVisitor::processGeometry(osg::Geometry* geo, osg::Matrix& m) {
ObjPrimitiveIndexWriter pif(_fout, geo, normalIndex, _lastVertexIndex, _lastNormalIndex, _lastTexIndex);
ps->accept(pif);
if(geo->getNormalArray() && geo->getNormalBinding() == osg::Geometry::BIND_PER_PRIMITIVE_SET)
if(geo->getNormalArray() && geo->getNormalArray()->getBinding() == osg::Array::BIND_PER_PRIMITIVE_SET)
++normalIndex;
}
if (geo->getVertexArray())

View File

@@ -269,7 +269,7 @@ void ToVRML::apply(osg::Drawable* drawable) {
void ToVRML::apply(osg::Geometry* geom) {
if (geom->containsDeprecatedData()) geom->fixDeprecatedData();
// are all primitives faces or line ?
GLenum mode;
osg::PrimitiveSet::Type type;
@@ -1106,7 +1106,8 @@ void ToVRML::writeNormal(osg::Geometry* geom, std::vector<int>& primitiveSetFace
return;
}
if (geom->getNormalBinding() == osg::Geometry::BIND_PER_VERTEX || geom->getNormalBinding() == osg::Geometry::BIND_OVERALL) {
osg::Array::Binding normalBinding = osg::getBinding(geom->getNormalArray());
if (normalBinding == osg::Array::BIND_PER_VERTEX || normalBinding == osg::Array::BIND_OVERALL) {
_fout << indentM() << "normalPerVertex TRUE \n";
} else {
_fout << indentM() << "normalPerVertex FALSE \n";
@@ -1117,20 +1118,20 @@ void ToVRML::writeNormal(osg::Geometry* geom, std::vector<int>& primitiveSetFace
indentM();
osg::Vec3 n;
if (geom->getNormalBinding() == osg::Geometry::BIND_PER_VERTEX) {
if (normalBinding == osg::Array::BIND_PER_VERTEX) {
for (unsigned int j = 0; j < (*nArray).size(); j++) {
n = (*nArray)[j];
_fout << indent() << n[0] << " " << n[1] << " " << n[2] << ",\n";
}
} else if (geom->getNormalBinding() == osg::Geometry::BIND_OVERALL) {
} else if (normalBinding == osg::Array::BIND_OVERALL) {
n = (*nArray)[0];
int size = ((osg::Vec3Array*) (geom->getVertexArray()))->size();
for (int j = 0; j < size; j++) {
_fout << indent() << n[0] << " " << n[1] << " " << n[2] << ",\n";
}
} else if (geom->getNormalBinding() == osg::Geometry::BIND_PER_PRIMITIVE_SET) {
} else if (normalBinding == osg::Array::BIND_PER_PRIMITIVE_SET) {
for (unsigned int j = 0; j < (*nArray).size(); j++) {
n = (*nArray)[j];
for (int k = 0; k < primitiveSetFaces[j]; k++) {
@@ -1254,7 +1255,8 @@ void ToVRML::writeColor(osg::Geometry* geom, std::vector<int>& primitiveSetFaces
return;
}
if (geom->getColorBinding() == osg::Geometry::BIND_PER_VERTEX || geom->getColorBinding() == osg::Geometry::BIND_OVERALL) {
osg::Array::Binding colorBinding = osg::getBinding(geom->getColorArray());
if (colorBinding == osg::Array::BIND_PER_VERTEX || colorBinding == osg::Array::BIND_OVERALL) {
_fout << indentM() << "colorPerVertex TRUE \n";
} else {
_fout << indentM() << "colorPerVertex FALSE \n";
@@ -1265,20 +1267,20 @@ void ToVRML::writeColor(osg::Geometry* geom, std::vector<int>& primitiveSetFaces
indentM();
osg::Vec4 c;
if (geom->getColorBinding() == osg::Geometry::BIND_PER_VERTEX) {
if (colorBinding == osg::Array::BIND_PER_VERTEX) {
for (unsigned int j = 0; j < (*cArray).size(); j++) {
c = (*cArray)[j];
_fout << indent() << c[0] << " " << c[1] << " " << c[2] << ",\n";
}
} else if (geom->getColorBinding() == osg::Geometry::BIND_OVERALL) {
} else if (colorBinding == osg::Array::BIND_OVERALL) {
c = (*cArray)[0];
int size = ((osg::Vec3Array*) (geom->getVertexArray()))->size();
for (int j = 0; j < size; j++) {
_fout << indent() << c[0] << " " << c[1] << " " << c[2] << ",\n";
}
} else if (geom->getColorBinding() == osg::Geometry::BIND_PER_PRIMITIVE_SET) {
} else if (colorBinding == osg::Array::BIND_PER_PRIMITIVE_SET) {
for (unsigned int j = 0; j < (*cArray).size(); j++) {
c = (*cArray)[j];
for (int k = 0; k < primitiveSetFaces[j]; k++) {

View File

@@ -4,11 +4,11 @@
#include <osgDB/OutputStream>
BEGIN_USER_TABLE( AttributeBinding, osg::Geometry );
ADD_USER_VALUE( BIND_OFF );
ADD_USER_VALUE( BIND_OVERALL );
ADD_USER_VALUE( BIND_PER_PRIMITIVE_SET );
lookup->add("BIND_PER_PRIMITIVE",3); //ADD_USER_VALUE( BIND_PER_PRIMITIVE );
ADD_USER_VALUE( BIND_PER_VERTEX );
lookup->add("BIND_OFF",0); // ADD_USER_VALUE("ADD_USER_VALUE( BIND_OFF );
lookup->add("BIND_OVERALL",1); // ADD_USER_VALUE( BIND_OVERALL );
lookup->add("BIND_PER_PRIMITIVE_SET",2); // ADD_USER_VALUE( BIND_PER_PRIMITIVE_SET );
lookup->add("BIND_PER_PRIMITIVE",3); //ADD_USER_VALUE( BIND_PER_PRIMITIVE );
lookup->add("BIND_PER_VERTEX",4); // ADD_USER_VALUE( BIND_PER_VERTEX );
END_USER_TABLE()
USER_READ_FUNC( AttributeBinding, readAttributeBinding )
@@ -37,7 +37,7 @@ static osg::Array* readArray( osgDB::InputStream& is)
int normalizeValue = 0;
is >> is.PROPERTY("Normalize") >> normalizeValue;
if (array.valid()) array->setNormalize(normalizeValue!=0);
return array.release();
}
@@ -52,7 +52,7 @@ static void writeArray( osgDB::OutputStream& os, const osg::Array* array)
if ( indices!=0 ) os << indices;
else os << std::endl;
os << os.PROPERTY("Binding"); writeAttributeBinding(os, (array!=0) ? static_cast<osg::Geometry::AttributeBinding>(array->getBinding()) : osg::Geometry::BIND_OFF); os << std::endl;
os << os.PROPERTY("Binding"); writeAttributeBinding(os, osg::getBinding(array)); os << std::endl;
os << os.PROPERTY("Normalize") << ((array!=0 && array->getNormalize()) ? 1:0) << std::endl;
}
@@ -123,7 +123,7 @@ struct GeometryFinishedObjectReadCallback : public osgDB::FinishedObjectReadCall
// implement backwards compatibility with reading/writing the FastPathHint
static bool checkFastPathHint( const osg::Geometry& geom ) { return false; }
static bool readFastPathHint( osgDB::InputStream& is, osg::Geometry& geom )
{
{
// Compatibility info:
// Previous Geometry wrapper (before 3.1.8) require a bool fast-path serializer.
// It saves "FastPathHint true" in ascii mode and a single [bool] in binary mode.