Java Code Examples for com.jme3.bullet.collision.shapes.CollisionShape#getCShape()

The following examples show how to use com.jme3.bullet.collision.shapes.CollisionShape#getCShape() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PhysicsRigidBody.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void setCollisionShape(CollisionShape collisionShape) {
    super.setCollisionShape(collisionShape);
    if(collisionShape instanceof MeshCollisionShape && mass!=0){
        throw new IllegalStateException("Dynamic rigidbody can not have mesh collision shape!");
    }
    if (rBody == null) {
        rebuildRigidBody();
    } else {
        collisionShape.calculateLocalInertia(mass, localInertia);
        constructionInfo.collisionShape = collisionShape.getCShape();
        rBody.setCollisionShape(collisionShape.getCShape());
    }
}
 
Example 2
Source File: PhysicsCharacter.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * @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();
}
 
Example 3
Source File: PhysicsCharacter.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@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());
    }
}
 
Example 4
Source File: PhysicsSpace.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * 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 greater than 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.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;

}
 
Example 5
Source File: PhysicsSpace.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * 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 greater than 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) {
    results.clear();
    if (!(shape.getCShape() instanceof ConvexShape)) {
        logger.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;
}
 
Example 6
Source File: PhysicsRigidBody.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void setCollisionShape(CollisionShape collisionShape) {
    super.setCollisionShape(collisionShape);
    if(collisionShape instanceof MeshCollisionShape && mass!=0){
        throw new IllegalStateException("Dynamic rigidbody can not have mesh collision shape!");
    }
    if (rBody == null) {
        rebuildRigidBody();
    } else {
        collisionShape.calculateLocalInertia(mass, localInertia);
        constructionInfo.collisionShape = collisionShape.getCShape();
        rBody.setCollisionShape(collisionShape.getCShape());
    }
}
 
Example 7
Source File: PhysicsCharacter.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * @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();
}
 
Example 8
Source File: PhysicsCharacter.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@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());
    }
}
 
Example 9
Source File: PhysicsSpace.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * 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;

}
 
Example 10
Source File: PhysicsSpace.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * 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) {
    results.clear();
    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;
}