{ вы знаете что такое карта высот? можно создать супер эффект на простом Canvas к сожалению мой код моргает при перерисовке, но вы уж поковыряйтесь.... :) }
type rgb32 = record b: byte; g: byte; r: byte; t: byte; end; type rgb24 = record r: integer; g: integer; b: integer; end;
var Form1: TForm1; bumpimage: tbitmap; current_X, Current_Y: integer; var Bump_Map: array[0..255, 0..255] of normal; Environment_map: array[0..255, 0..255] of integer; Palette: array[0..256] of rgb24;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject); type image_array = array[0..255, 0..255] of byte; var x, y: integer; Buffer: image_array; bump_file: file of image_array; ny2, nx, nz: double; c: integer; ca, cap: double; begin assignfile(bump_File, 'bump.raw'); reset(Bump_File); Read(Bump_File, buffer); for y := 1 to 254 do begin for x := 1 to 254 do begin Bump_Map[x, y].x := buffer[y + 1, x] - buffer[y + 1, x + 2]; bump_map[x, y].y := buffer[y, x + 1] - buffer[y + 2, x + 1]; end; end; closefile(bump_File);
for y := -128 to 127 do begin nY2 := y / 128; nY2 := nY2 * nY2; for X := -128 to 127 do begin nX := X / 128; nz := 1 - SQRT(nX * nX + nY2); c := trunc(nz * 255); if c 255 then palette[y].r := 255; palette[y].G := trunc((128 * ca) + (245 * cap)); if palette[y].g > 255 then palette[y].g := 255; palette[y].B := trunc(5 + (170 * ca) + (255 * cap)); ; if palette[y].b > 255 then palette[y].b := 255; end; bumpimage := TBitmap.create; bumpimage.width := 255; bumpimage.height := 255; bumpimage.PixelFormat := pf32bit; Image1.Picture.Bitmap := bumpimage; image1mousemove(self, [], 128, 128); application.ProcessMessages;