本文整理汇总了Java中com.bulletphysics.BulletGlobals.CONVEX_DISTANCE_MARGIN属性的典型用法代码示例。如果您正苦于以下问题:Java BulletGlobals.CONVEX_DISTANCE_MARGIN属性的具体用法?Java BulletGlobals.CONVEX_DISTANCE_MARGIN怎么用?Java BulletGlobals.CONVEX_DISTANCE_MARGIN使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.bulletphysics.BulletGlobals
的用法示例。
在下文中一共展示了BulletGlobals.CONVEX_DISTANCE_MARGIN属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calculateLocalInertia
@Override
public void calculateLocalInertia (float mass, Vector3 inertia) {
// as an approximation, take the inertia of the box that bounds the spheres
Stack stack = Stack.enter();
Transform ident = stack.allocTransform();
ident.setIdentity();
float radius = getRadius();
Vector3 halfExtents = stack.allocVector3();
halfExtents.set(radius, radius, radius);
VectorUtil.setCoord(halfExtents, getUpAxis(), radius + getHalfHeight());
float margin = BulletGlobals.CONVEX_DISTANCE_MARGIN;
float lx = 2f * (halfExtents.x + margin);
float ly = 2f * (halfExtents.y + margin);
float lz = 2f * (halfExtents.z + margin);
float x2 = lx * lx;
float y2 = ly * ly;
float z2 = lz * lz;
float scaledmass = mass * 0.08333333f;
inertia.x = scaledmass * (y2 + z2);
inertia.y = scaledmass * (x2 + z2);
inertia.z = scaledmass * (x2 + y2);
stack.leave();
}
示例2: calculateLocalInertia
@Override
public void calculateLocalInertia(float mass, Vector3f inertia) {
// as an approximation, take the inertia of the box that bounds the spheres
Transform ident = Stack.alloc(Transform.class);
ident.setIdentity();
float radius = getRadius();
Vector3f halfExtents = Stack.alloc(Vector3f.class);
halfExtents.set(radius, radius, radius);
VectorUtil.setCoord(halfExtents, getUpAxis(), radius + getHalfHeight());
float margin = BulletGlobals.CONVEX_DISTANCE_MARGIN;
float lx = 2f * (halfExtents.x + margin);
float ly = 2f * (halfExtents.y + margin);
float lz = 2f * (halfExtents.z + margin);
float x2 = lx * lx;
float y2 = ly * ly;
float z2 = lz * lz;
float scaledmass = mass * 0.08333333f;
inertia.x = scaledmass * (y2 + z2);
inertia.y = scaledmass * (x2 + z2);
inertia.z = scaledmass * (x2 + y2);
}