Mesh Terrain -> Heightmap

Blitz3D Forums/Blitz3D Programming/Mesh Terrain -> Heightmap

Tab(Posted 2008) [#1]
Hello ^_^

I am finishing some things on my Game editor and I need create a Heightmap from a Mesh Terrain... Anyone have a idea or code to make this?

Thanks in advance.


Naughty Alien(Posted 2008) [#2]
..usually I do that with 3dsmax..just export heightmap based on mesh, but I dont know are using 3dsmax or some other modeling tool..


Wings(Posted 2008) [#3]
Thanks alien.

(I too have this problem)

Iam using milkshape3d but a friend uses 3dsmax. and he dont like the gimp :)


Billp(Posted 2008) [#4]
assuming your mesh is Mesh_Width verts wide & deep this should work (greyscale ,height =0 to 255 or use all RGB components to allow a much greater range )...I haven't tested this although it is similar to the code I use in my terrain editor

Function BuildHeightMap(mesh)
	surface = GetSurface ( mesh, 1 )
	min=0:max=0
 	For index=0 To CountVertices ( surface )-1
		If VertexY# ( surface,index )< min Then min = index
		If VertexY# ( surface,index )> max Then max = index
	Next
	factor = (VertexY# ( surface,max)-VertexY# ( surface,min))/256		
	hm = CreateImage(Mesh_Width,Mesh_Width)
	SetBuffer ImageBuffer( hm )	
	For index=0 To CountVertices ( surface )-1
		Color VertexY# ( surface,index )*factor,VertexY# ( surface,index )*factor,VertexY# ( surface,index )*factor
		Plot index Mod  Mesh_Width,index/ Mesh_Width
	Next
	Return hm
End Function



Tab(Posted 2008) [#5]
Looks good...

Thanks Billp.