@arcman7 thanks… i will go thru this code. But it looks alot like the Ammo.js example for terrain except for the way you calculate min and max heights and calculate resolution.
And as you can see i get MOST of the terrain data like width, depth and resolution from Unity exported terrain data… The problem i had was with the heights…
But it look like you loop thru all the meshes and get the Bounding box info and use that to mark the min and max heights of the meshes for the bounding box… I was going to try and loop thru all the vertices and use the Y value to track min and max… but the bound box seems like less work… I will try that.
YO @arcman7 … One more question… Are you drawing a debug representation of your terrain ? And How… are just making your own mesh and aligning it where you THINK it should go or are you using some kind of ammo debug drawer info to show where ammo actually has that terrain ?
It’s a literal representation of the physics bodies using the Ammo debug drawer interface. Ammo js provides the vertices data, and then I render it using the Babylon.js point cloud system - I linked everything you need in a gist above ^
Np, I hope you find it useful. If you learn anything new please share! And feel free to make improvements, I’ll update that gist or just point it towards whatever you make if you decide to.
to generate an 800x800 hmap overnight while I slept. If you can get that shader version of the playground/script (something I was working on towards the end of the thread) working, then this could be near instant for any resolution on any sized model.
So all of that was to get the heights from the mesh… Well heck… I would be better off just using the raw heights array i get from Unity TerrainData.GetHeights function
1025 or 2049 is what what i can do for you… And What a heightmap of what terrain, from what unity scene… Or just any HILLY terrain example i can find ?
Note: I can only make heightmap of actual unity terrains… So it would have to be a Unity scene with an actual Unity Terrain for me to export the heightmap
But you could browse the Unity asset store for a free terrain or environment with a terrain… send me that link, i can download that Unity scene and export the height map data for you…
Oh yeah… how did you want that heightmap data?
Do you want is as a 16Bit encoded png heightmap image or a json with the heightmap float number array ?
There actually wasn’t any issue with your exported height map data. I just forgot the x,y,z format that it’s in when you pull it out of the babylon mesh via the getVerticesData call.
So if I could find a way to import a gltf file into Unity, I can just pass you a link to the resulting scene?
I found a mesh to terrain utility… let me player with that and see if i can convert you gltf to a terrain and then export the heightmap… How you want the heightmap data ?
If you are trying to get a heightmap from a mesh couldn’t you just do a rtt capture of depth of the mesh from above in whatever size you want and then convert the range?
You could also sample the vertex data and just convert the xz coords into a normalized space then interpolate the pixels on your buffer from that data?
Usually you make a mesh from a heightmap and not vice versa but if y’all really need a fast/nearly instant way to generate that the rtt method is probably the best.
That’s what I was trying to figure out how to do towards the end of that thread. I think I was just missing a few steps or inputting the correct values. I eventually will swing back to it, but in the mean time letting my slow method run over night solves the need that I have lol. I do want to use this for more maps later with quicker iterations.