Hi Mathieu,
On 21 June 2013 09:55, Mathieu MARACHE <[email protected]> wrote:
> Unfortunatly, osgdb_dae compilation is broken, it looks like it's using the
> removed indexed geometry API.
Getting COLLADA to compile will likely to me a while so rather than
wait for this I thought I'd have a bash at converting to ArrayData
based code to what the equivilant should be using osg::Array. I have
made these changes and checked them into svn/trunk, I haven't been
able to test the compile of them though as I don't have COLLADA built
yet. Could you try out an svn update and let me know if this gets the
build a bit further along.
Below are the changes I've made to the dae plugin. Fingers cross this
will be near to the final form that we'll need.
Cheers,
Robert.
$ svn diff
Index: src/osgPlugins/dae/daeRGeometry.cpp
===================================================================
--- src/osgPlugins/dae/daeRGeometry.cpp (revision 13511)
+++ src/osgPlugins/dae/daeRGeometry.cpp (working copy)
@@ -462,8 +462,8 @@
osg::ref_ptr<osg::Geometry> geometry = new osg::Geometry();
if (NULL != group->getMaterial())
geometry->setName(group->getMaterial());
-
+
osg::ref_ptr<osg::DrawElementsUInt> pDrawElements = new
osg::DrawElementsUInt(mode);
geometry->addPrimitiveSet(pDrawElements.get());
@@ -773,7 +773,7 @@
return false;
}
- /// Templated getter for memebers, used for createGeometryData()
+ /// Templated getter for memebers, used for createGeometryArray()
enum ValueType { POSITION, COLOR, NORMAL, TEXCOORD };
template <int Value>
inline int get() const;
@@ -796,12 +796,12 @@
typedef std::map<VertexIndices, GLuint> VertexIndicesIndexMap;
-/// Creates a value array, packed in a osg::Geometry::ArrayData,
corresponding to indexed values.
+/// Creates a value array, packed in a osg::Array, corresponding to
indexed values.
template <class ArrayType, int Value>
-osg::Geometry::ArrayData createGeometryData(domSourceReader &
sourceReader, const VertexIndicesIndexMap & vertexIndicesIndexMap, int
texcoordNum=-1) {
+ArrayType createGeometryArray(domSourceReader & sourceReader, const
VertexIndicesIndexMap & vertexIndicesIndexMap, int texcoordNum=-1) {
const ArrayType * source = sourceReader.getArray<ArrayType>();
- if (!source) return osg::Geometry::ArrayData();
- ArrayType * pArray = new ArrayType;
+ if (!source) return 0;
+ ArrayType * pArray = new ArrayType(osg::Geometry::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));
@@ -809,17 +809,17 @@
// Invalid data (index out of bounds)
//LOG_WARN << ...
//pArray->push_back(0);
- return osg::Geometry::ArrayData();
+ return 0;
}
}
- return osg::Geometry::ArrayData(pArray, osg::Geometry::BIND_PER_VERTEX);
+ return pArray;
}
template <class ArrayTypeSingle, class ArrayTypeDouble, int Value>
-inline osg::Geometry::ArrayData createGeometryData(domSourceReader &
sourceReader, const VertexIndicesIndexMap & vertexIndicesIndexMap,
bool useDoublePrecision, int texcoordNum=-1) {
- if (useDoublePrecision) return
createGeometryData<ArrayTypeDouble, Value>(sourceReader,
vertexIndicesIndexMap, texcoordNum);
- else return
createGeometryData<ArrayTypeSingle, Value>(sourceReader,
vertexIndicesIndexMap, texcoordNum);
+inline osg::Array* createGeometryArray(domSourceReader &
sourceReader, const VertexIndicesIndexMap & vertexIndicesIndexMap,
bool useDoublePrecision, int texcoordNum=-1) {
+ if (useDoublePrecision) return
createGeometryArray<ArrayTypeDouble, Value>(sourceReader,
vertexIndicesIndexMap, texcoordNum);
+ else return
createGeometryArray<ArrayTypeSingle, Value>(sourceReader,
vertexIndicesIndexMap, texcoordNum);
}
@@ -919,28 +919,28 @@
// Vertices
{
- osg::Geometry::ArrayData arrayData(
createGeometryData<osg::Vec3Array, osg::Vec3dArray,
VertexIndices::POSITION>(sources[position_source],
vertexIndicesIndexMap, readDoubleVertices) );
- if (arrayData.array.valid())
+ osg::ref_ptr<osg::Array> array(
createGeometryArray<osg::Vec3Array, osg::Vec3dArray,
VertexIndices::POSITION>(sources[position_source],
vertexIndicesIndexMap, readDoubleVertices) );
+ if (array.valid())
{
- geometry->setVertexData(arrayData);
+ geometry->setVertexArray(array.get());
}
}
if (color_source)
{
- osg::Geometry::ArrayData arrayData(
createGeometryData<osg::Vec4Array, osg::Vec4dArray,
VertexIndices::COLOR>(sources[color_source], vertexIndicesIndexMap,
readDoubleColors) );
- if (arrayData.array.valid())
+ osg::ref_ptr<osg::Array> array(
createGeometryArray<osg::Vec4Array, osg::Vec4dArray,
VertexIndices::COLOR>(sources[color_source], vertexIndicesIndexMap,
readDoubleColors) );
+ if (array.valid())
{
- geometry->setColorData(arrayData);
+ geometry->setColorArray(array.get());
}
}
if (normal_source)
{
- osg::Geometry::ArrayData arrayData(
createGeometryData<osg::Vec3Array, osg::Vec3dArray,
VertexIndices::NORMAL>(sources[normal_source], vertexIndicesIndexMap,
readDoubleNormals) );
- if (arrayData.array.valid())
+ osg::ref_ptr<osg::Array> array(
createGeometryArray<osg::Vec3Array, osg::Vec3dArray,
VertexIndices::NORMAL>(sources[normal_source], vertexIndicesIndexMap,
readDoubleNormals) );
+ if (array.valid())
{
- geometry->setNormalData(arrayData);
+ geometry->setNormalArray(array.get());
}
}
@@ -952,18 +952,18 @@
//We keep somewhere the mapping between daeElement id and
created arrays
_texCoordIdMap.insert(std::pair<std::string,size_t>(id,texcoord_set));
// 2D Texcoords
- osg::Geometry::ArrayData arrayData(
createGeometryData<osg::Vec2Array, osg::Vec2dArray,
VertexIndices::TEXCOORD>(sources[texcoord_source],
vertexIndicesIndexMap, readDoubleTexcoords, texcoord_set) );
- if (arrayData.array.valid())
+ osg::ref_ptr<osg::Array> array(
createGeometryArray<osg::Vec2Array, osg::Vec2dArray,
VertexIndices::TEXCOORD>(sources[texcoord_source],
vertexIndicesIndexMap, readDoubleTexcoords, texcoord_set) );
+ if (array.valid())
{
- geometry->setTexCoordData(texcoord_set, arrayData);
+ geometry->setTexCoordArray(texcoord_set, array.get());
}
else
{
// 3D Textcoords
- osg::Geometry::ArrayData arrayData(
createGeometryData<osg::Vec3Array, osg::Vec3dArray,
VertexIndices::TEXCOORD>(sources[texcoord_source],
vertexIndicesIndexMap, readDoubleTexcoords, texcoord_set) );
- if (arrayData.array.valid())
+ osg::ref_ptr<osg::Array> array(
createGeometryArray<osg::Vec3Array, osg::Vec3dArray,
VertexIndices::TEXCOORD>(sources[texcoord_source],
vertexIndicesIndexMap, readDoubleTexcoords, texcoord_set) );
+ if (array.valid())
{
- geometry->setTexCoordData(texcoord_set, arrayData);
+ geometry->setTexCoordArray(texcoord_set, array.get());
}
}
}
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org