|
模仿Sample osgearth_los 做一个demo,vecpoints是用Geometry->toVec3dArray()获取的地理坐标点,但是会出现沿着路径跑的对象飞到外太空去了。不知道如何入手。请教我一下,谢谢。
- osg::AnimationPath* CStormPlay::createAnimationPath(const vector<osg::Vec3d>& vecPoints, const SpatialReference* mapSRS)
- {
- // set up the animation path
- osg::AnimationPath* animationPath = new osg::AnimationPath;
- animationPath->setLoopMode(osg::AnimationPath::NO_LOOPING);
- int numSamples = 40;
- double time=0.0f;
- double time_delta = 1.0f;
- for (int i = 0;i < vecPoints.size();i++)
- {
- double dd = vecPoints[i].x();
- GeoPoint gpt(mapSRS, vecPoints[i].x(),vecPoints[i].y(),4133.06,ALTMODE_ABSOLUTE);
- GeoPoint mapPos;
- gpt.transform(mapSRS,mapPos);
- osg::Vec3d centerWorld;
- mapPos.toWorld(centerWorld);
- animationPath->insert(time,osg::AnimationPath::ControlPoint(centerWorld));
- time += time_delta;
- }
-
- return animationPath;
- }
复制代码
|
|