constraint

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 14, 2019 License: BSD-2-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package constraint implements physics constraints.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConeTwist

type ConeTwist struct {
	PointToPoint
	// contains filtered or unexported fields
}

ConeTwist constraint.

func NewConeTwist

func NewConeTwist(bodyA, bodyB IBody, pivotA, pivotB, axisA, axisB *math32.Vector3, angle, twistAngle, maxForce float32) *ConeTwist

NewConeTwist creates and returns a pointer to a new ConeTwist constraint object.

func (*ConeTwist) Update

func (ctc *ConeTwist) Update()

Update updates the equations with data.

type Constraint

type Constraint struct {
	// contains filtered or unexported fields
}

Constraint base struct.

func (*Constraint) AddEquation

func (c *Constraint) AddEquation(eq equation.IEquation)

AddEquation adds an equation to the constraint.

func (*Constraint) BodyA

func (c *Constraint) BodyA() IBody

func (*Constraint) BodyB

func (c *Constraint) BodyB() IBody

func (*Constraint) CollideConnected

func (c *Constraint) CollideConnected() bool

func (*Constraint) Equations

func (c *Constraint) Equations() []equation.IEquation

Equations returns the constraint's equations.

func (*Constraint) SetEnabled

func (c *Constraint) SetEnabled(state bool)

SetEnable sets the enabled flag of the constraint equations.

type Distance

type Distance struct {
	Constraint
	// contains filtered or unexported fields
}

Distance is a distance constraint. Constrains two bodies to be at a constant distance from each others center of mass.

func NewDistance

func NewDistance(bodyA, bodyB IBody, distance, maxForce float32) *Distance

NewDistance creates and returns a pointer to a new Distance constraint object.

func (*Distance) Update

func (dc *Distance) Update()

Update updates the equation with data.

type Hinge

type Hinge struct {
	PointToPoint
	// contains filtered or unexported fields
}

Hinge constraint. Think of it as a door hinge. It tries to keep the door in the correct place and with the correct orientation.

func NewHinge

func NewHinge(bodyA, bodyB IBody, pivotA, pivotB, axisA, axisB *math32.Vector3, maxForce float32) *Hinge

NewHinge creates and returns a pointer to a new Hinge constraint object.

func (*Hinge) SetMotorEnabled

func (hc *Hinge) SetMotorEnabled(state bool)

func (*Hinge) SetMotorMaxForce

func (hc *Hinge) SetMotorMaxForce(maxForce float32)

func (*Hinge) SetMotorSpeed

func (hc *Hinge) SetMotorSpeed(speed float32)

func (*Hinge) Update

func (hc *Hinge) Update()

Update updates the equations with data.

type IBody

type IBody interface {
	equation.IBody
	WakeUp()
	VectorToWorld(*math32.Vector3) math32.Vector3
	PointToLocal(*math32.Vector3) math32.Vector3
	VectorToLocal(*math32.Vector3) math32.Vector3
	Quaternion() *math32.Quaternion
}

type IConstraint

type IConstraint interface {
	Update() // Update all the equations with data.
	Equations() []equation.IEquation
	CollideConnected() bool
	BodyA() IBody
	BodyB() IBody
}

type Lock

type Lock struct {
	PointToPoint
	// contains filtered or unexported fields
}

Lock constraint. Removes all degrees of freedom between the bodies.

func NewLock

func NewLock(bodyA, bodyB IBody, maxForce float32) *Lock

NewLock creates and returns a pointer to a new Lock constraint object.

func (*Lock) Update

func (lc *Lock) Update()

Update updates the equations with data.

type PointToPoint

type PointToPoint struct {
	Constraint
	// contains filtered or unexported fields
}

PointToPoint is an offset constraint. Connects two bodies at the specified offset points.

func NewPointToPoint

func NewPointToPoint(bodyA, bodyB IBody, pivotA, pivotB *math32.Vector3, maxForce float32) *PointToPoint

NewPointToPoint creates and returns a pointer to a new PointToPoint constraint object.

func (*PointToPoint) Update

func (ptpc *PointToPoint) Update()

Update updates the equations with data.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL