Hi,   I want to write a class from osg::Drawable::UpdateCallback to update a 
Geometry call named geom,but there is no update happen.I dot't know what's 
wrong.Does someone knows?Thanks in advance!NiuHeming
 
class niuhm : public osg::Drawable::UpdateCallback{    public:
        niuhm(const osg::Vec3& v11,const osg::Vec3& v22,const osg::Vec3& v33)   
     {                v1=v11;                v2=v22;               v2=v33;      
            bs.radius()*=1.5f;                
bs=osg::BoundingSphere(osg::Vec3(0.0f,0.0f,0.0f),4.0f);                     
bb.expandBy(bs);        }            virtual void update(osg::NodeVisitor* nv, 
osg::Drawable* node)        {            osg::Geometry* geom = 
dynamic_cast<osg::Geometry*>(node);            const osg::FrameStamp* 
frameStamp = nv->getFrameStamp();            if (geom && frameStamp)            
{
                  osg::PositionAttitudeTransform* mt = new 
osg::PositionAttitudeTransform();                  {                     // set 
up the animation path                       osg::AnimationPath* animationPath = 
new osg::AnimationPath;                      
animationPath->insert(0.0,osg::AnimationPath::ControlPoint(bb.corner(0)));      
                
animationPath->insert(1.0,osg::AnimationPath::ControlPoint(bb.corner(1)));      
                 
animationPath->insert(2.0,osg::AnimationPath::ControlPoint(bb.corner(2)));      
                 
animationPath->insert(3.0,osg::AnimationPath::ControlPoint(bb.corner(3)));      
                   
animationPath->insert(4.0,osg::AnimationPath::ControlPoint(bb.corner(0)));      
                 animationPath->setLoopMode(osg::AnimationPath::SWING);         
              mt->setUpdateCallback(new 
osg::AnimationPathCallback(animationPath));                  }                  
    // create marker for point light.                    
   osg::Vec3 vertices = mt->getPosition();
 
                          unsigned int noXSteps = 100;                          
unsigned int noYSteps = 100;                          osg::Vec3Array* coords = 
new osg::Vec3Array;                      coords->reserve(noXSteps*noYSteps);    
                          osg::Vec3 dx = (v2-v1)/((float)noXSteps-1.0f);        
              osg::Vec3 dy = (v3-v1)/((float)noYSteps-1.0f);
                         unsigned int rowvertices;                           
unsigned int colvertices;                        rowvertices=(unsigned 
int)((vertices._v[0])/(dx._v[0]));                         
colvertices=(unsigned int)((vertices._v[1])/(dy._v[1]));                        
    unsigned int row;                       osg::Vec3 vRowStart = v1;           
             for(row=0;row<noYSteps;++row){                            
osg::Vec3 v = vRowStart;                            for(unsigned int 
col=0;col<noXSteps;++col){                               if 
((row==rowvertices)&&(col==colvertices))                                 
coords->push_back(v+osg::Vec3(0.0f,0.0f,-1.0f));                                
else                                  coords->push_back(v);
                                v += dx;                                 }      
                     vRowStart+=dy;                        }                    
                 geom->setVertexArray(coords);             }                 }  
         osg::Vec3 v1;           osg::Vec3 v2;           osg::Vec3 v3;          
  osg::BoundingSphere bs;            osg::BoundingBox bb;
};
_________________________________________________________________
MSN圣诞礼物火热登场,免费发放中,快来领取吧!
http://im.live.cn/emoticons/?ID=18
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to