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

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

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

Quaternion.getZ介绍

暂无

代码示例

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

/**
 * Sets the data contained in the given quaternion into the FloatBuffer at
 * the specified index.
 * 
 * @param quat
 *            the {@link Quaternion} to insert
 * @param buf
 *            the buffer to insert into
 * @param index
 *            the position to place the data; in terms of quaternions not
 *            floats
 */
public static void setInBuffer(Quaternion quat, FloatBuffer buf, int index) {
  buf.position(index * 4);
  buf.put(quat.getX());
  buf.put(quat.getY());
  buf.put(quat.getZ());
  buf.put(quat.getW());
}

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

public static void dumpArray(Object[] array) {
  if (array == null) {
    System.err.println("null");
    return;
  }
  for (int i = 0; i < array.length; i++) {
    Object o = array[i];
    System.err.print(i + ": ");
    if (o instanceof Quaternion) {
      Quaternion q = (Quaternion) o;
      System.err.print("(");
      if (q.getX() > 0.00001) System.err.print(q.getX() + ", ");
      else System.err.print("0.0, ");
      if (q.getY() > 0.00001) System.err.print(q.getY() + ", ");
      else System.err.print("0.0, ");
      if (q.getZ() > 0.00001) System.err.print(q.getZ() + ", ");
      else System.err.print("0.0, ");
      if (q.getW() > 0.00001) System.err.print(q.getW() + ", ");
      else System.err.print("0.0, ");
      System.err.println(")");
    } else {
      System.err.println(o.toString() + ", ");
    }
  }
  System.err.println("");
}

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

@Override
public void setArg(int index, Quaternion q) {
  FloatBuffer buf = Utils.tempBuffers[0].b16f;
  buf.position(0);
  buf.limit(4);
  buf.put(0, q.getX());
  buf.put(1, q.getY());
  buf.put(2, q.getZ());
  buf.put(3, q.getW());
  int ret = CL10.clSetKernelArg(kernel, index, buf);
  Utils.checkError(ret, "clSetKernelArg");
}

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

/**
 * Generate a new FloatBuffer using the given array of Quaternion objects.
 * The FloatBuffer will be 4 * data.length long and contain the vector data.
 * 
 * @param data
 *            array of Quaternion objects to place into a new FloatBuffer
 */
public static FloatBuffer createFloatBuffer(Quaternion... data) {
  if (data == null) {
    return null;
  }
  FloatBuffer buff = createFloatBuffer(4 * data.length);
  for (Quaternion element : data) {
    if (element != null) {
      buff.put(element.getX()).put(element.getY()).put(element.getZ()).put(element.getW());
    } else {
      buff.put(0).put(0).put(0).put(0);
    }
  }
  buff.flip();
  return buff;
}

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

@Override
public void setArg(int index, Quaternion q) {
  FloatBuffer buf = Utils.tempBuffers[0].b16f;
  buf.position(0);
  buf.limit(4);
  buf.put(0, q.getX());
  buf.put(1, q.getY());
  buf.put(2, q.getZ());
  buf.put(3, q.getW());
  int ret = cl.clSetKernelArg(kernel, index, 16, buf);
  Utils.checkError(ret, "clSetKernelArg");
}

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

public static javax.vecmath.Quat4f convert(com.jme3.math.Quaternion oldQuat, javax.vecmath.Quat4f newQuat) {
  newQuat.w = oldQuat.getW();
  newQuat.x = oldQuat.getX();
  newQuat.y = oldQuat.getY();
  newQuat.z = oldQuat.getZ();
  return newQuat;
}

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

public DQuaternion(Quaternion q) {
  this(q.getX(), q.getY(), q.getZ(), q.getW());
}

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

/**
 * Writes the value to the data buffer.
 *
 * @param data  the data buffer.
 * @param value the value.
 */
