Terrainclass

Terrain renders heightmap based terrain.

objectColliderTerrain
Namespace
Sandbox
Assembly
Sandbox.Engine
Declaration
public sealed class Sandbox.Terrain : Sandbox.Collider

Constructors1

Showing 1 constructors

Methods8

Showing 8 methods

public void Create()PUBLIC

Call on enable or storage change

Returns:void

public System.Nullable`1<Sandbox.Terrain.TerrainMaterialInfo> GetMaterialAtWorldPosition(Vector3 worldPosition)PUBLIC

Gets terrain material information at a world position. Returns null if the position is outside terrain bounds.

ParameterTypeDescription
worldPositionVector3
Returns:Nullable<TerrainMaterialInfo>

public void SyncCPUTexture(Sandbox.Terrain.SyncFlags flags, Sandbox.RectInt region)PUBLIC

Downloads dirty regions from the GPU texture maps onto the CPU, updating collider data and making changes saveable. This is used from the editor after modifying.

ParameterTypeDescription
flagsSyncFlags
regionRectInt
Returns:void

public void SyncGPUTexture()PUBLIC

Updates the GPU texture maps with the CPU data

Returns:void

public void UpdateCollision(Sandbox.Terrain.SyncFlags flags, Sandbox.RectInt region)PUBLICPER-FRAME

Update the collider heights/materials from the current CPU data for a region.

ParameterTypeDescription
flagsSyncFlags
regionRectInt
Returns:void

public void UpdateMaterialsBuffer()PUBLICPER-FRAME

Upload the Materials buffer, this should be called when materials are added, removed or modified.

Returns:void

Properties14

Showing 14 properties

public Sandbox.RenderAttributes Sandbox.Terrain.Attributes { get; set; }PUBLICGETSET

Attributes that are applied to the terrain based on the current material and shader. If the terrain is disabled, the changes are deferred until it is enabled again. Attributes are not saved to disk, and are not cloned when copying the terrain.

Returns:RenderAttributes

public int Sandbox.Terrain.ClipMapLodExtentTexels { get; set; }PUBLICGETSET

Returns:int

public int Sandbox.Terrain.ClipMapLodLevels { get; set; }PUBLICGETSET

Returns:int

public virtual int Sandbox.Terrain.ComponentVersion { get; set; }PUBLICVIRTUALGETSET

Returns:int

public bool Sandbox.Terrain.EnableCollision { get; set; }PUBLICGETSET

Returns:bool

public virtual bool Sandbox.Terrain.IsConcave { get; set; }PUBLICVIRTUALGETSET

Returns:bool

public int Sandbox.Terrain.SubdivisionFactor { get; set; }PUBLICGETSET

How many times to subdivide each block mesh (1 = one vertex per heightmap texel). Higher adds displacement detail at the cost of more vertices.

Returns:int

public float Sandbox.Terrain.TerrainHeight { get; set; }PUBLICGETSET

World size of the maximum height of the terrain.

Returns:float

public float Sandbox.Terrain.TerrainSize { get; set; }PUBLICGETSET

Uniform world size of the width and length of the terrain.

Returns:float

On this page

Constructorspublic Terrain()Methodspublic System.Void Create()public System.Nullable`1<Sandbox.Terrain.TerrainMaterialInfo> GetMaterialAtWorldPosition(Vector3 worldPosition)public System.Boolean RayIntersects(Ray ray, System.Single distance, Vector3 position, Vector3 normal)public System.Boolean RayIntersects(Ray ray, System.Single distance, Vector3 position)public System.Void SyncCPUTexture(Sandbox.Terrain.SyncFlags flags, Sandbox.RectInt region)public System.Void SyncGPUTexture()public System.Void UpdateCollision(Sandbox.Terrain.SyncFlags flags, Sandbox.RectInt region)public System.Void UpdateMaterialsBuffer()Propertiespublic Sandbox.RenderAttributes Sandbox.Terrain.Attributes { get; set; }public System.Int32 Sandbox.Terrain.ClipMapLodExtentTexels { get; set; }public System.Int32 Sandbox.Terrain.ClipMapLodLevels { get; set; }public virtual System.Int32 Sandbox.Terrain.ComponentVersion { get; set; }public Sandbox.Texture Sandbox.Terrain.ControlMap { get; set; }public System.Boolean Sandbox.Terrain.EnableCollision { get; set; }public Sandbox.Texture Sandbox.Terrain.HeightMap { get; set; }public virtual System.Boolean Sandbox.Terrain.IsConcave { get; set; }public Sandbox.Material Sandbox.Terrain.MaterialOverride { get; set; }public Sandbox.ModelRenderer.ShadowRenderType Sandbox.Terrain.RenderType { get; set; }public Sandbox.TerrainStorage Sandbox.Terrain.Storage { get; set; }public System.Int32 Sandbox.Terrain.SubdivisionFactor { get; set; }public System.Single Sandbox.Terrain.TerrainHeight { get; set; }public System.Single Sandbox.Terrain.TerrainSize { get; set; }Metadata