* Ported TestMessages to new SM

* Mesh.deepClone() will no longer keep old collision tree

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7050 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
sha..rd 14 years ago
parent b46a09066d
commit de14f87e8b
  1. 2
      engine/src/core/com/jme3/scene/CollisionData.java
  2. 6
      engine/src/core/com/jme3/scene/Mesh.java
  3. 42
      engine/src/test/jme3test/network/TestMessages.java

@ -44,7 +44,7 @@ import com.jme3.math.Matrix4f;
*
* @author Kirill Vainer
*/
public interface CollisionData extends Savable {
public interface CollisionData extends Savable, Cloneable {
public int collideWith(Collidable other,
Matrix4f worldMatrix,
BoundingVolume worldBound,

@ -127,7 +127,11 @@ public class Mesh implements Savable, Cloneable {
try{
Mesh clone = (Mesh) super.clone();
clone.meshBound = meshBound != null ? meshBound.clone() : null;
clone.collisionTree = collisionTree != null ? collisionTree : null;
// TODO: Collision tree cloning
//clone.collisionTree = collisionTree != null ? collisionTree : null;
clone.collisionTree = null; // it will get re-generated in any case
clone.buffers = new IntMap<VertexBuffer>();
for (Entry<VertexBuffer> ent : buffers){
clone.buffers.put(ent.getKey(), ent.getValue().clone());

@ -32,9 +32,11 @@
package jme3test.network;
import com.jme3.network.connection.Client;
import com.jme3.network.connection.Server;
import com.jme3.network.events.MessageAdapter;
import com.jme3.network.Client;
import com.jme3.network.HostedConnection;
import com.jme3.network.MessageListener;
import com.jme3.network.Network;
import com.jme3.network.Server;
import com.jme3.network.message.Message;
import com.jme3.network.serializing.Serializable;
import com.jme3.network.serializing.Serializer;
@ -50,19 +52,19 @@ public class TestMessages {
public static class PongMessage extends Message {
}
private static class PingResponder extends MessageAdapter {
@Override
public void messageReceived(Message message) {
try {
if (message instanceof PingMessage){
System.out.println("Received ping message!");
System.out.println("Sending pong message..");
message.getClient().send(new PongMessage());
}else if (message instanceof PongMessage){
System.out.println("Received pong message!");
}
} catch (IOException ex) {
ex.printStackTrace();
private static class ServerPingResponder implements MessageListener<HostedConnection> {
public void messageReceived(HostedConnection source, com.jme3.network.Message message) {
if (message instanceof PingMessage){
System.out.println("Server: Received ping message!");
source.send(new PongMessage());
}
}
}
private static class ClientPingResponder implements MessageListener<Client> {
public void messageReceived(Client source, com.jme3.network.Message message) {
if (message instanceof PongMessage){
System.out.println("Client: Received pong message!");
}
}
}
@ -71,14 +73,14 @@ public class TestMessages {
Serializer.registerClass(PingMessage.class);
Serializer.registerClass(PongMessage.class);
Server server = new Server(5110, 5110);
Server server = Network.createServer(5110);
server.start();
Client client = new Client("localhost", 5110, 5110);
Client client = Network.connectToServer("192.168.1.101", 5110, 5111);
client.start();
server.addMessageListener(new PingResponder(), PingMessage.class);
client.addMessageListener(new PingResponder(), PongMessage.class);
server.addMessageListener(new ServerPingResponder(), PingMessage.class);
client.addMessageListener(new ClientPingResponder(), PongMessage.class);
Thread.sleep(100);

Loading…
Cancel
Save