protected void writeVec4(final ByteBuffer data, final Object value) {
  if (value == null) {
    data.putLong(0).putLong(0);
  } else if (value instanceof Vector4f) {
    final Vector4f vec4 = (Vector4f) value;
    data.putFloat(vec4.getX())
        .putFloat(vec4.getY())
        .putFloat(vec4.getZ())
        .putFloat(vec4.getW());
  } else if(value instanceof Quaternion) {
    final Quaternion vec4 = (Quaternion) value;
    data.putFloat(vec4.getX())
        .putFloat(vec4.getY())
        .putFloat(vec4.getZ())
        .putFloat(vec4.getW());
  } else if(value instanceof ColorRGBA) {
    final ColorRGBA vec4 = (ColorRGBA) value;
    data.putFloat(vec4.getRed())
        .putFloat(vec4.getGreen())
        .putFloat(vec4.getBlue())
        .putFloat(vec4.getAlpha());
  }
}

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

public void onAction(String name, boolean value, float tpf) {
    if (!value) {
      return;
    }
    if (name.equals(INPUT_MAPPING_CAMERA_POS)) {
      Camera cam = app.getCamera();
      if (cam != null) {
        Vector3f loc = cam.getLocation();
        Quaternion rot = cam.getRotation();
        System.out.println("Camera Position: ("
            + loc.x + ", " + loc.y + ", " + loc.z + ")");
        System.out.println("Camera Rotation: " + rot);
        System.out.println("Camera Direction: " + cam.getDirection());
        System.out.println("cam.setLocation(new Vector3f("
            + loc.x + "f, " + loc.y + "f, " + loc.z + "f));");
        System.out.println("cam.setRotation(new Quaternion(" + rot.getX() + "f, " +rot.getY()+ "f, " + rot.getZ() + "f, " + rot.getW() + "f));");
       
      }
    } else if (name.equals(INPUT_MAPPING_MEMORY)) {
      BufferUtils.printCurrentDirectMemory(null);
    }
  }
}

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

@Override
protected void serialize(int i, Quaternion store) {
  int j = i * getTupleSize();
  array[j] = store.getX();
  array[j + 1] = store.getY();
  array[j + 2] = store.getZ();
  array[j + 3] = store.getW();
}

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

public static void convertMatrix4toQuat(Matrix4f in, Quaternion out) {
  // convert rotation matrix to quat
  out.fromRotationMatrix(in.m00, in.m01, in.m02, in.m10, in.m11, in.m12, in.m20, in.m21, in.m22);
  // flip the pitch
  out.set(-out.getX(), out.getY(), -out.getZ(), out.getW());
}

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

@Override
public void setArg(int index, Quaternion q) {
  int ret = CL10.clSetKernelArg4f(kernel, index, q.getX(), q.getY(), q.getZ(), q.getW());
  Utils.checkError(ret, "clSetKernelArg");
}

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

public static boolean equalsEpsilon(Quaternion q1, Quaternion q2) {
  return (FastMath.abs(q1.getX() - q2.getX()) < epsilon
      && FastMath.abs(q1.getY() - q2.getY()) < epsilon
      && FastMath.abs(q1.getZ() - q2.getZ()) < epsilon
      && FastMath.abs(q1.getW() - q2.getW()) < epsilon)
      ||
      (FastMath.abs(q1.getX() + q2.getX()) < epsilon
          && FastMath.abs(q1.getY() + q2.getY()) < epsilon
          && FastMath.abs(q1.getZ() + q2.getZ()) < epsilon
          && FastMath.abs(q1.getW() + q2.getW()) < epsilon);
}

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

