summaryrefslogtreecommitdiff
path: root/src/tesseract/objects/PhysicalObject.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/tesseract/objects/PhysicalObject.java')
-rw-r--r--src/tesseract/objects/PhysicalObject.java11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/tesseract/objects/PhysicalObject.java b/src/tesseract/objects/PhysicalObject.java
index 34cbec9..96c9bfa 100644
--- a/src/tesseract/objects/PhysicalObject.java
+++ b/src/tesseract/objects/PhysicalObject.java
@@ -11,6 +11,7 @@ import javax.vecmath.Vector3f;
import com.sun.j3d.utils.geometry.Primitive;
import common.CollidableObject;
+import common.PeerInformation;
/**
* This class is the parent of all objects in the world.
@@ -130,6 +131,16 @@ public class PhysicalObject extends CollidableObject {
}
/**
+ * Move the object to the correct side of the new world.
+ */
+ public void rotateForTransmission(PeerInformation a, PeerInformation b) {
+ double angle = /*Math.atan(-velocity.z / velocity.x) + */ Math.PI + Math.atan((b.location.getY() - a.location.getY()) / (b.location.getX() - a.location.getX()));
+
+ position.x = (float) (position.x * Math.cos(angle) - position.z * Math.sin(angle));
+ position.z = (float) (position.z * Math.cos(angle) + position.x * Math.sin(angle));
+ }
+
+ /**
* @return The orientation of the object.
*/
public Quat4f getOrientation() {