当前位置: 首页>>代码示例>>Java>>正文


Java LinePathParam类代码示例

本文整理汇总了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;
}
 
开发者ID:Mignet,项目名称:Inspiration,代码行数:27,代码来源:LinePath.java

示例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);
}
 
开发者ID:Mignet,项目名称:Inspiration,代码行数:38,代码来源:LinePath.java

示例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);
}
 
开发者ID:jsjolund,项目名称:GdxDemo3D,代码行数:11,代码来源:FollowPathSteerer.java

示例4: createParam

import com.badlogic.gdx.ai.steer.utils.paths.LinePath.LinePathParam; //导入依赖的package包/类
@Override
public LinePathParam createParam () {
	return new LinePathParam();
}
 
开发者ID:Mignet,项目名称:Inspiration,代码行数:5,代码来源:LinePath.java


注:本文中的com.badlogic.gdx.ai.steer.utils.paths.LinePath.LinePathParam类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。