1
0
mirror of https://github.com/moparisthebest/Simba synced 2025-01-30 14:50:18 -05:00

Well - DTM needs some more work. It doesn't fully detect what areas it should search in - yet.

Basically:
	x1 = x1 - max(areasize * (negative) distance to main point) <-- Max of all points. Same for the rest.



git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@109 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
Wizzup? 2009-10-06 06:52:38 +00:00
parent 5015ece4e2
commit a063b83081
5 changed files with 133 additions and 97 deletions

View File

@ -33,7 +33,7 @@
<PackageName Value="LCL"/>
</Item2>
</RequiredPackages>
<Units Count="132">
<Units Count="133">
<Unit0>
<Filename Value="project1.lpr"/>
<IsPartOfProject Value="True"/>
@ -41,7 +41,7 @@
<CursorPos X="33" Y="12"/>
<TopLine Value="1"/>
<EditorIndex Value="0"/>
<UsageCount Value="166"/>
<UsageCount Value="167"/>
<Loaded Value="True"/>
</Unit0>
<Unit1>
@ -172,8 +172,8 @@
<UnitName Value="TestUnit"/>
<CursorPos X="10" Y="11"/>
<TopLine Value="1"/>
<EditorIndex Value="14"/>
<UsageCount Value="132"/>
<EditorIndex Value="12"/>
<UsageCount Value="133"/>
<Loaded Value="True"/>
</Unit18>
<Unit19>
@ -305,7 +305,7 @@
<CursorPos X="39" Y="8"/>
<TopLine Value="1"/>
<EditorIndex Value="2"/>
<UsageCount Value="131"/>
<UsageCount Value="132"/>
<Loaded Value="True"/>
</Unit37>
<Unit38>
@ -315,7 +315,7 @@
<CursorPos X="38" Y="32"/>
<TopLine Value="11"/>
<EditorIndex Value="1"/>
<UsageCount Value="131"/>
<UsageCount Value="132"/>
<Loaded Value="True"/>
</Unit38>
<Unit39>
@ -331,15 +331,17 @@
<UnitName Value="files"/>
<CursorPos X="15" Y="76"/>
<TopLine Value="47"/>
<UsageCount Value="132"/>
<UsageCount Value="133"/>
</Unit40>
<Unit41>
<Filename Value="../../Units/MMLCore/window.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="Window"/>
<CursorPos X="41" Y="243"/>
<CursorPos X="4" Y="228"/>
<TopLine Value="228"/>
<UsageCount Value="131"/>
<EditorIndex Value="4"/>
<UsageCount Value="132"/>
<Loaded Value="True"/>
</Unit41>
<Unit42>
<Filename Value="../../../Documents/lazarus/lcl/forms.pp"/>
@ -353,9 +355,7 @@
<UnitName Value="CompTypes"/>
<CursorPos X="35" Y="727"/>
<TopLine Value="712"/>
<EditorIndex Value="9"/>
<UsageCount Value="28"/>
<Loaded Value="True"/>
</Unit43>
<Unit44>
<Filename Value="../../Units/MMLCore/windowutil.pas"/>
@ -377,7 +377,7 @@
<UnitName Value="finder"/>
<CursorPos X="79" Y="29"/>
<TopLine Value="15"/>
<UsageCount Value="124"/>
<UsageCount Value="125"/>
</Unit46>
<Unit47>
<Filename Value="../../../lazarus/lcl/graphics.pp"/>
@ -392,7 +392,7 @@
<UnitName Value="MMLThread"/>
<CursorPos X="10" Y="62"/>
<TopLine Value="50"/>
<UsageCount Value="122"/>
<UsageCount Value="123"/>
</Unit48>
<Unit49>
<Filename Value="../../../Documents/fpc/rtl/objpas/classes/classesh.inc"/>
@ -404,10 +404,10 @@
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="mmlpsthread"/>
<CursorPos X="7" Y="75"/>
<TopLine Value="61"/>
<EditorIndex Value="10"/>
<UsageCount Value="120"/>
<CursorPos X="34" Y="114"/>
<TopLine Value="101"/>
<EditorIndex Value="8"/>
<UsageCount Value="121"/>
<Loaded Value="True"/>
</Unit50>
<Unit51>
@ -515,9 +515,9 @@
</Unit65>
<Unit66>
<Filename Value="../../Units/MMLAddon/PSInc/pscompile.inc"/>
<CursorPos X="24" Y="25"/>
<CursorPos X="60" Y="12"/>
<TopLine Value="1"/>
<EditorIndex Value="11"/>
<EditorIndex Value="9"/>
<UsageCount Value="34"/>
<Loaded Value="True"/>
</Unit66>
@ -539,7 +539,7 @@
<UnitName Value="bitmaps"/>
<CursorPos X="31" Y="430"/>
<TopLine Value="419"/>
<UsageCount Value="110"/>
<UsageCount Value="111"/>
</Unit69>
<Unit70>
<Filename Value="../../../FPC/FPCCheckout/packages/fcl-image/src/fpcanvas.pp"/>
@ -559,7 +559,7 @@
<IsPartOfProject Value="True"/>
<CursorPos X="11" Y="61"/>
<TopLine Value="65"/>
<UsageCount Value="109"/>
<UsageCount Value="110"/>
</Unit72>
<Unit73>
<Filename Value="../../../FPC/FPCCheckout/packages/fcl-image/src/fpcanvas.inc"/>
@ -691,7 +691,7 @@
<UnitName Value="colour_conv"/>
<CursorPos X="11" Y="148"/>
<TopLine Value="140"/>
<UsageCount Value="92"/>
<UsageCount Value="93"/>
</Unit92>
<Unit93>
<Filename Value="../../../cogat/Units/CogatUnits/compcolors.pas"/>
@ -750,7 +750,7 @@
<UnitName Value="plugins"/>
<CursorPos X="86" Y="128"/>
<TopLine Value="128"/>
<UsageCount Value="86"/>
<UsageCount Value="87"/>
</Unit101>
<Unit102>
<Filename Value="../../../Compilertje/Units/CogatUnits/compfiles.pas"/>
@ -834,7 +834,7 @@
<UnitName Value="compDTM"/>
<CursorPos X="9" Y="79"/>
<TopLine Value="61"/>
<EditorIndex Value="6"/>
<EditorIndex Value="7"/>
<UsageCount Value="23"/>
<Loaded Value="True"/>
</Unit114>
@ -842,10 +842,10 @@
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="dtm"/>
<CursorPos X="1" Y="753"/>
<TopLine Value="498"/>
<CursorPos X="3" Y="399"/>
<TopLine Value="387"/>
<EditorIndex Value="3"/>
<UsageCount Value="67"/>
<UsageCount Value="68"/>
<Loaded Value="True"/>
</Unit115>
<Unit116>
@ -861,8 +861,8 @@
<UnitName Value="colourpicker"/>
<CursorPos X="53" Y="33"/>
<TopLine Value="15"/>
<EditorIndex Value="12"/>
<UsageCount Value="63"/>
<EditorIndex Value="10"/>
<UsageCount Value="64"/>
<Loaded Value="True"/>
</Unit117>
<Unit118>
@ -888,7 +888,7 @@
<UnitName Value="windowselector"/>
<CursorPos X="76" Y="83"/>
<TopLine Value="65"/>
<UsageCount Value="53"/>
<UsageCount Value="54"/>
</Unit120>
<Unit121>
<Filename Value="../../../../../../usr/lib64/fpc/2.2.4/source/rtl/objpas/classes/classesh.inc"/>
@ -922,8 +922,8 @@
<UnitName Value="dtmutil"/>
<CursorPos X="1" Y="13"/>
<TopLine Value="1"/>
<EditorIndex Value="5"/>
<UsageCount Value="40"/>
<EditorIndex Value="6"/>
<UsageCount Value="41"/>
<Loaded Value="True"/>
</Unit125>
<Unit126>
@ -931,15 +931,13 @@
<UnitName Value="CompMaths"/>
<CursorPos X="15" Y="640"/>
<TopLine Value="636"/>
<EditorIndex Value="7"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
</Unit126>
<Unit127>
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/dtm.inc"/>
<CursorPos X="53" Y="14"/>
<TopLine Value="1"/>
<EditorIndex Value="13"/>
<CursorPos X="2" Y="23"/>
<TopLine Value="6"/>
<EditorIndex Value="11"/>
<UsageCount Value="18"/>
<Loaded Value="True"/>
</Unit127>
@ -955,9 +953,7 @@
<UnitName Value="CompScript"/>
<CursorPos X="1" Y="529"/>
<TopLine Value="508"/>
<EditorIndex Value="8"/>
<UsageCount Value="14"/>
<Loaded Value="True"/>
</Unit129>
<Unit130>
<Filename Value="../../../../Documents/fpc/rtl/objpas/math.pp"/>
@ -971,132 +967,139 @@
<IsPartOfProject Value="True"/>
<UnitName Value="mmath"/>
<CursorPos X="35" Y="45"/>
<TopLine Value="9"/>
<EditorIndex Value="4"/>
<UsageCount Value="20"/>
<TopLine Value="14"/>
<EditorIndex Value="5"/>
<UsageCount Value="21"/>
<Loaded Value="True"/>
</Unit131>
<Unit132>
<Filename Value="../../../../Documents/fpc/rtl/objpas/types.pp"/>
<UnitName Value="types"/>
<CursorPos X="5" Y="75"/>
<TopLine Value="60"/>
<UsageCount Value="10"/>
</Unit132>
</Units>
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
<Caret Line="8" Column="76" TopLine="1"/>
<Filename Value="../../Units/MMLAddon/PSInc/pscompile.inc"/>
<Caret Line="18" Column="30" TopLine="1"/>
</Position1>
<Position2>
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
<Caret Line="105" Column="38" TopLine="90"/>
<Filename Value="../../../cogat/Units/CogatUnits/compdtm.pas"/>
<Caret Line="61" Column="24" TopLine="41"/>
</Position2>
<Position3>
<Filename Value="../../../cogat/compscript.pas"/>
<Caret Line="38" Column="12" TopLine="23"/>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="8" Column="27" TopLine="1"/>
</Position3>
<Position4>
<Filename Value="../../../cogat/compscript.pas"/>
<Caret Line="465" Column="24" TopLine="450"/>
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
<Caret Line="49" Column="5" TopLine="31"/>
</Position4>
<Position5>
<Filename Value="../../../cogat/compscript.pas"/>
<Caret Line="472" Column="24" TopLine="450"/>
<Filename Value="../../Units/MMLAddon/PSInc/pscompile.inc"/>
<Caret Line="63" Column="30" TopLine="48"/>
</Position5>
<Position6>
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
<Caret Line="176" Column="20" TopLine="171"/>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="672" Column="16" TopLine="306"/>
</Position6>
<Position7>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="2" Column="46" TopLine="1"/>
<Caret Line="792" Column="34" TopLine="788"/>
</Position7>
<Position8>
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
<Caret Line="138" Column="22" TopLine="122"/>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="718" Column="4" TopLine="695"/>
</Position8>
<Position9>
<Filename Value="../../Units/MMLAddon/PSInc/pscompile.inc"/>
<Caret Line="18" Column="30" TopLine="1"/>
<Filename Value="../../../cogat/Units/CogatUnits/compdtm.pas"/>
<Caret Line="79" Column="9" TopLine="61"/>
</Position9>
<Position10>
<Filename Value="../../../cogat/Units/CogatUnits/compdtm.pas"/>
<Caret Line="61" Column="24" TopLine="41"/>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="629" Column="32" TopLine="594"/>
</Position10>
<Position11>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="8" Column="27" TopLine="1"/>
<Caret Line="89" Column="25" TopLine="74"/>
</Position11>
<Position12>
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
<Caret Line="49" Column="5" TopLine="31"/>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="228" Column="81" TopLine="224"/>
</Position12>
<Position13>
<Filename Value="../../Units/MMLAddon/PSInc/pscompile.inc"/>
<Caret Line="63" Column="30" TopLine="48"/>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="80" Column="60" TopLine="74"/>
</Position13>
<Position14>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="672" Column="16" TopLine="306"/>
<Caret Line="8" Column="66" TopLine="1"/>
</Position14>
<Position15>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="792" Column="34" TopLine="788"/>
<Caret Line="389" Column="16" TopLine="374"/>
</Position15>
<Position16>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="488" Column="4" TopLine="492"/>
<Caret Line="21" Column="28" TopLine="21"/>
</Position16>
<Position17>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="718" Column="4" TopLine="695"/>
<Caret Line="26" Column="28" TopLine="21"/>
</Position17>
<Position18>
<Filename Value="../../../cogat/Units/CogatUnits/compdtm.pas"/>
<Caret Line="79" Column="9" TopLine="61"/>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="32" Column="30" TopLine="21"/>
</Position18>
<Position19>
<Filename Value="../../../cogat/Units/CogatUnits/compmaths.pas"/>
<Caret Line="17" Column="44" TopLine="1"/>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="37" Column="29" TopLine="21"/>
</Position19>
<Position20>
<Filename Value="../../../cogat/Units/CogatUnits/compmaths.pas"/>
<Caret Line="53" Column="22" TopLine="38"/>
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/dtm.inc"/>
<Caret Line="13" Column="42" TopLine="1"/>
</Position20>
<Position21>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="629" Column="32" TopLine="594"/>
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/dtm.inc"/>
<Caret Line="32" Column="36" TopLine="11"/>
</Position21>
<Position22>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="89" Column="25" TopLine="74"/>
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/dtm.inc"/>
<Caret Line="23" Column="50" TopLine="1"/>
</Position22>
<Position23>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="228" Column="81" TopLine="224"/>
<Caret Line="26" Column="1" TopLine="8"/>
</Position23>
<Position24>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="80" Column="60" TopLine="74"/>
<Caret Line="24" Column="41" TopLine="9"/>
</Position24>
<Position25>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="8" Column="66" TopLine="1"/>
<Caret Line="33" Column="37" TopLine="18"/>
</Position25>
<Position26>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="389" Column="16" TopLine="374"/>
<Caret Line="21" Column="32" TopLine="6"/>
</Position26>
<Position27>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="21" Column="28" TopLine="21"/>
<Caret Line="439" Column="31" TopLine="418"/>
</Position27>
<Position28>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="26" Column="28" TopLine="21"/>
<Caret Line="422" Column="47" TopLine="418"/>
</Position28>
<Position29>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="32" Column="30" TopLine="21"/>
<Caret Line="447" Column="34" TopLine="425"/>
</Position29>
<Position30>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="37" Column="29" TopLine="21"/>
<Caret Line="393" Column="3" TopLine="380"/>
</Position30>
</JumpHistory>
</ProjectOptions>

