Java Code Examples for com.jme3.bullet.PhysicsSpace#AXIS_Z

The following examples show how to use com.jme3.bullet.PhysicsSpace#AXIS_Z . 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: RangeOfMotion.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Instantiate a preset for rotation on a single axis.
 *
 * @param axisIndex which axis: 0→X, 1→Y, 2→Z
 */
public RangeOfMotion(int axisIndex) {
    switch (axisIndex) {
        case PhysicsSpace.AXIS_X:
            maxX = 1f;
            minX = -1f;
            break;
        case PhysicsSpace.AXIS_Y:
            maxY = 1f;
            minY = -1f;
            break;
        case PhysicsSpace.AXIS_Z:
            maxZ = 1f;
            minZ = -1f;
            break;
        default:
            String msg = String.format("axisIndex=%d", axisIndex);
            throw new IllegalArgumentException(msg);
    }
}
 
Example 2
Source File: RangeOfMotion.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Read the maximum rotation around the indexed axis.
 *
 * @param axisIndex which axis: 0→X, 1→Y, 2→Z
 *
 * @return the rotation angle (in radians)
 */
public float getMaxRotation(int axisIndex) {
    float result;
    switch (axisIndex) {
        case PhysicsSpace.AXIS_X:
            result = maxX;
            break;
        case PhysicsSpace.AXIS_Y:
            result = maxY;
            break;
        case PhysicsSpace.AXIS_Z:
            result = maxZ;
            break;
        default:
            String msg = String.format("axisIndex=%d", axisIndex);
            throw new IllegalArgumentException(msg);
    }

    return result;
}
 
Example 3
Source File: RangeOfMotion.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Read the minimum rotation around the indexed axis.
 *
 * @param axisIndex which axis: 0→X, 1→Y, 2→Z
 *
 * @return the rotation angle (in radians)
 */
public float getMinRotation(int axisIndex) {
    float result;
    switch (axisIndex) {
        case PhysicsSpace.AXIS_X:
            result = minX;
            break;
        case PhysicsSpace.AXIS_Y:
            result = minY;
            break;
        case PhysicsSpace.AXIS_Z:
            result = minZ;
            break;
        default:
            String msg = String.format("axisIndex=%d", axisIndex);
            throw new IllegalArgumentException(msg);
    }

    return result;
}
 
Example 4
Source File: ConeCollisionShape.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Creates a new cone collision shape with the given height, radius, and axis.
 *
 * @param radius The radius of the cone in world units.
 * @param height The height of the cone in world units.
 * @param axis The axis towards which the cone faces, see the PhysicsSpace.AXIS_* constants.
 */
public ConeCollisionShape(float radius, float height, int axis) {
    this.radius = radius;
    this.height = height;
    this.axis = axis;
    if (axis < PhysicsSpace.AXIS_X || axis > PhysicsSpace.AXIS_Z) {
        throw new UnsupportedOperationException("axis must be one of the PhysicsSpace.AXIS_* constants!");
    }
    createShape();
}
 
Example 5
Source File: ConeCollisionShape.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected void createShape() {
    if (axis == PhysicsSpace.AXIS_X) {
        cShape = new ConeShapeX(radius, height);
    } else if (axis == PhysicsSpace.AXIS_Y) {
        cShape = new ConeShape(radius, height);
    } else if (axis == PhysicsSpace.AXIS_Z) {
        cShape = new ConeShapeZ(radius, height);
    } else {
        throw new UnsupportedOperationException("Unexpected axis: " + axis);
    }
    cShape.setLocalScaling(Converter.convert(getScale()));
    cShape.setMargin(margin);
}
 
Example 6
Source File: ConeCollisionShape.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
protected void createShape() {
    if (axis == PhysicsSpace.AXIS_X) {
        cShape = new ConeShapeX(radius, height);
    } else if (axis == PhysicsSpace.AXIS_Y) {
        cShape = new ConeShape(radius, height);
    } else if (axis == PhysicsSpace.AXIS_Z) {
        cShape = new ConeShapeZ(radius, height);
    }
    cShape.setLocalScaling(Converter.convert(getScale()));
    cShape.setMargin(margin);
}