protected override void link() { base.link(); var chainStartSimObject = Owner.getOtherSimObject(chainStartSimObjectName); if (chainStartSimObject == null) { blacklist("Cannot find the chain start SimObject '{0}'", chainStartSimObjectName); } var ikBone = chainStartSimObject.getElement(boneName) as BEPUikBone; if (ikBone == null) { blacklist("Cannot find the ik bone '{0}' in chain start SimObject '{1}'", boneName, chainStartSimObjectName); } fkElement = chainStartSimObject.getElement(fkElementName) as FKElement; if (fkElement == null) { blacklist("Cannot find the fk element '{0}' in chain start SimObject '{1}'", fkElementName, chainStartSimObjectName); } lastTranslation = Owner.Translation; lastRotation = Owner.Rotation; //Do a late link to update the chain, since we don't know if the entire thing has been built yet. registerLateLinkAction(() => { updateFKChain(); fkElement.ChainStateApplied += fkElement_ChainStateApplied; }); }
protected override void link() { base.link(); SimObject parentSimObject = Owner.getOtherSimObject(parentSimObjectName); if (parentSimObject == null) { blacklist("Cannot find Parent SimObject named '{0}'", parentSimObjectName); } parent = parentSimObject.getElement(parentSimObjectLinkName) as FKElement; if (parent == null) { blacklist("Cannot find FKLink '{0}' on Parent SimObject '{1}'", parentSimObjectLinkName, parentSimObjectName); } if (!String.IsNullOrEmpty(jointSimObjectName)) { SimObject jointSimObject = Owner.getOtherSimObject(jointSimObjectName); if (jointSimObject == null) { blacklist("Cannot find Joint SimObject named '{0}'", jointSimObjectName); } //Find the center of rotation in this object's local space centerOfRotationOffset = jointSimObject.Translation - Owner.Translation; } parent.addChild(this); }
void fkElement_ChainStateApplied(FKElement element, FKChainState chainState) { foreach (String name in chain.ChainStateNames) { var state = chainState[name]; chain.setLinkState(name, state.LocalTranslation, state.LocalRotation); } }
public void removeChild(FKElement child) { children.Remove(child); }
public void addChild(FKElement child) { children.Add(child); }