Class LinearMotor
- Namespace
- Jitter2.Dynamics.Constraints
- Assembly
- Jitter2.dll
A motor constraint that drives relative translational velocity along an axis fixed in the reference frame of each body.
public class LinearMotor : Constraint<LinearMotor.LinearMotorData>, IDebugDrawable
- Inheritance
-
LinearMotor
- Implements
- Inherited Members
Properties
Impulse
Gets the accumulated impulse applied by this motor during the last step.
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
LocalAxis2
Gets or sets the motor axis on the second body in local space.
public JVector LocalAxis2 { get; set; }
Property Value
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.
Exceptions
- ArgumentOutOfRangeException
Thrown when
valueis negative.
TargetVelocity
Gets or sets the target linear velocity in units per second.
public float TargetVelocity { get; set; }
Property Value
- float
Default is 0.
Methods
Create()
Sets the Iterate and PrepareForIteration function pointer fields on this instance. Override this in derived classes to assign the correct solver methods. The pointers are later written into ConstraintData when the constraint is enabled.
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.
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
Stores the axes in local frames. Both axes are normalized internally. Default values: TargetVelocity = 0, MaximumForce = 0.
IterateLinearMotor(ref ConstraintData, float)
public static void IterateLinearMotor(ref ConstraintData constraint, float idt)
Parameters
constraintConstraintDataidtfloat
PrepareForIterationLinearMotor(ref ConstraintData, float)
public static void PrepareForIterationLinearMotor(ref ConstraintData constraint, float idt)
Parameters
constraintConstraintDataidtfloat