Hi Florian
Calling dirty on the modified array should be enough. Are you sure you
set the useDisplayList to false and the useVertexBufferObject to true?
You don't need to call setTexCoordArray unless you want to assign a
different array.
I don't quite recall if you need to set the datavariance of the geometry
to dynamic however, so it might be worth a shot.
Cheers
Sebastian
Greetings fellow OSG users :)
There is a detail in my code that I found disturbing:
Code:
void applyTextureToCenter( MyNameSpace::SpecificNode* floor )
{
MyNameSpace::MyGeode* center = floor->getCenterGeode() ;
osg::StateSet* stateSet = center->getOrCreateStateSet() ;
MyNameSpace::MyGeometry* geometry = center -> getGeometry() ;
const osg::DrawElementsUShort* indices = geometry -> getIndexArray() ;
const osg::Vec3Array* vtxArray = static_cast<osg::Vec3Array*>(
geometry->getVertexArray() ) ;
osg::Vec2Array* texArray = floor ->getTexCoordArray() ;
const unsigned numVertex = geometry->getVertexArray()->getNumElements() ;
const unsigned numIndices = geometry->getIndexArray() ->getNumIndices() ;
for ( unsigned id = 0 ; id < numIndices ; ++id )
{
const unsigned idx = (*indices)[id] ;
osg::Vec2 uv ;
/* *snip*
* some texture coordinates computation
*/
(*texArray)[idx].set( uv.x(), uv.y() ) ;
}
geometry->setTexCoordArray( 0, texArray ) ; //Why is this needed ?
/* *snip*
* Code setting the stateSet parameters (shader program, uniforms...)
*/
return ;
}
I don't understand why the line
Code:
geometry->setTexCoordArray( 0, texArray ) ;
is needed. AFAIK since texArray points to the value given by
getTexCoordArray(), we are not actually changing anything... :?
I was thinking that maybe it was because setTexCoordArray() caused dirty() to
be called, causing re-evaluation of the texture coordinates, but calling
Code:
geometry->getTexCoordArray(0)->dirty() ;
is not enough for my texture to be displayed.
So I went on and looked at the code for setTexCoordArray:
Code:
openscenegraph/OpenSceneGraph/blob/master/src/osg/Geometry.cpp
I see that it is calling
Code:
geometry->dirtyDisplayList() ;
but since we are using VBOs (Vertex Buffer Objects) and not display lists
that should not do anything.
The code is also calling
Code:
geometry->addVertexBufferObjectIfRequired()
, which should itself call
Code:
texArray->setVertexBufferObject(geometry->getOrCreateVertexBufferObject());
, which AFAIK should not be changing anything here either, since it is setting
the array to use the existing VBOs (which should already be the case).
What is your take on this? There must be something I'm missing.
Thank you!
Best regards,
Florian.
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=68035#68035
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org