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


Java QuaternionUtil.setRotation方法代码示例

本文整理汇总了Java中com.bulletphysics.linearmath.QuaternionUtil.setRotation方法的典型用法代码示例。如果您正苦于以下问题:Java QuaternionUtil.setRotation方法的具体用法?Java QuaternionUtil.setRotation怎么用?Java QuaternionUtil.setRotation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.bulletphysics.linearmath.QuaternionUtil的用法示例。


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

示例1: updateWheelTransform

import com.bulletphysics.linearmath.QuaternionUtil; //导入方法依赖的package包/类
public void updateWheelTransform(int wheelIndex, boolean interpolatedTransform) {
	WheelInfo wheel = wheelInfo.getQuick(wheelIndex);
	updateWheelTransformsWS(wheel, interpolatedTransform);
	Vector3f up = Stack.alloc(Vector3f.class);
	up.negate(wheel.raycastInfo.wheelDirectionWS);
	Vector3f right = wheel.raycastInfo.wheelAxleWS;
	Vector3f fwd = Stack.alloc(Vector3f.class);
	fwd.cross(up, right);
	fwd.normalize();
	// up = right.cross(fwd);
	// up.normalize();

	// rotate around steering over de wheelAxleWS
	float steering = wheel.steering;

	Quat4f steeringOrn = Stack.alloc(Quat4f.class);
	QuaternionUtil.setRotation(steeringOrn, up, steering); //wheel.m_steering);
	Matrix3f steeringMat = Stack.alloc(Matrix3f.class);
	MatrixUtil.setRotation(steeringMat, steeringOrn);

	Quat4f rotatingOrn = Stack.alloc(Quat4f.class);
	QuaternionUtil.setRotation(rotatingOrn, right, -wheel.rotation);
	Matrix3f rotatingMat = Stack.alloc(Matrix3f.class);
	MatrixUtil.setRotation(rotatingMat, rotatingOrn);

	Matrix3f basis2 = Stack.alloc(Matrix3f.class);
	basis2.setRow(0, right.x, fwd.x, up.x);
	basis2.setRow(1, right.y, fwd.y, up.y);
	basis2.setRow(2, right.z, fwd.z, up.z);

	Matrix3f wheelBasis = wheel.worldTransform.basis;
	wheelBasis.mul(steeringMat, rotatingMat);
	wheelBasis.mul(basis2);

	wheel.worldTransform.origin.scaleAdd(wheel.raycastInfo.suspensionLength, wheel.raycastInfo.wheelDirectionWS, wheel.raycastInfo.hardPointWS);
}
 
开发者ID:warlockcodes,项目名称:Null-Engine,代码行数:37,代码来源:RaycastVehicle.java

示例2: updateWheelTransform

