本文整理汇总了Java中com.bulletphysics.collision.shapes.ConvexShape类的典型用法代码示例。如果您正苦于以下问题:Java ConvexShape类的具体用法?Java ConvexShape怎么用?Java ConvexShape使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConvexShape类属于com.bulletphysics.collision.shapes包,在下文中一共展示了ConvexShape类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: read
import com.bulletphysics.collision.shapes.ConvexShape; //导入依赖的package包/类
@Override
public void read(JmeImporter e) throws IOException {
super.read(e);
InputCapsule capsule = e.getCapsule(this);
stepHeight = capsule.readFloat("stepHeight", 1.0f);
buildObject();
character = new KinematicCharacterController(gObject, (ConvexShape) collisionShape.getCShape(), stepHeight);
setGravity(capsule.readFloat("gravity", 9.8f * 3));
setMaxSlope(capsule.readFloat("maxSlope", 1.0f));
setFallSpeed(capsule.readFloat("fallSpeed", 55.0f));
setJumpSpeed(capsule.readFloat("jumpSpeed", 10.0f));
setUpAxis(capsule.readInt("upAxis", 1));
setCcdMotionThreshold(capsule.readFloat("ccdMotionThreshold", 0));
setCcdSweptSphereRadius(capsule.readFloat("ccdSweptSphereRadius", 0));
setPhysicsLocation((Vector3f) capsule.readSavable("physicsLocation", new Vector3f()));
}
示例2: calcPenDepth
import com.bulletphysics.collision.shapes.ConvexShape; //导入依赖的package包/类
public boolean calcPenDepth(SimplexSolverInterface simplexSolver,
ConvexShape pConvexA, ConvexShape pConvexB,
Transform transformA, Transform transformB,
Vector3 v, Vector3 wWitnessOnA, Vector3 wWitnessOnB,
IDebugDraw debugDraw/*, btStackAlloc* stackAlloc*/)
{
float radialmargin = 0f;
// JAVA NOTE: 2.70b1: update when GjkEpaSolver2 is ported
GjkEpaSolver.Results results = new GjkEpaSolver.Results();
if (gjkEpaSolver.collide(pConvexA, transformA,
pConvexB, transformB,
radialmargin/*,stackAlloc*/, results)) {
//debugDraw->drawLine(results.witnesses[1],results.witnesses[1]+results.normal,btVector3(255,0,0));
//resultOut->addContactPoint(results.normal,results.witnesses[1],-results.depth);
wWitnessOnA.set(results.witnesses[0]);
wWitnessOnB.set(results.witnesses[1]);
return true;
}
return false;
}
示例3: KinematicCharacterController
import com.bulletphysics.collision.shapes.ConvexShape; //导入依赖的package包/类
public KinematicCharacterController (PairCachingGhostObject ghostObject, ConvexShape convexShape, float stepHeight,
int upAxis) {
this.upAxis = upAxis;
this.addedMargin = 0.02f;
this.walkDirection.set(0, 0, 0);
this.useGhostObjectSweepTest = true;
this.ghostObject = ghostObject;
this.stepHeight = stepHeight;
this.turnAngle = 0.0f;
this.convexShape = convexShape;
this.useWalkDirection = true;
this.velocityTimeInterval = 0.0f;
this.verticalVelocity = 0.0f;
this.verticalOffset = 0.0f;
this.gravity = 9.8f; // 1G acceleration
this.fallSpeed = 55.0f; // Terminal velocity of a sky diver in m/s.
this.jumpSpeed = 10.0f; // ?
this.wasOnGround = false;
setMaxSlope((float)((50.0f / 180.0f) * Math.PI));
}
示例4: calcPenDepth
import com.bulletphysics.collision.shapes.ConvexShape; //导入依赖的package包/类
public boolean calcPenDepth(SimplexSolverInterface simplexSolver,
ConvexShape pConvexA, ConvexShape pConvexB,
Transform transformA, Transform transformB,
Vector3f v, Vector3f wWitnessOnA, Vector3f wWitnessOnB,
IDebugDraw debugDraw/*, btStackAlloc* stackAlloc*/)
{
float radialmargin = 0f;
// JAVA NOTE: 2.70b1: update when GjkEpaSolver2 is ported
GjkEpaSolver.Results results = new GjkEpaSolver.Results();
if (gjkEpaSolver.collide(pConvexA, transformA,
pConvexB, transformB,
radialmargin/*,stackAlloc*/, results)) {
//debugDraw->drawLine(results.witnesses[1],results.witnesses[1]+results.normal,btVector3(255,0,0));
//resultOut->addContactPoint(results.normal,results.witnesses[1],-results.depth);
wWitnessOnA.set(results.witnesses[0]);
wWitnessOnB.set(results.witnesses[1]);
return true;
}
return false;
}
示例5: init
import com.bulletphysics.collision.shapes.ConvexShape; //导入依赖的package包/类
public void init(/*StackAlloc psa,*/
Matrix3f wrot0, Vector3f pos0, ConvexShape shape0,
Matrix3f wrot1, Vector3f pos1, ConvexShape shape1,
float pmargin) {
pushStack();
wrotations[0].set(wrot0);
positions[0].set(pos0);
shapes[0] = shape0;
wrotations[1].set(wrot1);
positions[1].set(pos1);
shapes[1] = shape1;
//sa =psa;
//sablock =sa->beginBlock();
margin = pmargin;
failed = false;
}
示例6: KinematicCharacterController
import com.bulletphysics.collision.shapes.ConvexShape; //导入依赖的package包/类
public KinematicCharacterController(PairCachingGhostObject ghostObject, ConvexShape convexShape, float stepHeight, int upAxis) {
this.upAxis = upAxis;
this.addedMargin = 0.02f;
this.walkDirection.set(0, 0, 0);
this.useGhostObjectSweepTest = true;
this.ghostObject = ghostObject;
this.stepHeight = stepHeight;
this.turnAngle = 0.0f;
this.convexShape = convexShape;
this.useWalkDirection = true;
this.velocityTimeInterval = 0.0f;
this.verticalVelocity = 0.0f;
this.verticalOffset = 0.0f;
this.gravity = 9.8f; // 1G acceleration
this.fallSpeed = 55.0f; // Terminal velocity of a sky diver in m/s.
this.jumpSpeed = 10.0f; // ?
this.wasOnGround = false;
setMaxSlope((float)((50.0f/180.0f) * Math.PI));
}
示例7: calcPenDepth
import com.bulletphysics.collision.shapes.ConvexShape; //导入依赖的package包/类
public boolean calcPenDepth(SimplexSolverInterface simplexSolver,
ConvexShape pConvexA, ConvexShape pConvexB,
Transform transformA, Transform transformB,
Vector3f v, Vector3f wWitnessOnA, Vector3f wWitnessOnB,
IDebugDraw debugDraw/*, btStackAlloc* stackAlloc*/)
{
float radialmargin = 0f;
// JAVA NOTE: 2.70b1: update when GjkEpaSolver2 is ported
GjkEpaSolver.Results results = new GjkEpaSolver.Results();
if (GjkEpaSolver.collide(pConvexA, transformA,
pConvexB, transformB,
radialmargin/*,stackAlloc*/, results)) {
//debugDraw->drawLine(results.witnesses[1],results.witnesses[1]+results.normal,btVector3(255,0,0));
//resultOut->addContactPoint(results.normal,results.witnesses[1],-results.depth);
wWitnessOnA.set(results.witnesses[0]);
wWitnessOnB.set(results.witnesses[1]);
return true;
}
return false;
}
示例8: createRigidBody
import com.bulletphysics.collision.shapes.ConvexShape; //导入依赖的package包/类
private void createRigidBody(EntityRef entity) {
LocationComponent location = entity.getComponent(LocationComponent.class);
RigidBodyComponent rigidBody = entity.getComponent(RigidBodyComponent.class);
ConvexShape shape = getShapeFor(entity);
if (shape != null) {
float scale = location.getWorldScale();
shape.setLocalScaling(new Vector3f(scale, scale, scale));
Vector3f fallInertia = new Vector3f();
shape.calculateLocalInertia(rigidBody.mass, fallInertia);
RigidBodyConstructionInfo info = new RigidBodyConstructionInfo(rigidBody.mass, new EntityMotionState(entity), shape, fallInertia);
RigidBody collider = new RigidBody(info);
collider.setUserPointer(entity);
updateKinematicSettings(rigidBody, collider);
RigidBody oldBody = entityRigidBodies.put(entity, collider);
physics.addRigidBody(collider, Lists.<CollisionGroup>newArrayList(rigidBody.collisionGroup), rigidBody.collidesWith);
if (oldBody != null) {
physics.removeRigidBody(oldBody);
}
}
}
示例9: PhysicsCharacter
import com.bulletphysics.collision.shapes.ConvexShape; //导入依赖的package包/类
/**
* @param shape The CollisionShape (no Mesh or CompoundCollisionShapes)
* @param stepHeight The quantization size for vertical movement
*/
public PhysicsCharacter(CollisionShape shape, float stepHeight) {
this.collisionShape = shape;
if (!(shape.getCShape() instanceof ConvexShape)) {
throw (new UnsupportedOperationException("Kinematic character nodes cannot have mesh collision shapes"));
}
this.stepHeight = stepHeight;
buildObject();
}
示例10: setCollisionShape
import com.bulletphysics.collision.shapes.ConvexShape; //导入依赖的package包/类
@Override
public void setCollisionShape(CollisionShape collisionShape) {
if (!(collisionShape.getCShape() instanceof ConvexShape)) {
throw (new UnsupportedOperationException("Kinematic character nodes cannot have mesh collision shapes"));
}
super.setCollisionShape(collisionShape);
if (gObject == null) {
buildObject();
}else{
gObject.setCollisionShape(collisionShape.getCShape());
}
}
示例11: sweepTest
import com.bulletphysics.collision.shapes.ConvexShape; //导入依赖的package包/类
/**
* Performs a sweep collision test and returns the results as a list of PhysicsSweepTestResults<br/>
* You have to use different Transforms for start and end (at least distance > 0.4f).
* SweepTest will not see a collision if it starts INSIDE an object and is moving AWAY from its center.
*/
public List<PhysicsSweepTestResult> sweepTest(CollisionShape shape, Transform start, Transform end) {
List<PhysicsSweepTestResult> results = new LinkedList<PhysicsSweepTestResult>();
if (!(shape.getCShape() instanceof ConvexShape)) {
Logger.getLogger(PhysicsSpace.class.getName()).log(Level.WARNING, "Trying to sweep test with incompatible mesh shape!");
return results;
}
dynamicsWorld.convexSweepTest((ConvexShape) shape.getCShape(), Converter.convert(start, sweepTrans1), Converter.convert(end, sweepTrans2), new InternalSweepListener(results));
return results;
}
示例12: TriangleConvexcastCallback
import com.bulletphysics.collision.shapes.ConvexShape; //导入依赖的package包/类
public TriangleConvexcastCallback (ConvexShape convexShape, Transform convexShapeFrom, Transform convexShapeTo,
Transform triangleToWorld, float triangleCollisionMargin) {
this.convexShape = convexShape;
this.convexShapeFrom.set(convexShapeFrom);
this.convexShapeTo.set(convexShapeTo);
this.triangleToWorld.set(triangleToWorld);
this.hitFraction = 1f;
this.triangleCollisionMargin = triangleCollisionMargin;
}
示例13: init
import com.bulletphysics.collision.shapes.ConvexShape; //导入依赖的package包/类
public void init (ConvexShape objectA, ConvexShape objectB, SimplexSolverInterface simplexSolver,
ConvexPenetrationDepthSolver penetrationDepthSolver) {
this.cachedSeparatingAxis.set(0f, 0f, 1f);
this.ignoreMargin = false;
this.lastUsedMethod = -1;
this.catchDegeneracies = 1;
this.penetrationDepthSolver = penetrationDepthSolver;
this.simplexSolver = simplexSolver;
this.minkowskiA = objectA;
this.minkowskiB = objectB;
}
示例14: init
import com.bulletphysics.collision.shapes.ConvexShape; //导入依赖的package包/类
public void init (/* StackAlloc psa, */
Matrix3 wrot0, Vector3 pos0, ConvexShape shape0, Matrix3 wrot1, Vector3 pos1, ConvexShape shape1, float pmargin) {
pushStack();
wrotations[0].set(wrot0);
positions[0].set(pos0);
shapes[0] = shape0;
wrotations[1].set(wrot1);
positions[1].set(pos1);
shapes[1] = shape1;
// sa =psa;
// sablock =sa->beginBlock();
margin = pmargin;
failed = false;
}
示例15: BridgeTriangleConvexcastCallback
import com.bulletphysics.collision.shapes.ConvexShape; //导入依赖的package包/类
public BridgeTriangleConvexcastCallback (ConvexShape castShape, Transform from, Transform to,
ConvexResultCallback resultCallback, CollisionObject collisionObject, TriangleMeshShape triangleMesh,
Transform triangleToWorld) {
super(castShape, from, to, triangleToWorld, triangleMesh.getMargin());
this.resultCallback = resultCallback;
this.collisionObject = collisionObject;
this.triangleMesh = triangleMesh;
}