Log in

View Full Version : Problem with DDTMs, scar bug?



mastaraymond
07-07-2007, 06:17 PM
Oke, here is the problem: I thought a DDTM always takes up a lot of space so i just made a function which allows you to load DDTMs in 1 line. But it doesn't work, i did all kind of tests and I think its a bug in Scar :(.
Oke here the script:

program New;
var
X,Y,TheDTM,I:integer;
Bla:extended;
DDTM:TDTM;

Procedure MakeTheDTM;
begin
DDTM.MainPoint.x := 669;
DDTM.MainPoint.y := 86;
DDTM.MainPoint.AreaSize := 0;
DDTM.MainPoint.AreaShape := 0;
DDTM.MainPoint.Color := 5995142;
DDTM.MainPoint.Tolerance := 300;
SetArrayLength(DDTM.SubPoints, 5);
DDTM.SubPoints[0].x := 655;
DDTM.SubPoints[0].y := 81;
DDTM.SubPoints[0].AreaSize :=1;
DDTM.SubPoints[0].AreaShape := 0;
DDTM.SubPoints[0].Color := 195836;
DDTM.SubPoints[0].Tolerance := 0;
DDTM.SubPoints[1].x := 646;
DDTM.SubPoints[1].y := 96;
DDTM.SubPoints[1].AreaSize := 2;
DDTM.SubPoints[1].AreaShape := 0;
DDTM.SubPoints[1].Color := 15661038;
DDTM.SubPoints[1].Tolerance := 30;
DDTM.SubPoints[2].x := 677;
DDTM.SubPoints[2].y := 96;
DDTM.SubPoints[2].AreaSize := 2;
DDTM.SubPoints[2].AreaShape := 0;
DDTM.SubPoints[2].Color := 15661038;
DDTM.SubPoints[2].Tolerance := 30;
DDTM.SubPoints[3].x := 708;
DDTM.SubPoints[3].y := 108;
DDTM.SubPoints[3].AreaSize := 2;
DDTM.SubPoints[3].AreaShape := 0;
DDTM.SubPoints[3].Color := 15661038;
DDTM.SubPoints[3].Tolerance :=30;
DDTM.SubPoints[4].x := 669;
DDTM.SubPoints[4].y := 119;
DDTM.SubPoints[4].AreaSize := 7;
DDTM.SubPoints[4].AreaShape := 0;
DDTM.SubPoints[4].Color := 2383671;
DDTM.SubPoints[4].Tolerance := 0;
TheDTM := AddDTM(DDTM);
end;

Procedure MakeDTM(TheX,TheY,Color,Tolerance,Shape,Size: TIntegerArray);
begin;
DDTM.MainPoint.x:= TheX[0];
DDTM.MainPoint.y:= TheY[0];
DDTM.MainPoint.color:= Color[0];
DDTM.MainPoint.Tolerance:= Tolerance[0];
DDTM.MainPoint.AreaShape:= Shape[0];
DDTM.MainPoint.AreaSize:= Size[0];
SetArrayLength(DDTM.SubPoints,Length(TheX)-1);
For I:=1 to length(TheX) -1 do
begin;
DDTM.SubPoints[i-1].x:= TheX[i];
DDTM.SubPoints[i-1].y:= TheY[i];
DDTM.SubPoints[i-1].color:= Color[i];
DDTM.SubPoints[i-1].Tolerance:= Tolerance[i];
DDTM.SubPoints[i-1].AreaShape:= Shape[i];
DDTM.SubPoints[i-1].AreaSize:= Size[i];
end;
TheDTM := AddDTM(DDTM);
end;

begin
MakeDTM([669,655,646,677,708,699],[86,81,96,96,108,119],[5995142,195836,15661038,15661038,15661038,2383671],[300,0,30,30,30,0],[0,0,0,0,0,0],[0,1,2,2,2,7]); //This one Doesn't work!
MakeTheDTM; //This one does WORK
if FindDTMRotated(TheDTM,x,y,MMX1,MMY1,MMX2,MMY2,0,2* pi,0.05, bla) then MoveMouse(x,y);
end.
The MakeDTM function does NOT work but the MakeTheDTM one does work:redface:.
Here i took a picture of what is inside the DDTMs before converting them to a integer:
http://img68.imageshack.us/img68/5518/40810756vd9.png. Im confused :p

~Raymond

nielsie95
07-07-2007, 06:24 PM
Markus and I have done this before..
For the version of Markus take a look in the Paths thread. :) (first page).

These are mine:


// Returns a TDTMPoint from a string
function TDTMFromStr(Str: String): TDTMPointDef;
var
Strings: TStringList;
begin
Strings := TStringList.Create;
Strings.Delimiter := ','
Strings.DelimitedText := Str;
if Strings.Count < 5 then Exit;

