Thanks for the response, Robert. I'm in the midst of a small rewrite to try
something else to optimize my code and now I have another question: In my
UpdateCallBack for all my many quads I want to add a new quad only when it is
needed. However, with the code below I get a break point (exception) when OSG
calls its draw() method. So my question is: what is the appropriate way to
add/update vertices in a dynamic fashion. If you could just point me to one of
OSG's many fine examples that would be sufficient. Thanks.
virtual void operator() (osg::Node* node, osg::NodeVisitor* nv)
{
if( isInitialized ) {
osg::Geode *geode = dynamic_cast<osg::Geode*> (node);
if (nv && geode && nv->getFrameStamp())
{
osg::Geometry *nodeGeom = dynamic_cast<osg::Geometry*> (geode->getDrawable(1));
osg::Geometry *tailGeom = dynamic_cast<osg::Geometry*> (geode->getDrawable(0));
if( nodeGeom && tailGeom ) {
osg::Vec3Array *nodeVecs = dynamic_cast<osg::Vec3Array*>
(nodeGeom->getVertexArray());
osg::Vec3Array *tailVecs = dynamic_cast<osg::Vec3Array*>
(tailGeom->getVertexArray());
if( nodeVecs && tailVecs ) {
for( std::map< unsigned int,NODE >::iterator iter_node=nodeList.begin();
iter_node!=nodeList.end(); iter_node++ ) {
unsigned int nodeIndex = iter_node->first;
NODE thisNode = iter_node->second;
if( nodeIndex>=(nodeVecs->size()*4) ) {
nodeVecs->push_back(osg::Vec3(thisNode.pos_x-NODEWIDTH/2,
thisNode.pos_y-NODEHEIGHT/2, 0.0));
nodeVecs->push_back(osg::Vec3(thisNode.pos_x+NODEWIDTH/2,
thisNode.pos_y-NODEHEIGHT/2, 0.0));
nodeVecs->push_back(osg::Vec3(thisNode.pos_x+NODEWIDTH/2,
thisNode.pos_y+NODEHEIGHT/2, 0.0));
nodeVecs->push_back(osg::Vec3(thisNode.pos_x-NODEWIDTH/2,
thisNode.pos_y+NODEHEIGHT/2, 0.0));
}//if
}//for nodes
nodeGeom->setVertexArray(nodeVecs);
tailGeom->setVertexArray(tailVecs);
}//if vecs
}//if geom
}
}//if isInitialized
// must continue subgraph traversal.
traverse(node,nv);
}
_________________________________________________________________
Peek-a-boo FREE Tricks & Treats for You!
http://www.reallivemoms.com?ocid=TXT_TAGHM&loc=us
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org