From d3b71c17fb5bac19b71ca6a486291bb65c55bec6 Mon Sep 17 00:00:00 2001 From: Jesse Morgan Date: Mon, 7 Mar 2011 22:37:17 +0000 Subject: The moving side code is almost right... --- src/tesseract/objects/PhysicalObject.java | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/tesseract/objects/PhysicalObject.java') 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. @@ -129,6 +130,16 @@ public class PhysicalObject extends CollidableObject { position.x = -x; } + /** + * 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. */ -- cgit v1.2.3