1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79:
| unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;
type TVector = packed record x,y,z: single; end;
function vector3f(Px,py,pz: single): TVector; function vectostr(V: tVector): string;
type TForm1 = class(TForm) Button1: TButton; ListBox1: TListBox; Button2: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;
type PVector = ^Tvector;
var Form1: TForm1; vertexarray: Array of tvector; PointerArray: array of PVector; implementation
{$R *.dfm}
function vector3f(Px,py,pz: single): TVector; begin
result.x := PX; result.y := PY; result.z := PZ; end;
function vectostr(V: tVector): string; begin
result := 'x: ' + floattostrf(V.x,fffixed,10,2); result := result+ ' y: ' + floattostrf(V.y,fffixed,10,2); result := result+ ' z: ' + floattostrf(V.z,fffixed,10,2); end;
procedure TForm1.Button1Click(Sender: TObject); var i,j: integer; begin
setlength(Vertexarray,length(VertexArray)+3); Setlength(PointerArray,length(PointerArray)+3);
VertexArray[high(vertexarray)-2] := vector3f(4,4,4); VertexArray[high(vertexarray)-1] := vector3f(5,5,5); VertexArray[high(vertexarray)] := vector3f(6,6,6);
PointerArray[high(PointerArray)-2] := @Vertexarray[High(Vertexarray)-2]; PointerArray[high(PointerArray)-1] := @Vertexarray[High(Vertexarray)-1]; PointerArray[high(PointerArray)] := @Vertexarray[High(Vertexarray)];
j:=1; for i:=0 to high(Pointerarray) do begin Listbox1.items.add(vectostr(Pointerarray[i]^)); if j mod 3 = 0 then listbox1.Items.Add(''); inc(j); end;
end;
end. |