View File

@ -11,6 +11,8 @@ var
ppdtm: pdtm;
w,h,x,y,dtm,i: integer;
a: extended;
p,pp: TPointArray;
c,t,asz,ash: TIntegerArray;
@ -47,4 +49,10 @@ begin
inttostr(p[0].x) + ', ' + inttostr(p[0].y));
movemouse(p[0].x,p[0].y);
end;
if FindDTMRotated(dtm, x, y, 0, 0, w-1, h-1, -3.14, 3.14, 0.05, a) then
begin
writeln('Found DTM at ' + inttostr(x) + ', ' + inttostr(y) + ' Angle: ' + FloatToStr(a));
movemouse(x,y);
end;
end.

View File

@ -8,7 +8,30 @@ begin
Result := CurrThread.Client.MDTM.FindDTMs(DTM, p, x1, y1, x2, y2);
end;
function ps_FindDTMRotated(DTM: Integer; var x, y: Integer; x1, y1, x2, y2:
Integer; sAngle, eAngle, aStep: Extended;
var aFound: Extended): Boolean;
begin
Result := CurrThread.Client.MDTM.FindDTMRotated(DTM, x, y, x1, y1, x2, y2,
sAngle, eAngle, aStep, aFound);
end;
function ps_FindDTMsRotated(DTM: Integer; var x, y: Integer; x1, y1, x2, y2:
Integer; sAngle, eAngle, aStep: Extended;
var aFound: Extended): Boolean;
begin
Result := CurrThread.Client.MDTM.FindDTMRotated(DTM, x, y, x1, y1, x2, y2,
sAngle, eAngle, aStep, aFound);
end;
function ps_FindDTMsRotated(DTM: Integer; var Points: TPointArray; x1,
y1, x2, y2: Integer; sAngle, eAngle,
aStep: Extended; var aFound: T2DExtendedArray)
: Boolean;
begin
Result := CurrThread.Client.MDTM.FindDTMsRotated(DTM, Points, x1, y1, x2, y2,
sAngle, eAngle, aStep, aFound);
end;
function ps_DTMFromString(DTMString: String): Integer;
var

