object

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2020 License: BSD-2-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// A static body does not move during simulation and behaves as if it has infinite mass.
	// Static bodies can be moved manually by setting the position of the body.
	// The velocity of a static body is always zero.
	// Static bodies do not collide with other static or kinematic bodies.
	Static = BodyType(iota)

	// A kinematic body moves under simulation according to its velocity.
	// They do not respond to forces.
	// They can be moved manually, but normally a kinematic body is moved by setting its velocity.
	// A kinematic body behaves as if it has infinite mass.
	// Kinematic bodies do not collide with other static or kinematic bodies.
	Kinematic

	// A dynamic body is fully simulated.
	// Can be moved manually by the user, but normally they move according to forces.
	// A dynamic body can collide with all body types.
	// A dynamic body always has finite, non-zero mass.
	Dynamic
)
View Source
const (
	Awake = BodySleepState(iota)
	Sleepy
	Sleeping
)
View Source
const (
	SleepyEvent  = "physics.SleepyEvent"  // Dispatched after a body has gone in to the sleepy state.
	SleepEvent   = "physics.SleepEvent"   // Dispatched after a body has fallen asleep.
	WakeUpEvent  = "physics.WakeUpEvent"  // Dispatched after a sleeping body has woken up.
	CollideEvent = "physics.CollideEvent" // Dispatched after two bodies collide. This event is dispatched on each of the two bodies involved in the collision.
)

Events

