Hi Laurens,
On 21 June 2013 10:17, Laurens Voerman <[email protected]> wrote:
> attached is an update for OpenSceneGraph\src\osgPlugins\fbx\fbxRMesh.cpp to
> compile with current svn.
> tested on windows only.
I've review your change but feel it's a bit awkward and long winded,
pointing to a problem with the new API. This gave me a little prod to
implement something I was considering to do earlier but hadn't got
round to yet so I've gone ahead and implemented the addition of a
Array::Binding parameter to the set*Array methods:
They are of the form:
void setNormalArray(Array* array, osg::Array::Binding
binding=osg::Array::BIND_UNDEFINED);
If the binding is the default osg::Array::BIND_UNDEFINED then nothing
happens, otherwise it applies this binding via an
array->setBinding(binding).
With this new API it become a lot cleaner to map the old ArrayData
based calls in the fbx plugin across to the new set*Array methods
thus:
$ svn diff
Index: src/osgPlugins/fbx/fbxRMesh.cpp
===================================================================
--- src/osgPlugins/fbx/fbxRMesh.cpp (revision 13511)
+++ src/osgPlugins/fbx/fbxRMesh.cpp (working copy)
@@ -178,19 +178,19 @@
osgDB::Options::PrecisionHint precision = options.getPrecisionHint();
-
pGeometry->setVertexData(osg::Geometry::ArrayData(createVec3Array((precision
& osgDB::Options::DOUBLE_PRECISION_VERTEX) != 0),
osg::Geometry::BIND_PER_VERTEX));
- if (bNormal)
pGeometry->setNormalData(osg::Geometry::ArrayData(createVec3Array((precision
& osgDB::Options::DOUBLE_PRECISION_NORMAL) != 0),
osg::Geometry::BIND_PER_VERTEX));
+ pGeometry->setVertexArray(createVec3Array((precision &
osgDB::Options::DOUBLE_PRECISION_VERTEX) != 0),
osg::Array::BIND_PER_VERTEX);
+ if (bNormal) pGeometry->setNormalArray(createVec3Array((precision
& osgDB::Options::DOUBLE_PRECISION_NORMAL) != 0),
osg::Array::BIND_PER_VERTEX);
// create as much textures coordinates as needed...
if (useDiffuseMap)
- pGeometry->setTexCoordData(StateSetContent::DIFFUSE_TEXTURE_UNIT,
osg::Geometry::ArrayData(createVec2Array((precision &
osgDB::Options::DOUBLE_PRECISION_TEX_COORD) != 0),
osg::Geometry::BIND_PER_VERTEX));
+ pGeometry->setTexCoordArray(StateSetContent::DIFFUSE_TEXTURE_UNIT,
createVec2Array((precision &
osgDB::Options::DOUBLE_PRECISION_TEX_COORD) != 0),
osg::Array::BIND_PER_VERTEX);
if (useOpacityMap)
- pGeometry->setTexCoordData(StateSetContent::OPACITY_TEXTURE_UNIT,
osg::Geometry::ArrayData(createVec2Array((precision &
osgDB::Options::DOUBLE_PRECISION_TEX_COORD) != 0),
osg::Geometry::BIND_PER_VERTEX));
+ pGeometry->setTexCoordArray(StateSetContent::OPACITY_TEXTURE_UNIT,
createVec2Array((precision &
osgDB::Options::DOUBLE_PRECISION_TEX_COORD) != 0),
osg::Geometry::BIND_PER_VERTEX);
if (useEmissiveMap)
- pGeometry->setTexCoordData(StateSetContent::EMISSIVE_TEXTURE_UNIT,
osg::Geometry::ArrayData(createVec2Array((precision &
osgDB::Options::DOUBLE_PRECISION_TEX_COORD) != 0),
osg::Geometry::BIND_PER_VERTEX));
+ pGeometry->setTexCoordArray(StateSetContent::EMISSIVE_TEXTURE_UNIT,
createVec2Array((precision &
osgDB::Options::DOUBLE_PRECISION_TEX_COORD) != 0),
osg::Geometry::BIND_PER_VERTEX);
// create more textures coordinates here...
- if (bColor)
pGeometry->setColorData(osg::Geometry::ArrayData(createVec4Array((precision
& osgDB::Options::DOUBLE_PRECISION_COLOR) != 0),
osg::Geometry::BIND_PER_VERTEX));
+ if (bColor) pGeometry->setColorArray(createVec4Array((precision &
osgDB::Options::DOUBLE_PRECISION_COLOR) != 0),
osg::Geometry::BIND_PER_VERTEX);
if (mti < stateSetList.size())
{
I have made this change and checked it in to svn/trunk. I don't know
if it compiles and works though... Could you test out svn/trunk and
let me know.
Thanks,
Robert.
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org