public void Initiate(IKSolverFullBody solver) { this.node1 = (solver.GetPoint(this.bone1) as IKSolver.Node); this.node2 = (solver.GetPoint(this.bone2) as IKSolver.Node); this.node3 = (solver.GetPoint(this.bone3) as IKSolver.Node); this.direction = this.OrthoToBone1(this.OrthoToLimb(this.node2.transform.position - this.node1.transform.position)); this.defaultLocalDirection = Quaternion.Inverse(this.node1.transform.rotation) * this.direction; Vector3 point = Vector3.Cross((this.node3.transform.position - this.node1.transform.position).normalized, this.direction); this.defaultChildDirection = Quaternion.Inverse(this.node3.transform.rotation) * point; this.initiated = true; }
/* * Initiate the constraint and set defaults * */ public void Initiate(IKSolverFullBody solver) { node1 = solver.GetPoint(bone1) as IKSolver.Node; node2 = solver.GetPoint(bone2) as IKSolver.Node; node3 = solver.GetPoint(bone3) as IKSolver.Node; // Find the default bend direction orthogonal to the chain direction direction = OrthoToBone1(OrthoToLimb(node2.transform.position - node1.transform.position)); // Default bend direction relative to the first node defaultLocalDirection = Quaternion.Inverse(node1.transform.rotation) * direction; // Default plane normal Vector3 defaultNormal = Vector3.Cross((node3.transform.position - node1.transform.position).normalized, direction); // Default plane normal relative to the third node defaultChildDirection = Quaternion.Inverse(node3.transform.rotation) * defaultNormal; }
/* * Initiate the constraint and set defaults * */ public void Initiate(IKSolverFullBody solver) { node1 = solver.GetPoint(bone1) as IKSolver.Node; node2 = solver.GetPoint(bone2) as IKSolver.Node; node3 = solver.GetPoint(bone3) as IKSolver.Node; // Find the default bend direction orthogonal to the chain direction direction = OrthoToBone1(OrthoToLimb(node2.transform.position - node1.transform.position)); // Default bend direction relative to the first node defaultLocalDirection = Quaternion.Inverse(node1.transform.rotation) * direction; // Default plane normal Vector3 defaultNormal = Vector3.Cross((node3.transform.position - node1.transform.position).normalized, direction); // Default plane normal relative to the third node defaultChildDirection = Quaternion.Inverse(node3.transform.rotation) * defaultNormal; }
/// <summary> /// Determines whether this IKConstraintBend is valid. /// </summary> public bool IsValid(IKSolverFullBody solver, Warning.Logger logger) { if (bone1 == null || bone2 == null || bone3 == null) { if (logger != null) logger("Bend Constraint contains a null reference."); return false; } if (solver.GetPoint(bone1) == null) { if (logger != null) logger("Bend Constraint is referencing to a bone '" + bone1.name + "' that does not excist in the Node Chain."); return false; } if (solver.GetPoint(bone2) == null) { if (logger != null) logger("Bend Constraint is referencing to a bone '" + bone2.name + "' that does not excist in the Node Chain."); return false; } if (solver.GetPoint(bone3) == null) { if (logger != null) logger("Bend Constraint is referencing to a bone '" + bone3.name + "' that does not excist in the Node Chain."); return false; } return true; }
/// <summary> /// Determines whether this IKConstraintBend is valid. /// </summary> public bool IsValid(IKSolverFullBody solver, Warning.Logger logger) { if (bone1 == null || bone2 == null || bone3 == null) { if (logger != null) { logger("Bend Constraint contains a null reference."); } return(false); } if (solver.GetPoint(bone1) == null) { if (logger != null) { logger("Bend Constraint is referencing to a bone '" + bone1.name + "' that does not excist in the Node Chain."); } return(false); } if (solver.GetPoint(bone2) == null) { if (logger != null) { logger("Bend Constraint is referencing to a bone '" + bone2.name + "' that does not excist in the Node Chain."); } return(false); } if (solver.GetPoint(bone3) == null) { if (logger != null) { logger("Bend Constraint is referencing to a bone '" + bone3.name + "' that does not excist in the Node Chain."); } return(false); } return(true); }