【问题标题】:btHeightfieldTerrainShape constructor arguments not clearbtHeightfieldTerrainShape 构造函数参数不明确
【发布时间】:2021-05-24 04:55:13
【问题描述】:

我很难理解 btHeightfieldTerrainShape 的构造函数参数以及应该如何设置高度场数据。

前两个参数 heightStickField 和 widthStickField。它们代表什么?是整个地形的宽度和高度,以便缩放高度场以适应内部吗?还是它代表每个高度的“瓦片”总数,以便线性高度场数据可以分解为每个瓦片的高度?另外高度图的顺序是什么?

我像这样生成我的地形高度。这会匹配 btHeightfieldTerrainShape 的高度字段吗?

for (int i = 0; i <= mHeight; i++) {
                    for (int j = 0; j <= mWidth; j++) {
                        
                        double _noiseX = j + _xOffset;
                        double _noiseZ = i + _zOffset;
                        //float _height = 0.2f + ((float)mPerlinNoiseGenerator.GetValue(_noiseX, _noiseZ, 0.0) * 2);
                        float _height = (float)mPerlinNoiseGenerator.GetValue(_noiseX, _noiseZ, 0.0);
                        if (!i && !j) {
                            _terrainData->mMaxHeight = _height;
                            _terrainData->mMinHeight = _height;
                        }else {
                            _terrainData->mMaxHeight = std::max(_terrainData->mMaxHeight, _height);
                            _terrainData->mMinHeight = std::min(_terrainData->mMinHeight, _height);
                        }
                        _terrainData->mHeightMap.push_back(_height);
                    }
                }

我到处找,找不到任何关于使用 btHeightfieldTerrainShape 的明确解释。任何帮助表示赞赏。

谢谢!

【问题讨论】:

    标签: c++ game-physics bullet


    【解决方案1】:

    想通了。对于那些想知道顺序是 -x 到 +x 和 z+ 到 z- 的人。因此,如下所示的 for 循环将为您提供正确的排序。 这里的宽度和高度是根据每行/列的瓦片/高度值的数量

    for (int i = 0; i < mHeight; i++) {
                        for (int j = 0; j < mWidth; j++) {}}
    

    【讨论】:

      猜你喜欢
      • 2020-11-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-27
      相关资源
      最近更新 更多