Spline Constraint

struct nvSplineConstraint

Spline constraint definition.

This constrains the body to a catmull-rom spline path. https://en.wikipedia.org/wiki/Centripetal_Catmull%E2%80%93Rom_spline

struct nvSplineConstraintInitializer

Spline constraint initializer information.

This struct holds basic information for initializing and can be reused for multiple constraints if the bodies are changed.

Methods

nvConstraint *nvSplineConstraint_new(nvSplineConstraintInitializer init)

Create a new spline constraint.

Leave one of the body parameters as NULL to link the body to world. Don’t forget to change the anchor point to be in world space as well.

Returns NULL on error. Use nv_get_error to get more information.

Parameters:

init – Initializer info

Returns:

nvConstraint *

nvRigidBody *nvSplineConstraint_get_body(const nvConstraint *cons)

Get body of the constraint.

Parameters:

cons – Constraint

Returns:

nvRigidBody *

void nvSplineConstraint_set_anchor(nvConstraint *cons, nvVector2 anchor)

Set anchor point in world space.

Parameters:
  • cons – Constraint

  • anchor – Anchor

nvVector2 nvSplineConstraint_get_anchor(const nvConstraint *cons)

Get anchor point in world space.

Parameters:

cons – Constraint

Returns:

nvVector2

void nvSplineConstraint_set_max_force(nvConstraint *cons, nv_float max_force)

Set max force used to solve the constraint.

Parameters:
  • cons – Constraint

  • max_force – Max force

nv_float nvSplineConstraint_get_max_force(const nvConstraint *cons)

Get max force used to solve the constraint.

Parameters:

cons – Constraint

Returns:

nv_float

int nvSplineConstraint_set_control_points(nvConstraint *cons, nvVector2 *points, size_t num_points)

Set control points of the spline.

Returns non-zero on error. Use nv_get_error to get more information.

Parameters:
  • cons – Constraint

  • points – Array of nvVector2

  • num_points – Number of points

nvVector2 *nvSplineConstraint_get_control_points(const nvConstraint *cons)

Get control points of the spline.

Parameters:

cons – Constraint

Returns:

nvVector2 *

size_t nvSplineConstraint_get_number_of_control_points(const nvConstraint *cons)

Get the number of control points of the spline.

Parameters:

cons – Constraints

Returns:

size_t