hi all,
    I want to draw axes in screen position,the axes can't be scaled or 
transformed ,but which can be rotated with other scene.I do it like this,but 
the billboard (texts: 'X','Y','Z') doesn't work,what should I do to make the 
billboard work well?“axes.osg” is downloaded from the osg homepage.
 
osgViewer::Viewer viewer;
class orbit : public osg::NodeCallback 
{
public:
 orbit() {} 
 virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
 {  
  osg::PositionAttitudeTransform *pat = 
dynamic_cast<osg::PositionAttitudeTransform *>(node);
  if( tx != NULL )
  {
       osg::Camera *camera=viewer.getCamera();
       osg::Matrixd pMatrix = camera->getViewMatrix();
       pat->setAttitude(pMatrix.getRotate());
  }   
 }
}; 
osg::Group* fun()
{
   osg::Group *group=new osg::Group();
 
    osg::Node *axis=osgDB::readNodeFile("data\\axes.osg");
    osg::PositionAttitudeTransform * tran = new osg::PositionAttitudeTransform;
    tran->addChild(axis);
    tran->setPosition(osg::Vec3(5,5,0));
    tran->setUpdateCallback(new orbit());
 
    osg::MatrixTransform* ModelViewMatrix = new osg::MatrixTransform;
    ModelViewMatrix->setMatrix(osg::Matrix::identity()); 
    ModelViewMatrix->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
    ModelViewMatrix->addChild(tran);
 
    osg::Projection* ProjectionMatrix = new osg::Projection;
    ProjectionMatrix->setMatrix(osg::Matrix::ortho2D(0,10,0,10)); 
    ProjectionMatrix->addChild(ModelViewMatrix);
    
    group->addChild(ProjectionMatrix);
    return group;
}
 
int _tmain(int argc, _TCHAR* argv[])
{  
 osg::Group *mRoot =fun(); 
 viewer.setSceneData(mRoot);
 return viewer.run();
}
 
best regards
 
forest
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to