public static javax.vecmath.Matrix3f convert(com.jme3.math.Quaternion oldQuaternion, javax.vecmath.Matrix3f newMatrix) {
  float norm = oldQuaternion.getW() * oldQuaternion.getW() + oldQuaternion.getX() * oldQuaternion.getX() + oldQuaternion.getY() * oldQuaternion.getY() + oldQuaternion.getZ() * oldQuaternion.getZ();
  float s = (norm == 1f) ? 2f : (norm > 0f) ? 2f / norm : 0;
  // compute xs/ys/zs first to save 6 multiplications, since xs/ys/zs
  // will be used 2-4 times each.
  float xs = oldQuaternion.getX() * s;
  float ys = oldQuaternion.getY() * s;
  float zs = oldQuaternion.getZ() * s;
  float xx = oldQuaternion.getX() * xs;
  float xy = oldQuaternion.getX() * ys;
  float xz = oldQuaternion.getX() * zs;
  float xw = oldQuaternion.getW() * xs;
  float yy = oldQuaternion.getY() * ys;
  float yz = oldQuaternion.getY() * zs;
  float yw = oldQuaternion.getW() * ys;
  float zz = oldQuaternion.getZ() * zs;
  float zw = oldQuaternion.getW() * zs;
  // using s=2/norm (instead of 1/norm) saves 9 multiplications by 2 here
  newMatrix.m00 = 1 - (yy + zz);
  newMatrix.m01 = (xy - zw);
  newMatrix.m02 = (xz + yw);
  newMatrix.m10 = (xy + zw);
  newMatrix.m11 = 1 - (xx + zz);
  newMatrix.m12 = (yz - xw);
  newMatrix.m20 = (xz - yw);
  newMatrix.m21 = (yz + xw);
  newMatrix.m22 = 1 - (xx + yy);
  return newMatrix;
}

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

private void updateInstance(Matrix4f worldMatrix, float[] store,
              int offset, Matrix3f tempMat3,
              Quaternion tempQuat) {
  worldMatrix.toRotationMatrix(tempMat3);
  tempMat3.invertLocal();
  // NOTE: No need to take the transpose in order to encode
  // into quaternion, the multiplication in the shader is vec * quat
  // apparently...
  tempQuat.fromRotationMatrix(tempMat3);
  // Column-major encoding. The "W" field in each of the encoded
  // vectors represents the quaternion.
  store[offset + 0] = worldMatrix.m00;
  store[offset + 1] = worldMatrix.m10;
  store[offset + 2] = worldMatrix.m20;
  store[offset + 3] = tempQuat.getX();
  store[offset + 4] = worldMatrix.m01;
  store[offset + 5] = worldMatrix.m11;
  store[offset + 6] = worldMatrix.m21;
  store[offset + 7] = tempQuat.getY();
  store[offset + 8] = worldMatrix.m02;
  store[offset + 9] = worldMatrix.m12;
  store[offset + 10] = worldMatrix.m22;
  store[offset + 11] = tempQuat.getZ();
  store[offset + 12] = worldMatrix.m03;
  store[offset + 13] = worldMatrix.m13;
  store[offset + 14] = worldMatrix.m23;
  store[offset + 15] = tempQuat.getW();
}

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

public static Quaternion stripToYaw(Quaternion q) {
    float yaw;
    float w = q.getW();
    float x = q.getX();
    float y = q.getY();
    float z = q.getZ();
    float sqx = x*x;
    float sqy = y*y;
    float sqz = z*z;
    float sqw = w*w;
    float unit = sqx + sqy + sqz + sqw; // if normalized is one, otherwise
    // is correction factor
    float test = x * y + z * w;
    if (test > 0.499 * unit) { // singularity at north pole
      yaw = 2 * FastMath.atan2(x, w);
    } else if (test < -0.499 * unit) { // singularity at south pole
      yaw = -2 * FastMath.atan2(x, w);
    } else {
      yaw = FastMath.atan2(2 * y * w - 2 * x * z, sqx - sqy - sqz + sqw); // roll or heading 
    }
    FastFullAngles(q, yaw, 0f, 0f);
    return q;
  }    
}

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

Quaternion quat = (Quaternion) val;
  return quat.getX() + " " + quat.getY() + " "
      + quat.getZ() + " " + quat.getW();
} else {
  throw new UnsupportedOperationException("Unexpected Vector4 type: " + val);

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

float[] translation = new float[3];
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];

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

Quaternion quat = (Quaternion) value;
  return quat.getX() + " " + quat.getY() + " "
      + quat.getZ() + " " + quat.getW();
} else {
  throw new UnsupportedOperationException("Unexpected Vector4 type: " + value);

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

} else {
  Quaternion c = (Quaternion) uniform.getValue();
  gl.glUniform4f(loc, c.getX(), c.getY(), c.getZ(), c.getW());

相关文章