// From CPP // ---------------------------------------------------------------------------- // adjust the steering force passed to applySteeringForce. // // allows a specific vehicle class to redefine this adjustment. // default is to disallow backward-facing steering at low speed. // // xxx should the default be this ad-hocery, or no adjustment? // xxx experimental 8-20-02 // // parameter names commented out to prevent compiler warning from "-W" public Vector3 adjustRawSteeringForce(Vector3 force)//, const float /* deltaTime */) { float maxAdjustedSpeed = 0.2f * MaxSpeed(); if ((Speed() > maxAdjustedSpeed) || (force == Vector3.zero)) { return(force); } else { float range = Speed() / maxAdjustedSpeed; float cosine = OpenSteerUtility.interpolate((float)System.Math.Pow(range, 20), 1.0f, -1.0f); return(OpenSteerUtility.limitMaxDeviationAngle(force, cosine, Forward())); } }
public override Vector3 mapPathDistanceToPoint(float pathDistance) { // clip or wrap given path distance according to cyclic flag float remaining = pathDistance; if (cyclic) { remaining = (float)System.Math.IEEERemainder(pathDistance, totalPathLength); //remaining = (float) fmod (pathDistance, totalPathLength); } else { if (pathDistance < 0) { return(points[0]); } if (pathDistance >= totalPathLength) { return(points [pointCount - 1]); } } // step through segments, subtracting off segment lengths until // locating the segment that contains the original pathDistance. // Interpolate along that segment to find 3d point value to return. Vector3 result = Vector3.zero; for (int i = 1; i < pointCount; i++) { segmentLength = lengths[i]; if (segmentLength < remaining) { remaining -= segmentLength; } else { float ratio = remaining / segmentLength; result = OpenSteerUtility.interpolate(ratio, points[i - 1], points[i]); break; } } return(result); }