HeightmapTerrainShape

Package: Libraries.Game.Collision.Shapes · Inherits from: Libraries.Language.Object, Libraries.Game.Collision.Shapes.CollisionShape3D, Libraries.Game.Collision.Shapes.Box, Libraries.Game.Collision.Shapes.ConcaveShape3D

Actions

ComputeBoundingBox(Libraries.Game.BoundingBox boundingBox, Libraries.Game.Collision.PhysicsPosition3D transform)

stops a ray that does not move in x or z after its one cell.

Parameters

Copy()

Processes a single triangle from the x,y coordinates on the height map for either the left or right triangle.

Returns

Libraries.Game.Collision.Shapes.CollisionShape3D

GetChildCount()

the origin and only the lower half of the height range.

Returns

integer

GetTerrain()

is shown by a cross of 2, past the end of the ray.

Returns

Libraries.Game.Graphics.Worlds.Terrain

ProcessAllTriangles(Libraries.Game.Collision.LocalCollisionPoints3D collisionPoints, Libraries.Game.Collision.Shapes.CollisionShape3D shape, Libraries.Game.Collision.PhysicsPosition3D terrainTransform, Libraries.Game.Collision.PhysicsPosition3D shapeTransform, Libraries.Game.Collision.CollisionPointsResult3D result)

the bounding box and the cell search always agree on where the map is.

Parameters

ProcessTriangle(Libraries.Game.Collision.LocalCollisionPoints3D collisionPoints, Libraries.Game.Collision.Shapes.CollisionShape3D shape, Libraries.Game.Collision.PhysicsPosition3D shapeTransform, Libraries.Game.Collision.CollisionPointsResult3D result, Libraries.Compute.Matrix4 terrainNormalTransform, integer x, integer z, boolean leftTriangle)

Processes a single triangle from the x,y coordinates on the height map for either the left or right triangle.

Parameters

RayCast(Libraries.Compute.Vector3 from, Libraries.Compute.Vector3 to, Libraries.Game.Collision.PhysicsPosition3D transform, Libraries.Game.Collision.RayCastResult3D result)

This action checks whether a straight line segment, called a ray, touches this terrain. The ray starts at "from" and ends at "to," both in world space. The terrain's surface is made of two triangles for each square cell of its height map, and the ray hits the first of those triangles it reaches. Where the terrain sits in the world comes from the terrain's own transform, which includes its position, rotation, and scale. That is the same transform used to draw it and to collide with it. The "transform" parameter is accepted so that terrain can be used like any other shape, but it is not used. Rather than testing every triangle, this action walks across the height map one cell at a time, in the order the ray passes over them, and tests only the two triangles in each cell. It stops as soon as the cells left to visit are all farther along the ray than the closest hit found so far. A straight down ray, like the one a vehicle's suspension uses, only visits one cell. Either side of the terrain's surface can be hit, so a ray coming up from underneath hits it as well. The hit normal is the normal of the triangle that was hit, turned to face the ray. A ray that passes beyond the edges of the height map does not hit anything out there. The result works as both an input and an output. Its fraction is the farthest point along the ray that still counts as a hit, where 0 is "from" and 1 is "to." This action only reports a hit that is closer than the result's current fraction. When it finds one, it sets the result's hit flag to true, and sets its fraction, its hit point in world space, and its surface normal in world space. When there is no closer hit, the result is left unchanged. Call SetToDefault on the result before the first shape so that any hit along the whole ray counts. This action does not set the result's hit body, because a shape does not know which item it belongs to. The caller should set the hit body when this action returns true.

Parameters

Returns

boolean: true if this terrain was hit closer than the result's previous fraction, and false otherwise.

Example

use Libraries.Game.Graphics.Worlds.Terrain
use Libraries.Game.Collision.RayCastResult3D
use Libraries.Compute.Vector3
Terrain terrain
terrain:LoadHeightMap("Assets/HeightMap.png")
// A ray straight down from high above the terrain.
Vector3 from
from:Set(10, 100, 10)
Vector3 to
to:Set(10, -100, 10)
RayCastResult3D result
result:SetToDefault()
if terrain:GetShape():RayCast(from, to, terrain:GetCollisionTransform(), result)
    output "The ground under (10, 10) is at a height of " + result:GetHitPointWorldSpace():GetY()
end

SetTerrain(Libraries.Game.Graphics.Worlds.Terrain terrain)

of their own. A new PhysicsPosition3D is the identity.

Parameters

Inherited Actions

19 actions from Libraries.Game.Collision.Shapes.Box
7 actions from Libraries.Game.Collision.Shapes.CollisionShape3D
3 actions from Libraries.Language.Object