第七讲 矩阵操作 上

// 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();
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值