本文整理汇总了Java中com.bulletphysics.collision.dispatch.CollisionObject.getFriction方法的典型用法代码示例。如果您正苦于以下问题:Java CollisionObject.getFriction方法的具体用法?Java CollisionObject.getFriction怎么用?Java CollisionObject.getFriction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.bulletphysics.collision.dispatch.CollisionObject
的用法示例。
在下文中一共展示了CollisionObject.getFriction方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initSolverBody
import com.bulletphysics.collision.dispatch.CollisionObject; //导入方法依赖的package包/类
private void initSolverBody(SolverBody solverBody, CollisionObject collisionObject) {
RigidBody rb = RigidBody.upcast(collisionObject);
if (rb != null) {
rb.getAngularVelocity(solverBody.angularVelocity);
solverBody.centerOfMassPosition.set(collisionObject.getWorldTransform(Stack.alloc(Transform.class)).origin);
solverBody.friction = collisionObject.getFriction();
solverBody.invMass = rb.getInvMass();
rb.getLinearVelocity(solverBody.linearVelocity);
solverBody.originalBody = rb;
solverBody.angularFactor = rb.getAngularFactor();
}
else {
solverBody.angularVelocity.set(0f, 0f, 0f);
solverBody.centerOfMassPosition.set(collisionObject.getWorldTransform(Stack.alloc(Transform.class)).origin);
solverBody.friction = collisionObject.getFriction();
solverBody.invMass = 0f;
solverBody.linearVelocity.set(0f, 0f, 0f);
solverBody.originalBody = null;
solverBody.angularFactor = 1f;
}
solverBody.pushVelocity.set(0f, 0f, 0f);
solverBody.turnVelocity.set(0f, 0f, 0f);
}
示例2: contactAdded
import com.bulletphysics.collision.dispatch.CollisionObject; //导入方法依赖的package包/类
public boolean contactAdded(ManifoldPoint cp, CollisionObject colObj0, int partId0, int index0, CollisionObject colObj1, int partId1, int index1) {
float friction0 = colObj0.getFriction();
float friction1 = colObj1.getFriction();
float restitution0 = colObj0.getRestitution();
float restitution1 = colObj1.getRestitution();
if ((colObj0.getCollisionFlags() & CollisionFlags.CUSTOM_MATERIAL_CALLBACK) != 0) {
friction0 = 1f; //partId0,index0
restitution0 = 0f;
}
if ((colObj1.getCollisionFlags() & CollisionFlags.CUSTOM_MATERIAL_CALLBACK) != 0) {
if ((index1 & 1) != 0) {
friction1 = 1f; //partId1,index1
}
else {
friction1 = 0f;
}
restitution1 = 0f;
}
cp.combinedFriction = calculateCombinedFriction(friction0, friction1);
cp.combinedRestitution = calculateCombinedRestitution(restitution0, restitution1);
// this return value is currently ignored, but to be on the safe side: return false if you don't calculate friction
return true;
}
示例3: initSolverBody
import com.bulletphysics.collision.dispatch.CollisionObject; //导入方法依赖的package包/类
private void initSolverBody (SolverBody solverBody, CollisionObject collisionObject) {
Stack stack = Stack.enter();
RigidBody rb = RigidBody.upcast(collisionObject);
if (rb != null) {
rb.getAngularVelocity(solverBody.angularVelocity);
solverBody.centerOfMassPosition.set(collisionObject.getWorldTransform(stack.allocTransform()).origin);
solverBody.friction = collisionObject.getFriction();
solverBody.invMass = rb.getInvMass();
rb.getLinearVelocity(solverBody.linearVelocity);
solverBody.originalBody = rb;
solverBody.angularFactor.set(rb.getAngularFactor());
solverBody.linearFactor.set(rb.getLinearFactor());
} else {
solverBody.angularVelocity.set(0f, 0f, 0f);
solverBody.centerOfMassPosition.set(collisionObject.getWorldTransform(stack.allocTransform()).origin);
solverBody.friction = collisionObject.getFriction();
solverBody.invMass = 0f;
solverBody.linearVelocity.set(0f, 0f, 0f);
solverBody.originalBody = null;
solverBody.angularFactor.set(1f, 1f, 1f);
solverBody.linearFactor.set(1f, 1f, 1f);
}
solverBody.pushVelocity.set(0f, 0f, 0f);
solverBody.turnVelocity.set(0f, 0f, 0f);
stack.leave();
}
示例4: initSolverBody
import com.bulletphysics.collision.dispatch.CollisionObject; //导入方法依赖的package包/类
private void initSolverBody(SolverBody solverBody, CollisionObject collisionObject) {
RigidBody rb = RigidBody.upcast(collisionObject);
if (rb != null) {
rb.getAngularVelocity(solverBody.angularVelocity);
solverBody.centerOfMassPosition.set(collisionObject.getWorldTransform(Stack.alloc(Transform.class)).origin);
solverBody.friction = collisionObject.getFriction();
Vector3f v = rb.getLinearFactor();
solverBody.invMass.set(rb.getInvMass() * v.x,
rb.getInvMass() * v.y,
rb.getInvMass() * v.z);
rb.getLinearVelocity(solverBody.linearVelocity);
solverBody.originalBody = rb;
solverBody.angularFactor.set(rb.getAngularFactor());
solverBody.linearFactor.set(rb.getLinearFactor());
}
else {
solverBody.angularVelocity.set(0f, 0f, 0f);
solverBody.centerOfMassPosition.set(collisionObject.getWorldTransform(Stack.alloc(Transform.class)).origin);
solverBody.friction = collisionObject.getFriction();
solverBody.invMass.set(0, 0, 0);
solverBody.linearVelocity.set(0f, 0f, 0f);
solverBody.originalBody = null;
solverBody.angularFactor.set(1, 1, 1);
solverBody.linearFactor.set(1, 1, 1);
}
solverBody.pushVelocity.set(0f, 0f, 0f);
solverBody.turnVelocity.set(0f, 0f, 0f);
}