com.jme3.scene.Spatial.getLocalRotation()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(12.2k)|赞(0)|评价(0)|浏览(137)

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

Spatial.getLocalRotation介绍

[英]getLocalRotation retrieves the local rotation of this node.
[中]getLocalRotation检索此节点的本地旋转。

代码示例

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

/**
 * Access whichever spatial rotation corresponds to the physics rotation.
 *
 * @return the pre-existing quaternion (in physics-space coordinates, not
 * null)
 */
protected Quaternion getSpatialRotation() {
  if (applyLocal) {
    return spatial.getLocalRotation();
  }
  return spatial.getWorldRotation();
}

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

/**
 * Access whichever spatial rotation corresponds to the physics rotation.
 *
 * @return the pre-existing quaternion (not null)
 */
private Quaternion getSpatialRotation() {
  if (applyLocal) {
    return spatial.getLocalRotation();
  }
  return spatial.getWorldRotation();
}

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

/**
 * Access whichever spatial rotation corresponds to the physics rotation.
 *
 * @return the pre-existing quaternion (not null)
 */
private Quaternion getSpatialRotation() {
  if (applyLocal) {
    return spatial.getLocalRotation();
  }
  return spatial.getWorldRotation();
}

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

/**
 * Access whichever spatial rotation corresponds to the physics rotation.
 *
 * @return the pre-existing quaternion (in physics-space coordinates, not
 * null)
 */
protected Quaternion getSpatialRotation() {
  if (applyLocal) {
    return spatial.getLocalRotation();
  }
  return spatial.getWorldRotation();
}

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

/**
 * Access whichever spatial rotation corresponds to the physics rotation.
 *
 * @return the pre-existing quaternion (not null)
 */
private Quaternion getSpatialRotation(){
  if(motionState.isApplyPhysicsLocal()){
    return spatial.getLocalRotation();
  }
  return spatial.getWorldRotation();
}

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

private Quaternion getSpatialRotation(){
  if(motionState.isApplyPhysicsLocal()){
    return spatial.getLocalRotation();
  }
  return spatial.getWorldRotation();
}

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

/**
 * Access whichever spatial rotation corresponds to the physics rotation.
 *
 * @return the pre-existing quaternion (not null)
 */
private Quaternion getSpatialRotation(){
  if(motionState.isApplyPhysicsLocal()){
    return spatial.getLocalRotation();
  }
  return spatial.getWorldRotation();
}

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

private Quaternion getSpatialRotation(){
  if(motionState.isApplyPhysicsLocal()){
    return spatial.getLocalRotation();
  }
  return spatial.getWorldRotation();
}

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

