Replaced deprecated Geometry::set*Binding()

This commit is contained in:
Robert Osfield 2013-06-27 08:30:51 +00:00
parent 8e65ab7e45
commit 38bb71460a
8 changed files with 34 additions and 55 deletions

View File

@ -607,7 +607,7 @@ osg::Node* ReaderWriter3DS::ReaderObject::processNode(StateSetMap& drawStateMap,
meshTransform=new osg::MatrixTransform(meshMat);
meshAppliedMatPtr=NULL; // since meshTransform applies it
meshTransform->setName("3DSMeshMatrix");
meshTransform->setName("3DSMeshMatrix");
if (group) group->addChild(meshTransform);
} else {
meshTransform=group; // don't need the meshTransform node - note group can be NULL
@ -1027,8 +1027,7 @@ osg::Drawable* ReaderWriter3DS::ReaderObject::createDrawable(Lib3dsMesh *m,FaceL
osg::ref_ptr<osg::Vec3Array> osg_normals = new osg::Vec3Array();
osg_normals->reserve(m->nvertices);
geom->setNormalArray(osg_normals.get());
geom->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
geom->setNormalArray(osg_normals.get(), osg::Array::BIND_PER_VERTEX);
osg::ref_ptr<osg::Vec2Array> osg_texCoords = NULL;
@ -1085,8 +1084,7 @@ osg::Drawable* ReaderWriter3DS::ReaderObject::createDrawable(Lib3dsMesh *m,FaceL
// Set geometry color to white.
osg::ref_ptr<osg::Vec4ubArray> osg_colors = new osg::Vec4ubArray(1);
(*osg_colors)[0].set(255,255,255,255);
geom->setColorArray(osg_colors.get());
geom->setColorBinding(osg::Geometry::BIND_OVERALL);
geom->setColorArray(osg_colors.get(), osg::Array::BIND_OVERALL);
// Create triangle primitives.
int numIndices = faceCount * 3;
@ -1146,7 +1144,7 @@ osg::Texture2D* ReaderWriter3DS::ReaderObject::createTexture(Lib3dsTextureMap *
}
else
{
// MIKEC: We can still continue to call osgDB::readRefImageFile in case user has a ReadFileCallback registered
// MIKEC: We can still continue to call osgDB::readRefImageFile in case user has a ReadFileCallback registered
// in that case we just use the image's filename as it exists in the 3DS file
fileName=texture->name;
}

View File

@ -772,9 +772,8 @@ class LineBin : public PrimitiveBin
{
_geode->addDrawable(_geometry.get());
material.toStateSet(_geode->getOrCreateStateSet());
_geometry->setColorArray(material.getColorArray());
_geometry->setColorBinding(osg::Geometry::BIND_OVERALL);
_geometry->setNormalBinding(osg::Geometry::BIND_OFF);
_geometry->setColorArray(material.getColorArray(), osg::Array::BIND_OVERALL);
_geometry->setNormalArray(0);
return _geode.get();
}
};
@ -1010,20 +1009,15 @@ class SurfaceBin : public PrimitiveBin {
osg::Geometry* geometry = new osg::Geometry;
_geode->addDrawable(geometry);
geometry->setDataVariance(osg::Object::STATIC);
geometry->setColorArray(material.getColorArray());
geometry->setColorBinding(osg::Geometry::BIND_OVERALL);
geometry->setColorArray(material.getColorArray(), osg::Array::BIND_OVERALL);
osg::Vec3Array* normalArray = new osg::Vec3Array;
normalArray->setDataVariance(osg::Object::STATIC);
geometry->setNormalArray(normalArray);
geometry->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
geometry->setNormalArray(normalArray, osg::Array::BIND_PER_VERTEX);
osg::Vec3Array* vertexArray = new osg::Vec3Array;
vertexArray->setDataVariance(osg::Object::STATIC);
geometry->setVertexArray(vertexArray);
osg::Vec2Array* texcoordArray = 0;
if (textureData.valid())
{
texcoordArray = new osg::Vec2Array;
texcoordArray->setDataVariance(osg::Object::STATIC);
geometry->setTexCoordArray(0, texcoordArray);
}

View File

@ -637,15 +637,13 @@ ref_ptr<Group> VBSPGeometry::createGeometry()
// Add the vertex attributes
geometry->setVertexArray(vertex_array.get());
geometry->setNormalArray(normal_array.get());
geometry->setNormalBinding(Geometry::BIND_PER_VERTEX);
geometry->setNormalArray(normal_array.get(), Array::BIND_PER_VERTEX);
geometry->setTexCoordArray(0, texcoord_array.get());
// Add an overall color
color.set(1.0, 1.0, 1.0, 1.0);
colorArray = new Vec4Array(1, &color);
geometry->setColorArray(colorArray.get());
geometry->setColorBinding(Geometry::BIND_OVERALL);
geometry->setColorArray(colorArray.get(), Array::BIND_OVERALL);
// Add our primitive set to the geometry
geometry->addPrimitiveSet(primitive_set.get());
@ -668,12 +666,10 @@ ref_ptr<Group> VBSPGeometry::createGeometry()
// Add the vertex attributes
geometry->setVertexArray(disp_vertex_array.get());
geometry->setNormalArray(disp_normal_array.get());
geometry->setNormalBinding(Geometry::BIND_PER_VERTEX);
geometry->setNormalArray(disp_normal_array.get(), Array::BIND_PER_VERTEX);
geometry->setColorArray(disp_vertex_attr_array.get(), Array::BIND_PER_VERTEX);
geometry->setTexCoordArray(0, disp_texcoord_array.get());
geometry->setTexCoordArray(1, disp_texcoord_array.get());
geometry->setColorArray(disp_vertex_attr_array.get());
geometry->setColorBinding(Geometry::BIND_PER_VERTEX);
// Add our primitive set to the geometry
geometry->addPrimitiveSet(disp_primitive_set.get());

View File

@ -233,8 +233,7 @@ osgDB::ReaderWriter::ReadResult ReaderWriterLWO::readNode_LWO1(const std::string
lw_material.b,
1.0f);
gc._geom->setColorArray(colors);
gc._geom->setColorBinding(osg::Geometry::BIND_OVERALL);
gc._geom->setColorArray(colors, osg::Array::BIND_OVERALL);
// set up texture if needed.
if (gc._numPrimitivesWithTexCoords==gc._numPrimitives)

View File

@ -340,8 +340,7 @@ osg::Group *Surface::apply(osg::Geometry *geo, const VertexMap_map *texture_maps
if (color_maps) {
VertexMap_map::const_iterator i = color_maps->find(color_map_name_);
if (i != color_maps->end() && !i->second->empty()) {
geo->setColorArray(i->second->asVec4Array(num_points, color * color_map_intensity_, color * color_map_intensity_));
geo->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
geo->setColorArray(i->second->asVec4Array(num_points, color * color_map_intensity_, color * color_map_intensity_), osg::Array::BIND_PER_VERTEX);
} else {
OSG_WARN << "Warning: lwosg::Surface: surface '" << name_ << "' needs color map named '" << color_map_name_ << "' but I can't find it" << std::endl;
}

View File

@ -675,8 +675,7 @@ Lwo2::GenerateGroup( Group& group )
if (material) {
Vec4Array* colors = new Vec4Array();
colors->push_back(material->getDiffuse(Material::FRONT_AND_BACK));
geometry->setColorBinding(Geometry::BIND_OVERALL);
geometry->setColorArray(colors);
geometry->setColorArray(colors, osg::Array::BIND_OVERALL);
}
}
}

View File

@ -452,8 +452,7 @@ osg::Node* VertexData::readPlyFile( const char* filename, const bool ignoreColor
// Set the normals
if (_normals.valid())
{
geom->setNormalArray(_normals.get());
geom->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
geom->setNormalArray(_normals.get(), osg::Array::BIND_PER_VERTEX);
}
// Add the primitive set
@ -469,23 +468,19 @@ osg::Node* VertexData::readPlyFile( const char* filename, const bool ignoreColor
if(_colors.valid())
{
geom->setColorArray(_colors.get());
geom->setColorBinding( osg::Geometry::BIND_PER_VERTEX );
geom->setColorArray(_colors.get(), osg::Array::BIND_PER_VERTEX );
}
else if(_ambient.valid())
{
geom->setColorArray(_ambient.get());
geom->setColorBinding( osg::Geometry::BIND_PER_VERTEX );
geom->setColorArray(_ambient.get(), osg::Array::BIND_PER_VERTEX );
}
else if(_diffuse.valid())
{
geom->setColorArray(_diffuse.get());
geom->setColorBinding( osg::Geometry::BIND_PER_VERTEX );
geom->setColorArray(_diffuse.get(), osg::Array::BIND_PER_VERTEX );
}
else if(_specular.valid())
{
geom->setColorArray(_specular.get());
geom->setColorBinding( osg::Geometry::BIND_PER_VERTEX );
geom->setColorArray(_specular.get(), osg::Array::BIND_PER_VERTEX );
}
// set flage true to activate the vertex buffer object of drawable

View File

@ -74,9 +74,9 @@ struct AssignDirectionColour
colours = new osg::Vec4Array;
geometry->setColorArray(colours.get());
}
geometry->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
colours->setBinding(osg::Array::BIND_PER_VERTEX);
colours->resize(vertices->size(), osg::Vec4(0.0,0.0,0.0,0.0));
#if 1
#if 1
// allocate normals
osg::ref_ptr<osg::Vec3Array> normals = dynamic_cast<osg::Vec3Array*>(geometry->getNormalArray());
if (!normals)
@ -84,7 +84,7 @@ struct AssignDirectionColour
normals = new osg::Vec3Array;
geometry->setNormalArray(normals.get());
}
geometry->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
normals->setBinding(osg::Array::BIND_PER_VERTEX);
normals->resize(vertices->size(), osg::Vec3(0.0,0.0,0.0));
#endif
@ -147,11 +147,11 @@ struct AssignDirectionColour
if (divisors[vi_1]==0.0f) n1 = normal;
else n1 += normal;
#endif
divisors[vi_0] += 1.0f;
divisors[vi_1] += 1.0f;
}
}
}
}
for(unsigned int vi=0; vi<vertices->size(); ++vi)
@ -160,12 +160,12 @@ struct AssignDirectionColour
{
(*colours)[vi] /= divisors[vi];
(*normals)[vi].normalize();
}
}
std::string vertexShaderFile("track.vert");
osg::ref_ptr<osg::StateSet> stateset = geometry->getOrCreateStateSet();
osg::ref_ptr<osg::Program> program = new osg::Program;
@ -211,7 +211,7 @@ class ReaderWriterTRK : public osgDB::ReaderWriter
TrkHeader header;
fin.read(reinterpret_cast<char*>(&header), sizeof(TrkHeader));
if (fin.fail()) return ReadResult::ERROR_IN_READING_FILE;
if (fin.fail()) return ReadResult::ERROR_IN_READING_FILE;
OSG_NOTICE<<"Read header successfuly ["<<header.id_string<<"]"<<std::endl;
bool requiresByteSwap = header.hdr_size!=1000;
@ -234,7 +234,7 @@ class ReaderWriterTRK : public osgDB::ReaderWriter
osg::Matrixf matrix(reinterpret_cast<const float*>(header.vox_to_ras));
OSG_NOTICE<<"vox_to_ras="<<matrix<<std::endl;
OSG_NOTICE<<"invert_x="<<static_cast<int>(header.invert_x)<<std::endl;
OSG_NOTICE<<"invert_y="<<static_cast<int>(header.invert_y)<<std::endl;
OSG_NOTICE<<"invert_z="<<static_cast<int>(header.invert_z)<<std::endl;
@ -261,10 +261,9 @@ class ReaderWriterTRK : public osgDB::ReaderWriter
osg::ref_ptr<osg::StateSet> stateset = new osg::StateSet;
stateset->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
geometry->setStateSet(stateset.get());
#endif
#endif
osg::ref_ptr<osg::Vec4Array> colours = new osg::Vec4Array;
geometry->setColorArray(colours.get());
geometry->setColorBinding(osg::Geometry::BIND_OVERALL);
geometry->setColorArray(colours.get(), osg::Array::BIND_OVERALL);
colours->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
osg::ref_ptr<osg::Vec3Array> vertices = new osg::Vec3Array;
@ -289,7 +288,7 @@ class ReaderWriterTRK : public osgDB::ReaderWriter
float* point_data = new float[n_point_floats];
fin.read(reinterpret_cast<char*>(point_data), n_point_floats*4);
if (fin.fail()) break;
if (n_p!=0)
{
float* property_data = new float[n_p];
@ -322,7 +321,7 @@ class ReaderWriterTRK : public osgDB::ReaderWriter
delete [] point_data;
}
if (fin.fail())
{
OSG_NOTICE<<"Error on reading track file."<<std::endl;
@ -345,7 +344,7 @@ class ReaderWriterTRK : public osgDB::ReaderWriter
osgDB::ifstream fin(fileName.c_str(), std::ios::in | std::ios::binary);
if(!fin) return ReadResult::FILE_NOT_HANDLED;
return readNode(fin, options);
}
};