|
@@ -43,6 +43,7 @@ import com.jme3.export.OutputCapsule;
|
|
|
import java.io.IOException;
|
|
|
|
|
|
/**
|
|
|
+ * Cone collision shape represents a 3D cone with a radius, height, and axis (X, Y or Z).
|
|
|
*
|
|
|
* @author normenhansen
|
|
|
*/
|
|
@@ -52,19 +53,38 @@ public class ConeCollisionShape extends CollisionShape {
|
|
|
protected float height;
|
|
|
protected int axis;
|
|
|
|
|
|
+ /**
|
|
|
+ * Serialization only, do not use.
|
|
|
+ */
|
|
|
public ConeCollisionShape() {
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 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 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 = radius;
|
|
|
+ this.height = height;
|
|
|
this.axis = axis;
|
|
|
+ if (axis < PhysicsSpace.AXIS_X || axis > PhysicsSpace.AXIS_Z) {
|
|
|
+ throw new InvalidArgumentException("axis must be one of the PhysicsSpace.AXIS_* constants!");
|
|
|
+ }
|
|
|
createShape();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Creates a new cone collision shape with the given height, radius and default Y axis.
|
|
|
+ *
|
|
|
+ * @param radius The radius of the cone in world units.
|
|
|
+ * @param height The height of the cone in world units.
|
|
|
+ */
|
|
|
public ConeCollisionShape(float radius, float height) {
|
|
|
this.radius = radius;
|
|
|
- this.height = radius;
|
|
|
+ this.height = height;
|
|
|
this.axis = PhysicsSpace.AXIS_Y;
|
|
|
createShape();
|
|
|
}
|
|
@@ -72,6 +92,14 @@ public class ConeCollisionShape extends CollisionShape {
|
|
|
public float getRadius() {
|
|
|
return radius;
|
|
|
}
|
|
|
+
|
|
|
+ public float getHeight() {
|
|
|
+ return height;
|
|
|
+ }
|
|
|
+
|
|
|
+ public int getAxis() {
|
|
|
+ return axis;
|
|
|
+ }
|
|
|
|
|
|
public void write(JmeExporter ex) throws IOException {
|
|
|
super.write(ex);
|
|
@@ -97,6 +125,8 @@ public class ConeCollisionShape extends CollisionShape {
|
|
|
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);
|