getLocalRotation().lookAt(compVecA, upVector);
if ( getParent() != null ) {
  Quaternion rot=vars.quat1;
  rot =  rot.set(parent.getWorldRotation()).inverseLocal().multLocal(getLocalRotation());
  rot.normalizeLocal();
  setLocalRotation(rot);

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

Quaternion initRotation = model.getLocalRotation().clone();
initScale = model.getLocalScale().clone();

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

@Override
protected void controlUpdate(float tpf) {
  if (spatial != null && camera != null) {
    switch (controlDir) {
      case SpatialToCamera:
        camera.setLocation(spatial.getWorldTranslation());
        camera.setRotation(spatial.getWorldRotation());
        break;
      case CameraToSpatial:
        // set the localtransform, so that the worldtransform would be equal to the camera's transform.
        // Location:
        TempVars vars = TempVars.get();
        Vector3f vecDiff = vars.vect1.set(camera.getLocation()).subtractLocal(spatial.getWorldTranslation());
        spatial.setLocalTranslation(vecDiff.addLocal(spatial.getLocalTranslation()));
        // Rotation:
        Quaternion worldDiff = vars.quat1.set(camera.getRotation()).subtractLocal(spatial.getWorldRotation());
        spatial.setLocalRotation(worldDiff.addLocal(spatial.getLocalRotation()));
        vars.release();
        break;
    }
  }
}

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

public void update(float tpf) {
  if (enabled && spatial != null) {
    Quaternion localRotationQuat = spatial.getLocalRotation();
    Vector3f localLocation = spatial.getLocalTranslation();
    if (!applyLocal && spatial.getParent() != null) {
      getPhysicsLocation(localLocation);
      localLocation.subtractLocal(spatial.getParent().getWorldTranslation());
      localLocation.divideLocal(spatial.getParent().getWorldScale());
      tmp_inverseWorldRotation.set(spatial.getParent().getWorldRotation()).inverseLocal().multLocal(localLocation);
      spatial.setLocalTranslation(localLocation);
      if (useViewDirection) {
        localRotationQuat.lookAt(viewDirection, Vector3f.UNIT_Y);
        spatial.setLocalRotation(localRotationQuat);
      }
    } else {
      spatial.setLocalTranslation(getPhysicsLocation());
      localRotationQuat.lookAt(viewDirection, Vector3f.UNIT_Y);
      spatial.setLocalRotation(localRotationQuat);
    }
  }
}

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

public void update(float tpf) {
  if (enabled && spatial != null) {
    Quaternion localRotationQuat = spatial.getLocalRotation();
    Vector3f localLocation = spatial.getLocalTranslation();
    if (!applyLocal && spatial.getParent() != null) {
      getPhysicsLocation(localLocation);
      localLocation.subtractLocal(spatial.getParent().getWorldTranslation());
      localLocation.divideLocal(spatial.getParent().getWorldScale());
      tmp_inverseWorldRotation.set(spatial.getParent().getWorldRotation()).inverseLocal().multLocal(localLocation);
      spatial.setLocalTranslation(localLocation);
      if (useViewDirection) {
        localRotationQuat.lookAt(viewDirection, Vector3f.UNIT_Y);
        spatial.setLocalRotation(localRotationQuat);
      }
    } else {
      spatial.setLocalTranslation(getPhysicsLocation());
      localRotationQuat.lookAt(viewDirection, Vector3f.UNIT_Y);
      spatial.setLocalRotation(localRotationQuat);
    }
  }
}

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

public void applyWheelTransform() {
  if (wheelSpatial == null) {
    return;
  }
  Quaternion localRotationQuat = wheelSpatial.getLocalRotation();
  Vector3f localLocation = wheelSpatial.getLocalTranslation();
  if (!applyLocal && wheelSpatial.getParent() != null) {
    localLocation.set(wheelWorldLocation).subtractLocal(wheelSpatial.getParent().getWorldTranslation());
    localLocation.divideLocal(wheelSpatial.getParent().getWorldScale());
    tmp_inverseWorldRotation.set(wheelSpatial.getParent().getWorldRotation()).inverseLocal().multLocal(localLocation);
    localRotationQuat.set(wheelWorldRotation);
    tmp_inverseWorldRotation.set(wheelSpatial.getParent().getWorldRotation()).inverseLocal().mult(localRotationQuat, localRotationQuat);
    wheelSpatial.setLocalTranslation(localLocation);
    wheelSpatial.setLocalRotation(localRotationQuat);
  } else {
    wheelSpatial.setLocalTranslation(wheelWorldLocation);
    wheelSpatial.setLocalRotation(wheelWorldRotation);
  }
}

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

Quaternion localRotationQuat = spatial.getLocalRotation();
boolean physicsLocationDirty = applyTransform(motionStateId, localLocation, localRotationQuat);
if (!physicsLocationDirty) {

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

/**
 * Apply this wheel's physics location and orientation to its associated
 * spatial, if any.
 */
public void applyWheelTransform() {
  if (wheelSpatial == null) {
    return;
  }
  Quaternion localRotationQuat = wheelSpatial.getLocalRotation();
  Vector3f localLocation = wheelSpatial.getLocalTranslation();
  if (!applyLocal && wheelSpatial.getParent() != null) {
    localLocation.set(wheelWorldLocation).subtractLocal(wheelSpatial.getParent().getWorldTranslation());
    localLocation.divideLocal(wheelSpatial.getParent().getWorldScale());
    tmp_inverseWorldRotation.set(wheelSpatial.getParent().getWorldRotation()).inverseLocal().multLocal(localLocation);
    localRotationQuat.set(wheelWorldRotation);
    tmp_inverseWorldRotation.set(wheelSpatial.getParent().getWorldRotation()).inverseLocal().mult(localRotationQuat, localRotationQuat);
    wheelSpatial.setLocalTranslation(localLocation);
    wheelSpatial.setLocalRotation(localRotationQuat);
  } else {
    wheelSpatial.setLocalTranslation(wheelWorldLocation);
    wheelSpatial.setLocalRotation(wheelWorldRotation);
  }
}

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

/**
 * Apply a physics transform to the spatial.
 *
 * @param worldLocation location vector (in physics-space coordinates, not
 * null, unaffected)
 * @param worldRotation orientation (in physics-space coordinates, not null,
 * unaffected)
 */
protected void applyPhysicsTransform(Vector3f worldLocation, Quaternion worldRotation) {
  if (enabled && spatial != null) {
    Vector3f localLocation = spatial.getLocalTranslation();
    Quaternion localRotationQuat = spatial.getLocalRotation();
    if (!applyLocal && spatial.getParent() != null) {
      localLocation.set(worldLocation).subtractLocal(spatial.getParent().getWorldTranslation());
      localLocation.divideLocal(spatial.getParent().getWorldScale());
      tmp_inverseWorldRotation.set(spatial.getParent().getWorldRotation()).inverseLocal().multLocal(localLocation);
      localRotationQuat.set(worldRotation);
      tmp_inverseWorldRotation.set(spatial.getParent().getWorldRotation()).inverseLocal().mult(localRotationQuat, localRotationQuat);
      spatial.setLocalTranslation(localLocation);
      spatial.setLocalRotation(localRotationQuat);
    } else {
      spatial.setLocalTranslation(worldLocation);
      spatial.setLocalRotation(worldRotation);
    }
  }
}

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

/**
   * Apply the specified location and orientation to the specified spatial.
   *
   * @param worldLocation location vector (in physics-space coordinates, not
   * null, unaffected)
   * @param worldRotation orientation (in physics-space coordinates, not null,
   * unaffected)
   * @param spatial where to apply (may be null)
   */
  protected void applyPhysicsTransform(Vector3f worldLocation, Quaternion worldRotation, Spatial spatial) {
    if (spatial != null) {
      Vector3f localLocation = spatial.getLocalTranslation();
      Quaternion localRotationQuat = spatial.getLocalRotation();
      if (spatial.getParent() != null) {
        localLocation.set(worldLocation).subtractLocal(spatial.getParent().getWorldTranslation());
        localLocation.divideLocal(spatial.getParent().getWorldScale());
        tmp_inverseWorldRotation.set(spatial.getParent().getWorldRotation()).inverseLocal().multLocal(localLocation);
        localRotationQuat.set(worldRotation);
        tmp_inverseWorldRotation.set(spatial.getParent().getWorldRotation()).inverseLocal().mult(localRotationQuat, localRotationQuat);
        spatial.setLocalTranslation(localLocation);
        spatial.setLocalRotation(localRotationQuat);
      } else {
        spatial.setLocalTranslation(worldLocation);
        spatial.setLocalRotation(worldRotation);
      }
    }

  }
}

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

/**
 * Apply a physics transform to the spatial.
 *
 * @param worldLocation location vector (in physics-space coordinates, not
 * null, unaffected)
 * @param worldRotation orientation (in physics-space coordinates, not null,
 * unaffected)
 */
protected void applyPhysicsTransform(Vector3f worldLocation, Quaternion worldRotation) {
  if (enabled && spatial != null) {
    Vector3f localLocation = spatial.getLocalTranslation();
    Quaternion localRotationQuat = spatial.getLocalRotation();
    if (!applyLocal && spatial.getParent() != null) {
      localLocation.set(worldLocation).subtractLocal(spatial.getParent().getWorldTranslation());
      localLocation.divideLocal(spatial.getParent().getWorldScale());
      tmp_inverseWorldRotation.set(spatial.getParent().getWorldRotation()).inverseLocal().multLocal(localLocation);
      localRotationQuat.set(worldRotation);
      tmp_inverseWorldRotation.set(spatial.getParent().getWorldRotation()).inverseLocal().mult(localRotationQuat, localRotationQuat);
      spatial.setLocalTranslation(localLocation);
      spatial.setLocalRotation(localRotationQuat);
    } else {
      spatial.setLocalTranslation(worldLocation);
      spatial.setLocalRotation(worldRotation);
    }
  }
}

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

/**
   * Apply the specified location and orientation to the specified spatial.
   *
   * @param worldLocation location vector (in physics-space coordinates, not
   * null, unaffected)
   * @param worldRotation orientation (in physics-space coordinates, not null,
   * unaffected)
   * @param spatial where to apply (may be null)
   */
  protected void applyPhysicsTransform(Vector3f worldLocation, Quaternion worldRotation, Spatial spatial) {
    if (spatial != null) {
      Vector3f localLocation = spatial.getLocalTranslation();
      Quaternion localRotationQuat = spatial.getLocalRotation();
      if (spatial.getParent() != null) {
        localLocation.set(worldLocation).subtractLocal(spatial.getParent().getWorldTranslation());
        localLocation.divideLocal(spatial.getParent().getWorldScale());
        tmp_inverseWorldRotation.set(spatial.getParent().getWorldRotation()).inverseLocal().multLocal(localLocation);
        localRotationQuat.set(worldRotation);
        tmp_inverseWorldRotation.set(spatial.getParent().getWorldRotation()).inverseLocal().mult(localRotationQuat, localRotationQuat);
        spatial.setLocalTranslation(localLocation);
        spatial.setLocalRotation(localRotationQuat);
      } else {
        spatial.setLocalTranslation(worldLocation);
        spatial.setLocalRotation(worldRotation);
      }
    }

  }
}

相关文章

Spatial类方法