Documentation ¶
Index ¶
- Constants
- type Body
- func (b *Body) AllowSleep() bool
- func (b *Body) AngularDamping() float32
- func (b *Body) AngularFactor() math32.Vector3
- func (b *Body) AngularVelocity() math32.Vector3
- func (b *Body) ApplyDamping(dt float32)
- func (b *Body) ApplyForce(force, relativePoint *math32.Vector3)
- func (b *Body) ApplyForceField(force *math32.Vector3)
- func (b *Body) ApplyImpulse(impulse, relativePoint *math32.Vector3)
- func (b *Body) ApplyLocalForce(localForce, localPoint *math32.Vector3)
- func (b *Body) ApplyLocalImpulse(localImpulse, localPoint *math32.Vector3)
- func (b *Body) ApplyVelocityDeltas(linearD, angularD *math32.Vector3)
- func (b *Body) BodyType() BodyType
- func (b *Body) BoundingBox() math32.Box3
- func (b *Body) ClearForces()
- func (b *Body) CollidableWith(other *Body) bool
- func (b *Body) CollisionResponse() bool
- func (b *Body) Force() math32.Vector3
- func (b *Body) GetVelocityAtWorldPoint(worldPoint *math32.Vector3) *math32.Vector3
- func (b *Body) Index() int
- func (b *Body) Integrate(dt float32, quatNormalize, quatNormalizeFast bool)
- func (b *Body) InvMassEff() float32
- func (b *Body) InvRotInertiaWorldEff() *math32.Matrix3
- func (b *Body) LinearDamping() float32
- func (b *Body) LinearFactor() math32.Vector3
- func (b *Body) Material() *material.Material
- func (b *Body) Name() string
- func (b *Body) PointToLocal(worldPoint *math32.Vector3) math32.Vector3
- func (b *Body) PointToWorld(localPoint *math32.Vector3) math32.Vector3
- func (b *Body) Position() math32.Vector3
- func (b *Body) Quaternion() *math32.Quaternion
- func (b *Body) SetAllowSleep(state bool)
- func (b *Body) SetAngularDamping(d float32)
- func (b *Body) SetAngularFactor(factor *math32.Vector3)
- func (b *Body) SetAngularVelocity(vel *math32.Vector3)
- func (b *Body) SetBodyType(bodyType BodyType)
- func (b *Body) SetFixedRotation(state bool)
- func (b *Body) SetIndex(i int)
- func (b *Body) SetLinearDamping(d float32)
- func (b *Body) SetLinearFactor(factor *math32.Vector3)
- func (b *Body) SetMass(mass float32)
- func (b *Body) SetName(name string)
- func (b *Body) SetShape(shape shape.IShape)
- func (b *Body) SetVelocity(vel *math32.Vector3)
- func (b *Body) SetWakeUpAfterNarrowphase(state bool)
- func (b *Body) Shape() shape.IShape
- func (b *Body) Sleep()
- func (b *Body) SleepSpeedLimit() float32
- func (b *Body) SleepState() BodySleepState
- func (b *Body) SleepTick(time float32)
- func (b *Body) Sleeping() bool
- func (b *Body) Torque() math32.Vector3
- func (b *Body) UpdateEffectiveMassProperties()
- func (b *Body) UpdateInertiaWorld(force bool)
- func (b *Body) UpdateMassProperties()
- func (b *Body) VectorToLocal(worldVector *math32.Vector3) math32.Vector3
- func (b *Body) VectorToWorld(localVector *math32.Vector3) math32.Vector3
- func (b *Body) Velocity() math32.Vector3
- func (b *Body) WakeUp()
- func (b *Body) WakeUpAfterNarrowphase() bool
- type BodySleepState
- type BodyType
- type HullType
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 )
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 ¶
NewBody creates and returns a pointer to a new RigidBody. The igraphic's geometry *must* be convex.
func (*Body) AllowSleep ¶
func (*Body) AngularDamping ¶
func (*Body) AngularFactor ¶
func (*Body) AngularVelocity ¶
func (*Body) ApplyDamping ¶
func (*Body) ApplyForce ¶
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 ¶
Forces from a force field need to be multiplied by mass.
func (*Body) ApplyImpulse ¶
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 ¶
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 ¶
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 ¶
ApplyVelocityDeltas adds the specified deltas to the body's linear and angular velocities.
func (*Body) BoundingBox ¶
func (*Body) CollidableWith ¶
CollidableWith returns whether the body can collide with the specified body.
func (*Body) CollisionResponse ¶
func (*Body) GetVelocityAtWorldPoint ¶
Get world velocity of a point in the body.
func (*Body) Integrate ¶
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 (*Body) InvRotInertiaWorldEff ¶
func (*Body) LinearDamping ¶
func (*Body) LinearFactor ¶
func (*Body) PointToLocal ¶
PointToLocal converts a world point to local body frame. TODO maybe move to Node
func (*Body) PointToWorld ¶
PointToWorld converts a local point to world frame. TODO maybe move to Node
func (*Body) Quaternion ¶
func (b *Body) Quaternion() *math32.Quaternion
func (*Body) SetAllowSleep ¶
func (*Body) SetAngularDamping ¶
func (*Body) SetAngularFactor ¶
func (*Body) SetAngularVelocity ¶
func (*Body) SetBodyType ¶
SetBodyType sets the body type.
func (*Body) SetFixedRotation ¶
SetFixedRotation specifies whether the body should rotate.
func (*Body) SetLinearDamping ¶
func (*Body) SetLinearFactor ¶
func (*Body) SetShape ¶
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 (*Body) SetWakeUpAfterNarrowphase ¶
func (*Body) SleepSpeedLimit ¶
func (*Body) SleepState ¶
func (b *Body) SleepState() BodySleepState
func (*Body) SleepTick ¶
Called every timestep to update internal sleep timer and change sleep state if needed. time: The world time in seconds
func (*Body) Sleeping ¶
If checkSleeping is true then returns false if both bodies are currently sleeping.
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 ¶
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 ¶
VectorToLocal converts a world vector to local body frame. TODO maybe move to Node
func (*Body) VectorToWorld ¶
VectorToWorld converts a local vector to world frame. TODO maybe move to Node