Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package cz.ascaria.bullet.objects;
- import com.jme3.bullet.PhysicsSpace;
- import com.jme3.bullet.collision.shapes.CollisionShape;
- import com.jme3.bullet.objects.PhysicsRigidBody;
- import com.jme3.math.Vector3f;
- import cz.ascaria.borekboritel.dynamics.spaceship.SpaceShip;
- import java.util.ArrayList;
- /**
- *
- * @author Ascaria Quynn
- */
- public class PhysicsSpaceShip extends PhysicsRigidBody {
- protected SpaceShip spaceShip;
- protected ArrayList<SpaceShipGun> guns = new ArrayList<SpaceShipGun>();
- protected PhysicsSpace physicsSpace = null;
- protected float movementPower = 1f;
- protected float rotationPower = 1f;
- protected float angDamp = 0f;
- public PhysicsSpaceShip() {
- }
- public PhysicsSpaceShip(CollisionShape shape) {
- super(shape);
- }
- public PhysicsSpaceShip(CollisionShape shape, float mass) {
- super(shape, mass);
- }
- public void setMovementPower(float movementPower) {
- this.movementPower = movementPower;
- }
- public void setRotationPower(float rotationPower) {
- this.rotationPower = rotationPower;
- }
- public void setRotationStabilityControl(float damping) {
- angDamp = damping;
- }
- public void setEnabledRotationStabilityControl(boolean enabled) {
- setAngularDamping(enabled ? angDamp : 0f);
- }
- public boolean isEnabledRotationStabilityControl() {
- return getAngularDamping() > 0f;
- }
- public SpaceShipGun addGun(Vector3f location) {
- SpaceShipGun gun = new SpaceShipGun(location);
- guns.add(gun);
- return gun;
- }
- /**
- * Used internally, creates the actual space ship constraint.
- * when space ship is added to physics space
- */
- public void createSpaceShip(PhysicsSpace space) {
- physicsSpace = space;
- if (space == null) {
- return;
- }
- spaceShip = new SpaceShip();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment