Table of Contents

Class Terrain

Namespace
Alis.Core.Physic.Common.TextureTools
Assembly
Alis.dll

Simple class to maintain a terrain. It can keep track

public class Terrain

Inheritance

Inherited Members

Constructors

Terrain(World, AABB)

Creates a new terrain.

public Terrain(World world, AABB area)

Parameters

world World

The World

area AABB

The area of the terrain.

Terrain(World, Vector2, float, float)

Creates a new terrain

public Terrain(World world, Vector2 position, float width, float height)

Parameters

world World

The World

position Vector2

The position (center) of the terrain.

width float

The width of the terrain.

height float

The height of the terrain.

Fields

CellSize

Points per cell.

public int CellSize

Field Value

int

Center

Center of terrain in world units.

public Vector2 Center

Field Value

Vector2

Decomposer

Decomposer to use when regenerating terrain. Can be changed on the fly without consequence. Note: Some decomposerers are unstable.

public TriangulationAlgorithm Decomposer

Field Value

TriangulationAlgorithm

Height

Height of terrain in world units.

public float Height

Field Value

float

Iterations

Number of iterations to perform in the Marching Squares algorithm. Note: More then 3 has almost no effect on quality.

public int Iterations

Field Value

int

PointsPerUnit

Points per each world unit used to define the terrain in the point cloud.

public int PointsPerUnit

Field Value

int

SubCellSize

Points per sub cell.

public int SubCellSize

Field Value

int

Width

Width of terrain in world units.

public float Width

Field Value

float

World

World to manage terrain in.

public World World

Field Value

World

_bodyMap

Generated bodies.

private List<Body>[,] _bodyMap

Field Value

List<Body>[,]

_dirtyArea

The dirty area

private AABB _dirtyArea

Field Value

AABB

_localHeight

The local height

private float _localHeight

Field Value

float

_localWidth

The local width

private float _localWidth

Field Value

float

_terrainMap

Point cloud defining the terrain.

private sbyte[,] _terrainMap

Field Value

sbyte[,]

_topLeft

The top left

private Vector2 _topLeft

Field Value

Vector2

_xnum

The xnum

private int _xnum

Field Value

int

_ynum

The ynum

private int _ynum

Field Value

int

Methods

ApplyData(sbyte[,], Vector2)

Apply the specified texture data to the terrain.

public void ApplyData(sbyte[,] data, Vector2 offset = default)

Parameters

data sbyte[,]
offset Vector2

GenerateTerrain(int, int)

Generates the terrain using the specified gx

private void GenerateTerrain(int gx, int gy)

Parameters

gx int

The gx

gy int

The gy

Initialize()

Initialize the terrain for use.

public void Initialize()

ModifyTerrain(Vector2, sbyte)

Modify a single point in the terrain.

public void ModifyTerrain(Vector2 location, sbyte value)

Parameters

location Vector2

World location to modify. Automatically clipped.

value sbyte

-1 = inside terrain, 1 = outside terrain

RegenerateTerrain()

Regenerate the terrain.

public void RegenerateTerrain()

RemoveOldData(int, int, int, int)

Removes the old data using the specified x start

private void RemoveOldData(int xStart, int xEnd, int yStart, int yEnd)

Parameters

xStart int

The start

xEnd int

The end

yStart int

The start

yEnd int

The end