import com.bulletphysics.linearmath.QuaternionUtil; //导入方法依赖的package包/类
public void updateWheelTransform(int wheelIndex, boolean interpolatedTransform) {
	WheelInfo wheel = wheelInfo.get(wheelIndex);
	updateWheelTransformsWS(wheel, interpolatedTransform);
	Vector3f up = Stack.alloc(Vector3f.class);
	up.negate(wheel.raycastInfo.wheelDirectionWS);
	Vector3f right = wheel.raycastInfo.wheelAxleWS;
	Vector3f fwd = Stack.alloc(Vector3f.class);
	fwd.cross(up, right);
	fwd.normalize();
	// up = right.cross(fwd);
	// up.normalize();

	// rotate around steering over de wheelAxleWS
	float steering = wheel.steering;

	Quat4f steeringOrn = Stack.alloc(Quat4f.class);
	QuaternionUtil.setRotation(steeringOrn, up, steering); //wheel.m_steering);
	Matrix3f steeringMat = Stack.alloc(Matrix3f.class);
	MatrixUtil.setRotation(steeringMat, steeringOrn);

	Quat4f rotatingOrn = Stack.alloc(Quat4f.class);
	QuaternionUtil.setRotation(rotatingOrn, right, -wheel.rotation);
	Matrix3f rotatingMat = Stack.alloc(Matrix3f.class);
	MatrixUtil.setRotation(rotatingMat, rotatingOrn);

	Matrix3f basis2 = Stack.alloc(Matrix3f.class);
	basis2.setRow(0, right.x, fwd.x, up.x);
	basis2.setRow(1, right.y, fwd.y, up.y);
	basis2.setRow(2, right.z, fwd.z, up.z);

	Matrix3f wheelBasis = wheel.worldTransform.basis;
	wheelBasis.mul(steeringMat, rotatingMat);
	wheelBasis.mul(basis2);

	wheel.worldTransform.origin.scaleAdd(wheel.raycastInfo.suspensionLength, wheel.raycastInfo.wheelDirectionWS, wheel.raycastInfo.hardPointWS);
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:37,代码来源:RaycastVehicle.java

示例3: draw

import com.bulletphysics.linearmath.QuaternionUtil; //导入方法依赖的package包/类
public void draw(IGL gl) {
	gl.glDisable(GL_LIGHTING);
	gl.glColor3f(0f, 1f, 0f);
	gl.glBegin(GL_LINES);
	for (int i=0; i<NUMRAYS_IN_BAR; i++) {
		gl.glVertex3f(source[i].x, source[i].y, source[i].z);
		gl.glVertex3f(hit_com[i].x, hit_com[i].y, hit_com[i].z);
	}
	gl.glColor3f(1f, 1f, 1f);
	//gl.glBegin(GL_LINES);
	float normal_scale = 10f; // easier to see if this is big
	for (int i=0; i<NUMRAYS_IN_BAR; i++) {
		gl.glVertex3f(hit_surface[i].x, hit_surface[i].y, hit_surface[i].z);
		gl.glVertex3f(hit_surface[i].x + normal_scale * normal[i].x, hit_surface[i].y + normal_scale * normal[i].y, hit_surface[i].z + normal_scale * normal[i].z);
	}
	gl.glEnd();
	gl.glColor3f(0f, 1f, 1f);
	Quat4f qFrom = Stack.alloc(Quat4f.class);
	Quat4f qTo = Stack.alloc(Quat4f.class);
	QuaternionUtil.setRotation(qFrom, new Vector3f(1f, 0f, 0f), 0f);
	QuaternionUtil.setRotation(qTo, new Vector3f(1f, 0f, 0f), 0.7f);
	for (int i=0; i<NUMRAYS_IN_BAR; i++) {
		Transform from = Stack.alloc(Transform.class);
		from.basis.set(qFrom);
		from.origin.set(source[i]);

		Transform to = Stack.alloc(Transform.class);
		to.basis.set(qTo);
		to.origin.set(dest[i]);

		Vector3f linVel = Stack.alloc(Vector3f.class);
		Vector3f angVel = Stack.alloc(Vector3f.class);

		TransformUtil.calculateVelocity(from, to, 1f, linVel, angVel);
		Transform T = Stack.alloc(Transform.class);
		TransformUtil.integrateTransform(from, linVel, angVel, hit_fraction[i], T);
		drawCube(gl, T);
	}
	gl.glEnable(GL_LIGHTING);
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:41,代码来源:ConvexcastBatch.java

示例4: updateWheelTransform

import com.bulletphysics.linearmath.QuaternionUtil; //导入方法依赖的package包/类
public void updateWheelTransform (int wheelIndex, boolean interpolatedTransform) {
	WheelInfo wheel = wheelInfo.getQuick(wheelIndex);
	updateWheelTransformsWS(wheel, interpolatedTransform);
	Stack stack = Stack.enter();
	Vector3 up = stack.allocVector3();
	up.set(wheel.raycastInfo.wheelDirectionWS).scl(-1);
	Vector3 right = wheel.raycastInfo.wheelAxleWS;
	Vector3 fwd = stack.allocVector3();
	fwd.set(up).crs(right);
	fwd.nor();
	// up = right.cross(fwd);
	// up.nor();

	// rotate around steering over de wheelAxleWS
	float steering = wheel.steering;

	Quaternion steeringOrn = stack.allocQuaternion();
	QuaternionUtil.setRotation(steeringOrn, up, steering); // wheel.m_steering);
	Matrix3 steeringMat = stack.allocMatrix3();
	MatrixUtil.setRotation(steeringMat, steeringOrn);

	Quaternion rotatingOrn = stack.allocQuaternion();
	QuaternionUtil.setRotation(rotatingOrn, right, -wheel.rotation);
	Matrix3 rotatingMat = stack.allocMatrix3();
	MatrixUtil.setRotation(rotatingMat, rotatingOrn);

	Matrix3 basis2 = stack.allocMatrix3();
	MatrixUtil.setRow(basis2, 0, right.x, fwd.x, up.x);
	MatrixUtil.setRow(basis2, 1, right.y, fwd.y, up.y);
	MatrixUtil.setRow(basis2, 2, right.z, fwd.z, up.z);

	Matrix3 wheelBasis = wheel.worldTransform.basis;
	wheelBasis.set(steeringMat).mul(rotatingMat);
	wheelBasis.mul(basis2);

	wheel.worldTransform.origin.x = wheel.raycastInfo.hardPointWS.x
		+ wheel.raycastInfo.suspensionLength * wheel.raycastInfo.wheelDirectionWS.x;
	wheel.worldTransform.origin.y = wheel.raycastInfo.hardPointWS.y
		+ wheel.raycastInfo.suspensionLength * wheel.raycastInfo.wheelDirectionWS.y;
	wheel.worldTransform.origin.z = wheel.raycastInfo.hardPointWS.z
		+ wheel.raycastInfo.suspensionLength * wheel.raycastInfo.wheelDirectionWS.z;
	stack.leave();
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:44,代码来源:RaycastVehicle.java

示例5: cast

import com.bulletphysics.linearmath.QuaternionUtil; //导入方法依赖的package包/类
public void cast(CollisionWorld cw) {
	//#ifdef USE_BT_CLOCK
	frame_timer.reset();
	//#endif //USE_BT_CLOCK

	for (int i=0; i<NUMRAYS_IN_BAR; i++) {
		ClosestConvexResultCallback cb = new ClosestConvexResultCallback(source[i], dest[i]);

		Quat4f qFrom = Stack.alloc(Quat4f.class);
		Quat4f qTo = Stack.alloc(Quat4f.class);
		QuaternionUtil.setRotation(qFrom, new Vector3f(1f, 0f, 0f), 0f);
		QuaternionUtil.setRotation(qTo, new Vector3f(1f, 0f, 0f), 0.7f);

		Transform from = Stack.alloc(Transform.class);
		Transform to = Stack.alloc(Transform.class);
		from.basis.set(qFrom);
		from.origin.set(source[i]);
		to.basis.set(qTo);
		to.origin.set(dest[i]);
		
		cw.convexSweepTest(boxShape, from, to, cb);

		if (cb.hasHit()) {
			hit_surface[i].set(cb.hitPointWorld);
			VectorUtil.setInterpolate3(hit_com[i], source[i], dest[i], cb.closestHitFraction);
			hit_fraction[i] = cb.closestHitFraction;
			normal[i].set(cb.hitNormalWorld);
			normal[i].normalize();
		}
		else {
			hit_com[i].set(dest[i]);
			hit_surface[i].set(dest[i]);
			hit_fraction[i] = 1f;
			normal[i].set(1f, 0f, 0f);
		}

	}

	//#ifdef USE_BT_CLOCK
	ms += frame_timer.getTimeMilliseconds();
	//#endif //USE_BT_CLOCK
	
	frame_counter++;
	if (frame_counter > 50) {
		min_ms = ms < min_ms ? ms : min_ms;
		max_ms = ms > max_ms ? ms : max_ms;
		sum_ms += ms;
		sum_ms_samples++;
		float mean_ms = (float) sum_ms / (float) sum_ms_samples;
		System.out.printf("%d rays in %d ms %d %d %f\n", NUMRAYS_IN_BAR * frame_counter, ms, min_ms, max_ms, mean_ms);
		ms = 0;
		frame_counter = 0;
	}
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:55,代码来源:ConvexcastBatch.java


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