[osg-users] UpdateCallback

Robert Osfield robert.osfield at gmail.com
Wed Aug 26 00:31:19 PDT 2015


Hi Julie,

On 26 August 2015 at 08:06, Julie Green <laroux92 at mail.ru> wrote:

> Stupid me finally got it.
>
> Code:
>
> osg::Geometry surface = new osg::Geometry();
> surface->setVertexArray(vertexArray);
> surface->setDataVariance(osg::Object::DYNAMIC);
> surface->setUpdateCallback(new UpdateSurfaceCallback());
>
>
> What i don't understand is how to get elements of vertex array in operator
> method using node pointer.
>
>

Either do a asGeometry() or a dynamic_cast of the Node* to osg::Geometry*
and then get the arrays from there. i.e



void UpdateSurfaceCallback::operator()(Node* node, NodeVisitor*)
{
    osg::Geometry* geometry = node->asGeometry();  // asGeometry() is
faster than dynamic_cast<>, but requires Node* to be a valid object.
    if (geometry)
    {
         osg::Array* vertices = geometry->getVertexArray();
         .....
    }
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20150826/206ef165/attachment-0002.htm>


More information about the osg-users mailing list