// osg_lesson01.cpp : 定义控制台应用程序的入口点。
//
#include "../Common/Common.h"
#include<osgViewer/Viewer>
#include<osgDB/ReadFile>
#include <osgGA/GUIEventAdapter>
#include <osgViewer/ViewerEventHandlers>
#include <osgGA/TrackballManipulator>
#include <osg/Geode>
#include <osg/ShapeDrawable>
#include<iostream>
#include<osg/Material>
#include <osg/Image>
#include <osg/Texture2D>
#include<osg/LineWidth>
#include<osg/MatrixTransform>
#ifdef _DEBUG
#pragma comment(lib,"../Debug/Common.lib")
#else
#pragma comment(lib,"../Release/Common.lib")
#endif
//Matrix Operation
osg::ref_ptr<osg::Node> MatrixOperation()
{
osg::ref_ptr<osg::Group>group=new osg::Group;
osg::ref_ptr<osg::MatrixTransform> max=new osg::MatrixTransform;
osg::ref_ptr<osg::Node> node = osgDB::readNodeFile("glider.osg");
osg::ref_ptr<osg::MatrixTransform> max2=new osg::MatrixTransform;
osg::ref_ptr<osg::MatrixTransform> max3=new osg::MatrixTransform;
osg::ref_ptr<osg::MatrixTransform> max4=new osg::MatrixTransform;
max2->addChild(node);
max2->setMatrix(osg::Matrix::translate(5.0,0.0,0.0));
max->setUpdateCallback(new osg::AnimationPathCallback(osg::Vec3(5.0,0.0,0.0),osg::Z_AXIS,1.0));
max->addChild(max2);
max4->addChild(node);
max4->setMatrix(osg::Matrix::translate(-5.0,0.0,0.0));
max3->setUpdateCallback(new osg::AnimationPathCallback(osg::Vec3(-5.0,0.0,0.0),osg::Z_AXIS,1.0));
max3->addChild(max4);
group->addChild(node);
group->addChild(max);
group->addChild(max3);
return group;
}
int main()
{
osg::ref_ptr<osgViewer::Viewer> viewer=new osgViewer::Viewer;
/*osg::ref_ptr<osg::Group> group=new osg::Group;
group->addChild(osgDB::readNodeFile("glider.osg"));*/
viewer->setSceneData(MatrixOperation());
return viewer->run();
}
第七讲 矩阵操作 上
最新推荐文章于 2023-07-09 21:56:17 发布