當前位置: 首頁>>代碼示例>>Java>>正文


Java FastMath.HALF_PI屬性代碼示例

本文整理匯總了Java中com.jme3.math.FastMath.HALF_PI屬性的典型用法代碼示例。如果您正苦於以下問題:Java FastMath.HALF_PI屬性的具體用法?Java FastMath.HALF_PI怎麽用?Java FastMath.HALF_PI使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在com.jme3.math.FastMath的用法示例。


在下文中一共展示了FastMath.HALF_PI屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: simpleUpdate

@Override
public void simpleUpdate(float tpf){
    Bone b = control.getSkeleton().getBone("spinehigh");
    Bone b2 = control.getSkeleton().getBone("uparm.left");
    
    angle += tpf * rate;        
    if (angle > FastMath.HALF_PI / 2f){
        angle = FastMath.HALF_PI / 2f;
        rate = -1;
    }else if (angle < -FastMath.HALF_PI / 2f){
        angle = -FastMath.HALF_PI / 2f;
        rate = 1;
    }

    Quaternion q = new Quaternion();
    q.fromAngles(0, angle, 0);

    b.setUserControl(true);
    b.setUserTransforms(Vector3f.ZERO, q, Vector3f.UNIT_XYZ);
    
    b2.setUserControl(true);
    b2.setUserTransforms(Vector3f.ZERO, Quaternion.IDENTITY, new Vector3f(1+angle,1+ angle, 1+angle));
  
  
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:25,代碼來源:TestOgreComplexAnim.java

示例2: physicsTick

@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);
		}
	}
}
 
開發者ID:rockfireredmoon,項目名稱:iceclient,代碼行數:67,代碼來源:CopyOfPlayerPhysicsControl.java


注:本文中的com.jme3.math.FastMath.HALF_PI屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。