com.jme3.math.Quaternion.toAngles()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(79)

本文整理了Java中com.jme3.math.Quaternion.toAngles方法的一些代码示例,展示了Quaternion.toAngles的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Quaternion.toAngles方法的具体详情如下:
包路径:com.jme3.math.Quaternion
类名称:Quaternion
方法名:toAngles

Quaternion.toAngles介绍

[英]toAngles returns this quaternion converted to Euler rotation angles (x,y,z) aka (pitch, yaw, roll).
Note that the result is not always 100% accurate due to the implications of euler angles.
[中]toAngles返回转换为欧拉旋转角度(x、y、z)的四元数(俯仰、偏航、滚动)。
请注意,由于欧拉角的影响,结果并非总是100%准确。

代码示例

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

void set(Quaternion rot) {
  rotation.set(rot);
  float[] a = new float[3];
  rotation.toAngles(a);
  eulerAngles.set(a[0], a[1], a[2]);
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

public void setWorldBindPose(Matrix4f worldBindPose) {
  if (cachedWorldBindPose != null) {
    if (!cachedWorldBindPose.equals(worldBindPose)) {
      throw new UnsupportedOperationException("Bind poses don't match");
    }
  }
  
  cachedWorldBindPose = worldBindPose;
  
  this.jmeWorldBindPose = new Transform();
  this.jmeWorldBindPose.setTranslation(worldBindPose.toTranslationVector());
  this.jmeWorldBindPose.setRotation(worldBindPose.toRotationQuat());
  this.jmeWorldBindPose.setScale(worldBindPose.toScaleVector());
  
  System.out.println("\tBind Pose for " + getName());
  System.out.println(jmeWorldBindPose);
  
  float[] angles = new float[3];
  jmeWorldBindPose.getRotation().toAngles(angles);
  System.out.println("Angles: " + angles[0] * FastMath.RAD_TO_DEG + ", " + 
                  angles[1] * FastMath.RAD_TO_DEG + ", " + 
                  angles[2] * FastMath.RAD_TO_DEG);
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

ownerAngles = ownerRotation.toAngles(ownerAngles);
targetAngles = targetTransform.getRotation().toAngles(targetAngles);

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

ownerTransform.getRotation().toAngles(angles);

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

Quaternion q = new Quaternion();
float[] angles = new float[3];
model.getLocalRotation().toAngles(angles);
q.fromAngleAxis(angles[1], Vector3f.UNIT_Y);
model.setLocalRotation(q);

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

Quaternion[] rotations = new Quaternion[framesAmount + 1];
float[] quaternionRotation = new float[] { localRotation.getX(), localRotation.getY(), localRotation.getZ(), localRotation.getW(), };
float[] eulerRotation = localRotation.toAngles(null);
Vector3f[] scales = new Vector3f[framesAmount + 1];
float[] scale = new float[] { localScale.x, localScale.y, localScale.z };

代码示例来源:origin: net.sf.phat/phat-devices

private void printAngles(Quaternion q) {
  q.toAngles(angles);
  System.out.println(
      "x=" + Math.round(FastMath.RAD_TO_DEG * angles[0])
      + "; y=" + Math.round(FastMath.RAD_TO_DEG * angles[1])
      + "; z=" + Math.round(FastMath.RAD_TO_DEG * angles[2]));
}
Vector3f gravity = new Vector3f();

代码示例来源:origin: net.sf.phat/phat-core

public static void angularSpeed(Quaternion q1, Quaternion q2, float dt, Vector3f angularSpeed) {
    TempVars tempVars = TempVars.get();
    float[] angles1 = tempVars.fWdU;
    float[] angles2 = tempVars.fAWdU;
    
    q1.toAngles(angles1);
    q2.toAngles(angles2);
    
    angularSpeed.set(
        (angles2[0]-angles1[0]) / dt, 
        (angles2[1]-angles1[1]) / dt,
        (angles2[2]-angles1[2]) / dt);
    tempVars.release();
  }
}

代码示例来源:origin: org.jmonkeyengine/jme3-core

void set(Quaternion rot) {
  rotation.set(rot);
  float[] a = new float[3];
  rotation.toAngles(a);
  eulerAngles.set(a[0], a[1], a[2]);
}

代码示例来源:origin: info.projectkyoto/mms-engine

void set(Quaternion rot) {
  rotation.set(rot);
  float[] a = new float[3];
  rotation.toAngles(a);
  eulerAngles.set(a[0], a[1], a[2]);
}

代码示例来源:origin: org.jmonkeyengine/jme3-plugins

public void setWorldBindPose(Matrix4f worldBindPose) {
  if (cachedWorldBindPose != null) {
    if (!cachedWorldBindPose.equals(worldBindPose)) {
      throw new UnsupportedOperationException("Bind poses don't match");
    }
  }
  
  cachedWorldBindPose = worldBindPose;
  
  this.jmeWorldBindPose = new Transform();
  this.jmeWorldBindPose.setTranslation(worldBindPose.toTranslationVector());
  this.jmeWorldBindPose.setRotation(worldBindPose.toRotationQuat());
  this.jmeWorldBindPose.setScale(worldBindPose.toScaleVector());
  
  System.out.println("\tBind Pose for " + getName());
  System.out.println(jmeWorldBindPose);
  
  float[] angles = new float[3];
  jmeWorldBindPose.getRotation().toAngles(angles);
  System.out.println("Angles: " + angles[0] * FastMath.RAD_TO_DEG + ", " + 
                  angles[1] * FastMath.RAD_TO_DEG + ", " + 
                  angles[2] * FastMath.RAD_TO_DEG);
}

代码示例来源:origin: net.sf.phat/phat-core

@Override
protected void controlUpdate(float tpf) {
  if (stateChanged) {
    spatial.getLocalRotation().toAngles(angles);
    float rot = tpf * angularSpeed;
    if (state.equals(FridgeDoorControl.STATE.CLOSED)) {
      angles[2] -= rot;
      if (angles[2] < 0f) {
        angles[2] = 0f;
        stateChanged = false;
      }
      spatial.setLocalRotation(new Quaternion(angles));
    } else if (state.equals(FridgeDoorControl.STATE.OPENED)) {
      angles[2] += rot;
      if (angles[2] > openingAngle) {
        angles[2] = openingAngle;
        stateChanged = false;
      }
      spatial.setLocalRotation(new Quaternion(angles));
    }
  }
}
float[] angles = new float[3];

代码示例来源:origin: net.sf.phat/phat-core

private void updateLocation(Spatial spatial) {
  if(head == null) {
    head = spatial.getParent().getParent().getChild("male/head/middle_aged");
  }
  loc.set(spatial.getParent().getWorldTranslation());
  center.set(SpatialUtils.getCenterBoinding(head));
  //System.out.println("Human Loc = "+loc+", head Loc = "+center);
  center.subtractLocal(loc);
  center.addLocal(offset);
  spatial.setLocalTranslation(center);
  
  rotation.set(spatial.getParent().getParent().getLocalRotation());
  rotation.toAngles(angles);
  angles[0] *= -1;
  angles[1] *= -1;
  angles[2] *= -1;
  rotation.fromAngles(angles);        
  
  spatial.getParent().setLocalRotation(rotation);
}

代码示例来源:origin: org.cogchar/org.cogchar.lib.render.hominoid

public void makeSinbadStandUp() { 
  Vector3f v = new Vector3f();
  Node sceneNode = getFigureNode();
  HumanoidFigureConfig hfc = getFigureConfig();
  v.set(sceneNode.getLocalTranslation());
  v.y = hfc.getInitY();
  sceneNode.setLocalTranslation(v);
  Quaternion q = new Quaternion();
  float[] angles = new float[3];
  sceneNode.getLocalRotation().toAngles(angles);
  q.fromAngleAxis(angles[1], Vector3f.UNIT_Y);
  sceneNode.setLocalRotation(q);
  AnimChannel animChan = getFigureAnimChannel();
  HumanoidRagdollControl ragdollControl = getRagdollControl();

  if (angles[0] < 0) {
    animChan.setAnim(ANIM_STAND_BACK);
    ragdollControl.blendToKinematicMode(DEFAULT_ANIM_BLEND_RATE);
  } else {
    animChan.setAnim(ANIM_STAND_FRONT);
    ragdollControl.blendToKinematicMode(DEFAULT_ANIM_BLEND_RATE);
  }
}
public void runSinbadBoogieAnim() {

代码示例来源:origin: info.projectkyoto/mms-engine

rot.toAngles(buf);
float x = buf[0];
Quaternion currentRot = currentBone.getLocalRotation();
currentRot.toAngles(buf);
float x2 = buf[0];
if (x2 + x > FastMath.PI) {

代码示例来源:origin: info.projectkyoto/mms-engine

hizaBone.getLocalRotation().toAngles(buf);
hizaBone.getLocalRotation().fromAngles(0f, buf[1], buf[2]);
updateWorldVectors(hizaBone);

相关文章