Home | History | Annotate | Download | only in shapes
      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.jme3.export.InputCapsule;
      9 import com.jme3.export.JmeExporter;
     10 import com.jme3.export.JmeImporter;
     11 import com.jme3.export.OutputCapsule;
     12 import com.jme3.math.Plane;
     13 import com.jme3.math.Vector3f;
     14 import java.io.IOException;
     15 import java.util.logging.Level;
     16 import java.util.logging.Logger;
     17 
     18 /**
     19  *
     20  * @author normenhansen
     21  */
     22 public class PlaneCollisionShape extends CollisionShape{
     23     private Plane plane;
     24 
     25     public PlaneCollisionShape() {
     26     }
     27 
     28     /**
     29      * Creates a plane Collision shape
     30      * @param plane the plane that defines the shape
     31      */
     32     public PlaneCollisionShape(Plane plane) {
     33         this.plane = plane;
     34         createShape();
     35     }
     36 
     37     public final Plane getPlane() {
     38         return plane;
     39     }
     40 
     41     public void write(JmeExporter ex) throws IOException {
     42         super.write(ex);
     43         OutputCapsule capsule = ex.getCapsule(this);
     44         capsule.write(plane, "collisionPlane", new Plane());
     45     }
     46 
     47     public void read(JmeImporter im) throws IOException {
     48         super.read(im);
     49         InputCapsule capsule = im.getCapsule(this);
     50         plane = (Plane) capsule.readSavable("collisionPlane", new Plane());
     51         createShape();
     52     }
     53 
     54     protected void createShape() {
     55         objectId = createShape(plane.getNormal(), plane.getConstant());
     56         Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Created Shape {0}", Long.toHexString(objectId));
     57 //        objectId = new StaticPlaneShape(Converter.convert(plane.getNormal()),plane.getConstant());
     58 //        objectId.setLocalScaling(Converter.convert(getScale()));
     59 //        objectId.setMargin(margin);
     60         setScale(scale);
     61         setMargin(margin);
     62     }
     63 
     64     private native long createShape(Vector3f normal, float constant);
     65 
     66 }
     67