本文整理汇总了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();
}