try
Result.x := StrToInt(Strings.Strings[0]);
Result.y := StrToInt(Strings.Strings[1]);
Result.AreaSize := StrToInt(Strings.Strings[2]);
Result.AreaShape := StrToInt(Strings.Strings[3]);
Result.Color := StrToInt(Strings.Strings[4]);
Result.Tolerance := StrToInt(Strings.Strings[5]);
except end;

Strings.Free;
end;

// Returns a DTM from a string
function DDTMFromStr(Str: String): Integer;
var
TempTDTM: TDTM;
dtmMainPoint: TDTMPointDef;
dtmSubPoints: Array of TDTMPointDef;
i: Integer;
Strings: TStringList;
begin
Strings := TStringList.Create;
Strings.Delimiter := ';'
Strings.DelimitedText := Str;
if Strings.Count < 2 then Exit;
dtmMainPoint := TDTMFromStr(Strings.Strings[0]);
SetArrayLength(dtmSubPoints, 0);

for i := 0 to Strings.Count -2 do
begin
SetArrayLength(dtmSubPoints, GetArrayLength(dtmSubPoints) +1);
dtmSubPoints[GetArrayLength(dtmSubPoints) -1] := TDTMFromStr(Strings.Strings[i + 1]);
end;

TempTDTM.MainPoint := dtmMainPoint;
TempTDTM.SubPoints := dtmSubPoints;
Result := AddDTM(TempTDTM);
Strings.Free;
end;

This is how your DDTM's now look like:



DDTMFromStr('425,230,0,0,3570130,255;' +
'427,227,0,0,65536,0;' +
'427,234,0,0,65536,0;' +
'421,226,0,0,65536,0');

mastaraymond
07-07-2007, 06:31 PM
Markus and I have done this before..
For the version of Markus take a look in the Paths thread. :) (first page).

These are mine:


This is how your DDTM's now look like:



DDTMFromStr('425,230,0,0,3570130,255;' +
'427,227,0,0,65536,0;' +
'427,234,0,0,65536,0;' +
'421,226,0,0,65536,0');


Well i still want to know what is wrong with mine :( because i really have no clue, but thaks for posting!

EDIT: I made a similair function like i had before but now it does work Procedure MakeDDTM(TheDDTM: TIntegerArray);
var
TempLength:integer;
begin;
TempLength:= (Length(TheDDTM) div 6)
DDTM.MainPoint.x:= TheDDTM[0];
DDTM.MainPoint.y:= TheDDTM[1];
DDTM.MainPoint.AreaSize:= TheDDTM[2];
DDTM.MainPoint.AreaShape:= TheDDTM[3];
DDTM.MainPoint.Color:= TheDDTM[4];
DDTM.MainPoint.Tolerance:= TheDDTM[5];
SetArrayLength(DDTM.SubPoints, 0);
for i := 0 to TempLength -2 do
begin
SetArrayLength(DDTM.SubPoints, Length(DDTM.SubPoints) +1);
DDTM.SubPoints[Length(DDTM.SubPoints) -1].x:= TheDDTM[(I+1)*6 + 0];
DDTM.SubPoints[Length(DDTM.SubPoints) -1].y:= TheDDTM[(I+1)*6 + 1];
DDTM.SubPoints[Length(DDTM.SubPoints) -1].AreaSize:= TheDDTM[(I+1)*6 + 2];
DDTM.SubPoints[Length(DDTM.SubPoints) -1].AreaShape:= TheDDTM[(I+1)*6 + 3];
DDTM.SubPoints[Length(DDTM.SubPoints) -1].Color:= TheDDTM[(I+1)*6 + 4];
DDTM.SubPoints[Length(DDTM.SubPoints) -1].Tolerance:= TheDDTM[(I+1)*6 + 5];
end;
TheDTM := AddDTM(DDTM);
end;

begin
MakeDDTM([669,86,0,0,5995142,300, 655,81,1,0,195836,0, 646,96,2,0,15661038,30, 677,96,2,0,15661038,30, 708,108,2,0,15661038,30, 669,119,7,0,2383671,0]);
if FindDTMRotated(TheDTM,x,y,MMX1,MMY1,MMX2,MMY2,0,2* pi,0.05, bla) then MoveMouse(x,y);
end.


EDIT: I can make it look pretty yours too :

MakeDDTM([669,86,0,0,5995142,300,
655,81,1,0,195836,0,
646,96,2,0,15661038,30,
677,96,2,0,15661038,30,
708,108,2,0,15661038,30,
669,119,7,0,2383671,0]);
^^