- function TD3DHEightmap.GenerateVB( _bytes_vertices, _x_count, _z_count: Cardinal;
- _width, _depht : Single; ) : HRESULT ;
- var
- pVertices : Pointer ;
- x,y,z : Word ;
- Vertices : array of TD3DLVertex ;
- begin
- //Zunächst Vertices laden
- SetLength(Vertices,_z_count* _x_count)
- dx := _width / _x_count ;
- dz := _depth / _z_count ;
- for z := 0 to _z_count-1 do
- begin
- for x := 0 to _x_count-1 do
- begin
- SetLength(Vertices,High(Vertices)+2) ;
- hoehe := -(x*dx-(_width/2))*(x*dx-(_width/2))*0.1 + (z*dz-(_depth/2))*(z*dz-(_depth/2))*0.07 ;
- vertices[z*_z_count + x] := GetTD3DLVertex(x*dx-(_width/2),
- hoehe,
- z*dz-(_depth/2),
- D3DColor_RGBA(round(x*dx*10), round(255-z*dz*10),round((x*dx+z*dz)*10),0)) ;
- end;
- end;
- //Dann alles dem Vertexbuffer übergeben.
- result := pdevice.CreateVertexBuffer( _bytes_vertices,
- D3DUSAGE_WRITEONLY,
- D3DFVF_TD3DLVertex,
- D3DPOOL_DEFAULT,
- vb,nil);
- if result <> D3D_OK then exit ;
- vb.Lock(0, sizeOf(Vertices), pVertices,0);
- Move(Vertices,pVertices^, sizeOf(Vertices)) ;
- vb.unlock ;
- end;