MCPcopy Create free account
hub / github.com/dartsim/dart / createHeightmapShape

Function createHeightmapShape

examples/heightmap/main.cpp:50–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48
49template <typename S>
50dynamics::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
75template <typename S>
76dynamics::SimpleFramePtr createHeightmapFrame(

Callers 2

createHeightmapFrameFunction · 0.85
updateHeightmapShapeMethod · 0.85

Calls 3

Vector3Class · 0.85
setHeightFieldMethod · 0.80
setScaleMethod · 0.45

Tested by

no test coverage detected