当前位置: 首页>>代码示例>>Java>>正文


Java Quaternion类代码示例

本文整理汇总了Java中org.lwjgl.util.vector.Quaternion的典型用法代码示例。如果您正苦于以下问题:Java Quaternion类的具体用法?Java Quaternion怎么用?Java Quaternion使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Quaternion类属于org.lwjgl.util.vector包,在下文中一共展示了Quaternion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: Camera

import org.lwjgl.util.vector.Quaternion; //导入依赖的package包/类
/**
    * Creates a camera with the specified projection matrix
    * @param projection
    */
   public Camera(Matrix4f projection) {
this.projection = projection;

// Set the view to a default identity matrix
view = new Matrix4f();

// Set the position to origin
position = new Vector3f();
// Set the orientation to standard
orientation = new Quaternion();

// Create the default local axes (right handed)
up = new Vector3f(AXIS_Y);
forward = new Vector3f(AXIS_Z).negate(null);
right = new Vector3f(AXIS_X);
   }
 
开发者ID:camilne,项目名称:open-world,代码行数:21,代码来源:Camera.java

示例2: rotate

import org.lwjgl.util.vector.Quaternion; //导入依赖的package包/类
/**
    * Rotates the camera around the specified axis in the counter-clockwise direction
    * @param axis The axis to rotate around
    * @param v1 The first local camera vector to be updated
    * @param v2 The second local camera vector to be updated
    * @param angle The amount to rotate around the axis in degrees
    */
   private void rotate(Vector3f axis, Vector3f v1, Vector3f v2, float angle) {
Quaternion rotation = QuaternionUtil.createFromAxisAngle(axis, angle, null);
Quaternion.mul(rotation, orientation, orientation);

QuaternionUtil.rotate(v1, rotation, v1);
QuaternionUtil.rotate(v2, rotation, v2);

v1.normalise();
v2.normalise();
   }
 
开发者ID:camilne,项目名称:open-world,代码行数:18,代码来源:Camera.java

示例3: copy

import org.lwjgl.util.vector.Quaternion; //导入依赖的package包/类
/**
    * Creates a copy of this camera object
    * @return
    */
   public Camera copy() {
Camera res = new Camera(new Matrix4f(this.getProjection()));
res.setPosition(new Vector3f(this.getPosition()));
res.setView(new Matrix4f(this.getView()));
res.orientation = new Quaternion(this.orientation);
res.up = new Vector3f(this.up);
res.right = new Vector3f(this.right);
res.forward = new Vector3f(this.forward);
res.pitch = this.pitch;

return res;
   }
 
开发者ID:camilne,项目名称:open-world,代码行数:17,代码来源:Camera.java

示例4: makeQuaternion

