一、背景
在osgEarth中,使模型运动有两种方案:
- 使用回调函数setUpdateCallback(Path)让模型按预设路径飞行,这种方法飞行过程很流畅
- 使用csn->getEllipsoidModel()->computeLocalToWorldTransformFromLatLongHeight(osg::DegreesToRadians(lat), osg::DegreesToRadians(log), 100.0, matrix)更新模型的位置
二、代码
#include<Windows.h>
#include<osgViewer/Viewer>
#include<osgDB/ReadFile>
#include<osg/MatrixTransform>
#include<osgEarth/MapNode>
#include<osg/AnimationPath>
#include<osg/CoordinateSystemNode>
#include <osg/PositionAttitudeTransform>
#include <osgEarthUtil/EarthManipulator>
#include <osgEarthUtil/ExampleResources>
int main()
{
osg::ref_ptr<osgViewer::Viewer> viewer = new osgVi