本文整理匯總了Java中com.jme3.math.Vector2f.angleBetween方法的典型用法代碼示例。如果您正苦於以下問題:Java Vector2f.angleBetween方法的具體用法?Java Vector2f.angleBetween怎麽用?Java Vector2f.angleBetween使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.jme3.math.Vector2f
的用法示例。
在下文中一共展示了Vector2f.angleBetween方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: physicsTick
import com.jme3.math.Vector2f; //導入方法依賴的package包/類
@Override
public void physicsTick(PhysicsSpace space, float tpf) {
super.physicsTick(space, tpf);
// Update the spawn object with the new locations
if (updateSpawn) {
Vector3f st = getSpatialTranslation();
// Icelib.removeMe("Translation in pre-physics tick %s / %s", st,
// getWalkDirection());
// spawn.setLocation(IceUI.toLocation(st));
// Rotation
short deg = IceUI.getDegrees(getSpatialRotation());
short dirDeg;
// Direction
if (moveableControl.isMoving()) {
// When moving, use the direction of movement
Vector3f adir = walkDirection.normalize();
Vector2f dir = new Vector2f(adir.x, adir.z);
float angle = (dir.angleBetween(Constants.FORWARD_XY));
if (angle < 0) {
angle = (FastMath.HALF_PI * 3f) + (FastMath.HALF_PI + angle);
}
dirDeg = (short) ((int) Math.round(angle * FastMath.RAD_TO_DEG));
} else {
// When not moving current rotation
if (!moveableControl.isMovingToTarget()) {
dirDeg = 0;
// TODO hmm
// spawn.setDirection(-1);
} else {
dirDeg = deg;
}
}
spawn.setVelocity(deg, dirDeg, (short) (moveableControl.getMoveSpeed() * 100f));
}
if (!moveableControl.isSwim() && !moveableControl.isMovingToTarget()) {
float peak = Math.abs(Constants.GRAVITY) * 0.3f;
float jumpDetectVel = Math.abs(Constants.GRAVITY) * 0.3f;
final MoveableCharacterControl.JumpStage jumpStage = moveableControl.getJumpStage();
if (jumpStage == null) {
if (!isOnGround() && velocity.y > jumpDetectVel) {
LOG.info(String.format("Detect jump at velocity %s", velocity));
moveableControl.move(Type.JUMP, true, tpf);
}
} else if (MoveableCharacterControl.JumpStage.UP.equals(jumpStage)) {
if (velocity.y < peak) {
LOG.info(String.format("Risen above peak (vel: %f against %f", velocity.y, Constants.JUMP_FORCE * 0.85f));
moveableControl.move(Type.PEAKED, true, tpf);
}
} else if (moveableControl.getJumpStage() != null && isOnGround()) {
LOG.info("Now on ground");
moveableControl.move(Type.FALLING, false, tpf);
} else if (MoveableCharacterControl.JumpStage.TOP.equals(moveableControl.getJumpStage())) {
if (velocity.y <= -peak) {
LOG.info("Fallen below peak");
moveableControl.move(Type.FALLING, true, tpf);
}
} else if (moveableControl.getJumpStage() == null && !isOnGround() && velocity.y < peak) {
LOG.info("Falling");
moveableControl.move(Type.FALLING, true, tpf);
}
}
}