• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * To change this template, choose Tools | Templates
3  * and open the template in the editor.
4  */
5 
6 package com.jme3.bullet.collision.shapes;
7 
8 import com.bulletphysics.collision.shapes.StaticPlaneShape;
9 import com.jme3.bullet.util.Converter;
10 import com.jme3.export.InputCapsule;
11 import com.jme3.export.JmeExporter;
12 import com.jme3.export.JmeImporter;
13 import com.jme3.export.OutputCapsule;
14 import com.jme3.math.Plane;
15 import java.io.IOException;
16 
17 /**
18  *
19  * @author normenhansen
20  */
21 public class PlaneCollisionShape extends CollisionShape{
22     private Plane plane;
23 
PlaneCollisionShape()24     public PlaneCollisionShape() {
25     }
26 
27     /**
28      * Creates a plane Collision shape
29      * @param plane the plane that defines the shape
30      */
PlaneCollisionShape(Plane plane)31     public PlaneCollisionShape(Plane plane) {
32         this.plane = plane;
33         createShape();
34     }
35 
getPlane()36     public final Plane getPlane() {
37         return plane;
38     }
39 
write(JmeExporter ex)40     public void write(JmeExporter ex) throws IOException {
41         super.write(ex);
42         OutputCapsule capsule = ex.getCapsule(this);
43         capsule.write(plane, "collisionPlane", new Plane());
44     }
45 
read(JmeImporter im)46     public void read(JmeImporter im) throws IOException {
47         super.read(im);
48         InputCapsule capsule = im.getCapsule(this);
49         plane = (Plane) capsule.readSavable("collisionPlane", new Plane());
50         createShape();
51     }
52 
createShape()53     protected void createShape() {
54         cShape = new StaticPlaneShape(Converter.convert(plane.getNormal()),plane.getConstant());
55         cShape.setLocalScaling(Converter.convert(getScale()));
56         cShape.setMargin(margin);
57     }
58 
59 }
60