本文整理汇总了Java中com.badlogic.gdx.ai.utils.Location.setOrientation方法的典型用法代码示例。如果您正苦于以下问题:Java Location.setOrientation方法的具体用法?Java Location.setOrientation怎么用?Java Location.setOrientation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.ai.utils.Location
的用法示例。
在下文中一共展示了Location.setOrientation方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calculateSlotLocation
import com.badlogic.gdx.ai.utils.Location; //导入方法依赖的package包/类
@Override
public Location<T> calculateSlotLocation (Location<T> outLocation, int slotNumber) {
if (numberOfSlots > 1) {
// Place the slot around the circle based on its slot number
float angleAroundCircle = (MathUtils.PI2 * slotNumber) / numberOfSlots;
// The radius depends on the radius of the member,
// and the number of members in the circle:
// we want there to be no gap between member's shoulders.
float radius = memberRadius / (float)Math.sin(Math.PI / numberOfSlots);
// Fill location components based on the angle around circle.
outLocation.angleToVector(outLocation.getPosition(), angleAroundCircle).scl(radius);
// The members should be facing out
outLocation.setOrientation(angleAroundCircle);
}
else {
outLocation.getPosition().setZero();
outLocation.setOrientation(MathUtils.PI2 * slotNumber);
}
// Return the slot location
return outLocation;
}
示例2: 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;
}
示例3: calculateSlotLocation
import com.badlogic.gdx.ai.utils.Location; //导入方法依赖的package包/类
@Override
public Location<Vector2> calculateSlotLocation(Location<Vector2> outLocation, int slotNumber) {
float offset = memberRadius * (numberOfSlots - 1);
outLocation.getPosition().set(0, slotNumber * (memberRadius + memberRadius) - offset);
outLocation.setOrientation(0);
return outLocation;
}
示例4: calculateSlotLocation
import com.badlogic.gdx.ai.utils.Location; //导入方法依赖的package包/类
@Override
public Location<Vector2> calculateSlotLocation(
Location<Vector2> outLocation, int slotNumber) {
int row = calculateRow(slotNumber);
float col = calculateColumn(slotNumber, row);
float memberDiameter = memberRadius + memberRadius;
outLocation.getPosition().set(-row * memberDiameter, -col * memberDiameter);
outLocation.setOrientation(0);
return outLocation;
}
示例5: calculateSlotLocation
import com.badlogic.gdx.ai.utils.Location; //导入方法依赖的package包/类
@Override
public Location<Vector2> calculateSlotLocation (Location<Vector2> outLocation, int slotNumber) {
int x = slotNumber / columns;
int y = slotNumber % columns;
float memberDiameter = memberRadius + memberRadius;
float offset = memberRadius * (columns - 1);
outLocation.getPosition().set(x * memberDiameter - offset, y * memberDiameter - offset);
outLocation.setOrientation(0);
return outLocation;
}
示例6: calculateSlotLocation
import com.badlogic.gdx.ai.utils.Location; //导入方法依赖的package包/类
@Override
public Location<Vector2> calculateSlotLocation(
Location<Vector2> outLocation, int slotNumber) {
Vector2 side = ((slotNumber + 1) % 2) == 0 ? side1 : side2;
float radius = ((slotNumber + 1) / 2) * (memberRadius + memberRadius);
outLocation.getPosition().set(side).scl(radius);
outLocation.setOrientation(0);
return outLocation;
}
示例7: calculateSlotLocation
import com.badlogic.gdx.ai.utils.Location; //导入方法依赖的package包/类
@Override
public Location<T> calculateSlotLocation (Location<T> outLocation, int slotNumber) {
super.calculateSlotLocation(outLocation, slotNumber);
outLocation.setOrientation(outLocation.getOrientation() + MathUtils.PI);
return outLocation;
}
示例8: 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);
}
}
示例9: calculateSlotLocation
import com.badlogic.gdx.ai.utils.Location; //导入方法依赖的package包/类
@Override
public Location<Vector2> calculateSlotLocation(Location<Vector2> outLocation, int slotNumber) {
outLocation.getPosition().set(- slotNumber * (memberRadius + memberRadius), 0);
outLocation.setOrientation(0);
return outLocation;
}