当前位置: 首页>>代码示例>>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;未经允许,请勿转载。