SRL Archive - OSR Help

Why is this not doing what it should?


Cage

2014-06-20 10:33:40

Hello all,

I am currently working on my object finding function to find ores within an area.
As far as finding the actual ores goes, it is fine. Debug ATPA shows nice neat little boxes surrounding all of the ores.

However, I have tried two things to try and organise the ores by distance from the centre of the screen (aka me) I have tried FindColorsSpiralTolerence and SortATPAFrom.

With both of these, should't the ATPA be organised on its distance from my character? Because at the moment the first one it appears to finding is pretty far away. See code and Pic Below:

What am I doing wrong guys? :)



Function OreFinder : boolean;

var
X, Y, I, OriginalCTS : Integer;
OriginalHue, OriginalSat: Extended;
TPA: TPointArray;
TPAA: T2DPointArray;

begin
OriginalCTS := GetColorToleranceSpeed;
GetColorspeed2Modifiers(OriginalHue, OriginalSat);
SetColorToleranceSpeed(2);
SetColorspeed2Modifiers(0.08, 0.14);
FindColorsSpiralTolerance(X, Y, TPA, 2767437, MSX1, MSY1, MSX2, MSY2, 17);
ColorToleranceSpeed(OriginalCTS);
SetColorspeed2Modifiers(OriginalHue, OriginalSat);
TPAA := TPAtoATPAEx(TPA, 28, 28);
SortATPAFrom(TPAA, Point(MSCX, MSCY));
SMART_DebugATPA(True, TPAA);
end;

Olly

2014-06-20 10:45:57

Use SortATPAFromMidPoint, SortATPAFrom sorts each tpa in the atpa from the point.

rj

2014-06-20 11:52:06

You should use clustertpa it is a lot faster and accurate for this it will get rid of a lot of those boxes (thus also speeding the function above up)

Atpa := clustertpa (tpa, 4)

4 is the distance between each point

Olly

2014-06-20 11:53:06

Or in use simbas you can PartitionTPA :D