本文整理匯總了Java中com.badlogic.gdx.ai.steer.utils.paths.LinePath.LinePathParam類的典型用法代碼示例。如果您正苦於以下問題:Java LinePathParam類的具體用法?Java LinePathParam怎麽用?Java LinePathParam使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
LinePathParam類屬於com.badlogic.gdx.ai.steer.utils.paths.LinePath包,在下文中一共展示了LinePathParam類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: calculateDistance
import com.badlogic.gdx.ai.steer.utils.paths.LinePath.LinePathParam; //導入依賴的package包/類
@Override
public float calculateDistance (T agentCurrPos, LinePathParam parameter) {
// Find the nearest segment
float smallestDistance2 = Float.POSITIVE_INFINITY;
Segment<T> nearestSegment = null;
for (int i = 0; i < segments.size; i++) {
Segment<T> segment = segments.get(i);
float distance2 = calculatePointSegmentSquareDistance(nearestPointOnCurrentSegment, segment.begin, segment.end,
agentCurrPos);
// first point
if (distance2 < smallestDistance2) {
nearestPointOnPath.set(nearestPointOnCurrentSegment);
smallestDistance2 = distance2;
nearestSegment = segment;
parameter.segmentIndex = i;
}
}
// Distance from path start
float lengthOnPath = nearestSegment.cumulativeLength - nearestPointOnPath.dst(nearestSegment.end);
parameter.setDistance(lengthOnPath);
return lengthOnPath;
}
示例2: calculateTargetPosition
import com.badlogic.gdx.ai.steer.utils.paths.LinePath.LinePathParam; //導入依賴的package包/類
@Override
public void calculateTargetPosition (T out, LinePathParam param, float targetDistance) {
if (isOpen) {
// Open path support
if (targetDistance < 0) {
// Clamp target distance to the min
targetDistance = 0;
} else if (targetDistance > pathLength) {
// Clamp target distance to the max
targetDistance = pathLength;
}
} else {
// Closed path support
if (targetDistance < 0) {
// Backwards
targetDistance = pathLength + (targetDistance % pathLength);
} else if (targetDistance > pathLength) {
// Forward
targetDistance = targetDistance % pathLength;
}
}
// Walk through lines to see on which line we are
Segment<T> desiredSegment = null;
for (int i = 0; i < segments.size; i++) {
Segment<T> segment = segments.get(i);
if (segment.cumulativeLength >= targetDistance) {
desiredSegment = segment;
break;
}
}
// begin-------targetPos-------end
float distance = desiredSegment.cumulativeLength - targetDistance;
out.set(desiredSegment.begin).sub(desiredSegment.end).scl(distance / desiredSegment.length).add(desiredSegment.end);
}
示例3: FollowPathSteerer
import com.badlogic.gdx.ai.steer.utils.paths.LinePath.LinePathParam; //導入依賴的package包/類
public FollowPathSteerer(final SteerableBody steerableBody) {
super(steerableBody);
// At least two points are needed to construct a line path
Array<Vector3> waypoints = new Array<Vector3>(new Vector3[]{new Vector3(), new Vector3(1, 0, 1)});
this.linePath = new LinePath<Vector3>(waypoints, true);
this.followPathSB = new FollowPath<Vector3, LinePath.LinePathParam>(steerableBody, linePath, 1);
this.prioritySteering.add(followPathSB);
}
示例4: createParam
import com.badlogic.gdx.ai.steer.utils.paths.LinePath.LinePathParam; //導入依賴的package包/類
@Override
public LinePathParam createParam () {
return new LinePathParam();
}