# MM2MS The core for our minimap to mainscreen projection. Supports rotation, and zoom, and resizable client. MM2MS extends the Minimap interface as well as the mainscreen interface with functionality to convert coordinates to & from the minimap to the mainscreen (mm2ms). Original work done by [slacky](https://slacky.one/). It's thanks to {ref}`MM2MS` that we can have the following grid: ```{figure} ../../images/mm2ms.png ``` MM2MS by itself is just a 3D grid with infinite cross sections in all axis (read {ref}`MM2MS Projector` for more information). It's up to you to give it coordinates you want to be converted, for example: ```pascal {$I WaspLib/osrs.simba} begin while True do begin Options.GetZoomLevel(False); Minimap.DebugTiles([]); end; end. ``` ```{figure} ../../images/mm2ms_flat.gif ``` But you can for example, use it with a {ref}`TRSMap` heightmap data for more advanced projections: ```pascal {$I WaspLib/osrs.simba} begin Map.Setup([ERSChunk.VARROCK]); while True do begin Options.GetZoomLevel(False); Map.DebugHeight(); end; end. ``` ```{figure} ../../images/mm2ms_height.gif ``` - - - ## TRSMM2MS Main record responsible for minimap to mainscreen ({ref}`MM2MS`) conversion. - - - ## MM2MS.Run ```pascal function TRSMM2MS.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 `TRSMinimap` and `TRSMainScreen` extensions below. - - - ## MM2MS variable Global {ref}`TRSMM2MS` variable. It's unlikely you need to use this directly. You usually only need the `TRSMinimap` and `TRSMainScreen` extensions below. - - - ## Minimap Vectors To MainScreen ```pascal function TRSMinimap.Vectors2MS(vectors: TVector3Array; angle: Single): TPointArray; function TRSMinimap.Vector2MS(vector: TVector3; angle: Single): TPoint; ``` Converts a minimap `vector` or `vectors` to the mainscreen with the help of `MM2MS`. - - - ## Minimap Points To MainScreen ```pascal function TRSMinimap.Points2MS(points: TPointArray; angle: Single = $FFFF): TPointArray; function TRSMinimap.Point2MS(pt: TPoint; angle: Single = $FFFF): TPoint; function TRSMinimap.ATPA2MS(atpa: T2DPointArray; angle: Single = $FFFF): T2DPointArray; overload; ``` Converts minimap `points` to the mainscreen with the help of `MM2MS`. - - - ## Minimap Points To MainScreen Quads ```pascal function TRSMinimap.Vector2MSQuad(vector: TVector3; angle: Single; size: TVector2 = [1,1]; offset: TVector3 = [0,0,0]): TQuad; function TRSMinimap.Point2MSQuad(pt: TPoint; size: TVector2 = [1,1]; angle: Single = $FFFF): TQuad; ``` Converts a minimap point `pt` or `vector` to a mainscreen `TQuad` with the help of `MM2MS`. Example: ```pascal while True do begin quad := Minimap.Point2MSQuad(Minimap.Center); ShowOnTarget(quad); end; ``` - - - ## Minimap Points To MainScreen Cuboids ```pascal function TRSMinimap.Vector2MSCuboid(vector, size: TVector3; angle: Single; offset: TVector3 = [0,0,0]): TCuboid; function TRSMinimap.Point2MSCuboid(pt: TPoint; size: TVector3; angle: Single = $FFFF): TCuboid; ``` Converts a minimap point `pt` or `vector` to a mainscreen `TCuboid` with the help of `MM2MS`. Example: ```pascal while True do begin cuboid := Minimap.Point2MSCuboid(Minimap.Center, [2,2,6]); ShowOnTarget(cuboid); end; ``` - - - ## MainScreen.Point2MM ```pascal function TRSMainScreen.Point2MM(pt: TPoint; height: Integer; angle: Single; accuracy: Single = 0.2): 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. - - - ## Minimap.ZoomQuad ```pascal property TRSMinimap.ZoomQuad: TQuad; ``` Returns a `TQuad` on the minimap of what's visible on the mainscreen at the current zoom level. Example: ```pascal while True do begin Options.GetZoomLevel(False); ShowOnTarget(Minimap.ZoomQuad); end; ``` - - - ## Minimap.PointOnZoomQuad ```pascal function TRSMinimap.PointOnZoomQuad(pt: TPoint): Boolean; ``` Returns True/False if a point `pt` is within our "zoom quad". Read `Minimap.ZoomQuad` for more information. Example: ```pascal WriteLn Minimap.PointOnZoomQuad(pt); ``` - - - ## Minimap.RandomPointOnZoomQuad ```pascal function TRSMinimap.RandomPointOnZoomQuad(pt: TPoint; randomness: Integer): TPoint; ``` Creates a random point within the zoom quad that is within `randomness` distance from `pt`. - - - ## Minimap.FacePoint ```pascal function TRSMinimap.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: ```pascal WriteLn Minimap.FacePoint([620, 100]); //keep in mind this example uses a static point, you will probably never do this. ``` - - - ## MainScreen.FacePoint ```pascal function TRSMainScreen.FacePoint(pt: TPoint; randomness: Integer = 0): Boolean; override; ``` Rotates the camera to face point `pt`. - - - ## MainScreen.NormalizeDistance ```pascal function TRSMainScreen.NormalizeDistance(dist: Integer; accuracy: Single = 1.05): Integer; ``` Converts a distance acquired from the **fixed client* and **default zoom** to the current mainscreen. Example: ```pascal // 20 pixels on the fixed client and default zoom(50) is currently x pixels at the current zoom & client size. WriteLn(MainScreen.TranslateDistance(20)); ``` - - - ## Minimap.InZoomRange ```pascal function TRSMinimap.InZoomRangeEx(pt: TPoint; out corner: TPoint): Boolean; function TRSMinimap.InZoomRange(pt: TPoint): Boolean; function TRSMinimap.AnyInZoomRange(tpa: TPointArray): Boolean; overload; ``` Method used to know if a point `pt`is within reach of the Zoom rectangle without adjusting the zoom level. Check `TRSMinimap.ZoomQuad` for information on the zoom quad. Example: ```pascal WriteLn Minimap.InZoomRange([620, 100]); ``` - - - ## Minimap.GetZoomToPoint ```pascal function TRSMinimap.GetZoomToPoint(p: TPoint; randomness: Integer = 0): Integer; ``` This function gives us a zoom level where **P** would be visible in the MainScreen. Example: ```pascal p := Minimap.GetDots(ERSMinimapDot.ITEM)[0]; //find an item dot and returns it's coodinates. Options.SetZoomLevel(Minimap.ZoomToVisiblePoint(p)); ``` - - - ## Minimap.SetZoom2Point ```pascal function TRSMinimap.SetZoom2Point(pt: TPoint; randomness: Integer = 0): Boolean; ``` This function adjusts the zoom level so the point **pt** is true in `TRSMinimap.InZoomRange()`. - - - ## Minimap.MakePointVisible ```pascal function TRSMinimap.MakePointVisible(p: TPoint): Boolean; ``` Uses both Minimap.Zoom2Point() and Minimap.FacePoint() to make a point visible on the Mainscreen. - - - ## Minimap.DebugTiles ```pascal procedure TRSMinimap.DebugTiles(dots: ERSMinimapDots = [ERSMinimapDot.PLAYER, ERSMinimapDot.NPC, ERSMinimapDot.ITEM]); ``` 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 `ERSMinimapDot` you want to highlight. By default all are highlighted. Example: ```pascal Minimap.DebugTiles(); ``` - - - ## MainScreen.PlayerBox ```pascal property TRSMainScreen.PlayerBox: TBox; ``` Returns a `TBox` on the mainscreen that tightly bounds the player. Results are cached per zoom level to avoid unnecessary recomputation. Example: ```pascal {$I WaspLib/osrs.simba} begin while True do begin Options.GetZoomLevel(False); ShowOnTarget(MainScreen.PlayerBox); end; end. ``` ```{figure} ../../images/mm2ms_playerbox.gif ```