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; } }
public new void materialize() { base.materialize(); // attach the behavior script this.behaviour = this.go.AddComponent<MuscleBehavior>(); this.behaviour.init(this.clock); }
public KinectIKFace(KinectIKBone parentBone, float distanceToParent, SimObjectBase faceTargetSimObject) { leftCP = ControlPointController.getControlPoint("LeftCP"); rightCP = ControlPointController.getControlPoint("RightCP"); movingMuscle = MuscleController.getMuscle("MovingMuscleDynamic"); movingMuscleTarget = MuscleController.MovingTarget; neutralProtrusion = leftCP.NeutralLocation; this.parentBone = parentBone; this.distanceToParent = distanceToParent; this.faceTargetSimObject = faceTargetSimObject; currentOrientation = Quaternion.Identity; }
void adaptButton_CheckedChanged(Widget sender, EventArgs e) { if (adaptButton.Checked) { ControlPointBehavior leftCP = ControlPointController.getControlPoint("LeftCP"); ControlPointBehavior rightCP = ControlPointController.getControlPoint("RightCP"); MuscleBehavior movingMuscle = MuscleController.getMuscle("MovingMuscleDynamic"); MovingMuscleTarget movingMuscleTarget = MuscleController.MovingTarget; leftCP.setLocation(leftCP.NeutralLocation); rightCP.setLocation(rightCP.NeutralLocation); movingMuscle.changeForce(TeethController.AdaptForce); movingMuscleTarget.Offset = Vector3.Zero; } TeethController.adaptAllTeeth(adaptButton.Checked); }
public override void opening() { ControlPointBehavior leftCP = ControlPointController.getControlPoint("LeftCP"); ControlPointBehavior rightCP = ControlPointController.getControlPoint("RightCP"); MuscleBehavior movingMuscle = MuscleController.getMuscle("MovingMuscleDynamic"); MovingMuscleTarget movingMuscleTarget = MuscleController.MovingTarget; leftCP.setLocation(leftCP.NeutralLocation); rightCP.setLocation(rightCP.NeutralLocation); movingMuscle.changeForce(TeethController.AdaptForce); movingMuscleTarget.Offset = Vector3.Zero; gridPropertiesControl.Origin = TeethController.getToothCenter(); gridPropertiesControl.updateGrid(); teethMovementPanel.setDefaultTools(); teethMovementPanel.opening(); base.opening(); }
public void sceneUnloading(SimScene scene) { if (movingMuscle != null) { movingMuscle.ForceChanged -= movingMuscle_ForceChanged; movingMuscle = null; } if (movingMuscleTarget != null) { movingMuscleTarget.OffsetChanged -= movingMuscleTarget_OffsetChanged; movingMuscleTarget = null; } if (leftCP != null) { leftCP.PositionChanged -= leftCP_PositionChanged; leftCP = null; } if (rightCP != null) { rightCP.PositionChanged -= rightCP_PositionChanged; rightCP = null; } }
void movingMuscle_ForceChanged(MuscleBehavior source, float force) { synchronizeForce(movingMuscle, movingMuscle.getForce()); }