|
lod中有两种模式,距离模式和像素模式,最近在研究使用像素模式加载点云,发现了osg中像素值计算原理的问题
osg中节点在屏幕上的像素值使用cullstack类中的 pixelsize函数:bs.radius()/bs.center()*_pixelSizeVector计算,有来两个疑问:
1.这个公式的计算原理是什么?
2._pixelSizeVector代表的是什么?这个vector计算使用的是cullingset类中的computePixelSizeVector(W, P, M),代码如下
osg::Vec4 CullingSet::computePixelSizeVector(const Viewport& W, const Matrix& P, const Matrix& M)
{
// pre adjust P00,P20,P23,P33 by multiplying them by the viewport window matrix.
// here we do it in short hand with the knowledge of how the window matrix is formed
// note P23,P33 are multiplied by an implicit 1 which would come from the window matrix.
// Robert Osfield, June 2002.
// scaling for horizontal pixels
float P00 = P(0,0)*W.width()*0.5f;
float P20_00 = P(2,0)*W.width()*0.5f + P(2,3)*W.width()*0.5f;
osg::Vec3 scale_00(M(0,0)*P00 + M(0,2)*P20_00,
M(1,0)*P00 + M(1,2)*P20_00,
M(2,0)*P00 + M(2,2)*P20_00);
// scaling for vertical pixels
float P10 = P(1,1)*W.height()*0.5f;
float P20_10 = P(2,1)*W.height()*0.5f + P(2,3)*W.height()*0.5f;
osg::Vec3 scale_10(M(0,1)*P10 + M(0,2)*P20_10,
M(1,1)*P10 + M(1,2)*P20_10,
M(2,1)*P10 + M(2,2)*P20_10);
float P23 = P(2,3);
float P33 = P(3,3);
osg::Vec4 pixelSizeVector(M(0,2)*P23,
M(1,2)*P23,
M(2,2)*P23,
M(3,2)*P23 + M(3,3)*P33);
float scaleRatio = 0.7071067811f/sqrtf(scale_00.length2()+scale_10.length2());
pixelSizeVector *= scaleRatio;
return pixelSizeVector;
}
这个是类似问题的一个帖子,看的不是很懂,希望兴趣的朋友可以看下,一起讨论
http://bbs.osgchina.org/forum.ph ... amp;_dsign=ea7ba408
|
|