SCAR Code:
Function FindPartialDDTM(MainPoint: TDTMPointDef; SubPoints: Array of TDTMPointDef; Var x,y: Integer; x1,y1,x2,y2: Integer): Boolean;
Var
DDTMSkeleton: TDTM;
DTM,i,storeTol: Integer;
time: Integer;
ia: Array[0..0] of Integer;
foundAngle: Extended;
Begin
DDTMSkeleton.MainPoint := MainPoint;
DDTMSkeleton.SubPoints := SubPoints;
DTM:= AddDTM(DDTMSkeleton);
If(FindDTMRotated(DTM,x,y,x1,y1,x2,y2,-PI*2,PI*2,0.5,foundAngle)) Then
Begin
Result:= True;
FreeDTM(DTM);
// Writeln('Yay, DTM found with all points');
Exit;
End
Else
Begin
FreeDTM(DTM);
// Writeln('DTM not found with all points');
End;
For i:= 0 to (GetArrayLength(SubPoints)-1) do
Begin
storeTol:= SubPoints[i].Tolerance;
// Writeln('Stored tolerance');
SubPoints[i].Tolerance:= 999;
// Writeln('Maxed tolerance on point '+IntToStr(i));
DDTMSkeleton.MainPoint := MainPoint;
DDTMSkeleton.SubPoints := SubPoints;
DTM:= AddDTM(DDTMSkeleton);
// Writeln('Assembled DDTM');
If(FindDTMRotated(DTM,x,y,x1,y1,x2,y2,-PI*2,PI*2,0.5,foundAngle)) Then
Begin
Result:= True;
FreeDTM(DTM);
// Writeln('Found DTM - Point '+IntToStr(i)+' was not used');
Exit;
End
Else
Begin
FreeDTM(DTM);
// Writeln('DTM was not found when not using point '+IntToStr(i));
End;
SubPoints[i].Tolerance:= storeTol;
// Writeln('Restored tolerance of point '+IntToStr(i));
End;
End;
SCAR Code:
MainPointS.x:= 53;
MainPointS.y:= 38;
MainPointS.areasize:= 0;
MainPointS.areashape:= 0;
MainPointS.color:= 10525679;
MainPointS.tolerance:= 255;
SubPointsS[0].x:= 32;
SubPointsS[0].y:= 28;
SubPointsS[0].areasize:= 0;
SubPointsS[0].areashape:= 0;
SubPointsS[0].color:= 10525679;
SubPointsS[0].tolerance:= 5;
SubPointsS[1].x:= 31;
SubPointsS[1].y:= 53;
SubPointsS[1].areasize:= 0;
SubPointsS[1].areashape:= 0;
SubPointsS[1].color:= 1514015;
SubPointsS[1].tolerance:= 5;
SubPointsS[2].x:= 34;
SubPointsS[2].y:= 73;
SubPointsS[2].areasize:= 0;
SubPointsS[2].areashape:= 0;
SubPointsS[2].color:= 1514015;
SubPointsS[2].tolerance:= 5;
SubPointsS[3].x:= 14;
SubPointsS[3].y:= 48;
SubPointsS[3].areasize:= 0;
SubPointsS[3].areashape:= 0;
SubPointsS[3].color:= 1514015;
SubPointsS[3].tolerance:= 5;
SubPointsS[4].x:= 66;
SubPointsS[4].y:= 24;
SubPointsS[4].areasize:= 0;
SubPointsS[4].areashape:= 0;
SubPointsS[4].color:= 10525679;
SubPointsS[4].tolerance:= 5;
If(FindPartialDDTM(x,y,MainPointS,SubPointsS,0,0,600,350)) Then
Begin
Writeln('yay');
MoveMouse(x,y);
End;
Which should write 'Yay' and move the mouse just to the right of the middle when it finds the attatched bmp (tested it by loading it into the DTM editor and moving it to the top left).