From 7c77fc404b61bce99042153df20b65f60eade4b4 Mon Sep 17 00:00:00 2001 From: "PSp..om" Date: Sat, 24 Sep 2011 09:14:34 +0000 Subject: [PATCH] Removing deprecated networking code. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8284 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../test/jme3test/network/sync/BoxEntity.java | 47 -------- .../network/sync/ClientBoxEntity.java | 46 ------- .../test/jme3test/network/sync/TestSync.java | 113 ------------------ 3 files changed, 206 deletions(-) delete mode 100644 engine/src/test/jme3test/network/sync/BoxEntity.java delete mode 100644 engine/src/test/jme3test/network/sync/ClientBoxEntity.java delete mode 100644 engine/src/test/jme3test/network/sync/TestSync.java diff --git a/engine/src/test/jme3test/network/sync/BoxEntity.java b/engine/src/test/jme3test/network/sync/BoxEntity.java deleted file mode 100644 index 969c93e5b..000000000 --- a/engine/src/test/jme3test/network/sync/BoxEntity.java +++ /dev/null @@ -1,47 +0,0 @@ -package jme3test.network.sync; - -import com.jme3.asset.AssetManager; -import com.jme3.material.Material; -import com.jme3.math.ColorRGBA; -import com.jme3.math.Vector3f; -import com.jme3.network.sync.Sync; -import com.jme3.network.sync.SyncEntity; -import com.jme3.scene.Geometry; -import com.jme3.scene.shape.Box; - -public class BoxEntity extends Geometry implements SyncEntity { - - protected @Sync Vector3f pos; - protected @Sync Vector3f vel; - - public BoxEntity(AssetManager assetManager, ColorRGBA color){ - super("Box", new Box(1,1,1)); - setMaterial(new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md")); - getMaterial().setColor("Color", color); - } - - public void setPosVel(Vector3f pos, Vector3f vel){ - setLocalTranslation(pos); - this.pos = pos; - this.vel = vel; - } - - public void onRemoteCreate() { - } - - public void onRemoteUpdate(float latencyDelta) { - } - - public void onRemoteDelete() { - removeFromParent(); - } - - public void onLocalUpdate() { - } - - public void interpolate(float blendAmount) { - } - - public void extrapolate(float tpf) { - } -} diff --git a/engine/src/test/jme3test/network/sync/ClientBoxEntity.java b/engine/src/test/jme3test/network/sync/ClientBoxEntity.java deleted file mode 100644 index 1480884ab..000000000 --- a/engine/src/test/jme3test/network/sync/ClientBoxEntity.java +++ /dev/null @@ -1,46 +0,0 @@ -package jme3test.network.sync; - -import com.jme3.asset.AssetManager; -import com.jme3.math.ColorRGBA; -import com.jme3.math.Vector3f; - -public class ClientBoxEntity extends BoxEntity { - - private Vector3f prevPos = new Vector3f(); - - public ClientBoxEntity(AssetManager assetManager, ColorRGBA color){ - super(assetManager, color); - } - - @Override - public void onRemoteCreate() { - System.out.println("ClientBoxEntity created"); - } - - @Override - public void onRemoteDelete() { - System.out.println("ClientBoxEntity deleted"); - } - - @Override - public void onRemoteUpdate(float latencyDelta) { - prevPos.set(getLocalTranslation()); - pos.addLocal(vel.mult(latencyDelta)); - } - - @Override - public void interpolate(float blendAmount) { - if (pos != null){ - getLocalTranslation().interpolate(prevPos, pos, blendAmount); - setLocalTranslation(getLocalTranslation()); - } - } - - @Override - public void extrapolate(float tpf) { - if (pos != null){ - pos.addLocal(vel.mult(tpf)); - setLocalTranslation(pos); - } - } - } \ No newline at end of file diff --git a/engine/src/test/jme3test/network/sync/TestSync.java b/engine/src/test/jme3test/network/sync/TestSync.java deleted file mode 100644 index 626d862c0..000000000 --- a/engine/src/test/jme3test/network/sync/TestSync.java +++ /dev/null @@ -1,113 +0,0 @@ -package jme3test.network.sync; - -import com.jme3.app.SimpleApplication; -import com.jme3.effect.shapes.EmitterSphereShape; -import com.jme3.math.ColorRGBA; -import com.jme3.math.Vector3f; -import com.jme3.network.connection.Client; -import com.jme3.network.connection.Server; -import com.jme3.network.serializing.Serializer; -import com.jme3.network.sync.ClientSyncService; -import com.jme3.network.sync.EntityFactory; -import com.jme3.network.sync.ServerSyncService; -import com.jme3.network.sync.SyncEntity; -import com.jme3.network.sync.SyncMessage; -import java.io.IOException; - -public class TestSync extends SimpleApplication implements EntityFactory { - - // Client Variables - private Client client; - private ClientSyncService clientSyncServ; - - // Server Variables - private Server server; - private ServerSyncService serverSyncServ; - private BoxEntity serverBox; - - private Vector3f targetPos = new Vector3f(); - private float boxSpeed = 3f; - private EmitterSphereShape randomPosSphere = new EmitterSphereShape(Vector3f.ZERO, 5); - - public static void main(String[] args){ - TestSync app = new TestSync(); - app.start(); - } - - public void simpleInitApp(){ - Serializer.registerClass(SyncMessage.class); - - // ----- Start Server ------- - try { - server = new Server(5110, 5110); - server.start(); - } catch (IOException ex) { - ex.printStackTrace(); - } - - // Create SyncService for server - serverSyncServ = server.getService(ServerSyncService.class); - // Create server box entity (red) - serverBox = new BoxEntity(assetManager, ColorRGBA.Red); - serverSyncServ.addNpc(serverBox); - rootNode.attachChild(serverBox); - - // Enable 10% packet drop rate and 200 ms latency - serverSyncServ.setNetworkSimulationParams(0.1f, 200); - - - // ------ Start Client ------- - try { - client = new Client("localhost", 5110, 5110); - client.start(); - } catch (IOException ex) { - ex.printStackTrace(); - } - - clientSyncServ = client.getService(ClientSyncService.class); - clientSyncServ.setEntityFactory(this); - } - - /** - * Create a new entity (for client) - * @param entityType - * @return - */ - public SyncEntity createEntity(Class entityType) { - BoxEntity clientBox = new ClientBoxEntity(assetManager, ColorRGBA.Green); - rootNode.attachChild(clientBox); - return clientBox; - } - - @Override - public void simpleUpdate(float tpf){ - // --------- Update Client Sync --------- - clientSyncServ.update(tpf); - - // --------- Update Server Sync --------- - // if needed determine next box position - if (serverBox.getLocalTranslation().distance(targetPos) < 0.1f){ - randomPosSphere.getRandomPoint(targetPos); - }else{ - Vector3f velocity = new Vector3f(targetPos); - velocity.subtractLocal(serverBox.getLocalTranslation()); - velocity.normalizeLocal().multLocal(boxSpeed); - - Vector3f newPos = serverBox.getLocalTranslation().clone(); - newPos.addLocal(velocity.mult(tpf)); - serverBox.setPosVel(newPos, velocity); - } - - serverSyncServ.update(tpf); - } - - @Override - public void destroy(){ - super.destroy(); - try { - client.disconnect(); - } catch (IOException ex) { - ex.printStackTrace(); - } - } -}