procedure TForm1.InitCollision; var Ax, Ay, Az, Bx, By, Bz, Cx, Cy, Cz, Dx, Dy, Dz: double; //Body objektu Px, Py, Pz: double; //Pozice kamery Xdiff, Ydiff, Zdiff, Cdiff, Fdiff : boolean; //Kolizni hodnoty i: integer; //Pocet objektu begin //pozice kamery Px := X; Py := -Y; //znamenko minus je tam proto, aby odpovidala Y souradnice kamery Y souradnici objektu Pz := -Z; //znamenko minus je tam proto, aby odpovidala Z souradnice kamery Y souradnici objektu for i := 1 to 6 do begin //stena 1 if i = 1 then begin //pozice bodu A Ax := VertexPointer[0].X; Ay := VertexPointer[0].Y; Az := VertexPointer[0].Z; //pozice bodu B Bx := VertexPointer[1].X; By := VertexPointer[1].Y; Bz := VertexPointer[1].Z; //pozice bodu C Cx := VertexPointer[2].X; Cy := VertexPointer[2].Y; Cz := VertexPointer[2].Z; //pozice bodu D Dx := VertexPointer[5].X; Dy := VertexPointer[5].Y; Dz := VertexPointer[5].Z; end; //stena 2 if i = 2 then begin //pozice bodu A Ax := VertexPointer2[0].X; Ay := VertexPointer2[0].Y; Az := VertexPointer2[0].Z; //pozice bodu B Bx := VertexPointer2[1].X; By := VertexPointer2[1].Y; Bz := VertexPointer2[1].Z; //pozice bodu C Cx := VertexPointer2[2].X; Cy := VertexPointer2[2].Y; Cz := VertexPointer2[2].Z; //pozice bodu D Dx := VertexPointer2[5].X; Dy := VertexPointer2[5].Y; Dz := VertexPointer2[5].Z; end; //stena 3 if i = 3 then begin //pozice bodu A Ax := VertexPointer3[0].X; Ay := VertexPointer3[0].Y; Az := VertexPointer3[0].Z; //pozice bodu B Bx := VertexPointer3[1].X; By := VertexPointer3[1].Y; Bz := VertexPointer3[1].Z; //pozice bodu C Cx := VertexPointer3[2].X; Cy := VertexPointer3[2].Y; Cz := VertexPointer3[2].Z; //pozice bodu D Dx := VertexPointer3[5].X; Dy := VertexPointer3[5].Y; Dz := VertexPointer3[5].Z; end; //stena 4 if i = 4 then begin //pozice bodu A Ax := VertexPointer4[0].X; Ay := VertexPointer4[0].Y; Az := VertexPointer4[0].Z; //pozice bodu B Bx := VertexPointer4[1].X; By := VertexPointer4[1].Y; Bz := VertexPointer4[1].Z; //pozice bodu C Cx := VertexPointer4[2].X; Cy := VertexPointer4[2].Y; Cz := VertexPointer4[2].Z; //pozice bodu D Dx := VertexPointer4[5].X; Dy := VertexPointer4[5].Y; Dz := VertexPointer4[5].Z; end; //strop if i = 5 then begin //pozice bodu A Ax := VertexPointer5[0].X; Ay := VertexPointer5[0].Y; Az := VertexPointer5[0].Z; //pozice bodu B Bx := VertexPointer5[1].X; By := VertexPointer5[1].Y; Bz := VertexPointer5[1].Z; //pozice bodu C Cx := VertexPointer5[2].X; Cy := VertexPointer5[2].Y; Cz := VertexPointer5[2].Z; //pozice bodu D Dx := VertexPointer5[5].X; Dy := VertexPointer5[5].Y; Dz := VertexPointer5[5].Z; end; //podlaha if i = 6 then begin //pozice bodu A Ax := VertexPointer6[0].X; Ay := VertexPointer6[0].Y; Az := VertexPointer6[0].Z; //pozice bodu B Bx := VertexPointer6[1].X; By := VertexPointer6[1].Y; Bz := VertexPointer6[1].Z; //pozice bodu C Cx := VertexPointer6[2].X; Cy := VertexPointer6[2].Y; Cz := VertexPointer6[2].Z; //pozice bodu D Dx := VertexPointer6[5].X; Dy := VertexPointer6[5].Y; Dz := VertexPointer6[5].Z; end; //rozdily vzdalenosti bodu if Ax <= Bx then Xdiff := True else Xdiff := False; if Cy <= Ay then Ydiff := True else Ydiff := False; if Dz <= Cz then Zdiff := True else Zdiff := False; //vypocet //X hodnota if Xdiff then begin if ((Bx - Ax) <= 0) then begin //zrusi nulovou hodnotu Ax := Ax - 0.5; Bx := Bx + 0.5; end; if ((Px >= Ax)and(Px <= Bx)) or ((Px >= Cx)and(Px <= Dx)) then Xtrue[i] := True else Xtrue[i] := False; end; if not Xdiff then begin if ((Px >= Bx)and(Px <= Ax)) or ((Px >= Dx)and(Px <= Cx)) then Xtrue[i] := True else Xtrue[i] := False; end; //Y hodnota if Ydiff then begin if ((Ay - Cy) <= 0) then begin //zrusi nulovou hodnotu Ay := Ay + 0.5; Cy := Cy - 0.5; end; if ((Py <= Ay)and(Py >= Cy)) or ((Py <= By)and(Py >= Dy)) then Ytrue[i] := True else Ytrue[i] := False; end; if not Ydiff then begin if ((Py <= Cy)and(Py >= Ay)) or ((Py <= Dy)and(Py >= By)) then Ytrue[i] := True else Ytrue[i] := False; end; //Z hodnota if Zdiff then begin if ((Az - Bz) <= 0) then begin //zrusi nulovou hodnotu Bz := Bz - 0.5; Az := Az + 0.5 end; if (((Pz <= Az)and(Pz >= Bz)) or ((Pz <= Cz)and(Pz >= Dz))) //steny or (((Pz >= Az)and(Pz <= Cz)) or ((Pz >= Bz)and(Pz <= Dz))) then //podlaha a strop Ztrue[i] := True else Ztrue[i] := False; end; if not Zdiff then begin if ((Pz <= Bz)and(Pz >= Az)) or ((Pz <= Dz)and(Pz >= Cz)) then Ztrue[i] := True else Ztrue[i] := False; end; //posledni pozice kamery pred kolizi if (Xtrue[i] = False) or (Ytrue[i] = False) or (Ztrue[i] = False) then begin PxLast[i] := X; PyLast[i] := Y; PzLast[i] := Z; end; end; end;