summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Morgan <jesse@jesterpm.net>2011-03-07 22:37:17 +0000
committerJesse Morgan <jesse@jesterpm.net>2011-03-07 22:37:17 +0000
commitd3b71c17fb5bac19b71ca6a486291bb65c55bec6 (patch)
treeb6353f2ea82962f6c5163330c3806d0d039657e8
parent78d5996f09a23b66eb10fa2f2b94dd41967f3d5d (diff)
The moving side code is almost right...
-rw-r--r--src/common/Peer.java7
-rw-r--r--src/tesseract/World.java3
-rw-r--r--src/tesseract/objects/PhysicalObject.java11
3 files changed, 19 insertions, 2 deletions
diff --git a/src/common/Peer.java b/src/common/Peer.java
index 2ba0d83..9fe4560 100644
--- a/src/common/Peer.java
+++ b/src/common/Peer.java
@@ -353,6 +353,13 @@ public class Peer extends Observable {
public int getPeerSize() {
return peers.size();
}
+
+ /**
+ * Get the PeerInformation.
+ */
+ public PeerInformation getPeerInformation() {
+ return this.myInfo;
+ }
/**
* A method that sends a CollidableObject to all
diff --git a/src/tesseract/World.java b/src/tesseract/World.java
index 648f537..da385e1 100644
--- a/src/tesseract/World.java
+++ b/src/tesseract/World.java
@@ -279,8 +279,7 @@ public class World implements Observer {
PeerInformation peer = myPeer.getPeerInDirection(o.getVelocity().x, -o.getVelocity().z);
if (peer != null) {
- o.switchX();
- o.switchZ();
+ o.rotateForTransmission(myPeer.getPeerInformation(), peer);
myPeer.sendPayloadToPeer(peer, o);
o.detach();
myObjects.remove(o);
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() {