View File

@ -8,7 +8,7 @@ Sender.Comp.AddTypes('TDTMPointDef', 'record x, y, Color, Tolerance, AreaSize, A
Sender.Comp.AddTypes('TDTMPointDefArray', 'Array Of TDTMPointDef;');
Sender.Comp.AddTypes('TDTM','record MainPoint: TDTMPointDef; SubPoints: TDTMPointDefArray; end;');
Sender.Comp.AddTypeS('pDTM','record p: TPointArray; c, t, asz, ash: TIntegerArray; end');
Sender.Comp.AddTypeS('T2DExtendedArray', 'array of array of extended');
Sender.AddFunction(@ThreadSafeCall,'function ThreadSafeCall(ProcName: string; var V: TVariantArray): Variant;');
Sender.AddFunction(@psWriteln,'procedure writeln(s : string);');
@ -23,6 +23,8 @@ Sender.AddFunction(@ps_DTMFromString, 'function DTMFromString(DTMString: String)
Sender.AddFunction(@ps_FreeDTM, 'procedure FreeDTM(DTM: Integer);');
Sender.AddFunction(@ps_FindDTM, 'function FindDTM(DTM: Integer; var x, y: Integer; x1, y1, x2, y2: Integer): Boolean;');
Sender.AddFunction(@ps_FindDTMs, 'function FindDTMs(DTM: Integer; var p: TPointArray; x1, y1, x2, y2: Integer): Boolean;');
Sender.AddFunction(@ps_FindDTMRotated, 'function FindDTMRotated(DTM: Integer; var x, y: Integer; x1, y1, x2, y2: Integer; sAngle, eAngle, aStep: Extended; var aFound: Extended): Boolean;');
Sender.AddFunction(@ps_FindDTMsRotated, 'function FindDTMsRotated(DTM: Integer; var Points: TPointArray; x1, y1, x2, y2: Integer; sAngle, eAngle, aStep: Extended; var aFound: T2DExtendedArray) : Boolean;');
Sender.AddFunction(@ps_addDTM, 'function AddDTM(d: TDTM): Integer;');
Sender.AddFunction(@ps_addpDTM, 'function AddpDTM(d: pDTM): Integer;');

View File

@ -425,8 +425,8 @@ begin
MaxSubPointDist.Y := Max(DTM.p[I].y, MaxSubPointDist.Y);
end;
X2 := X2 - MaxSubPointDist.X - 1;
Y2 := Y2 - MaxSubPointDist.Y - 1;
X2 := X2 - MaxSubPointDist.X;
Y2 := Y2 - MaxSubPointDist.Y;
X1 := X1 + MaxSubPointDist.X;
Y1 := Y1 + MaxSubPointDist.Y;
{If X2 > X1 then
@ -521,8 +521,8 @@ Begin
DTM.p[I].y := DTM.p[I].y - DTM.p[0].y;
End;
X2 := X2 - MaxSubPointDist.X - 1;
Y2 := Y2 - MaxSubPointDist.Y - 1;
X2 := X2 - MaxSubPointDist.X;
Y2 := Y2 - MaxSubPointDist.Y;
X1 := X1 + MaxSubPointDist.X;
Y1 := Y1 + MaxSubPointDist.Y;
{If X2 > X1 then
@ -615,8 +615,8 @@ Begin
DTM.p[I].y := DTM.p[I].y - DTM.p[0].y;
End;
X2 := X2 - MaxSubPointDist.X - 1;
Y2 := Y2 - MaxSubPointDist.Y - 1;
X2 := X2 - MaxSubPointDist.X;
Y2 := Y2 - MaxSubPointDist.Y;
X1 := X1 + MaxSubPointDist.X;
Y1 := Y1 + MaxSubPointDist.Y;
{If X2 > X1 then
@ -751,8 +751,8 @@ Begin
DTM.p[I].y := DTM.p[I].y - DTM.p[0].y;
End;
X2 := X2 - MaxSubPointDist.X - 1;
Y2 := Y2 - MaxSubPointDist.Y - 1;
X2 := X2 - MaxSubPointDist.X;
Y2 := Y2 - MaxSubPointDist.Y;
X1 := X1 + MaxSubPointDist.X;
Y1 := Y1 + MaxSubPointDist.Y;
{If X2 > X1 then