本文整理汇总了Java中com.bulletphysics.collision.shapes.SphereShape.getRadius方法的典型用法代码示例。如果您正苦于以下问题:Java SphereShape.getRadius方法的具体用法?Java SphereShape.getRadius怎么用?Java SphereShape.getRadius使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.bulletphysics.collision.shapes.SphereShape
的用法示例。
在下文中一共展示了SphereShape.getRadius方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processCollision
import com.bulletphysics.collision.shapes.SphereShape; //导入方法依赖的package包/类
@Override
public void processCollision (CollisionObject col0, CollisionObject col1, DispatcherInfo dispatchInfo,
ManifoldResult resultOut) {
if (manifoldPtr == null) {
return;
}
Stack stack = Stack.enter();
Transform tmpTrans1 = stack.allocTransform();
Transform tmpTrans2 = stack.allocTransform();
resultOut.setPersistentManifold(manifoldPtr);
SphereShape sphere0 = (SphereShape)col0.getCollisionShape();
SphereShape sphere1 = (SphereShape)col1.getCollisionShape();
Vector3 diff = stack.allocVector3();
diff.set(col0.getWorldTransform(tmpTrans1).origin).sub(col1.getWorldTransform(tmpTrans2).origin);
float len = diff.len();
float radius0 = sphere0.getRadius();
float radius1 = sphere1.getRadius();
// #ifdef CLEAR_MANIFOLD
// manifoldPtr.clearManifold(); // don't do this, it disables warmstarting
// #endif
// if distance positive, don't generate a new contact
if (len > (radius0 + radius1)) {
// #ifndef CLEAR_MANIFOLD
resultOut.refreshContactPoints();
// #endif //CLEAR_MANIFOLD
return;
}
// distance (negative means penetration)
float dist = len - (radius0 + radius1);
Vector3 normalOnSurfaceB = stack.allocVector3();
normalOnSurfaceB.set(1f, 0f, 0f);
if (len > BulletGlobals.FLT_EPSILON) {
normalOnSurfaceB.set(diff).scl(1f / len);
}
Vector3 tmp = stack.allocVector3();
// point on A (worldspace)
Vector3 pos0 = stack.allocVector3();
tmp.set(normalOnSurfaceB).scl(radius0);
pos0.set(col0.getWorldTransform(tmpTrans1).origin).sub(tmp);
// point on B (worldspace)
Vector3 pos1 = stack.allocVector3();
tmp.set(normalOnSurfaceB).scl(radius1);
pos1.set(col1.getWorldTransform(tmpTrans2).origin).add(tmp);
// report a contact. internally this will be kept persistent, and contact reduction is done
resultOut.addContactPoint(normalOnSurfaceB, pos1, dist);
// #ifndef CLEAR_MANIFOLD
resultOut.refreshContactPoints();
// #endif //CLEAR_MANIFOLD
stack.leave();
}
示例2: processCollision
import com.bulletphysics.collision.shapes.SphereShape; //导入方法依赖的package包/类
@Override
public void processCollision(CollisionObject col0, CollisionObject col1, DispatcherInfo dispatchInfo, ManifoldResult resultOut) {
if (manifoldPtr == null) {
return;
}
Transform tmpTrans1 = Stack.alloc(Transform.class);
Transform tmpTrans2 = Stack.alloc(Transform.class);
resultOut.setPersistentManifold(manifoldPtr);
SphereShape sphere0 = (SphereShape) col0.getCollisionShape();
SphereShape sphere1 = (SphereShape) col1.getCollisionShape();
Vector3f diff = Stack.alloc(Vector3f.class);
diff.sub(col0.getWorldTransform(tmpTrans1).origin, col1.getWorldTransform(tmpTrans2).origin);
float len = diff.length();
float radius0 = sphere0.getRadius();
float radius1 = sphere1.getRadius();
//#ifdef CLEAR_MANIFOLD
//manifoldPtr.clearManifold(); // don't do this, it disables warmstarting
//#endif
// if distance positive, don't generate a new contact
if (len > (radius0 + radius1)) {
//#ifndef CLEAR_MANIFOLD
resultOut.refreshContactPoints();
//#endif //CLEAR_MANIFOLD
return;
}
// distance (negative means penetration)
float dist = len - (radius0 + radius1);
Vector3f normalOnSurfaceB = Stack.alloc(Vector3f.class);
normalOnSurfaceB.set(1f, 0f, 0f);
if (len > BulletGlobals.FLT_EPSILON) {
normalOnSurfaceB.scale(1f / len, diff);
}
Vector3f tmp = Stack.alloc(Vector3f.class);
// point on A (worldspace)
Vector3f pos0 = Stack.alloc(Vector3f.class);
tmp.scale(radius0, normalOnSurfaceB);
pos0.sub(col0.getWorldTransform(tmpTrans1).origin, tmp);
// point on B (worldspace)
Vector3f pos1 = Stack.alloc(Vector3f.class);
tmp.scale(radius1, normalOnSurfaceB);
pos1.add(col1.getWorldTransform(tmpTrans2).origin, tmp);
// report a contact. internally this will be kept persistent, and contact reduction is done
resultOut.addContactPoint(normalOnSurfaceB, pos1, dist);
//#ifndef CLEAR_MANIFOLD
resultOut.refreshContactPoints();
//#endif //CLEAR_MANIFOLD
}
示例3: processCollision
import com.bulletphysics.collision.shapes.SphereShape; //导入方法依赖的package包/类
@Override
public void processCollision(CollisionObject col0, CollisionObject col1, DispatcherInfo dispatchInfo, ManifoldResult resultOut) {
if (manifoldPtr == null) {
return;
}
Transform tmpTrans1 = Stack.alloc(Transform.class);
Transform tmpTrans2 = Stack.alloc(Transform.class);
resultOut.setPersistentManifold(manifoldPtr);
SphereShape sphere0 = (SphereShape) col0.getCollisionShape();
SphereShape sphere1 = (SphereShape) col1.getCollisionShape();
Vector3f diff = Stack.alloc(Vector3f.class);
diff.sub(col0.getWorldTransform(tmpTrans1).origin, col1.getWorldTransform(tmpTrans2).origin);
float len = diff.length();
float radius0 = sphere0.getRadius();
float radius1 = sphere1.getRadius();
//manifoldPtr.clearManifold(); // don't do this, it disables warmstarting
// if distance positive, don't generate a new contact
if (len > (radius0 + radius1)) {
return;
}
// distance (negative means penetration)
float dist = len - (radius0 + radius1);
Vector3f normalOnSurfaceB = Stack.alloc(Vector3f.class);
normalOnSurfaceB.set(1f, 0f, 0f);
if (len > BulletGlobals.FLT_EPSILON) {
normalOnSurfaceB.scale(1f / len, diff);
}
Vector3f tmp = Stack.alloc(Vector3f.class);
// point on A (worldspace)
Vector3f pos0 = Stack.alloc(Vector3f.class);
tmp.scale(radius0, normalOnSurfaceB);
pos0.sub(col0.getWorldTransform(tmpTrans1).origin, tmp);
// point on B (worldspace)
Vector3f pos1 = Stack.alloc(Vector3f.class);
tmp.scale(radius1, normalOnSurfaceB);
pos1.add(col1.getWorldTransform(tmpTrans2).origin, tmp);
// report a contact. internally this will be kept persistent, and contact reduction is done
resultOut.addContactPoint(normalOnSurfaceB, pos1, dist);
//no resultOut->refreshContactPoints(); needed, because of clearManifold (all points are new)
}