protected override void constructed() { DiscController.addDisc(this); SimObject controlPointObj = Owner.getOtherSimObject(controlPointObject); if (controlPointObj != null) { controlPoint = controlPointObj.getElement(controlPointBehavior) as ControlPointBehavior; if (controlPoint == null) { blacklist("Could not find controlPointBehavior {0}.", controlPointBehavior); } } else { blacklist("Could not find controlPointObject {0}.", controlPointObject); } SimObject fossaSimObject = Owner.getOtherSimObject(fossaObject); if (fossaSimObject != null) { fossa = fossaSimObject.getElement(fossaName) as Fossa; if (fossa == null) { blacklist("Could not find Fossa {0} in SimObject {1}.", fossaName, fossaObject); } } else { blacklist("Could not find Fossa SimObject {0}.", fossaObject); } SceneNodeElement node = Owner.getElement(sceneNodeName) as SceneNodeElement; if (node != null) { Entity entity = node.getNodeObject(entityName) as Entity; if (entity != null) { if (entity.hasSkeleton()) { SkeletonInstance skeleton = entity.getSkeleton(); medialPole.findBone(skeleton); lateralPole.findBone(skeleton); ventralPole.findBone(skeleton); posteriorPole.initialize(skeleton, Owner, controlPoint, this); topSurface.initialize(skeleton, fossa, Owner); } } else { blacklist("Could not find entity {0} in node {1}.", entityName, sceneNodeName); } } else { blacklist("Could not find SceneNode {0}.", sceneNodeName); } }
/// <summary> /// Primary blend funciton, will always use the terminating state's mandible muscle force and target offset. /// This is to retain compatability with animations that rely on this blend funciton to work. /// </summary> /// <param name="targetState"></param> /// <param name="blendFactor"></param> public void blend(MusclePosition targetState, float blendFactor) { float modifiedBlendFactor = blendFactor; if (blendFactor < 1.0f) { EasingFunctions.Ease(targetState.Easing, 0, 1, blendFactor, 1); } if (MuscleController.MovingTarget != null) //If this is null then the whole mandible simulation is invalid and its better to do nothing { MuscleController.changeForce("MovingMuscleDynamic", targetState.muscleForce); MuscleController.MovingTarget.Offset = targetState.movingTargetPosition; ControlPointBehavior leftCP = ControlPointController.getControlPoint("LeftCP"); float delta = targetState.leftCPPosition - leftCPPosition; leftCP.setLocation(leftCPPosition + delta * modifiedBlendFactor); ControlPointBehavior rightCP = ControlPointController.getControlPoint("RightCP"); delta = targetState.rightCPPosition - rightCPPosition; rightCP.setLocation(rightCPPosition + delta * modifiedBlendFactor); } FKRoot pelvis; if (pelvisChainState != null && targetState.pelvisChainState != null && PoseableObjectsManager.tryGetFkChainRoot("Pelvis", out pelvis)) { //This creates garbage, but it is unknown if this has negative effects FKChainState blendedState = new FKChainState(); blendedState.setToBlendOf(pelvisChainState, targetState.pelvisChainState, modifiedBlendFactor); pelvis.applyChainState(blendedState); } }
public void initialize(Skeleton skeleton, SimObject owner, ControlPointBehavior controlPoint, Disc disc) { this.controlPoint = controlPoint; this.disc = disc; Vector3 rotRad = nineOClockRotation * DEG_TO_RAD; nineOClockRotationQuat.setEuler(rotRad.x, rotRad.y, rotRad.z); startingRot = owner.Rotation; rotationRange = nineOClockPosition - oneOClockPosition; posteriorPoleRotator = skeleton.getBone(boneName); posteriorPoleRotator.setManuallyControlled(true); }
public void captureState() { MuscleBehavior movingMuscle = MuscleController.getMuscle("MovingMuscleDynamic"); if (movingMuscle != null) { muscleForce = movingMuscle.getForce(); } if (MuscleController.MovingTarget != null) { movingTargetPosition = MuscleController.MovingTarget.Offset; } ControlPointBehavior leftCP = ControlPointController.getControlPoint("LeftCP"); ControlPointBehavior rightCP = ControlPointController.getControlPoint("RightCP"); if (leftCP != null) { leftCPPosition = leftCP.CurrentLocation; } if (rightCP != null) { rightCPPosition = rightCP.CurrentLocation; } //Setup the pelvis fk chain if available FKRoot pelvis; if (PoseableObjectsManager.tryGetFkChainRoot("Pelvis", out pelvis)) { pelvisChainState = new FKChainState(); pelvis.addToChainState(pelvisChainState); } else { pelvisChainState = null; } }
protected override void constructed() { curve = new CatmullRomSpline3d(); FossaController.add(this); SimObject eminanceSimObject = Owner.getOtherSimObject(eminanceName); if (eminanceSimObject == null) { blacklist("Cannot find the eminance SimObject {0}", eminanceName); } eminanceOffset = eminanceSimObject.Translation; SceneNodeElement eminanceSceneNode = eminanceSimObject.getElement(eminanceNodeName) as SceneNodeElement; if (eminanceSceneNode == null) { blacklist("Cannot find the eminance scene node {0}", eminanceNodeName); } Entity eminanceEntity = eminanceSceneNode.getNodeObject(eminanceEntityName) as Entity; if (eminanceEntity == null) { blacklist("Cannot find the eminance entity {0}", eminanceEntityName); } if (!eminanceEntity.hasSkeleton()) { blacklist("Eminance entity {0} does not have a skeleton.", eminanceEntityName); } SkeletonInstance skeleton = eminanceEntity.getSkeleton(); for (int i = 1; skeleton.hasBone(fossaBoneBaseName + i); ++i) { Bone bone = skeleton.getBone(fossaBoneBaseName + i); eminanceBones.Add(bone); bone.setManuallyControlled(true); } SimObject skullSimObject = Owner.getOtherSimObject(skullName); if (skullSimObject == null) { blacklist("Could not find a skull SimObject named {0}.", skullName); } skullOffset = skullSimObject.Translation; SceneNodeElement skullNode = skullSimObject.getElement(skullNodeName) as SceneNodeElement; if (skullNode == null) { blacklist("Could not find skull node {0}.", skullNodeName); } Entity skullEntity = skullNode.getNodeObject(skullEntityName) as Entity; if (skullEntity == null) { blacklist("Could not find skull entity {0}.", skullEntityName); } if (!skullEntity.hasSkeleton()) { blacklist("Skull entity {0} does not have a skeleton.", skullEntityName); } skeleton = skullEntity.getSkeleton(); Vector3 eminanceTrans = Vector3.Zero; for (int i = 1; skeleton.hasBone(fossaBoneBaseName + i); ++i) { Bone bone = skeleton.getBone(fossaBoneBaseName + i); skullBones.Add(bone); bone.setManuallyControlled(true); Vector3 trans = bone.getDerivedPosition() + skullSimObject.Translation - this.Owner.Translation; trans.x = 0; basePoints.Add(trans); if (i < eminanceStart) { eminanceDistort.Add(trans); eminanceTrans = trans; } else { trans.y = eminanceTrans.y; eminanceDistort.Add(trans); } } foreach (Vector3 point in basePoints) { curve.addControlPoint(point); } //Find the control point SimObject controlPointObj = Owner.getOtherSimObject(controlPointObject); if (controlPointObj == null) { blacklist("Could not find controlPointObject {0}.", controlPointObject); } controlPoint = controlPointObj.getElement(controlPointBehavior) as ControlPointBehavior; if (controlPoint == null) { blacklist("Could not find controlPointBehavior {0}.", controlPointBehavior); } }
public void initialize(ControlPointBehavior controlPoint, SimObject owner) { this.controlPoint = controlPoint; this.owner = owner; offset = bone.getDerivedPosition() + owner.Translation - (controlPoint.MandibleBonePosition + controlPoint.MandibleTranslation); }
public static void removeControlPoint(ControlPointBehavior cp) { controlPoints.Remove(cp.Owner.Name); }
public static void addControlPoint(ControlPointBehavior cp) { controlPoints.Add(cp.Owner.Name, cp); }