Gondwana Game Engine
Gondwana is a cross-platform 2.5D game and rendering engine written in C#/.NET 8. It provides fine-grained control over rendering, timing, and scene composition, with built-in support for parallax, z-ordering, pixel overhang, collision detection, and particle effects. Gondwana targets desktop, mobile, and web platforms using SkiaSharp for graphics and NAudio for sound.
Loading...
Searching...
No Matches
Gondwana.Rendering.Views.View Class Referencesealed

Represents a rendered view of a scene, combining a camera position with a viewport configuration to control what portion of the world is visible and how it is displayed on screen. Multiple views can be used to create split-screen, picture-in-picture, or other multi-viewport rendering scenarios. More...

Public Member Functions

void ZoomAroundScreenPoint (SceneLayer layer, PointF screenPoint, float targetZoom, float durationSeconds)
 Smoothly zooms the view so that a given screen-space point appears to zoom in/out around a fixed world position beneath it, similar to map-style mouse-wheel zoom. Both the viewport zoom and camera position are animated over the specified duration.
PointF ScreenPxToWorldPx (SceneLayer layer, PointF screenPx)
 Converts a screen-space pixel position into world-space coordinates for the specified scene layer, accounting for the view's camera position, viewport zoom, screen offsets, and the layer's parallax factor.
PointF WorldPxToScreenPx (SceneLayer layer, PointF worldPx)
 Converts a world-space pixel position into screen-space coordinates for this view, accounting for the camera position, viewport zoom, screen offsets, and the specified layer's parallax factor.
PointF ScreenPxToGrid (SceneLayer layer, PointF screenPx)
 Converts a point in screen-space into the grid coordinate on the specified SceneLayer by first mapping the screen pixel to world-space, then letting the layer's coordinate system resolve the corresponding tile.
RectangleF WorldRectToScreenRect (SceneLayer layer, RectangleF worldRect)
 Converts a world-space pixel rectangle into a screen-space rectangle for this View, using the specified layer's parallax factor.
RectangleF ScreenRectToWorldRect (SceneLayer layer, RectangleF screenRect)
 Converts a screen-space rectangle (on the adapter) into a world-space rectangle for the given layer, respecting zoom, camera position, viewport offsets, and the layer's parallax factor.

Properties

Guid Id = Guid.NewGuid() [get]
 Gets the unique identifier for this view instance.
Camera Camera [get]
 Gets the camera that controls the world-space position and following behavior for this view. The camera determines which part of the world is visible.
Viewport Viewport [get]
 Gets the viewport that defines the screen-space rectangle, zoom level, and other rendering parameters for this view. The viewport controls how the camera's visible world region is mapped to screen pixels.
int ZOrder = 0 [get, set]
 Controls the draw order of this view relative to other views. Lower values are drawn first (behind); higher values are drawn later (in front).

Detailed Description

Represents a rendered view of a scene, combining a camera position with a viewport configuration to control what portion of the world is visible and how it is displayed on screen. Multiple views can be used to create split-screen, picture-in-picture, or other multi-viewport rendering scenarios.

Member Function Documentation

◆ ScreenPxToGrid()

PointF Gondwana.Rendering.Views.View.ScreenPxToGrid ( SceneLayer layer,
PointF screenPx )

Converts a point in screen-space into the grid coordinate on the specified SceneLayer by first mapping the screen pixel to world-space, then letting the layer's coordinate system resolve the corresponding tile.

Parameters
layerThe SceneLayer whose grid the point should be mapped onto.
screenPxThe pixel position relative to the RenderSurface.
Returns
The grid coordinate (column/row or axial) under the screen pixel.

◆ ScreenPxToWorldPx()

PointF Gondwana.Rendering.Views.View.ScreenPxToWorldPx ( SceneLayer layer,
PointF screenPx )

Converts a screen-space pixel position into world-space coordinates for the specified scene layer, accounting for the view's camera position, viewport zoom, screen offsets, and the layer's parallax factor.

Parameters
layerThe scene layer whose parallax factor should be used for the conversion.
screenPxThe screen-space pixel position relative to the render surface.
Returns
The corresponding world-space pixel position.

The transformation formula is:

world = camera * parallax + (screen - offset) * zoom

This is commonly used for mouse picking and screen-to-world raycasting.

◆ ScreenRectToWorldRect()

RectangleF Gondwana.Rendering.Views.View.ScreenRectToWorldRect ( SceneLayer layer,
RectangleF screenRect )

Converts a screen-space rectangle (on the adapter) into a world-space rectangle for the given layer, respecting zoom, camera position, viewport offsets, and the layer's parallax factor.

Inverse of: screen = offset + (world - camera * p) / zoom

◆ WorldPxToScreenPx()

PointF Gondwana.Rendering.Views.View.WorldPxToScreenPx ( SceneLayer layer,
PointF worldPx )

Converts a world-space pixel position into screen-space coordinates for this view, accounting for the camera position, viewport zoom, screen offsets, and the specified layer's parallax factor.

Parameters
layerThe scene layer whose parallax factor should be used for the conversion.
worldPxThe world-space pixel position to convert.
Returns
The corresponding screen-space pixel position on the render surface.

The transformation formula is:

screen = offset + (world - camera * parallax) / zoom

This is commonly used for rendering world objects to screen coordinates and for UI elements that track world positions.

◆ WorldRectToScreenRect()

RectangleF Gondwana.Rendering.Views.View.WorldRectToScreenRect ( SceneLayer layer,
RectangleF worldRect )

Converts a world-space pixel rectangle into a screen-space rectangle for this View, using the specified layer's parallax factor.

Matches the render path: screen = offset + (world - camera * parallax) / zoom

Parameters
layerScene layer whose parallax should be applied.
worldRectWorld-space rectangle (in pixels).
Returns
Screen-space rectangle on the render surface.

◆ ZoomAroundScreenPoint()

void Gondwana.Rendering.Views.View.ZoomAroundScreenPoint ( SceneLayer layer,
PointF screenPoint,
float targetZoom,
float durationSeconds )

Smoothly zooms the view so that a given screen-space point appears to zoom in/out around a fixed world position beneath it, similar to map-style mouse-wheel zoom. Both the viewport zoom and camera position are animated over the specified duration.

Parameters
layerReference layer whose parallax factor is used for the world-space transform. Typically the main gameplay layer (parallax = 1).
screenPointMouse position in adapter/screen pixels relative to the render surface.
targetZoomDesired zoom factor after the animation completes.
durationSecondsApproximate duration in seconds for the zoom + pan animation. Values <= 0 snap immediately.

Property Documentation

◆ Camera

Camera Gondwana.Rendering.Views.View.Camera
get

Gets the camera that controls the world-space position and following behavior for this view. The camera determines which part of the world is visible.

The Views.Camera instance associated with this view.

◆ Id

Guid Gondwana.Rendering.Views.View.Id = Guid.NewGuid()
get

Gets the unique identifier for this view instance.

A GUID that uniquely identifies this view throughout its lifetime.

◆ Viewport

Viewport Gondwana.Rendering.Views.View.Viewport
get

Gets the viewport that defines the screen-space rectangle, zoom level, and other rendering parameters for this view. The viewport controls how the camera's visible world region is mapped to screen pixels.

The Views.Viewport instance associated with this view.

◆ ZOrder

int Gondwana.Rendering.Views.View.ZOrder = 0
getset

Controls the draw order of this view relative to other views. Lower values are drawn first (behind); higher values are drawn later (in front).