Sending scene graph as datagram

Now, this might not be so horrble as it sounds. I'm working with a game with completely interactive environment. It's made up of blocks which can be moved and manipulated, from a jump-n-run/2D perspective (though drawn in 3D). So I want the server to caclutate which data is relevant to show to the player and then send it as a Node, which the client simply draw in its render function. I've tried to send a LinkedList<String> without any problems, but didn't get socket.writeObject(scene) to work. Here's the relevant code from the server thread (looped):

                scene = new Node("Scene graph");


                Vector3f v = new Vector3f(1, 0, 0);

                Box b = new Box("1", v, 20, 10, 10);

                b.setLocalTranslation(new Vector3f(0, 0, -40));

                b.setModelBound(new BoundingBox());




                scene.updateGeometricState(0.0f, true);



And from the clients render():

            scene = (Node) receive.readObject();



Obviously I missed something. Any ideas?

If you want to do it like this, you should use the write() method of Node, which serializes the Node properly before sending and then use the read() on the other side.

I'd suggest using JGN and creating the nodes on the client side from construction data.

Okey, so documentation for Node.write() seems poor, as is the case for JMEExporter, which is required by write(). I any way, I realized I don't need this functionality. New routin will be like this (if anyone is interrested):

Server will send a LinkedList<Drawables> (using UDP writeObject()) with game objects that all implement interface Drawable. This interface provide function generateSpatial() which the client uses to generate the scene graph. So, pretty much as Normens suggestion. :slight_smile:

Thanks for the tip, anyway!