-
Hello! I am trying to get the HeightFieldShape to work for my heightmap. I figured out 95% of it, but one little thing is making me struggle. When I create the HeightFieldShape, I pass all of the data I load into it. So I know for a fact that the y points are the same ones as my rendered y points. And that both my render and collision shape is centered at 0, 0, 0. But for some reason my width and height (depth) is off, my X and Z. I am using a 200 x 200 image to calculate the heightmap. So for my rendered heightmap, I get numbers like -99, 16, -100. But for some reason, the HeightFieldShape is reporting -98.5, 16, -99.5. I am using the physics common createHeightFieldShape() method. Everything else is working well. If you know anything about why this could be happening, please let me know |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Alright I think I found something.
My image is 200 x 200. So 200 gets put in for the width and height. Subtracting 1 makes it 199.
And here I see that the width and height (length) are set by halving it. So 199 / 2 = 99.5. This explains where those values come from. |
Beta Was this translation helpful? Give feedback.
Alright I think I found something.
So when you create the HeightFieldShape, you subtract 1 from it and divide by 2 to get widths and heights.
mWidth(static_cast<decimal>(nbGridColumns - 1)), mLength(static_cast<decimal>(nbGridRows - 1))
My image is 200 x 200. So 200 gets put in for the width and height. Subtracting 1 makes it 199.
mAABB.setMin(Vector3(-mWidth * decimal(0.5), -halfHeight, -mLength * decimal(0.5))); mAABB.setMax(Vector3(mWidth * decimal(0.5), halfHeight, mLength * decimal(0.5)));
And here I see that the width and height (length) are set by halving it. So 199 / 2 = 99.5.
This explains where those values come from.
But now I need to figure out how to correct it.
If I use 20…