public void sceneLoaded(SimScene scene) { //restoreButton.Enabled = false; leftCP = ControlPointController.getControlPoint("LeftCP"); rightCP = ControlPointController.getControlPoint("RightCP"); movingMuscle = MuscleController.getMuscle("MovingMuscleDynamic"); movingMuscleTarget = MuscleController.MovingTarget; Enabled = leftCP != null && rightCP != null && movingMuscle != null && movingMuscleTarget != null; if (Enabled) { //setup ui float leftNeutral = leftCP.NeutralLocation; synchronizeLeftCP(leftCP, leftNeutral); leftForwardBack.Minimum = leftCP.PosteriorShiftMaxLocation; leftForwardBack.SequentialChange = (leftForwardBack.Maximum - leftForwardBack.Minimum) / 10.0f; float rightNeutral = rightCP.NeutralLocation; synchronizeRightCP(rightCP, rightNeutral); rightForwardBack.Minimum = rightCP.PosteriorShiftMaxLocation; rightForwardBack.SequentialChange = (rightForwardBack.Maximum - rightForwardBack.Minimum) / 10.0f; bothForwardBack.Value = rightForwardBack.Value; bothForwardBack.Minimum = rightForwardBack.Minimum < leftForwardBack.Minimum ? rightForwardBack.Minimum : leftForwardBack.Minimum; bothForwardBack.SequentialChange = rightForwardBack.SequentialChange; synchronizeMovingMuscleOffset(movingMuscleTarget, movingMuscleTarget.Offset); synchronizeForce(movingMuscle, movingMuscle.getForce()); //setup callbacks leftCP.PositionChanged += leftCP_PositionChanged; rightCP.PositionChanged += rightCP_PositionChanged; movingMuscleTarget.OffsetChanged += movingMuscleTarget_OffsetChanged; movingMuscle.ForceChanged += movingMuscle_ForceChanged; } }
void movingMuscle_ForceChanged(MuscleBehavior source, float force) { synchronizeForce(movingMuscle, movingMuscle.getForce()); }