Been trying to get this function to load a heightmap and it works ok. But...
The bottom and right vertices aren't effected by the heighmap and stay at 0,0,0. I've tried all kinds of stuff and probably spent too long on it. Can a fresh set of eyes see what the problem is?
The bottom and right vertices aren't effected by the heighmap and stay at 0,0,0. I've tried all kinds of stuff and probably spent too long on it. Can a fresh set of eyes see what the problem is?
Function CreateSegQuad(hmap$) temp = LoadImage(hmap$) If temp = 0 Then End tdim = ImageWidth(temp) seg=tdim mesh = CreateMesh() surf = CreateSurface(mesh) ; vertices For y = 0 To seg For x = 0 To seg AddVertex surf,x,0,y-1,0,x,-y VertexTexCoords surf,x+((seg+1)*y),x,-y Next Next ; triangles For y = 0 To seg-1 For x = 0 To seg-1 v=x+s AddTriangle surf,v,v+seg+1,v+seg+2 AddTriangle surf,v,v+seg+2,v+1 Next s=s+seg+1 Next ; center quad PositionEntity mesh,-seg/2.0,0,-seg/2.0 ; alter vertice height to match the heightmap red channel SetBuffer ImageBuffer(temp) For lx = 0 To x For ly = 0 To y GetColor lx,y-ly index = lx + ((x+1)*ly) VertexCoords surf, index , VertexX(surf,index), ColorRed()/20.0,VertexZ(surf,index) Next Next SetBuffer BackBuffer() UpdateNormals mesh Return mesh End Function