- procedure TEngine.move;
- var
- RotMat : TMatrix4f;
- Ang: single;
- RotateX : single;
- RotateY : single;
- RotateZ : single;
- begin
- RotateX := 0;
- RotateY := 0;
- RotateZ := 0;
- if Keys[ord('W')] then RotateX := RotSpeed;
- if Keys[ord('S')] then RotateX := -RotSpeed;
- if Keys[ord('D')] then RotateY := -RotSpeed;
- if Keys[ord('A')] then RotateY := RotSpeed;
- if Keys[ord('Q')] then RotateZ := RotSpeed;
- if Keys[ord('E')] then RotateZ := -RotSpeed;
- if Keys[ord('R')] then
- if Direction > 0 then Direction := Direction + BreakSpeed
- else Direction := Direction + MoveSpeed
- else
- if Keys[ord('F')] then
- if Direction < 0 then Direction := Direction - BreakSpeed
- else Direction := Direction - MoveSpeed;
- Ang := DegToRad(RotateX);
- VectorRotate(LocalY, LocalX, Ang);
- VectorRotate(LocalZ, LocalX, Ang);
- RotMat := CreateRotationMatrix(LocalX, Ang);
- WorldMat := MatrixMultiply(WorldMat, RotMat);
- Ang := DegToRad(RotateY);
- VectorRotate(LocalX, LocalY, Ang);
- VectorRotate(LocalZ, LocalY, Ang);
- RotMat := CreateRotationMatrix(LocalY, Ang);
- WorldMat := MatrixMultiply(WorldMat, RotMat);
- Ang := DegToRad(RotateZ);
- VectorRotate(LocalX, LocalZ, Ang);
- VectorRotate(LocalY, LocalZ, Ang);
- RotMat := CreateRotationMatrix(LocalZ, Ang);
- WorldMat := MatrixMultiply(WorldMat, RotMat);
- PosVect[0] := PosVect[0] + (LocalZ[0] * Direction);
- PosVect[1] := PosVect[1] + (LocalZ[1] * Direction);
- PosVect[2] := PosVect[2] + (LocalZ[2] * Direction);
- end;