|
楼主 |
发表于 2016-6-3 14:59:02
|
显示全部楼层
class TD_UpdateRigGeometry : public osg:rawable::UpdateCallback
{
public:
TD_UpdateRigGeometry();
TD_UpdateRigGeometry(const TD_UpdateRigGeometry&, const osg::CopyOp&);
META_Object(osgAnimation, TD_UpdateRigGeometry);
virtual void update(osg::NodeVisitor*, osg::Drawable* drw);
};
class NodeTriangleMeshVistor:public osg::NodeVisitor
{
public:
NodeTriangleMeshVistor();
~NodeTriangleMeshVistor();
public:
virtual void apply(osg::Node& node);
virtual void apply(osg::Geometry& geometry);
}
这里重写update的时候参考源码UpdateRigGeometry结构体中实现的update,copy过来就行,因为播动画的时候必须要调用geometry->update()来更新几何体的数据,否则显示不正确,所以我就重写了update,在开头直接获取顶点数据即可,如下:
osg::Geometry *testGeom = dynamic_cast<osg::Geometry*>(drw);
if (testGeom){
CDApp::TriangleMeshPtr pMesh(new CDApp::TriangleMesh);
TD_getGeometryVertexs(testGeom, pMesh);
TD_gMeshList = pMesh;
}
这个需要自己加到update里面去。 |
|