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


Java ManifoldPoint.getPositionWorldOnA方法代码示例

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


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

示例1: onCollision

import com.bulletphysics.collision.narrowphase.ManifoldPoint; //导入方法依赖的package包/类
@Override
public void onCollision(ManifoldPoint mp, GameObject object) {
	// TODO: check if impact material is equal to "material"
	// TODO: check how hard the impact is, should include "mass" in the calculation
	
	final float lowerLimit = 20.0f;
	final float upperLimit = 100.0f;
	
	if (mp.appliedImpulse > lowerLimit) {
	
		int soundId = 0;
		if (mp.appliedImpulse >= upperLimit) {
			soundId = impacts.length - 1;
		} else {
			soundId = (int)(((mp.appliedImpulse - lowerLimit) / (upperLimit - lowerLimit)) * (float)impacts.length);
		}
		
		Sound impactSound = impacts[soundId];
		
		if (!impactSound.isPlaying()) {
			javax.vecmath.Vector3f pos = new javax.vecmath.Vector3f();
			mp.getPositionWorldOnA(pos );
			impactSound.setPosition(new Vector3f(pos.x, pos.y, pos.z));
			impactSound.play();
		}
	}
}
 
开发者ID:Axodoss,项目名称:Wicken,代码行数:28,代码来源:SoundOnImpact.java

示例2: resolveSingleCollision

