本文整理汇总了Java中com.bulletphysics.collision.shapes.StaticPlaneShape.getPlaneConstant方法的典型用法代码示例。如果您正苦于以下问题:Java StaticPlaneShape.getPlaneConstant方法的具体用法?Java StaticPlaneShape.getPlaneConstant怎么用?Java StaticPlaneShape.getPlaneConstant使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.bulletphysics.collision.shapes.StaticPlaneShape
的用法示例。
在下文中一共展示了StaticPlaneShape.getPlaneConstant方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: get_plane_equation
import com.bulletphysics.collision.shapes.StaticPlaneShape; //导入方法依赖的package包/类
public static void get_plane_equation (StaticPlaneShape shape, Quaternion equation) {
Stack stack = Stack.enter();
Vector3 tmp = stack.allocVector3();
equation.set(shape.getPlaneNormal(tmp), 0);
equation.w = shape.getPlaneConstant();
stack.leave();
}
示例2: get_plane_equation
import com.bulletphysics.collision.shapes.StaticPlaneShape; //导入方法依赖的package包/类
public static void get_plane_equation(StaticPlaneShape shape, Vector4f equation) {
Vector3f tmp = Stack.alloc(Vector3f.class);
equation.set(shape.getPlaneNormal(tmp));
equation.w = shape.getPlaneConstant();
}
示例3: processCollision
import com.bulletphysics.collision.shapes.StaticPlaneShape; //导入方法依赖的package包/类
@Override
public void processCollision (CollisionObject body0, CollisionObject body1, DispatcherInfo dispatchInfo,
ManifoldResult resultOut) {
if (manifoldPtr == null) {
return;
}
Stack stack = Stack.enter();
Transform tmpTrans = stack.allocTransform();
CollisionObject convexObj = isSwapped ? body1 : body0;
CollisionObject planeObj = isSwapped ? body0 : body1;
ConvexShape convexShape = (ConvexShape)convexObj.getCollisionShape();
StaticPlaneShape planeShape = (StaticPlaneShape)planeObj.getCollisionShape();
boolean hasCollision = false;
Vector3 planeNormal = planeShape.getPlaneNormal(stack.allocVector3());
float planeConstant = planeShape.getPlaneConstant();
Transform planeInConvex = stack.allocTransform();
convexObj.getWorldTransform(planeInConvex);
planeInConvex.inverse();
planeInConvex.mul(planeObj.getWorldTransform(tmpTrans));
Transform convexInPlaneTrans = stack.allocTransform();
convexInPlaneTrans.inverse(planeObj.getWorldTransform(tmpTrans));
convexInPlaneTrans.mul(convexObj.getWorldTransform(tmpTrans));
Vector3 tmp = stack.allocVector3();
tmp.set(planeNormal).scl(-1);
tmp.mul(planeInConvex.basis);
Vector3 vtx = convexShape.localGetSupportingVertex(tmp, stack.allocVector3());
Vector3 vtxInPlane = stack.alloc(vtx);
convexInPlaneTrans.transform(vtxInPlane);
float distance = (planeNormal.dot(vtxInPlane) - planeConstant);
Vector3 vtxInPlaneProjected = stack.allocVector3();
tmp.set(planeNormal).scl(distance);
vtxInPlaneProjected.set(vtxInPlane).sub(tmp);
Vector3 vtxInPlaneWorld = stack.alloc(vtxInPlaneProjected);
planeObj.getWorldTransform(tmpTrans).transform(vtxInPlaneWorld);
hasCollision = distance < manifoldPtr.getContactBreakingThreshold();
resultOut.setPersistentManifold(manifoldPtr);
if (hasCollision) {
// report a contact. internally this will be kept persistent, and contact reduction is done
Vector3 normalOnSurfaceB = stack.alloc(planeNormal);
normalOnSurfaceB.mul(planeObj.getWorldTransform(tmpTrans).basis);
Vector3 pOnB = stack.alloc(vtxInPlaneWorld);
resultOut.addContactPoint(normalOnSurfaceB, pOnB, distance);
}
if (ownManifold) {
if (manifoldPtr.getNumContacts() != 0) {
resultOut.refreshContactPoints();
}
}
stack.leave();
}
示例4: processCollision
import com.bulletphysics.collision.shapes.StaticPlaneShape; //导入方法依赖的package包/类
@Override
public void processCollision(CollisionObject body0, CollisionObject body1, DispatcherInfo dispatchInfo, ManifoldResult resultOut) {
if (manifoldPtr == null) {
return;
}
Transform tmpTrans = Stack.alloc(Transform.class);
CollisionObject convexObj = isSwapped ? body1 : body0;
CollisionObject planeObj = isSwapped ? body0 : body1;
ConvexShape convexShape = (ConvexShape) convexObj.getCollisionShape();
StaticPlaneShape planeShape = (StaticPlaneShape) planeObj.getCollisionShape();
boolean hasCollision = false;
Vector3f planeNormal = planeShape.getPlaneNormal(Stack.alloc(Vector3f.class));
float planeConstant = planeShape.getPlaneConstant();
Transform planeInConvex = Stack.alloc(Transform.class);
convexObj.getWorldTransform(planeInConvex);
planeInConvex.inverse();
planeInConvex.mul(planeObj.getWorldTransform(tmpTrans));
Transform convexInPlaneTrans = Stack.alloc(Transform.class);
convexInPlaneTrans.inverse(planeObj.getWorldTransform(tmpTrans));
convexInPlaneTrans.mul(convexObj.getWorldTransform(tmpTrans));
Vector3f tmp = Stack.alloc(Vector3f.class);
tmp.negate(planeNormal);
planeInConvex.basis.transform(tmp);
Vector3f vtx = convexShape.localGetSupportingVertex(tmp, Stack.alloc(Vector3f.class));
Vector3f vtxInPlane = Stack.alloc(vtx);
convexInPlaneTrans.transform(vtxInPlane);
float distance = (planeNormal.dot(vtxInPlane) - planeConstant);
Vector3f vtxInPlaneProjected = Stack.alloc(Vector3f.class);
tmp.scale(distance, planeNormal);
vtxInPlaneProjected.sub(vtxInPlane, tmp);
Vector3f vtxInPlaneWorld = Stack.alloc(vtxInPlaneProjected);
planeObj.getWorldTransform(tmpTrans).transform(vtxInPlaneWorld);
hasCollision = distance < manifoldPtr.getContactBreakingThreshold();
resultOut.setPersistentManifold(manifoldPtr);
if (hasCollision) {
// report a contact. internally this will be kept persistent, and contact reduction is done
Vector3f normalOnSurfaceB = Stack.alloc(planeNormal);
planeObj.getWorldTransform(tmpTrans).basis.transform(normalOnSurfaceB);
Vector3f pOnB = Stack.alloc(vtxInPlaneWorld);
resultOut.addContactPoint(normalOnSurfaceB, pOnB, distance);
}
if (ownManifold) {
if (manifoldPtr.getNumContacts() != 0) {
resultOut.refreshContactPoints();
}
}
}