StringBuilder DumpBaseJoint(Joint joint) { var msg = new StringBuilder(); msg.Append("name: ").Append(joint.name).AppendLine(); msg.Append("ownerBody: ") .Append(DebugEx.ObjectToString(joint.gameObject.GetComponent <Rigidbody>())) .AppendLine(); msg.Append("connectedBody: ") .Append(DebugEx.ObjectToString(joint.connectedBody)) .AppendLine(); // Collider setup. msg.Append("enableCollision: ").Append(joint.enableCollision).AppendLine(); // Optimization. msg.Append("enablePreprocessing: ").Append(joint.enablePreprocessing).AppendLine(); // Break forces. msg.Append("breakForce: ").Append(joint.breakForce).AppendLine(); msg.Append("breakTorque: ").Append(joint.breakTorque).AppendLine(); // Geometry. msg.Append("anchor: ").Append(DbgFormatter.Vector(joint.anchor)).AppendLine(); msg.Append("connectedAnchor: ") .Append(DbgFormatter.Vector(joint.connectedAnchor)) .AppendLine(); msg.Append("axis: ").Append(DbgFormatter.Vector(joint.axis)).AppendLine(); return(msg); }
/// <summary>Returns an anchor for the physical joint at the target part.</summary> /// <remarks> /// The anchor will be calculated in the source's part scale, and the target's model scale will /// be ignored. /// </remarks> /// <param name="source">The source of the link.</param> /// <param name="target">The target of the link.</param> /// <returns>The position in the world coordinates.</returns> protected Vector3 GetTargetPhysicalAnchor(ILinkSource source, ILinkTarget target) { var scale = source.nodeTransform.lossyScale; if (Mathf.Abs(scale.x - scale.y) > 1e-05 || Mathf.Abs(scale.x - scale.z) > 1e-05) { HostedDebugLog.Error(this, "Uneven scale on the source part is not supported: {0}", DbgFormatter.Vector(scale)); } return(target.nodeTransform.position + target.nodeTransform.rotation * (anchorAtTarget * scale.x)); }
/// <inheritdoc/> public string DumpJoint(ConfigurableJoint joint) { if (joint == null) { return("<NULL JOINT>"); } var msg = DumpBaseJoint(joint); // Geometry. msg.Append("secondaryAxis: ").Append(DbgFormatter.Vector(joint.secondaryAxis)).AppendLine(); // X axis settings. msg.Append("xDrive: ").Append(Dump(joint.xDrive)).AppendLine(); msg.Append("xMotion: ").Append(joint.xMotion).AppendLine(); msg.Append("angularXMotion: ").Append(joint.angularXMotion).AppendLine(); msg.Append("angularXLimitSpring: ").Append(Dump(joint.angularXLimitSpring)).AppendLine(); msg.Append("angularXDrive: ").Append(Dump(joint.angularXDrive)).AppendLine(); msg.Append("lowAngularXLimit: ").Append(Dump(joint.lowAngularXLimit)).AppendLine(); msg.Append("highAngularXLimit: ").Append(Dump(joint.highAngularXLimit)).AppendLine(); // Y axis settings. msg.Append("yDrive: ").Append(Dump(joint.yDrive)).AppendLine(); msg.Append("yMotion: ").Append(joint.yMotion).AppendLine(); msg.Append("angularYMotion: ").Append(joint.angularYMotion).AppendLine(); msg.Append("angularYLimit: ").Append(Dump(joint.angularYLimit)).AppendLine(); // Z axis settings. msg.Append("zDrive: ").Append(Dump(joint.zDrive)).AppendLine(); msg.Append("zMotion: ").Append(joint.zMotion).AppendLine(); msg.Append("angularZMotion: ").Append(joint.angularZMotion).AppendLine(); msg.Append("angularZLimit: ").Append(Dump(joint.angularZLimit)).AppendLine(); // Multiple axis settings. msg.Append("linearLimit: ").Append(Dump(joint.linearLimit)).AppendLine(); msg.Append("linearLimitSpring: ").Append(Dump(joint.linearLimitSpring)).AppendLine(); msg.Append("angularYZDrive: ").Append(Dump(joint.angularYZDrive)).AppendLine(); msg.Append("angularYZLimitSpring: ").Append(Dump(joint.angularYZLimitSpring)).AppendLine(); return(msg.ToString()); }
/// <summary>Shows a human readable representation.</summary> /// <returns>String value.</returns> public override string ToString() { return(string.Format( "[PosAndRot Pos={0}, Euler={1}]", DbgFormatter.Vector(pos), DbgFormatter.Vector(euler))); }