import com.bulletphysics.collision.narrowphase.ManifoldPoint; //导入方法依赖的package包/类
/** Response between two dynamic objects with friction. */
public static float resolveSingleCollision (RigidBody body1, RigidBody body2, ManifoldPoint contactPoint,
	ContactSolverInfo solverInfo) {

	Stack stack = Stack.enter();
	Vector3 tmpVec = stack.allocVector3();

	Vector3 pos1_ = contactPoint.getPositionWorldOnA(stack.allocVector3());
	Vector3 pos2_ = contactPoint.getPositionWorldOnB(stack.allocVector3());
	Vector3 normal = contactPoint.normalWorldOnB;

	// constant over all iterations
	Vector3 rel_pos1 = stack.allocVector3();
	rel_pos1.set(pos1_).sub(body1.getCenterOfMassPosition(tmpVec));

	Vector3 rel_pos2 = stack.allocVector3();
	rel_pos2.set(pos2_).sub(body2.getCenterOfMassPosition(tmpVec));

	Vector3 vel1 = body1.getVelocityInLocalPoint(rel_pos1, stack.allocVector3());
	Vector3 vel2 = body2.getVelocityInLocalPoint(rel_pos2, stack.allocVector3());
	Vector3 vel = stack.allocVector3();
	vel.set(vel1).sub(vel2);

	float rel_vel;
	rel_vel = normal.dot(vel);

	float Kfps = 1f / solverInfo.timeStep;

	// btScalar damping = solverInfo.m_damping ;
	float Kerp = solverInfo.erp;
	float Kcor = Kerp * Kfps;

	ConstraintPersistentData cpd = (ConstraintPersistentData)contactPoint.userPersistentData;
	assert (cpd != null);
	float distance = cpd.penetration;
	float positionalError = Kcor * -distance;
	float velocityError = cpd.restitution - rel_vel; // * damping;

	float penetrationImpulse = positionalError * cpd.jacDiagABInv;

	float velocityImpulse = velocityError * cpd.jacDiagABInv;

	float normalImpulse = penetrationImpulse + velocityImpulse;

	// See Erin Catto's GDC 2006 paper: Clamp the accumulated impulse
	float oldNormalImpulse = cpd.appliedImpulse;
	float sum = oldNormalImpulse + normalImpulse;
	cpd.appliedImpulse = 0f > sum ? 0f : sum;

	normalImpulse = cpd.appliedImpulse - oldNormalImpulse;

	// #ifdef USE_INTERNAL_APPLY_IMPULSE
	Vector3 tmp = stack.allocVector3();
	if (body1.getInvMass() != 0f) {
		tmp.set(contactPoint.normalWorldOnB).scl(body1.getInvMass());
		body1.internalApplyImpulse(tmp, cpd.angularComponentA, normalImpulse);
	}
	if (body2.getInvMass() != 0f) {
		tmp.set(contactPoint.normalWorldOnB).scl(body2.getInvMass());
		body2.internalApplyImpulse(tmp, cpd.angularComponentB, -normalImpulse);
	}
	// #else //USE_INTERNAL_APPLY_IMPULSE
	// body1.applyImpulse(normal*(normalImpulse), rel_pos1);
	// body2.applyImpulse(-normal*(normalImpulse), rel_pos2);
	// #endif //USE_INTERNAL_APPLY_IMPULSE

	stack.leave();
	return normalImpulse;
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:70,代码来源:ContactConstraint.java

示例3: resolveSingleCollision

import com.bulletphysics.collision.narrowphase.ManifoldPoint; //导入方法依赖的package包/类
/**
 * Response between two dynamic objects with friction.
 */
public static float resolveSingleCollision(
		RigidBody body1,
		RigidBody body2,
		ManifoldPoint contactPoint,
		ContactSolverInfo solverInfo) {
	
	Vector3f tmpVec = Stack.alloc(Vector3f.class);

	Vector3f pos1_ = contactPoint.getPositionWorldOnA(Stack.alloc(Vector3f.class));
	Vector3f pos2_ = contactPoint.getPositionWorldOnB(Stack.alloc(Vector3f.class));
	Vector3f normal = contactPoint.normalWorldOnB;

	// constant over all iterations
	Vector3f rel_pos1 = Stack.alloc(Vector3f.class);
	rel_pos1.sub(pos1_, body1.getCenterOfMassPosition(tmpVec));

	Vector3f rel_pos2 = Stack.alloc(Vector3f.class);
	rel_pos2.sub(pos2_, body2.getCenterOfMassPosition(tmpVec));

	Vector3f vel1 = body1.getVelocityInLocalPoint(rel_pos1, Stack.alloc(Vector3f.class));
	Vector3f vel2 = body2.getVelocityInLocalPoint(rel_pos2, Stack.alloc(Vector3f.class));
	Vector3f vel = Stack.alloc(Vector3f.class);
	vel.sub(vel1, vel2);

	float rel_vel;
	rel_vel = normal.dot(vel);

	float Kfps = 1f / solverInfo.timeStep;

	// btScalar damping = solverInfo.m_damping ;
	float Kerp = solverInfo.erp;
	float Kcor = Kerp * Kfps;

	ConstraintPersistentData cpd = (ConstraintPersistentData) contactPoint.userPersistentData;
	assert (cpd != null);
	float distance = cpd.penetration;
	float positionalError = Kcor * -distance;
	float velocityError = cpd.restitution - rel_vel; // * damping;

	float penetrationImpulse = positionalError * cpd.jacDiagABInv;

	float velocityImpulse = velocityError * cpd.jacDiagABInv;

	float normalImpulse = penetrationImpulse + velocityImpulse;

	// See Erin Catto's GDC 2006 paper: Clamp the accumulated impulse
	float oldNormalImpulse = cpd.appliedImpulse;
	float sum = oldNormalImpulse + normalImpulse;
	cpd.appliedImpulse = 0f > sum ? 0f : sum;

	normalImpulse = cpd.appliedImpulse - oldNormalImpulse;

	//#ifdef USE_INTERNAL_APPLY_IMPULSE
	Vector3f tmp = Stack.alloc(Vector3f.class);
	if (body1.getInvMass() != 0f) {
		tmp.scale(body1.getInvMass(), contactPoint.normalWorldOnB);
		body1.internalApplyImpulse(tmp, cpd.angularComponentA, normalImpulse);
	}
	if (body2.getInvMass() != 0f) {
		tmp.scale(body2.getInvMass(), contactPoint.normalWorldOnB);
		body2.internalApplyImpulse(tmp, cpd.angularComponentB, -normalImpulse);
	}
	//#else //USE_INTERNAL_APPLY_IMPULSE
	//	body1.applyImpulse(normal*(normalImpulse), rel_pos1);
	//	body2.applyImpulse(-normal*(normalImpulse), rel_pos2);
	//#endif //USE_INTERNAL_APPLY_IMPULSE

	return normalImpulse;
}
 
开发者ID:warlockcodes,项目名称:Null-Engine,代码行数:73,代码来源:ContactConstraint.java


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