本文整理匯總了Java中com.jme3.math.FastMath.RAD_TO_DEG屬性的典型用法代碼示例。如果您正苦於以下問題:Java FastMath.RAD_TO_DEG屬性的具體用法?Java FastMath.RAD_TO_DEG怎麽用?Java FastMath.RAD_TO_DEG使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類com.jme3.math.FastMath
的用法示例。
在下文中一共展示了FastMath.RAD_TO_DEG屬性的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: update
@Override
public void update(ElementParticle particle, float tpf) {
if (isEnabled) {
if (rotateFromEmitterPosition) {
tempV2a.set(
emitter.getPositionX(),
emitter.getPositionY()
);
tempV2b.set(particle.position);
particle.angle = getRotationBetween(
tempV2a, tempV2b
)+90;
} else if (rotateToVelocity) {
particle.angle = getRotationFromVelocity(particle.velocity);
} else {
if (particle.rotateDir)
particle.angle += particle.rotateSpeed * tpf * FastMath.RAD_TO_DEG;
else
particle.angle -= particle.rotateSpeed * tpf * FastMath.RAD_TO_DEG;
}
}
}
示例2: updateAngle
private void updateAngle() {
Vector3f temp, higher, lower;
if (point2.y > point1.y) {
temp = point2;
higher = point2;
lower = point1;
} else {
temp = point1;
higher = point1;
lower = point2;
}
temp = temp.clone().setY(lower.y);
float angle = ((FastMath.asin(temp.distance(higher) / lower.distance(higher))) * FastMath.RAD_TO_DEG);
angleText.setText(angle + " degrees");
angleText.setLocalTranslation(new Vector3f().interpolateLocal(point1, point2, 0.5f));
if (line.getParent() == null) {
parent.attachChild(line);
parent.attachChild(angleText);
}
((Line) line.getMesh()).updatePoints(point1, point2);
}
示例3: set
void set(Spatial item) {
isActive = item.getControl(MyRigidBodyControl.class).isActive();
final Transform trans = item.getWorldTransform();
trans.getTranslation(location);
trans.getRotation().toAngles(angles);
// location: transform to user coordinate system
float tmp = location.y;
location.y = -location.z;
location.z = tmp;
// rotation
tmp = angles[1];
angles[1] = -angles[2];
angles[2] = tmp;
angles[0] *= FastMath.RAD_TO_DEG;
angles[1] *= FastMath.RAD_TO_DEG;
angles[2] *= FastMath.RAD_TO_DEG;
}
示例4: updateAngle
private void updateAngle() {
Vector3f temp, higher, lower;
Vector3f point2 = p2.getTarget().getWorldTranslation();
Vector3f point1 = p1.getTarget().getWorldTranslation();
if (point2.y > point1.y) {
temp = point2;
higher = point2;
lower = point1;
} else {
temp = point1;
higher = point1;
lower = point2;
}
temp = temp.clone().setY(lower.y);
float angle = ((FastMath.asin(temp.distance(higher) / lower.distance(higher))) * FastMath.RAD_TO_DEG);
angleText.setText(angle + "");
angleText.setLocalTranslation(new Vector3f().interpolateLocal(point1, point2, 0.5f));
if (line.getParent() == null) {
edit.getEditRoot().attachChild(line);
edit.getEditRoot().attachChild(angleText);
}
((Line) line.getMesh()).updatePoints(point1, point2);
}
示例5: controlUpdate
@Override
protected void controlUpdate(final float tpf) {
// check rotation
final float rotation = spatial.getWorldRotation().toAngles(null)[1] * FastMath.RAD_TO_DEG;
final float dist = FastMath.abs(direction.getAngle() - rotation);
if (dist > 10f) {
spatial.rotate(0f, direction.getRotation() * tpf * 15f, 0f);
} else {
spatial.lookAt(spatial.getWorldTranslation().add(0f, 0f, direction.getRotation()), Vector3f.UNIT_Y);
}
// get sprite and its control
final AnimatedSprite animatedSprite = (AnimatedSprite) ((Node) spatial).getChild(0);
final AnimatedSpriteControl animatedSpriteControl = animatedSprite.getControl(AnimatedSpriteControl.class);
// handle 'halt'
if (!up && !down && !right && !left) {
animatedSpriteControl.setAnimation("idle");
return;
}
// handle 'walk'
animatedSpriteControl.setAnimation("walk");
final Vector3f move = new Vector3f();
if (up) {
move.z = -1;
}
if (down) {
move.z = 1;
}
if (right) {
move.x = 1;
}
if (left) {
move.x = -1;
}
if (!move.equals(Vector3f.ZERO)) {
spatial.move(move.mult(tpf * 20f));
}
}
示例6: getRotationFromVelocity
private float getRotationFromVelocity(Vector2f velocity) {
tempV2a.set(velocity).normalizeLocal();
float angle = FastMath.atan2(tempV2a.y, tempV2a.x)*FastMath.RAD_TO_DEG;
angle += 90;
return angle;
}
示例7: updateHandInfo
private void updateHandInfo() {
if (demonstrator == null) {
return;
}
Demonstrator.Hand hand = demonstrator.getCurrHand();
if (hand.isIdle()) {
lbGrasped.setText("<empty>");
btRelease.disable();
btDestroy.disable();
btPlaneRotL.disable();
btPlaneRotR.disable();
for (int i = 0; i < sbObjRot.length; ++i) {
sbObjRot[i].disable();
sbObjRot[i].setValue(180);
lbObjAngles[i].setText("0");
}
} else {
lbGrasped.setText(hand.getGraspedItemName());
btRelease.enable();
btDestroy.enable();
btPlaneRotL.enable();
btPlaneRotR.enable();
float[] userRotAngles = hand.getUserRotAngles();
float tmp = userRotAngles[2];
userRotAngles[2] = userRotAngles[1];
userRotAngles[1] = -tmp;
for (int i = 0; i < sbObjRot.length; ++i) {
userRotAngles[i] *= FastMath.RAD_TO_DEG;
int angleRounded = Math.round(userRotAngles[i]);
sbObjRot[i].disable();
sbObjRot[i].setValue(180 + angleRounded);
lbObjAngles[i].setText("" + angleRounded);
sbObjRot[i].enable();
}
}
}
示例8: doUpdateAnimation
@Override
protected void doUpdateAnimation(String animation, boolean loop
, float animFullTime, float animStartTime) {
shotDir = 1; // horizontal
// 目標角色
Entity target = getTarget();
if ((this.animationShotDown != null || this.animationShotUp != null) && target != null) {
TempVars tv = TempVars.get();
Vector3f viewPos = tv.vect1;
Vector3f targetPos = target.getSpatial().getWorldBound().getCenter();
Vector3f selfPos = actor.getSpatial().getWorldBound().getCenter();
viewPos.set(targetPos).setY(selfPos.getY());
Vector3f vec1 = tv.vect2;
Vector3f vec2 = tv.vect3;
targetPos.subtract(selfPos, vec1).normalizeLocal();
viewPos.subtract(selfPos, vec2).normalizeLocal();
float angle = vec1.angleBetween(vec2) * FastMath.RAD_TO_DEG;
boolean up = targetPos.y > viewPos.y;
tv.release();
if (angle > 15) {
if (up && animationShotUp != null) {
animation = animationShotUp;
shotDir = 2;
} else if (animationShotDown != null) {
animation = animationShotDown;
shotDir = 0;
}
}
}
super.doUpdateAnimation(animation, loop, animFullTime, animStartTime);
}
示例9: getInner
@Property(weight = 110, hint = Property.Hint.ANGLE)
public float getInner() {
return getLight().getSpotInnerAngle() * FastMath.RAD_TO_DEG;
}
示例10: getOuter
@Property(weight = 120, hint = Property.Hint.ANGLE)
public float getOuter() {
return getLight().getSpotOuterAngle() * FastMath.RAD_TO_DEG;
}
示例11: getRotationBetween
private float getRotationBetween(Vector2f v1, Vector2f v2) {
float deltaY = v2.y - v1.y;
float deltaX = v2.x - v1.x;
return FastMath.atan2(deltaY,deltaX) * FastMath.RAD_TO_DEG;
}
示例12: onSbObjRotChanged
@NiftyEventSubscriber(pattern="sbObjRot(X|Y|Z)")
public void onSbObjRotChanged(String id, ScrollbarChangedEvent e) {
if (!e.getScrollbar().isEnabled()) {
return;
}
int ind = -1;
for (int i = 0; i < sbObjRot.length; ++i) {
if (e.getScrollbar() == sbObjRot[i]) {
ind = i;
break;
}
}
if (ind < 0) {
return;
}
int angle = Math.round(e.getValue() - 180);
int prevAngle = Integer.parseInt(lbObjAngles[ind].getText());
if (FastMath.abs(angle - prevAngle) < 46) {
int axisInd = -1;
if (ind == 0) {
axisInd = 0;
} else if (ind == 1) {
axisInd = 2;
angle = -angle;
} else if (ind == 2) {
axisInd = 1;
}
float newAngle = demonstrator.rotate(axisInd, angle * FastMath.DEG_TO_RAD);
newAngle *= FastMath.RAD_TO_DEG;
if (axisInd == 2) {
newAngle = -newAngle;
}
int newAngleRounded = Math.round(newAngle);
e.getScrollbar().disable();
e.getScrollbar().setValue(180 + newAngleRounded);
e.getScrollbar().enable();
lbObjAngles[ind].setText("" + newAngleRounded);
} else {
// ignore huge-angle rotations
e.getScrollbar().disable();
e.getScrollbar().setValue(180 + prevAngle);
e.getScrollbar().enable();
}
}