
Originally Posted by
Obscurity
Brandon, I'm at work so can't send any examples ATM, but his map issue may relate to mine.
Whe tracing the coordinates returned by GLX map coords (I don't remember the exact name - again, work), it's off by up to 200px sometimes, if I recall correctly. It's still a perfect rectangle around the map, but the actual map image is in much farther then the actual point given.
I'll give examples and screenshots when I get home, mate. Cheers.
Are you talking about:

Because if so, then you are missing the point of the function entirely..
Simba Code:
{$DEFINE SMART}
{$DEFINE SmartWrappers}
{$I GLX/Setup.Simba}
var
Smart: TSmart;
TL, BL, BR, TR: FloatPoint;
R: TBox;
begin
ClearDebug();
SetupGLX(Smart, 800, 600);
GL_GetMapCoords(TL, BL, BR, TR);
R := ToRect(TL, BL, BR, TR);
Smart.Graphics().DrawRotatedBoxes([R]);
end.
That function is supposed to return the bounds of the map and it does exactly that (regardless of rotation). Nothing more.. nothing less.. You can try saving the map to the disk and see that it has an alpha layer surrounding it.. So it's not actually wrong. It's just the bounds it returns ALSO includes the transparent pixels surrounding the map..
Hence:
Simba Code:
{*
Returns the current loaded map as a bitmap.
Developer Notes:
Returned Bitmap Size: 512x512
*}
Function GL_MapToImageEx: Integer;
{*
Returns the current loaded map as a bitmap with the outline stripped.
Developer Notes:
Original Size: 512x512
Returned Bitmap Size: 408x408
*}
Function GL_MapToImage: Integer;
Is that what you meant?
As for GL_GetLocalPos.. It isn't wrong..

Simba Code:
{$DEFINE SMART}
{$DEFINE SmartWrappers}
{$I GLX/Setup.Simba}
Function ToRect(TL, BL, BR, TR: FloatPoint): TBox;
begin
Result.X1 := round(TL.X);
Result.Y1 := round(TL.Y);
Result.X2 := round(BR.X);
Result.Y2 := round(BR.Y);
end;
Function LocalPosToMM(Pos: TPoint): TPoint;
var
Me: TPoint;
DX, DY: Integer;
Begin
Me := GL_GetLocalPos;
DX := Pos.X - Me.X;
DY := Pos.Y - Me.Y;
Me := MiddleBox(GL_MMBounds);
Result.X := Me.X + DX;
Result.Y := Me.Y + DY;
End;
var
Smart: TSmart;
P: TPoint;
TL, BL, BR, TR: FloatPoint;
begin
//ClearDebug();
SetupGLX(Smart, 800, 600);
GL_GetMapCoords(TL, BL, BR, TR);
P := GL_GetLocalPos;
P := LocalPosToMM(P);
Mouse(P);
end.
Remember that the local pos in OpenGL is NOT the same as in Reflection. The LocalPos in OpenGL is the coordinate RELATIVE to the map! (specifically the top left). Assume the map is perfectly north:
MMPos = TopLeftOfMap + P.
Assume the map is perfectly South (upside down):
MMPos = TopLeft - P.
Why minus? Because the top left of the map is literally drawn at the bottom right of the minimap. The player stands at the center of the map.
LocalPos works by returning a negative coord when facing south. If the top left is drawn at the bottom right, the player stands at a negative position relative to the bottom right (top left of the map). It uses CrossProduct to determine the player's position WITHIN the current chunk of the map. NOT the global world map!
The above LocalPos will return a point on the minimap relative to the TopLeft of the map (wherever that is drawn).. Just because the map is upside down (when facing perfectly south), does not mean that it's top left is now the bottom right because that's wrong! The top left is simply "drawn" at a different position (bottom right) but it is STILL the top left (it's the way OpenGL works). Very confusing!
A simpler way of saying it is this: If you want to draw an image upside down, why flip all the pixels? You can simply specify a negative coordinate around the horizontal axis to flip it OR you can swap the Y values.. This will flip the image upside down by simply drawing the top where the bottom is supposed to be and the bottom where the top is supposed to be.. However, the image itself is still upright. It is just "drawn" upside down so the top of the image itself is still the top! Only its coordinates changed.
The original way (Kasi's way) of calculating local pos was to "un-rotate" the map coords around the center of the minimap (such that the top is horizontal and the map faces north) and then calculate position relative to the top left.. but there's no need for that (Bart's way).. Kasi's is probably better for calculating MMPos from a point.
Anyway..
When you log in, the map you are standing in, is the TRUE CHUNK of the global map.. You are placed at the center of this map. However, when you walk to a new map chunk, you are positioned at one of its edges (you are east, walking west when you hit a new map, you will be placed far east on a combined chunk of the map).. This makes LocalPos entirely useless unless you combine it with SPS.. thus making it the "perfect" SPS there can possibly be. Hence.. the need for GlobalPos arose but I never figured out how to get it..
I hope I have covered all the bases and crossed the T's, dotted the I's..
I understand there's very little documentation on the internals but I did explain all this once upon a time I think?