import org.lwjgl.util.vector.Quaternion; //导入依赖的package包/类
private static Quaternion makeQuaternion(float p_188035_0_, float p_188035_1_, float p_188035_2_)
{
    float f = p_188035_0_ * 0.017453292F;
    float f1 = p_188035_1_ * 0.017453292F;
    float f2 = p_188035_2_ * 0.017453292F;
    float f3 = MathHelper.sin(0.5F * f);
    float f4 = MathHelper.cos(0.5F * f);
    float f5 = MathHelper.sin(0.5F * f1);
    float f6 = MathHelper.cos(0.5F * f1);
    float f7 = MathHelper.sin(0.5F * f2);
    float f8 = MathHelper.cos(0.5F * f2);
    return new Quaternion(f3 * f6 * f8 + f4 * f5 * f7, f4 * f5 * f8 - f3 * f6 * f7, f3 * f5 * f8 + f4 * f6 * f7, f4 * f6 * f8 - f3 * f5 * f7);
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:14,代码来源:ItemCameraTransforms.java

示例5: quatToGlMatrix

import org.lwjgl.util.vector.Quaternion; //导入依赖的package包/类
public static FloatBuffer quatToGlMatrix(FloatBuffer p_187418_0_, Quaternion p_187418_1_)
{
    p_187418_0_.clear();
    float f = p_187418_1_.x * p_187418_1_.x;
    float f1 = p_187418_1_.x * p_187418_1_.y;
    float f2 = p_187418_1_.x * p_187418_1_.z;
    float f3 = p_187418_1_.x * p_187418_1_.w;
    float f4 = p_187418_1_.y * p_187418_1_.y;
    float f5 = p_187418_1_.y * p_187418_1_.z;
    float f6 = p_187418_1_.y * p_187418_1_.w;
    float f7 = p_187418_1_.z * p_187418_1_.z;
    float f8 = p_187418_1_.z * p_187418_1_.w;
    p_187418_0_.put(1.0F - 2.0F * (f4 + f7));
    p_187418_0_.put(2.0F * (f1 + f8));
    p_187418_0_.put(2.0F * (f2 - f6));
    p_187418_0_.put(0.0F);
    p_187418_0_.put(2.0F * (f1 - f8));
    p_187418_0_.put(1.0F - 2.0F * (f + f7));
    p_187418_0_.put(2.0F * (f5 + f3));
    p_187418_0_.put(0.0F);
    p_187418_0_.put(2.0F * (f2 + f6));
    p_187418_0_.put(2.0F * (f5 - f3));
    p_187418_0_.put(1.0F - 2.0F * (f + f4));
    p_187418_0_.put(0.0F);
    p_187418_0_.put(0.0F);
    p_187418_0_.put(0.0F);
    p_187418_0_.put(0.0F);
    p_187418_0_.put(1.0F);
    p_187418_0_.rewind();
    return p_187418_0_;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:32,代码来源:GlStateManager.java

示例6: rotate

import org.lwjgl.util.vector.Quaternion; //导入依赖的package包/类
public static void rotate(Quaternion q, float pitch, float yaw, float roll) {
	 // Assuming the angles are in radians.
	 float c1 = (float)Math.cos(pitch/2);
	 float s1 = (float)Math.sin(pitch/2);
	 float c2 = (float)Math.cos(yaw/2);
	 float s2 = (float)Math.sin(yaw/2);
	 float c3 = (float)Math.cos(roll/2);
	 float s3 = (float)Math.sin(roll/2);
	 float c1c2 = c1*c2;
	 float s1s2 = s1*s2;
	 q.w =(c1c2*c3 - s1s2*s3);
	 q.x =(c1c2*s3 + s1s2*c3);
	 q.y =(s1*c2*c3 + c1*s2*s3);
	 q.z =(c1*s2*c3 - s1*c2*s3);
}
 
开发者ID:Itaros,项目名称:AxialShift,代码行数:16,代码来源:QuaternionHelper.java

示例7: toMatrix4f

import org.lwjgl.util.vector.Quaternion; //导入依赖的package包/类
public static Matrix4f toMatrix4f(Quaternion q){
	float x2 = q.x * q.x;
	float y2 = q.y * q.y;
	float z2 = q.z * q.z;
	float xy = q.x * q.y;
	float xz = q.x * q.z;
	float yz = q.y * q.z;
	float wx = q.w * q.x;
	float wy = q.w * q.y;
	float wz = q.w * q.z;
 
	Matrix4f rslt = new Matrix4f();
	rslt.m00=1.0f - 2.0f * (y2 + z2);
	rslt.m01=2.0f * (xy - wz);
	rslt.m02=2.0f * (xz + wy);
	rslt.m03=0.0f;
	rslt.m10=2.0f * (xy + wz);
	rslt.m11=1.0f - 2.0f * (x2 + z2);
	rslt.m12=2.0f * (yz - wx);
	rslt.m13=0.0f;
	rslt.m20=2.0f * (xz - wy);
	rslt.m21=2.0f * (yz + wx);
	rslt.m22=1.0f - 2.0f * (x2 + y2);
	rslt.m23=0.0f;
	rslt.m30=0.0f;
	rslt.m31=0.0f;
	rslt.m32=0.0f;
	rslt.m33=1.0f;
	return rslt;
}
 
开发者ID:Itaros,项目名称:AxialShift,代码行数:31,代码来源:Conversions.java

示例8: execute

import org.lwjgl.util.vector.Quaternion; //导入依赖的package包/类
@Override
public void execute(RenderingManager renderingManager) {
	Quaternion rot = object.getRotation();
	Quaternion n = new Quaternion();
	QuaternionHelper.rotate(n, pitch, yaw, roll);
	rot = Quaternion.mul(rot, n, rot);
	object.setRotation(rot);
}
 
开发者ID:Itaros,项目名称:AxialShift,代码行数:9,代码来源:ApplyRotationPass.java

示例9: interpolate

import org.lwjgl.util.vector.Quaternion; //导入依赖的package包/类
@Override
public void interpolate(Quaternion dest, Quaternion left, Quaternion right, float progress)
{
    float rev = 1.0f - progress;
    dest.set(left.x * rev + right.x * progress,
            left.y * rev + right.y * progress,
            left.z * rev + right.z * progress,
            left.w * rev + right.w * progress);
}
 
开发者ID:Ivorforce,项目名称:IvToolkit,代码行数:10,代码来源:NodeFieldAnimatorQuaternion.java

示例10: G3DModelLoader

import org.lwjgl.util.vector.Quaternion; //导入依赖的package包/类
public G3DModelLoader(Logger logger)
{
    this.logger = logger;

    GsonBuilder gsonBuilder = new GsonBuilder();
    gsonBuilder.registerTypeAdapter(Color.class, new ColorDeserializer());
    gsonBuilder.registerTypeAdapter(Quaternion.class, new QuaternionDeserializer());
    gsonBuilder.registerTypeAdapter(Vector2f.class, new Vector2fDeserializer());
    gsonBuilder.registerTypeAdapter(Vector3f.class, new Vector3fDeserializer());
    gson = gsonBuilder.create();
}
 
开发者ID:Ivorforce,项目名称:IvToolkit,代码行数:12,代码来源:G3DModelLoader.java

示例11: rotateWithQuaternion

import org.lwjgl.util.vector.Quaternion; //导入依赖的package包/类
private final void rotateWithQuaternion(final float angleDir, final float xSpeed, final float ySpeed, final float zSpeed)
{
	Quaternion qRotation = new Quaternion();
	Quaternion qView = new Quaternion();
	Quaternion qNewView = new Quaternion();

	// Create the rotation quaternion based on the axis we are rotating on.
	Vector4f quat = new Vector4f(xSpeed, ySpeed, zSpeed, angleDir);
	qRotation.setFromAxisAngle(quat);

	// Create the view quaternion.  This will be the direction of the view and position.
	qView.x = m_vView.x - m_vPosition.x;		// This gets the direction of the X.
	qView.y = m_vView.y - m_vPosition.y;		// This gets the direction of the Y.
	qView.z = m_vView.z - m_vPosition.z;		// This gets the direction of the Z.
	qView.w = 0;

	// Create the resulting quaternion by multiplying the rotation quat by the view quat
	// then multiplying that by the conjugate of the rotation quat.
	
	Quaternion q = new Quaternion();
	Quaternion.mul(qRotation, qView, q);
	
	Quaternion.mul(q, qRotation.negate(qRotation), qNewView);
	
	//qNewView = Quaternion.multiply(Quaternion.multiply(qRotation,qView), qRotation.conjugate());

	// Update the view information by adding the position to the resulting quaternion.
	m_vView.x = m_vPosition.x + qNewView.x;
	m_vView.y = m_vPosition.y + qNewView.y;
	m_vView.z = m_vPosition.z + qNewView.z;
  
}
 
开发者ID:gems-uff,项目名称:dominoes,代码行数:33,代码来源:Camera.java

示例12: rotateWithQuaternion

import org.lwjgl.util.vector.Quaternion; //导入依赖的package包/类
private final void rotateWithQuaternion(final float angleDir, final float xSpeed,
        final float ySpeed, final float zSpeed) {

    final Quaternion qRotation = new Quaternion();
    final Quaternion qView = new Quaternion();
    final Quaternion qNewView = new Quaternion();

    // Create the rotation quaternion based on the axis we are rotating on.
    qRotation.setFromAxisAngle(new Vector4f(xSpeed, ySpeed, zSpeed, angleDir));

    // Create the view quaternion. This will be the direction of the view
    // and position.
    qView.x = this.m_vView.x - this.m_vPosition.x; // This gets the
                                                   // direction of the
    // X.
    qView.y = this.m_vView.y - this.m_vPosition.y; // This gets the
                                                   // direction of the
    // Y.
    qView.z = this.m_vView.z - this.m_vPosition.z; // This gets the
                                                   // direction of the
    // Z.
    qView.w = 0;

    // Create the resulting quaternion by multiplying the rotation quat by
    // the view quat
    // then multiplying that by the conjugate of the rotation quat.

    final Quaternion dv = new Quaternion();
    final Quaternion nqRotation = new Quaternion();
    Quaternion.mul(qRotation, qView, dv);
    qRotation.negate(nqRotation);
    Quaternion.mul(dv, nqRotation, qNewView);

    // Update the view information by adding the position to the resulting
    // quaternion.
    this.m_vView.x = this.m_vPosition.x + qNewView.x;
    this.m_vView.y = this.m_vPosition.y + qNewView.y;
    this.m_vView.z = this.m_vPosition.z + qNewView.z;

}
 
开发者ID:JMaNGOS,项目名称:JMaNGOS,代码行数:41,代码来源:Camera.java

示例13: quarternionToMatrix

import org.lwjgl.util.vector.Quaternion; //导入依赖的package包/类
public static FloatBuffer quarternionToMatrix(Quaternion q, FloatBuffer buffer)
	{		
		//System.out.println(q);
		//if(q.length() != 0)
		//	System.out.println("n:" + q.normalise());
		
//		System.out.println("Matrix before:");
//		System.out.println(String.format("%f %f %f %f", buffer.get(0), buffer.get(1), buffer.get(2), buffer.get(3)));
//		System.out.println(String.format("%f %f %f %f", buffer.get(4), buffer.get(5), buffer.get(6), buffer.get(7)));
//		System.out.println(String.format("%f %f %f %f", buffer.get(8), buffer.get(9), buffer.get(10), buffer.get(11)));
//		System.out.println(String.format("%f %f %f %f", buffer.get(12), buffer.get(13), buffer.get(14), buffer.get(15)));

		//System.out.println(q);
		
//		q = new Quaternion(0.5F, -0.1F, 0.4F, 0.8F);
//		q.normalise();
		
		FloatBuffer buffer2;
		float[] rotationMatrixF = new 
				float[]{1,0,0,0,
						0,1,0,0,
						0,0,1,0,
						0,0,0,1};
		ByteBuffer vbb = ByteBuffer.allocateDirect(rotationMatrixF.length*4);
		vbb.order(ByteOrder.nativeOrder());
		buffer2 = vbb.asFloatBuffer();
		buffer2.put(buffer);
		buffer.position(0);
		buffer2.position(0);
		
		float xx2=q.x*q.x*2;
		float yy2=q.y*q.y*2;
		float zz2=q.z*q.z*2;
		float xy2 = q.x*q.y*2;
		float xz2 = q.x*q.z*2;
		float yz2 = q.y*q.z*2;
		float wx2 = q.w*q.x*2;
		float wy2 = q.w*q.y*2;
		float wz2 = q.w*q.z*2;
		
//		buffer2.position(0);
//		buffer2.put(1-yy2-zz2);
//		buffer2.put(xy2+wz2);
//		buffer2.put(xz2-wy2);
//		buffer2.put(0);
//		buffer2.put(xy2-wz2);
//		buffer2.put(1-xx2-zz2);
//		buffer2.put(yz2+wx2);
//		buffer2.put(0);
//		buffer2.put(xz2+wy2);
//		buffer2.put(yz2-wx2);
//		buffer2.put(1-xx2-yy2);
//		buffer2.put(0);
//		buffer2.position(0);
		
		buffer2.position(0);
		buffer2.put(1-yy2-zz2);
		buffer2.put(xy2-wz2);
		buffer2.put(xz2+wy2);
		buffer2.put(0);
		buffer2.put(xy2+wz2);
		buffer2.put(1-xx2-zz2);
		buffer2.put(yz2-wx2);
		buffer2.put(0);
		buffer2.put(xz2-wy2);
		buffer2.put(yz2+wx2);
		buffer2.put(1-xx2-yy2);
		buffer2.put(0);
		buffer2.position(0);
		
//		System.out.println("Matrix after:");
//		System.out.println(String.format("%f %f %f %f", buffer2.get(0), buffer2.get(1), buffer2.get(2), buffer2.get(3)));
//		System.out.println(String.format("%f %f %f %f", buffer2.get(4), buffer2.get(5), buffer2.get(6), buffer2.get(7)));
//		System.out.println(String.format("%f %f %f %f", buffer2.get(8), buffer2.get(9), buffer2.get(10), buffer2.get(11)));
//		System.out.println(String.format("%f %f %f %f", buffer2.get(12), buffer2.get(13), buffer2.get(14), buffer2.get(15)));

		return buffer;
	}
 
开发者ID:ObsidianSuite,项目名称:ObsidianSuite,代码行数:79,代码来源:MathHelper.java

示例14: rotate

import org.lwjgl.util.vector.Quaternion; //导入依赖的package包/类
public static void rotate(Quaternion p_187444_0_)
{
    multMatrix(quatToGlMatrix(BUF_FLOAT_16, p_187444_0_));
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:5,代码来源:GlStateManager.java

示例15: setRotation

import org.lwjgl.util.vector.Quaternion; //导入依赖的package包/类
public void setRotation(Quaternion q){
	rotation=q;
	markDirty();
}
 
开发者ID:Itaros,项目名称:AxialShift,代码行数:5,代码来源:Entity.java


注:本文中的org.lwjgl.util.vector.Quaternion类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。