Method AddMesh
- Namespace
- Box3D
- Assembly
- Box3D.NET.dll
AddMesh(CollisionMesh, Vector3?, ShapeDefinition?)
Attaches a triangle mesh to this body, which must be static.
public Shape AddMesh(CollisionMesh mesh, Vector3? scale = null, ShapeDefinition? definition = null)Parameters
meshCollisionMesh-
The mesh. It is not copied, so it must outlive this shape.
scaleVector3?-
The scale to apply, or null for none. May be non-uniform and may have negative components, which mirrors the mesh.
definitionShapeDefinition?-
The shape settings, or null for the defaults.
Returns
- Shape
-
The new shape.
Examples
using var terrain = CollisionMesh.FromTriangles(vertices, indices);
Body level = world.CreateStaticBody();
level.AddMesh(terrain);
Remarks
Box3D only generates mesh contacts against static bodies. Attaching one to a dynamic or kinematic body would trip an assertion in a debug build of the engine and be silently accepted in a release build, so it is rejected here instead.
Exceptions
- ArgumentNullException
-
meshis null. - ObjectDisposedException
-
meshhas been disposed. - InvalidOperationException
-
This body is not static.