渐进网格的新自动细节级别选择(第2部分,共2部分)

这是关于自动细节级别 (LOD) 选择系列文章的第二篇。有关该系列的第一篇文章,请参阅第1部分

Visualize SDK 21.4 支持 OdTvProgressiveMeshData 的自动细节级别选择。您可以通过调用以下方法启用它:

virtual OdTvResult setAutoLODSelection( LODAutoSelectType autoSelectType ) = 0;

其中 autoSelectType 是 LODAutoSelectType 值之一:

  • OdTvProgressiveMeshData::kAutoLOD_None 禁用自动 LOD 选择。
  • OdTvProgressiveMeshData::kAutoLOD_SqrInterpolation 启用 OdGiProgressiveMesh::kSqrInterpolation LOD 选择。
  • OdTvProgressiveMeshData::kAutoLOD_SqrtInterpolation 启用 OdGiProgressiveMesh::kSqrtInterpolation LOD 选择。
  • OdTvProgressiveMeshData::kAutoLOD_CustomInterpolation 启用 OdGiProgressiveMesh::kCustom LOD 选择。

可以使用以下方法指定插值参数:

virtual OdTvResult setAutoLODSelectMaxInterpolationThreshold( OdUInt32 nMax ) = 0;
virtual OdTvResult setAutoLODSelectMinInterpolationThreshold( OdUInt32 nMin ) = 0;

Visualize SDK 自定义 LOD 插值示例

OdTvCustomInterpolation 类用于为细节级别提供自定义插值。由于 Visualize SDK 不提供细节级别的线性插值,因此它是一个自定义实现:

class LinearInterpolation : public OdTvCustomInterpolation
{
public:
  virtual OdUInt32 interpolate( OdUInt32 minX, OdUInt32 minY, OdUInt32 maxX, OdUInt32 maxY, OdUInt32 x ) const
  {
    //interpolation: Y = A * x + B, where minY = A * minX + B and maxY = A * maxX + B
    double A = ( (double)( maxY - minY ) ) / ( (double)( maxX - minX ) );
    double B = maxY - A * maxX;
    return OdUInt32( A * x + B );
  }
};
…
LinearInterpolation* interp = new LinearInterpolation();
pPM->setAutoLODCustomInterpolation( interp );
pPM->setAutoLODSelection ( OdTvProgressiveMeshData::kAutoLOD_CustomInterpolation );

OdTvProgressiveMeshData 对象的所有属性都保存在 .vsf 文件中。但是,指向 OdTvCustomInterpolation 的指针无法保存。因此,OdTvProgressiveMeshData 在保存时,会为 getAutoLODSelectInterpolationThresholds() 返回的区间中的每个值调用 OdTvCustomInterpolation::interpolate() 方法。加载后,OdTvProgressiveMeshData 对象使用此数据执行自定义插值,直到指定新的 OdTvCustomInterpolation 对象指针。

今天就开始行动

免费试用 ODA 软件 60 天。
无风险,无需信用卡。

免费试用