b3dCreateTerrainPhysicsMesh

Creates physics collision mesh for terrain entity. Takes entity (terrain entity from b3dLoadMesh or terrain creation function). Returns physics mesh handle.

3D Graphics

Parameters & Returns

Parameters

entity Int

Returns

Int

Quick Summary

Creates physics collision mesh for terrain entity. Takes entity (terrain entity from b3dLoadMesh or terrain creation function). Returns physics mesh handle.

Technical Exegesis...

Creates physics collision mesh for terrain entity. Takes entity (terrain entity handle, typically large mesh representing ground/landscape). Returns physics mesh handle for use with Jolt physics system. Generates triangle mesh collision shape from terrain geometry for accurate ground collision.

Example

Example.bam
; Load and create physics for terrain
terrain = b3dLoadMesh("landscape.glb", 1, 0)
b3dPositionEntity(terrain, 0, 0, 0)

; Create terrain physics mesh
terrainPhysics = b3dCreateTerrainPhysicsMesh(terrain)

; Create static physics body (mass=0 for immovable terrain)
b3dCreatePhysicsBody(terrain, 0, 0.0, 0, 0, 0)

; Set terrain surface friction
b3dSetPhysicsBodyFriction(terrain, 0.8)

; Now dynamic objects will collide with terrain
box = b3dCreateBox()
b3dPositionEntity(box, 0, 50, 0)
b3dCreatePhysicsBody(box, 1, 10.0, 0, 0, 0)  ; Falls onto terrain