當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。