|
楼主 |
发表于 2010-4-13 14:07:02
|
显示全部楼层
想利用节点更新回调来实现粒子运动,//利用节点更新回调来产生动画class AgentsCallback : public osg::NodeCallback
{
protected:
float _x,_y,_r;
float _nx,_ny,_nr;
int i;
public:
AgentsCallback() : osg::NodeCallback(),_x(0.0),_y(0.0),_r(0.0),_nx(0.0),_ny(0.0),_nr(0.0),i(0) {}
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
{
osg:ositionAttitudeTransform* pat = dynamic_cast<osg::PositionAttitudeTransform*>(node);
if (pat)
{
_x = rbModel.m_uTemporaryAry[i].position_x;
_y = rbModel.m_uTemporaryAry[i].position_y;
_r = rbModel.m_uTemporaryAry[i].radii;
rbModel.SetTemporaryAry(i);
if (rbModel.m_uTemporaryAry[i].position_x<300 && rbModel.m_uTemporaryAry[i].position_y<300)
{
rbModel.ResetPos(i);
}
_nx = rbModel.m_uTemporaryAry[i].position_x;
_ny = rbModel.m_uTemporaryAry[i].position_y;
_nr = rbModel.m_uTemporaryAry[i].radii;
pat->setPosition(osg::Vec3(_nx-_x,_ny-_y,0.0));
i+=1;
}
traverse(node,nv);
}
}; |
|