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 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
| unit Camera;
interface
uses
Microsoft.DirectX,
Microsoft.DirectX.Direct3D,
Microsoft.DirectX.Direct3DX;
type
KCamera = class(System.&Object)
PosMesh, PosCam : Vector3;
u,d,l,r,n,j,w,c : boolean;
FDevice : Device;
matrx : matrix;
teste : integer;
angle: double;
procedure Initialisation(dev : device);
procedure resetPosition(x_i,y_i,z_i : Single);
procedure mouvement(dir : char);
procedure Update;
Private
procedure view();
end;
implementation
procedure KCamera.Initialisation(dev : Device);
begin
FDevice := dev;
view;
end;
procedure KCamera.resetPosition(x_i,y_i,z_i : Single);
begin
angle := cos(90) - 1.2 ;
PosCam.x := 1.0 + cos (angle);
PosCam.y := 1.0;
PosCam.z := 1.0 + sin (angle);
PosMesh.x := PosCam.x;
PosMesh.y := PosCam.y;
PosMesh.z := PosCam.z + 1;
end;
procedure KCamera.mouvement(dir : char);
begin
case dir of
'u' : begin
if (poscam.z < 23) and (posmesh.z < 23) then
begin
PosMesh.z := PosMesh.z + 0.2;
PosCam.z := PosCam.z + 0.2;
end;
Update;
end;
'd' : begin
if (poscam.z > -23) and (posmesh.z > -23) then
begin
PosMesh.z := PosMesh.z - 0.2;
PosCam.z := PosCam.z - 0.2;
end;
Update;
end;
'l' : begin
if (poscam.x > -23) and (posmesh.x > -23) then
begin
PosMesh.x := PosMesh.x - 0.2;
PosCam.x := PosCam.x - 0.2;
end;
Update;
end;
'r' : begin
if (poscam.x < 23) and (posmesh.x < 23) then
begin
PosMesh.x := PosMesh.x + 0.2;
PosCam.x := PosCam.x + 0.2;
end;
Update;
end;
'n' : begin
if posmesh.y <= 8 then
begin
PosMesh.y := PosMesh.y + 0.5;
PosCam.y := PosCam.y + 0.5;
end;
Update;
end;
'j' : begin
if posmesh.y > 1 then
begin
PosMesh.y := PosMesh.y - 0.32;
PosCam.y := PosCam.y - 0.32;
end;
Update;
end;
'w' : begin
angle := angle + 0.02;
PosCam.x := Poscam.x + cos(angle);
PosCam.z := Poscam.z + sin(angle);
Update;
end;
'x' : begin
angle := angle - 0.02;
PosCam.x := PosMesh.x + cos(angle);
PosCam.z := PosMesh.z + sin(angle);
Update;
end;
end;
end;
procedure KCamera.Update;
begin
Matrx := Matrix.LookAtLH( Vector3.Create( PosMesh.x + cos(angle), PosMesh.y, PosMesh.z + sin(angle)), Vector3.Create( PosMesh.x, PosMesh.y, PosMesh.z ), Vector3.Create( 0, 1, 0 ) ); // Ne pas toucher sinon plus de boule FUCK CA TOURNE DONC ON TOUCHE ENCORE MOIN
FDevice.Transform.View := Matrx;
inc(teste);
end;
procedure KCamera.view;
begin
matrx := Matrix.Identity * Matrix.RotationY(angle) * Matrix.Translation(PosCam.x ,PosCam.y ,PosCam.z);
FDevice.Transform.View := Matrx;
end;
end. |
Partager