| 48 | |
| 49 | template <typename S> |
| 50 | dynamics::ShapePtr createHeightmapShape( |
| 51 | std::size_t xResolution = 20u, |
| 52 | std::size_t yResolution = 20u, |
| 53 | S xSize = S(2), |
| 54 | S ySize = S(2), |
| 55 | S zMin = S(0.0), |
| 56 | S zMax = S(0.1)) |
| 57 | { |
| 58 | using Vector3 = Eigen::Matrix<S, 3, 1>; |
| 59 | |
| 60 | typename HeightmapShape<S>::HeightField data(yResolution, xResolution); |
| 61 | for (auto i = 0u; i < yResolution; ++i) { |
| 62 | for (auto j = 0u; j < xResolution; ++j) { |
| 63 | data(i, j) = math::Random::uniform(zMin, zMax); |
| 64 | } |
| 65 | } |
| 66 | auto scale = Vector3(xSize / xResolution, ySize / yResolution, 1); |
| 67 | |
| 68 | auto terrainShape = std::make_shared<HeightmapShape<S>>(); |
| 69 | terrainShape->setScale(scale); |
| 70 | terrainShape->setHeightField(data); |
| 71 | |
| 72 | return terrainShape; |
| 73 | } |
| 74 | |
| 75 | template <typename S> |
| 76 | dynamics::SimpleFramePtr createHeightmapFrame( |
no test coverage detected