Projection¶
The core for our minimap to mainscreen projection.
Supports rotation, and zoom, and resizable client.
In the case of TCamera it also supports different pitch levels.
Projection extends the Minimap and MainScreen interfaces with
functionality to convert coordinates to & from one to the other, usually refered
to as MM2MS or MS2MM.
There’s 2 systems of projection:
MM2MS, original work done by slacky.
RSCamera, a reverse engineered projection from the client itself.
It’s thanks to these that we can project the following grid, in this example MM2MS is being used:
Projection by itself is just a 3D space, sort of like a grid with infinite cross sections in all axis (read MM2MS Projector for more information).
It’s up to you to give it coordinates you want to be converted, for example:
{$I WaspLib/main.simba}
begin
while True do
begin
Options.GetZoomLevel(False);
Minimap.DebugTiles();
end;
end.
But you can for example, use it with a TMap heightmap data for more advanced projections:
{$I WaspLib/main.simba}
begin
Map.Setup([EChunk.VARROCK]);
while True do
begin
Options.GetZoomLevel(False);
Map.DebugHeight();
end;
end.
TProjection¶
Main record responsible for projection.
Projection.Run¶
function TProjection.Run(arr: TVector3Array; roll: Single): TPointArray;
Core method that will run the TMM2MSProjector to convert points from the
minimap to the mainscreen.
You will likely not need to use this directly and will only interact with the
TMinimap and TMainScreen extensions below.
Projection.ProjectModel¶
function TProjection.ProjectModelEx(model: TModel; minimapCoord: TVector3; heights: array [0..3] of Single; rotation, radians: Single): TPointArray;
function TProjection.ProjectModel(model: TModel; minimapCoord: TVector3; rotation, radians: Single): TPointArray;
Projects a model from a Minimap Coordinate to the MainScreen.
Example:
{$I WaspLib/main.simba}
var
model: TModel;
tpa: TPointArray;
begin
model := new TModel('path/to/my/model.obj');
tpa := Projection.ProjectModel(Minimap.Center.ToVec3(), Minimap.CompassRadians, 0);
ShowOnTarget(tpa);
end.
Projection variable¶
Global TProjection variable.
It’s unlikely you need to use this directly.
You usually only need the TMinimap and TMainScreen extensions below.
Minimap Projection Extensions¶
This section contains multiple extensiosn to TMinimap type related to Projection.
Minimap Vectors To MainScreen¶
function TMinimap.Vectors2MS(vectors: TVector3Array; radians: Single): TPointArray;
function TMinimap.Vector2MS(vector: TVector3; radians: Single): TPoint;
Converts a minimap vector or vectors to the mainscreen with the help of MM2MS.
Minimap Points To MainScreen¶
function TMinimap.Points2MS(points: TPointArray; radians: Single = $FFFF): TPointArray;
function TMinimap.Point2MS(pt: TPoint; radians: Single = $FFFF): TPoint;
function TMinimap.ATPA2MS(atpa: T2DPointArray; radians: Single = $FFFF): T2DPointArray; overload;
Converts minimap points to the mainscreen with the help of MM2MS.
Minimap Points To MainScreen Quads¶
function TMinimap.Vector2MSQuad(vector: TVector3; radians: Single; size: TVector2 = [1,1]; offset: TVector3 = [0,0,0]): TQuad;
function TMinimap.Point2MSQuad(pt: TPoint; size: TVector2 = [1,1]; radians: Single = $FFFF): TQuad;
Converts a minimap point pt or vector to a mainscreen TQuad with the help of MM2MS.
Example:
while True do
begin
quad := Minimap.Point2MSQuad(Minimap.Center);
ShowOnTarget(quad);
end;
Minimap Points To MainScreen Cuboids¶
function TMinimap.Vector2MSCuboid(vector, size: TVector3; radians: Single; offset: TVector3 = [0,0,0]): TCuboid;
function TMinimap.Point2MSCuboid(pt: TPoint; size: TVector3; radians: Single = $FFFF): TCuboid;
Converts a minimap point pt or vector to a mainscreen TCuboid with the help of MM2MS.
Example:
while True do
begin
cuboid := Minimap.Point2MSCuboid(Minimap.Center, [2,2,6]);
ShowOnTarget(cuboid);
end;
Minimap.ZoomQuad¶
property TMinimap.ZoomQuad: TQuad;
Returns a TQuad on the minimap of what’s visible on the mainscreen at the current zoom level.
Example:
{$I WaspLib/main.simba}
begin
while True do
begin
Options.GetZoomLevel(False);
ShowOnTarget(Minimap.ZoomQuad);
end;
end.
Minimap.PointOnZoomQuad¶
function TMinimap.PointOnZoomQuad(pt: TPoint): Boolean;
Returns True/False if a point pt is within our “zoom quad”.
Read Minimap.ZoomQuad for more information.
Example:
WriteLn Minimap.PointOnZoomQuad(pt);
Minimap.RandomPointOnZoomQuad¶
function TMinimap.RandomPointOnZoomQuad(pt: TPoint; randomness: Integer): TPoint;
Creates a random point within the zoom quad that is within randomness distance from pt.
Minimap.FacePoint¶
function TMinimap.FacePoint(pt: TPoint; randomness: Integer = 0): Boolean;
This method will rotate the camera so that pt is within the zoom rectangle without adjusting the zoom level.
Example:
WriteLn Minimap.FacePoint([620, 100]); //keep in mind this example uses a static point, you will probably never do this.
Minimap.InZoomRange¶
function TMinimap.InZoomRangeEx(pt: TPoint; out corner: TPoint): Boolean;
function TMinimap.InZoomRange(pt: TPoint): Boolean;
function TMinimap.AnyInZoomRange(tpa: TPointArray): Boolean; overload;
Method used to know if a point ptis within reach of the Zoom rectangle without adjusting the zoom level.
Check TMinimap.ZoomQuad for information on the zoom quad.
Example:
WriteLn Minimap.InZoomRange([620, 100]);
Minimap.GetZoomToPoint¶
function TMinimap.GetZoomToPoint(pt: TPoint; randomness: Integer = 0): Integer;
This function gives us a zoom level where pt would be visible in the
MainScreen.
Example:
{$I WaspLib/main.simba}
var
pt: TPoint;
begin
pt := Minimap.GetDots(EDot.ITEM)[0]; //find an item dot and returns it's coodinates.
RSMouseZoom.SetZoomLevel(Minimap.GetZoomToPoint(pt));
end.
Minimap.SetZoomToPoint¶
function TMinimap.SetZoomToPoint(pt: TPoint; randomness: Integer = 0): Boolean;
This function adjusts the zoom level so the point pt is true in Minimap.InZoomRange.
Minimap.MakePointVisible¶
function TMinimap.MakePointVisible(p: TPoint; randomness: Integer = 0): Boolean;
Uses both Minimap.SetZoomToPoint and Minimap.FacePoint to make a point visible on the MainScreen.
Minimap.DebugTiles¶
procedure TMinimap.DebugTiles(img: TImage; dots: EDots);
procedure TMinimap.DebugTiles(dots: EDots = [EDot.PLAYER..EDot.ITEM]); overload;
Simply meant for debugging purposes.
Will draw a grid of tiles on the mainscreen with the help of MM2MS.
You can optionally specify which minimap EDot you want to highlight.
By default all are highlighted.
Example:
Minimap.DebugTiles();
MainScreen Projection Extensions¶
This section contains multiple extensiosn to TMainScreen related to Projection.
MainScreen.Point2MM¶
function TMainScreen.Point2MM(pt: TPoint; height: Integer; radians: Single): TVector3;
Converts a mainscreen point pt to a minimap TPoint with the help of MM2MS.
This is not an exact reversion of what MM2MS does but it’s very accurate.
MainScreen.FacePoint¶
function TMainScreen.FacePoint(pt: TPoint; randomness: Integer = 0): Boolean; override;
Rotates the camera to face point pt.
MainScreen.NormalizeDistance¶
function TMainScreen.NormalizeDistance(dist: Integer): Integer;
Converts a distance acquired from the *fixed client and default zoom to the current mainscreen with help of MM2MS.
For example, say you want to create a box with the same size regardless of the zoom level:
{$I WaspLib/main.simba}
var
b: TBox;
dist: Integer;
begin
while True do
begin
Options.GetZoomLevel(False);
dist := MainScreen.NormalizeDistance(50);
b := TBox.Create(MainScreen.Center, dist, dist);
ShowOnTarget(b);
end;
end.
It will look something like this:
MainScreen.PlayerBox¶
property TMainScreen.PlayerBox: TBox;
Returns a TBox on the mainscreen that tightly bounds the player.
Results are cached per zoom level to avoid unnecessary recomputation.
Example:
{$I WaspLib/main.simba}
begin
while True do
begin
Options.GetZoomLevel(False);
ShowOnTarget(MainScreen.PlayerBox);
end;
end.
MainScreen.SetHighestPitch¶
function TMainScreen.SetHighestPitch(): Boolean;
Attempts to set the camera pitch to the highest possible.
Example:
if not MainScreen.HighestPitch then
MainScreen.SetHighestPitch();
MainScreen.SetLowestPitch¶
function TMainScreen.SetLowestPitch(): Boolean;
Attempts to set the camera pitch to the lowest possible.
Example:
if MainScreen.HighestPitch then
MainScreen.SetLowestPitch();