• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Location类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



Location类属于com.badlogic.gdx.ai.utils包,在下文中一共展示了Location类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
 
开发者ID:Mignet,项目名称:Inspiration,代码行数:26,代码来源:DefensiveCircleFormationPattern.java


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


示例3: Formation

import com.badlogic.gdx.ai.utils.Location; //导入依赖的package包/类
/** Creates a {@code Formation} for the specified {@code pattern}, {@code slotAssignmentStrategy} and {@code moderator}.
 * @param anchor the anchor point of this formation, usually a {@link Steerable}. Cannot be {@code null}.
 * @param pattern the pattern of this formation
 * @param slotAssignmentStrategy the strategy used to assign a member to his slot
 * @param motionModerator the motion moderator. Can be {@code null} if moderation is not needed
 * @throws IllegalArgumentException if the anchor point is {@code null} */
public Formation (Location<T> anchor, FormationPattern<T> pattern, SlotAssignmentStrategy<T> slotAssignmentStrategy,
	FormationMotionModerator<T> motionModerator) {
	if (anchor == null) throw new IllegalArgumentException("The anchor point cannot be null");
	this.anchor = anchor;
	this.pattern = pattern;
	this.slotAssignmentStrategy = slotAssignmentStrategy;
	this.motionModerator = motionModerator;

	this.slotAssignments = new Array<SlotAssignment<T>>();
	this.driftOffset = anchor.newLocation();
	this.positionOffset = anchor.getPosition().cpy();
}
 
开发者ID:Mignet,项目名称:Inspiration,代码行数:19,代码来源:Formation.java


示例4: Hide

import com.badlogic.gdx.ai.utils.Location; //导入依赖的package包/类
/** Creates a {@code Hide} behavior for the specified owner, target and proximity.
 * @param owner the owner of this behavior
 * @param target the target of this behavior
 * @param proximity the proximity to find nearby obstacles */
public Hide (Steerable<T> owner, Location<T> target, Proximity<T> proximity) {
	super(owner, target);
	this.proximity = proximity;

	this.bestHidingSpot = newVector(owner);
	this.toObstacle = null; // Set to null since we'll reuse steering.linear for this vector
}
 
开发者ID:Mignet,项目名称:Inspiration,代码行数:12,代码来源:Hide.java


示例5: 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;
}
 
开发者ID:libgdx-jam,项目名称:GDXJam,代码行数:8,代码来源:LineFormationPattern.java


示例6: 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;
}
 
开发者ID:libgdx-jam,项目名称:GDXJam,代码行数:11,代码来源:WedgeFormationPattern.java


示例7: 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;
}
 
开发者ID:libgdx-jam,项目名称:GDXJam,代码行数:11,代码来源:SquareFormationPattern.java


示例8: 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;
}
 
开发者ID:libgdx-jam,项目名称:GDXJam,代码行数:10,代码来源:VFormationPattern.java


示例9: newLocation

import com.badlogic.gdx.ai.utils.Location; //导入依赖的package包/类
@Override
public Location<Vector2> newLocation () {
        return new Scene2dLocation();
        }
 
开发者ID:MSLacerda,项目名称:DarkDay,代码行数:5,代码来源:Scene2dLocation.java


示例10: newLocation

import com.badlogic.gdx.ai.utils.Location; //导入依赖的package包/类
@Override
public Location<Vector2> newLocation () {
	return new SteerLocation();
}
 
开发者ID:unlimitedggames,项目名称:gdxjam-ugg,代码行数:5,代码来源:SteerableComponent.java


示例11: newLocation

import com.badlogic.gdx.ai.utils.Location; //导入依赖的package包/类
@Override
public Location<Vector2> newLocation() {
	return null;
}
 
开发者ID:android-workloads,项目名称:JACWfA,代码行数:5,代码来源:Agent.java


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


示例13: calculateSlotLocation

import com.badlogic.gdx.ai.utils.Location; //导入依赖的package包/类
/** Returns the location of the given slot index. */
public Location<T> calculateSlotLocation (Location<T> outLocation, int slotNumber);
 
开发者ID:Mignet,项目名称:Inspiration,代码行数:3,代码来源:FormationPattern.java


示例14: getAnchorPoint

import com.badlogic.gdx.ai.utils.Location; //导入依赖的package包/类
/** Returns the current anchor point of the formation. This can be the location (i.e. position and orientation) of a leader
 * member, a modified center of mass of the members in the formation, or an invisible but steered anchor point for a two-level
 * steering system. */
public Location<T> getAnchorPoint () {
	return anchor;
}
 
开发者ID:Mignet,项目名称:Inspiration,代码行数:7,代码来源:Formation.java


示例15: setAnchorPoint

import com.badlogic.gdx.ai.utils.Location; //导入依赖的package包/类
/** Sets the anchor point of the formation.
 * @param anchor the anchor point to set */
public void setAnchorPoint (Location<T> anchor) {
	this.anchor = anchor;
}
 
开发者ID:Mignet,项目名称:Inspiration,代码行数:6,代码来源:Formation.java


示例16: 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


示例17: getTargetLocation

import com.badlogic.gdx.ai.utils.Location; //导入依赖的package包/类
/** Returns the target location of this formation member. */
public Location<T> getTargetLocation ();
 
开发者ID:Mignet,项目名称:Inspiration,代码行数:3,代码来源:FormationMember.java


示例18: setTarget

import com.badlogic.gdx.ai.utils.Location; //导入依赖的package包/类
@Override
public Interpose<T> setTarget (Location<T> target) {
	this.target = target;
	return this;
}
 
开发者ID:Mignet,项目名称:Inspiration,代码行数:6,代码来源:Interpose.java


示例19: Flee

import com.badlogic.gdx.ai.utils.Location; //导入依赖的package包/类
/** Creates a {@code Flee} behavior for the specified owner and target.
 * @param owner the owner of this behavior
 * @param target the target agent of this behavior. */
public Flee (Steerable<T> owner, Location<T> target) {
	super(owner, target);
}
 
开发者ID:Mignet,项目名称:Inspiration,代码行数:7,代码来源:Flee.java


示例20: setTarget

import com.badlogic.gdx.ai.utils.Location; //导入依赖的package包/类
@Override
public Flee<T> setTarget (Location<T> target) {
	this.target = target;
	return this;
}
 
开发者ID:Mignet,项目名称:Inspiration,代码行数:6,代码来源:Flee.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Strings类代码示例发布时间:2022-05-23
下一篇:
Java AccessibleHyperlink类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap