1, pagedlod和lod

简而言之,lod是根据距离或者显隐物体,PagedLod是根据距离加载或者卸载物体。(也有按像素点的,这个暂时不考虑)

所以,pagedlod只需要三步

1,中心点

1,距离

2,物体名称

这里先设置始终能看到,即距离( 0, FLT_MAX)

复制代码
osg::ref_ptr<osg::PagedLOD> plod = new osg::PagedLOD;
plod->setFileName(0,strName);
plod->setCenter(osg::Vec3(0, 0, 0));
plod->setRange(0, 0, FLT_MAX);

先出现一头牛

全部源码如下:

#include <osgViewer/Viewer>

#include <osg/Node>

#include <osgdb/ReadFile>

#include <osg/PagedLod>

#include <osgGA/TrackballManipulator>

int main()

{

osg::ref_ptrosgViewer::Viewer viewer = new osgViewer::Viewer;

std::string strName = "D:/install/osg365_oe210_vs2019/OpenSceneGraph-Data/cow.osg";

osg::ref_ptrosg::PagedLOD plod = new osg::PagedLOD;

plod->setFileName(0,strName);

plod->setCenter(osg::Vec3(0, 0, 0));

plod->setRange(0, 0, FLT_MAX);

viewer->setSceneData(plod);

osg::ref_ptr< osgGA::TrackballManipulator> manip = new osgGA::TrackballManipulator();

复制代码
// 设置自定义的初始位置:眼睛位置、观察点、向上向量
manip->setHomePosition(
	osg::Vec3d(0.0, -100.0, 5.0),   // 眼睛位置
	osg::Vec3d(0.0, 0.0, 0.0),      // 观察中心
	osg::Vec3d(0.0, 0.0, 1.0),       // 向上向量(Z轴向上)
	false                            // 不自动计算
);

viewer->setCameraManipulator(manip);
return viewer->run();

}

相关推荐
directx3d_beginner18 天前
10,cookbook的lod示例
osg
directx3d_beginner19 天前
8,将0级简模文件和精模文件同时放入pagedlod
osg
directx3d_beginner19 天前
9,0级建模文件和0级精模文件写成根节点
osg
directx3d_beginner20 天前
5,保存4个一级节点
osg
CHPCWWHSU2 个月前
pointCloudExtractor:一个基于 osgPotree 的 Potree 点云数据提取工具
目标识别·osg·potree·点云提取
CHPCWWHSU3 个月前
CesiumforUnreal环境准备
c++·cesium·unreal·osg
妙为3 个月前
osgEarth中文显示乱码
中文乱码·osgearth·osg
CHPCWWHSU4 个月前
osg中文字的使用
osg·osgtext·text3d
CHPCWWHSU5 个月前
osg中相机矩阵到vsg相机矩阵的转换
opengl·osg·投影矩阵·vulkan·vsg