engine: github.com/g3n/engine/experimental/physics/object Index | Files

package object

import "github.com/g3n/engine/experimental/physics/object"

Index

Package Files

body.go

Constants

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
)
const (
    Awake = BodySleepState(iota)
    Sleepy
    Sleeping
)
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

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

type Body Uses

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 Uses

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 Uses

func (b *Body) AllowSleep() bool

func (*Body) AngularDamping Uses

func (b *Body) AngularDamping() float32

func (*Body) AngularFactor Uses

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

func (*Body) AngularVelocity Uses

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

func (*Body) ApplyDamping Uses

func (b *Body) ApplyDamping(dt float32)

func (*Body) ApplyForce Uses

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 Uses

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

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

func (*Body) ApplyImpulse Uses

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 Uses

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 Uses

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 Uses

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

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

func (*Body) BodyType Uses

func (b *Body) BodyType() BodyType

func (*Body) BoundingBox Uses

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

func (*Body) ClearForces Uses

func (b *Body) ClearForces()

ClearForces clears all forces on the body.

func (*Body) CollidableWith Uses

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

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

func (*Body) CollisionResponse Uses

func (b *Body) CollisionResponse() bool

func (*Body) Force Uses

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

func (*Body) GetVelocityAtWorldPoint Uses

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

Get world velocity of a point in the body.

func (*Body) Index Uses

func (b *Body) Index() int

func (*Body) Integrate Uses

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 Uses

func (b *Body) InvMassEff() float32

func (*Body) InvRotInertiaWorldEff Uses

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

func (*Body) LinearDamping Uses

func (b *Body) LinearDamping() float32

func (*Body) LinearFactor Uses

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

func (*Body) Material Uses

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

func (*Body) Name Uses

func (b *Body) Name() string

func (*Body) PointToLocal Uses

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 Uses

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 Uses

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

func (*Body) Quaternion Uses

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

func (*Body) SetAllowSleep Uses

func (b *Body) SetAllowSleep(state bool)

func (*Body) SetAngularDamping Uses

func (b *Body) SetAngularDamping(d float32)

func (*Body) SetAngularFactor Uses

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

func (*Body) SetAngularVelocity Uses

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

func (*Body) SetBodyType Uses

func (b *Body) SetBodyType(bodyType BodyType)

SetBodyType sets the body type.

func (*Body) SetFixedRotation Uses

func (b *Body) SetFixedRotation(state bool)

SetFixedRotation specifies whether the body should rotate.

func (*Body) SetIndex Uses

func (b *Body) SetIndex(i int)

func (*Body) SetLinearDamping Uses

func (b *Body) SetLinearDamping(d float32)

func (*Body) SetLinearFactor Uses

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

func (*Body) SetMass Uses

func (b *Body) SetMass(mass float32)

func (*Body) SetName Uses

func (b *Body) SetName(name string)

func (*Body) SetShape Uses

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 Uses

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

func (*Body) SetWakeUpAfterNarrowphase Uses

func (b *Body) SetWakeUpAfterNarrowphase(state bool)

func (*Body) Shape Uses

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

func (*Body) Sleep Uses

func (b *Body) Sleep()

Sleep forces the body to sleep.

func (*Body) SleepSpeedLimit Uses

func (b *Body) SleepSpeedLimit() float32

func (*Body) SleepState Uses

func (b *Body) SleepState() BodySleepState

func (*Body) SleepTick Uses

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 Uses

func (b *Body) Sleeping() bool

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

func (*Body) Torque Uses

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

func (*Body) UpdateEffectiveMassProperties Uses

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 Uses

func (b *Body) UpdateInertiaWorld(force bool)

Update .inertiaWorld and .invRotInertiaWorld

func (*Body) UpdateMassProperties Uses

func (b *Body) UpdateMassProperties()

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

func (*Body) VectorToLocal Uses

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 Uses

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 Uses

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

func (*Body) WakeUp Uses

func (b *Body) WakeUp()

WakeUp wakes the body up.

func (*Body) WakeUpAfterNarrowphase Uses

func (b *Body) WakeUpAfterNarrowphase() bool

type BodySleepState Uses

type BodySleepState int

BodyStatus specifies

type BodyType Uses

type BodyType int

BodyType specifies how the body is affected during the simulation.

type HullType Uses

type HullType int

TODO

Package object imports 4 packages (graph) and is imported by 2 packages. Updated 2018-07-30. Refresh now. Tools for package owners.