|
楼主 |
发表于 2009-12-22 15:32:15
|
显示全部楼层
还有一个问题想问,还是加载子节点的问题,加载子节点使用的是什么机制?在void PagedLOD::traverse(NodeVisitor& nv)中
for(unsigned int i=0;i<_rangeList.size();++i)
{
if (_rangeList[i].first<=required_range && required_range<_rangeList[i].second)
{
if (i<_children.size())
{
if (updateTimeStamp)
{
_perRangeDataList[i]._timeStamp=timeStamp;
_perRangeDataList[i]._frameNumber=frameNumber;
}
_children[i]->accept(nv);
lastChildTraversed = (int)i;
}
else
{
needToLoadChild = true;
}
}
}
if (needToLoadChild)
{
unsigned int numChildren = _children.size();
// select the last valid child.
if (numChildren>0 && ((int)numChildren-1)!=lastChildTraversed)
{
if (updateTimeStamp)
{
_perRangeDataList[numChildren-1]._timeStamp=timeStamp;
_perRangeDataList[numChildren-1]._frameNumber=frameNumber;
}
_children[numChildren-1]->accept(nv);
}
// now request the loading of the next unloaded child.
if (nv.getDatabaseRequestHandler() && numChildren<_perRangeDataList.size())
{
// compute priority from where abouts in the required range the distance falls.
float priority = (_rangeList[numChildren].second-required_range)/(_rangeList[numChildren].second-_rangeList[numChildren].first);
// invert priority for PIXEL_SIZE_ON_SCREEN mode
if(_rangeMode==PIXEL_SIZE_ON_SCREEN)
{
priority = -priority;
}
// modify the priority according to the child's priority offset and scale.
priority = _perRangeDataList[numChildren]._priorityOffset + priority * _perRangeDataList[numChildren]._priorityScale;
if (_databasePath.empty())
{
nv.getDatabaseRequestHandler()->requestNodeFile(_perRangeDataList[numChildren]._filename,this,priority,nv.getFrameStamp(), _perRangeDataList[numChildren]._databaseRequest);
}
else
{
// prepend the databasePath to the child's filename.
nv.getDatabaseRequestHandler()->requestNodeFile(_databasePath+_perRangeDataList[numChildren]._filename,this,priority,nv.getFrameStamp(), _perRangeDataList[numChildren]._databaseRequest);
}
}
为什么numChildren = _children.size()就是需要加载的节点了,好像节点加载进来也没把nv传下去啊?
翻阅了《最长的一帧》,《OSG编程入门指南》以及新书《三维渲染引擎设计与实践》都没对pagdlod节点加载机制的解释,array能不能通过这段代码解释一下吗?有人说OSG默认从最低精度的LOD开始读取,不管初始位置。对每个pagedlod将其所有级别LOD均加载进来。同时数据管理线程及时移除不活动节点(超过一定时间未访问)。是这样吗? |
|