1、新建vs控制台项目,勾选空项目
2、新建.h文件命名为osg.h,用来包含用到的OSG头文件
#include <osgViewer/Viewer>
#include <osgDB/ReadFile>
#include <osgViewer/Viewer>
#include <osg/Node>
#include <osg/MatrixTransform>
#include <osgUtil/Optimizer>
3、新建cpp文件,用来写回调,以及主函数
4、在cpp文件中加入以下代码。
//******************************************************************//
// 此文件中添加mycallback回调函数和主程序 //
//******************************************************************//
#include "osg.h"
#include <Windows.h>
//添加回调
class mycallback:public osg::NodeCallback
{
public:
mycallback(float pos)
{
m_pos=pos;
}
virtual void operator() (osg::Node* node,osg::NodeVisitor* nv)
{
osg::ref_ptr<osg::MatrixTransform> transpos=dynamic_cast<osg::MatrixTransform*>(node);
if (nv&&tra