Guest User

Untitled

a guest
May 7th, 2014
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.03 KB | None | 0 0
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5. package cz.ascaria.bullet.objects;
  6.  
  7. import com.jme3.bullet.PhysicsSpace;
  8. import com.jme3.bullet.collision.shapes.CollisionShape;
  9. import com.jme3.bullet.objects.PhysicsRigidBody;
  10. import com.jme3.math.Vector3f;
  11. import cz.ascaria.borekboritel.dynamics.spaceship.SpaceShip;
  12. import java.util.ArrayList;
  13.  
  14. /**
  15.  *
  16.  * @author Ascaria Quynn
  17.  */
  18. public class PhysicsSpaceShip extends PhysicsRigidBody {
  19.  
  20.     protected SpaceShip spaceShip;
  21.     protected ArrayList<SpaceShipGun> guns = new ArrayList<SpaceShipGun>();
  22.     protected PhysicsSpace physicsSpace = null;
  23.  
  24.     protected float movementPower = 1f;
  25.     protected float rotationPower = 1f;
  26.  
  27.     protected float angDamp = 0f;
  28.  
  29.     public PhysicsSpaceShip() {
  30.     }
  31.  
  32.     public PhysicsSpaceShip(CollisionShape shape) {
  33.         super(shape);
  34.     }
  35.  
  36.     public PhysicsSpaceShip(CollisionShape shape, float mass) {
  37.         super(shape, mass);
  38.     }
  39.  
  40.     public void setMovementPower(float movementPower) {
  41.         this.movementPower = movementPower;
  42.     }
  43.  
  44.     public void setRotationPower(float rotationPower) {
  45.         this.rotationPower = rotationPower;
  46.     }
  47.  
  48.     public void setRotationStabilityControl(float damping) {
  49.         angDamp = damping;
  50.     }
  51.  
  52.     public void setEnabledRotationStabilityControl(boolean enabled) {
  53.         setAngularDamping(enabled ? angDamp : 0f);
  54.     }
  55.  
  56.     public boolean isEnabledRotationStabilityControl() {
  57.         return getAngularDamping() > 0f;
  58.     }
  59.  
  60.     public SpaceShipGun addGun(Vector3f location) {
  61.         SpaceShipGun gun = new SpaceShipGun(location);
  62.         guns.add(gun);
  63.         return gun;
  64.     }
  65.  
  66.     /**
  67.      * Used internally, creates the actual space ship constraint.
  68.      * when space ship is added to physics space
  69.      */
  70.     public void createSpaceShip(PhysicsSpace space) {
  71.         physicsSpace = space;
  72.         if (space == null) {
  73.             return;
  74.         }
  75.         spaceShip = new SpaceShip();
  76.     }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment