ModelBuilder AddCollisionBox( Vector3 extents, System.Nullable<Vector3> center, System.Nullable<Rotation> rotation )

book_4_sparkGenerated
code_blocksInput

Description

The AddCollisionBox method is used to add a collision box to the model being constructed by the ModelBuilder. This method allows you to specify the dimensions, position, and orientation of the collision box within the model's local space.

Usage

To use the AddCollisionBox method, you need to provide the following parameters:

  • extents (Vector3): The size of the collision box in each dimension (width, height, depth).
  • center (Nullable<Vector3>): The center position of the collision box relative to the model's origin. If not specified, the default is the origin (0,0,0).
  • rotation (Nullable<Rotation>): The rotation of the collision box. If not specified, the default is no rotation.

This method returns the ModelBuilder instance, allowing for method chaining.

Example

// Example of adding a collision box to a model
ModelBuilder builder = new ModelBuilder();

// Define the extents of the collision box
Vector3 extents = new Vector3(1.0f, 2.0f, 3.0f);

// Optionally define the center and rotation
Vector3? center = new Vector3(0.5f, 0.5f, 0.5f);
Rotation? rotation = Rotation.FromAxis(Vector3.Up, 45.0f);

// Add the collision box to the model
builder.AddCollisionBox(extents, center, rotation);

// Continue building the model...
Model model = builder.Create();