Newer
Older
CactusServer / src / main / java / cactusServer / entities / MovableObject.java
y-ota on 1 Nov 2018 3 KB 修正
package cactusServer.entities;

import org.ntlab.radishforandroidstudio.framework.gameMain.OvergroundActor;
import org.ntlab.radishforandroidstudio.framework.model3D.Model3D;
import org.ntlab.radishforandroidstudio.framework.model3D.Object3D;
import org.ntlab.radishforandroidstudio.framework.model3D.Position3D;
import org.ntlab.radishforandroidstudio.framework.model3D.Quaternion3D;
import org.ntlab.radishforandroidstudio.framework.physics.AngularVelocity3D;
import org.ntlab.radishforandroidstudio.framework.physics.Velocity3D;

import cactusServer.models.ObjectModelManager;
//import framework.model3D.Position3D;
//import framework.physics.AngularVelocity3D;
//import framework.physics.Velocity3D;
import net.arnx.jsonic.JSONHint;

public class MovableObject extends Entity3D {
	private Position3D position;
	private Velocity3D velocity;
	private AngularVelocity3D angularVelocity;
	private Quaternion3D angle;
	private Attribute attribute;
	private Model3D model;
	private Object3D object;

	@JSONHint(ignore = true)
	public static final int UNIQUE_ID_LENGTH = 12;

	@SuppressWarnings("unused")
	private MovableObject() {
		// JSONDecode時の呼び出し用
	}

	public MovableObject(Position3D position, Velocity3D velocity, AngularVelocity3D angularVelocity,
			Quaternion3D angle, Attribute attribute, int modelID) {
		setModel(modelID);
		setObject(model.createObject());
		setPlaceable(new OvergroundActor(object, null));
		setPosition(position);
		setVelocity(velocity);
		setAngularVelocity(angularVelocity);
		setAngle(angle);
		setAttribute(attribute);
	}

	public Position3D getPosition() {
		return position;
	}

	public Velocity3D getVelocity() {
		return velocity;
	}

	public AngularVelocity3D getAngularVelocity() {
		return angularVelocity;
	}

	public Quaternion3D getAngle() {
		return angle;
	}

	public Attribute getAttribute() {
		return attribute;
	}

	public Model3D getModel() {
		return model;
	}

	public void setPosition(Position3D position) {
		this.position = position;
		if (placeable != null)
			((Object3D) (getPlaceable().getBody())).setPosition(position);
	}

	public void setVelocity(Velocity3D velocity) {
		this.velocity = velocity;
	}

	public void setAngularVelocity(AngularVelocity3D angularVelocity) {
		this.angularVelocity = angularVelocity;
	}

	public void setAngle(Quaternion3D angle) {
		this.angle = angle;
		if (placeable != null)
			((Object3D) getPlaceable().getBody()).apply(angle, false);
	}

	public void setAttribute(Attribute attribute) {
		this.attribute = attribute;
	}

	public void setModel(int modelID) {
		this.model = ObjectModelManager.getInstance().getObject(modelID);
	}

	public static class Attribute {
		private boolean movable; // 可動
		private double cof; // 摩擦係数

		@SuppressWarnings("unused")
		private Attribute() {

		}

		public Attribute(boolean moveable, double cof) {
			setMovable(moveable);
			setCof(cof);
		}

		public boolean isMovable() {
			return movable;
		}

		public double getCof() {
			return cof;
		}

		public void setMovable(boolean moveable) {
			this.movable = moveable;
		}

		public void setCof(double cof) {
			this.cof = cof;
		}
	}

	@JSONHint(ignore = true)
	public Object3D getObject() {
		return (Object3D) getPlaceable().getBody();
	}

	public void setObject(Object3D object) {
		this.object = object;
	}

}