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


Java Location.getPosition方法代码示例

本文整理汇总了Java中com.badlogic.gdx.ai.utils.Location.getPosition方法的典型用法代码示例。如果您正苦于以下问题:Java Location.getPosition方法的具体用法?Java Location.getPosition怎么用?Java Location.getPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.ai.utils.Location的用法示例。


在下文中一共展示了Location.getPosition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: calculateDriftOffset

import com.badlogic.gdx.ai.utils.Location; //导入方法依赖的package包/类
/** Calculates the drift offset when members are in the given set of slots for the specified pattern.
 * @param centerOfMass the output location set to the calculated drift offset
 * @param slotAssignments the set of slots
 * @param pattern the pattern
 * @return the given location for chaining. */
public Location<T> calculateDriftOffset (Location<T> centerOfMass, Array<SlotAssignment<T>> slotAssignments,
	FormationPattern<T> pattern) {

	// Clear the center of mass
	centerOfMass.getPosition().setZero();
	float centerOfMassOrientation = 0;

	// Make sure tempLocation is instantiated
	if (tempLocation == null) tempLocation = centerOfMass.newLocation();

	T centerOfMassPos = centerOfMass.getPosition();
	T tempLocationPos = tempLocation.getPosition();

	// Go through each assignment and add its contribution to the center
	float numberOfAssignments = slotAssignments.size;
	for (int i = 0; i < numberOfAssignments; i++) {
		pattern.calculateSlotLocation(tempLocation, slotAssignments.get(i).slotNumber);
		centerOfMassPos.add(tempLocationPos);
		centerOfMassOrientation += tempLocation.getOrientation();
	}

	// Divide through to get the drift offset.
	centerOfMassPos.scl(1f / numberOfAssignments);
	centerOfMassOrientation /= numberOfAssignments;
	centerOfMass.setOrientation(centerOfMassOrientation);

	return centerOfMass;
}
 
开发者ID:Mignet,项目名称:Inspiration,代码行数:34,代码来源:FormationMotionModerator.java

示例2: updateSlots

import com.badlogic.gdx.ai.utils.Location; //导入方法依赖的package包/类
/** Writes new slot locations to each member */
	public void updateSlots () {
		// Find the anchor point
		Location<T> anchor = getAnchorPoint();

		positionOffset.set(anchor.getPosition());
		float orientationOffset = anchor.getOrientation();
		if (motionModerator != null) {
			positionOffset.sub(driftOffset.getPosition());
			orientationOffset -= driftOffset.getOrientation();
		}

		// Get the orientation of the anchor point as a matrix
		orientationMatrix.idt().rotateRad(anchor.getOrientation());

		// Go through each member in turn
		for (int i = 0; i < slotAssignments.size; i++) {
			SlotAssignment<T> slotAssignment = slotAssignments.get(i);

			// Retrieve the location reference of the formation member to calculate the new value
			Location<T> relativeLoc = slotAssignment.member.getTargetLocation();

			// Ask for the location of the slot relative to the anchor point
			pattern.calculateSlotLocation(relativeLoc, slotAssignment.slotNumber);

			T relativeLocPosition = relativeLoc.getPosition();

// System.out.println("relativeLoc.position = " + relativeLocPosition);

// [17:31] <@Xoppa> davebaol, interface Transform<T extends Vector<T>> { T getTranslation(); T getScale(); float getRotation();
// void transform(T val); }
// [17:31] <@Xoppa>
// https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/graphics/g3d/utils/BaseAnimationController.java#L40
// [17:34] * ThreadL0ck ([email protected]) Quit (Remote host closed the connection)
// [17:35] <davebaol> thanks Xoppa, sounds interesting

			// TODO Consider the possibility of declaring mul(orientationMatrix) in Vector
			// Transform it by the anchor point's position and orientation
// relativeLocPosition.mul(orientationMatrix).add(anchor.position);
			if (relativeLocPosition instanceof Vector2)
				((Vector2)relativeLocPosition).mul(orientationMatrix);
			else if (relativeLocPosition instanceof Vector3) ((Vector3)relativeLocPosition).mul(orientationMatrix);

			// Add the anchor and drift components
			relativeLocPosition.add(positionOffset);
			relativeLoc.setOrientation(relativeLoc.getOrientation() + orientationOffset);
		}

		// Possibly reset the anchor point if a moderator is set
		if (motionModerator != null) {
			motionModerator.updateAnchorPoint(anchor);
		}
	}
 
开发者ID:Mignet,项目名称:Inspiration,代码行数:54,代码来源:Formation.java


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