Class LinearMotor
- Namespace
- Jitter2.Dynamics.Constraints
- Assembly
- Jitter2.dll
Drives relative linear velocity along an axis attached to each body.
public class LinearMotor : Constraint<LinearMotor.LinearMotorData>, IDebugDrawable
- Inheritance
-
LinearMotor
- Implements
- Inherited Members
Properties
Impulse
Gets the accumulated solver impulse from the last solved substep.
public float Impulse { get; }
Property Value
LocalAxis1
Gets or sets the motor axis on the first body in local space.
public JVector LocalAxis1 { get; set; }
Property Value
Exceptions
- ArgumentException
Thrown when the assigned value is not finite or normalized.
LocalAxis2
Gets or sets the motor axis on the second body in local space.
public JVector LocalAxis2 { get; set; }
Property Value
Exceptions
- ArgumentException
Thrown when the assigned value is not finite or normalized.
MaximumForce
Gets or sets the maximum force the motor can apply.
public float MaximumForce { get; set; }
Property Value
- float
Default is 0. Must be non-negative. Positive infinity allows unlimited force.
Remarks
Changing the value wakes the connected bodies.
Exceptions
- ArgumentOutOfRangeException
Thrown when
valueis negative or NaN.
TargetVelocity
Gets or sets the target linear velocity in units per second.
public float TargetVelocity { get; set; }
Property Value
- float
Default is 0.
Remarks
Changing the value wakes the connected bodies.
Methods
Create()
Called when the world creates this constraint. Override to set DispatchId to the ID returned by registering the constraint's solver methods.
protected override void Create()
DebugDraw(IDebugDrawer)
Draws a debug visualization of this constraint.
public override void DebugDraw(IDebugDrawer drawer)
Parameters
drawerIDebugDrawerThe debug drawer to receive visualization primitives.
Exceptions
- NotImplementedException
Thrown if the derived class does not override this method.
DebugDraw(IDebugDrawer, in DebugDrawSettings)
Draws this constraint using the supplied visualization settings. Custom constraints that only override DebugDraw(IDebugDrawer) use their default visualization.
public override void DebugDraw(IDebugDrawer drawer, in DebugDrawSettings settings)
Parameters
drawerIDebugDrawersettingsDebugDrawSettings
Initialize(JVector, JVector)
Initializes the motor with axes for each body.
public void Initialize(JVector axis1, JVector axis2)
Parameters
axis1JVectorMotor axis on the first body in world space.
axis2JVectorMotor axis on the second body in world space.
Remarks
The axes rotate with their respective bodies and are normalized internally. Default values: TargetVelocity = 0, MaximumForce = 0.
Exceptions
- ArgumentException
Thrown when
axis1oraxis2is zero or contains a non-finite value.
IterateLinearMotor(ref ConstraintData, in TimeStep)
public static void IterateLinearMotor(ref ConstraintData constraint, in TimeStep timeStep)
Parameters
constraintConstraintDatatimeStepTimeStep
PrepareForIterationLinearMotor(ref ConstraintData, in TimeStep)
public static void PrepareForIterationLinearMotor(ref ConstraintData constraint, in TimeStep timeStep)
Parameters
constraintConstraintDatatimeStepTimeStep
ResetWarmStart()
Clears impulses saved from the previous solve, without changing constraint settings.
public override void ResetWarmStart()
Remarks
Use after restoring a saved state or making a sudden change to the bodies, when impulses from their previous state should no longer be reused.
ToString()
Returns a short description of the constraint's ID, connected bodies, and state.
public override string ToString()