Table of Contents

Struct MapViewTransform

Namespace
FishMMO.Client
Assembly
FishMMO.Client.dll

The window a map panel is showing: where it is centred in the world, how much of the world it covers, and which way is up.

public readonly struct MapViewTransform
Inherited Members

Remarks

One struct shared by the minimap and the world map, and by the camera and the UI inside each. That is the point of it: the overhead camera, the fog overlay and every marker have to agree on the mapping from world space to the rectangle on screen, and three hand-rolled copies of the same trigonometry is how a marker ends up a few pixels off its terrain — or, once the map can rotate, drifting further out the further it gets from the centre.

The mapping is deliberately expressed in normalised view coordinates — 0..1 across the visible rectangle, Y up — rather than in pixels. The two panels are different sizes and the world map is resizable, so pixels are the caller's business; and normalised coordinates are what both the camera projection and UI Toolkit's mesh UVs want anyway.

Constructors

MapViewTransform(Vector3, float, float)

Builds a view window.

public MapViewTransform(Vector3 center, float range, float rotationDegrees)

Parameters

center Vector3

World-space centre. Y is ignored.

range float

Half-extent in world metres. Clamped to a positive value.

rotationDegrees float

Rotation in degrees clockwise. Zero puts +Z up.

Fields

Center

World-space centre of the view. Y is ignored.

public readonly Vector3 Center

Field Value

Vector3

Range

Half the width and half the height of the view, in world metres.

public readonly float Range

Field Value

float

Remarks

Square rather than a full rectangle. The minimap frame is square, the world map keeps its aspect by letterboxing rather than by stretching the world, and a single number is what the camera's orthographic size wants.

RotationDegrees

Rotation of the view, in degrees clockwise. Zero puts world +Z at the top.

public readonly float RotationDegrees

Field Value

float

Properties

Diameter

The diameter of the view in world metres.

public float Diameter { get; }

Property Value

float

WorldRect

The world-space rectangle this view covers when it is not rotated.

public Rect WorldRect { get; }

Property Value

Rect

Remarks

Only meaningful at zero rotation — a rotated view covers a rotated square, which is not a Rect. Used for the axis-aligned work that only the world map does, where the view is always north-up.

Methods

ViewToWorld(Vector2)

Converts normalised view coordinates back into a world position.

public Vector3 ViewToWorld(Vector2 view)

Parameters

view Vector2

Normalised view coordinates, X and Y in 0..1.

Returns

Vector3

The world position, with Y taken from Center.

WorldToView(Vector3)

Converts a world position into normalised view coordinates.

public Vector2 WorldToView(Vector3 worldPosition)

Parameters

worldPosition Vector3

The world position. Y is ignored.

Returns

Vector2

X and Y in 0..1 across the view, Y increasing towards the top of the map. Values outside 0..1 are returned as they are: a caller drawing an off-view marker needs the unclamped vector to work out which edge to pin it to.

WorldToViewAngle(float)

Converts a world-space heading into the angle it should be drawn at on this view.

public float WorldToViewAngle(float worldDegrees)

Parameters

worldDegrees float

Heading in degrees clockwise from world north.

Returns

float

Heading in degrees clockwise from the top of the map.