View Source
const (
	Sphere = HullType(iota)
	Capsule
	Mesh // use mesh itself
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Body

type Body struct {
	*graphic.Graphic // TODO future - embed core.Node instead and calculate properties recursively
	// contains filtered or unexported fields
}

Body represents a physics-driven body.

func NewBody

func NewBody(igraphic graphic.IGraphic) *Body

NewBody creates and returns a pointer to a new RigidBody. The igraphic's geometry *must* be convex.

func (*Body) AllowSleep

func (b *Body) AllowSleep() bool

func (*Body) AngularDamping

func (b *Body) AngularDamping() float32

func (*Body) AngularFactor

func (b *Body) AngularFactor() math32.Vector3

func (*Body) AngularVelocity

func (b *Body) AngularVelocity() math32.Vector3

func (*Body) ApplyDamping

func (b *Body) ApplyDamping(dt float32)

func (*Body) ApplyForce

func (b *Body) ApplyForce(force, relativePoint *math32.Vector3)

Apply force to a world point. This could for example be a point on the Body surface. Applying force this way will add to Body.force and Body.torque. relativePoint: A point relative to the center of mass to apply the force on.

func (*Body) ApplyForceField

func (b *Body) ApplyForceField(force *math32.Vector3)

Forces from a force field need to be multiplied by mass.

func (*Body) ApplyImpulse

func (b *Body) ApplyImpulse(impulse, relativePoint *math32.Vector3)

Apply impulse to a world point. This could for example be a point on the Body surface. An impulse is a force added to a body during a short period of time (impulse = force * time). Impulses will be added to Body.velocity and Body.angularVelocity. impulse: The amount of impulse to add. relativePoint: A point relative to the center of mass to apply the force on.

func (*Body) ApplyLocalForce

func (b *Body) ApplyLocalForce(localForce, localPoint *math32.Vector3)

Apply force to a local point in the body. force: The force vector to apply, defined locally in the body frame. localPoint: A local point in the body to apply the force on.

func (*Body) ApplyLocalImpulse

func (b *Body) ApplyLocalImpulse(localImpulse, localPoint *math32.Vector3)

Apply locally-defined impulse to a local point in the body. force: The force vector to apply, defined locally in the body frame. localPoint: A local point in the body to apply the force on.

func (*Body) ApplyVelocityDeltas

func (b *Body) ApplyVelocityDeltas(linearD, angularD *math32.Vector3)

ApplyVelocityDeltas adds the specified deltas to the body's linear and angular velocities.

func (*Body) BodyType

func (b *Body) BodyType() BodyType

func (*Body) BoundingBox

func (b *Body) BoundingBox() math32.Box3

func (*Body) ClearForces

func (b *Body) ClearForces()

ClearForces clears all forces on the body.

func (*Body) CollidableWith

func (b *Body) CollidableWith(other *Body) bool

CollidableWith returns whether the body can collide with the specified body.

func (*Body) CollisionResponse

func (b *Body) CollisionResponse() bool

func (*Body) Force

func (b *Body) Force() math32.Vector3

func (*Body) GetVelocityAtWorldPoint

func (b *Body) GetVelocityAtWorldPoint(worldPoint *math32.Vector3) *math32.Vector3

Get world velocity of a point in the body.

func (*Body) Index

func (b *Body) Index() int

func (*Body) Integrate

func (b *Body) Integrate(dt float32, quatNormalize, quatNormalizeFast bool)

Move the body forward in time. dt: Time step quatNormalize: Set to true to normalize the body quaternion quatNormalizeFast: If the quaternion should be normalized using "fast" quaternion normalization

func (*Body) InvMassEff

func (b *Body) InvMassEff() float32

func (*Body) InvRotInertiaWorldEff

func (b *Body) InvRotInertiaWorldEff() *math32.Matrix3

func (*Body) LinearDamping

func (b *Body) LinearDamping() float32

func (*Body) LinearFactor

func (b *Body) LinearFactor() math32.Vector3

func (*Body) Material

func (b *Body) Material() *material.Material

func (*Body) Name

func (b *Body) Name() string

func (*Body) PointToLocal

func (b *Body) PointToLocal(worldPoint *math32.Vector3) math32.Vector3

PointToLocal converts a world point to local body frame. TODO maybe move to Node

func (*Body) PointToWorld

func (b *Body) PointToWorld(localPoint *math32.Vector3) math32.Vector3

PointToWorld converts a local point to world frame. TODO maybe move to Node

func (*Body) Position

func (b *Body) Position() math32.Vector3

func (*Body) Quaternion

func (b *Body) Quaternion() *math32.Quaternion

func (*Body) SetAllowSleep

func (b *Body) SetAllowSleep(state bool)

func (*Body) SetAngularDamping

func (b *Body) SetAngularDamping(d float32)

func (*Body) SetAngularFactor

func (b *Body) SetAngularFactor(factor *math32.Vector3)

func (*Body) SetAngularVelocity

func (b *Body) SetAngularVelocity(vel *math32.Vector3)

func (*Body) SetBodyType

func (b *Body) SetBodyType(bodyType BodyType)

SetBodyType sets the body type.

func (*Body) SetFixedRotation

func (b *Body) SetFixedRotation(state bool)

SetFixedRotation specifies whether the body should rotate.

func (*Body) SetIndex

func (b *Body) SetIndex(i int)

func (*Body) SetLinearDamping

func (b *Body) SetLinearDamping(d float32)

func (*Body) SetLinearFactor

func (b *Body) SetLinearFactor(factor *math32.Vector3)

func (*Body) SetMass

func (b *Body) SetMass(mass float32)

func (*Body) SetName

func (b *Body) SetName(name string)

func (*Body) SetShape

func (b *Body) SetShape(shape shape.IShape)

TODO future: modify this to be "AddShape" and keep track of list of shapes, their positions and orientations For now each body can only be a single shape or a single geometry

func (*Body) SetVelocity

func (b *Body) SetVelocity(vel *math32.Vector3)

func (*Body) SetWakeUpAfterNarrowphase

func (b *Body) SetWakeUpAfterNarrowphase(state bool)

func (*Body) Shape

func (b *Body) Shape() shape.IShape

func (*Body) Sleep

func (b *Body) Sleep()

Sleep forces the body to sleep.

func (*Body) SleepSpeedLimit

func (b *Body) SleepSpeedLimit() float32

func (*Body) SleepState

func (b *Body) SleepState() BodySleepState

func (*Body) SleepTick

func (b *Body) SleepTick(time float32)

Called every timestep to update internal sleep timer and change sleep state if needed. time: The world time in seconds

func (*Body) Sleeping

func (b *Body) Sleeping() bool

If checkSleeping is true then returns false if both bodies are currently sleeping.

func (*Body) Torque

func (b *Body) Torque() math32.Vector3

func (*Body) UpdateEffectiveMassProperties

func (b *Body) UpdateEffectiveMassProperties()

UpdateEffectiveMassProperties If the body is sleeping, it should be immovable and thus have infinite mass during solve. This is solved by having a separate "effective mass" and other "effective" properties

func (*Body) UpdateInertiaWorld

func (b *Body) UpdateInertiaWorld(force bool)

Update .inertiaWorld and .invRotInertiaWorld

func (*Body) UpdateMassProperties

func (b *Body) UpdateMassProperties()

UpdateMassProperties Should be called whenever you change the body shape or mass.

func (*Body) VectorToLocal

func (b *Body) VectorToLocal(worldVector *math32.Vector3) math32.Vector3

VectorToLocal converts a world vector to local body frame. TODO maybe move to Node

func (*Body) VectorToWorld

func (b *Body) VectorToWorld(localVector *math32.Vector3) math32.Vector3

VectorToWorld converts a local vector to world frame. TODO maybe move to Node

func (*Body) Velocity

func (b *Body) Velocity() math32.Vector3

func (*Body) WakeUp

func (b *Body) WakeUp()

WakeUp wakes the body up.

func (*Body) WakeUpAfterNarrowphase

func (b *Body) WakeUpAfterNarrowphase() bool

type BodySleepState

type BodySleepState int

BodyStatus specifies

type BodyType

type BodyType int

BodyType specifies how the body is affected during the simulation.

type HullType

type HullType int

TODO

Jump to

Keyboard shortcuts

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