An easy way to do it, which may work for starters, is to conceptualize your system as having a 'server' and 'clients'.  The server maintains the authoritative state of all objects in your simulation.  The clients are merely a reflection of that state.  When a client wishes to operate on an object, such as changing its position, it publishes a request to the server, who then moves its local instance of that object and then echoes out the new state of said object to all clients - including the one who originally made the request.  In this scheme you could also speculatively move the clients instance of the object under the presumption that the movement would soon be reflected by the server.  If objects had deterministic behavior such as acting freely under the force of gravity or undergoing a constant velocity or angular velocity then you could speculatively predict that as well and reduce the apparent latency between client and server.
 
The model of such a system can be elaborated in a little more detail.  You would first instance a copy of the server and populate it with your objects.  Conceivably you could instance your world on demand as well.  Anyway, at this time your server now has a tree of all objects in the simulation.  You register the server with some IP address and port and have it watch for new connections.  When a client logs into the server you have to publish to the client from the server a list of all of the objects and it will recreate the same tree.  The client and server can even be identical code as long as the client is aware that it is non authoritative for the objects positions.  Ultimately objects are only acted upon on the server and all changes are echoed to everybody who is relevant.  Creation, destruction, movement happen on the server and are echoed to duplicate objects on the client.
 
For your purposes you need to keep in mind a distinction between 'visible graphics' and 'internal state'.  The graphics themselves are probably not something that you want to network.  You probably only want to network lighter weight state transitions such as changes in the position of a TransformGroup above a Shape3D node.  Therefore your clients will need to have a copy of all of the graphics already.
 
It is also convenient to think of your entire simulation as simply a 'database' or a 'system with state'.  Your mission ( should you choose to accept it ) is to write a chunk of code which will safely and speedily replicate that state between multiple mirror images distributed across various computers.  If your approach works well, then all instances of your code running on different machines should all ideally be perfect mirrors of each other.
 
There are many other ways to do networking and there is a long history of techniques in use.  There are most certainly many documents and source code examples available on various forums.  Take a look at various vendors such as RTime or Blaxxun or people like that.  Also by now there must certainly be some vendors who offer turnkit solutions for this kind of thing.
 
Java provides some concepts which can faciliated distribution as well.  Java has nice networking support, and there is support for remote method invocation which may help you to communicate between servers and clients without having to concern yourself with IP traffic as much.  Lately there are other services in Java which I don't know much about but which may also be helpful.
 
Java3D itself doesn't provide any special services for networking.  In fact I don't believe that Java3D objects automatically serialize themselves - so you will have to extract the features you wish to guarantee and deliver them over the network yourself.
 
Resources?  Hmmm, I'm sure there must be lots.  Lots of books on the topic anyway.  Try some of the game developer resources, this has often been a good source of ideas from an applied focus.
 
 - Andy
-----Original Message-----
From: Ale <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Thursday, September 09, 1999 12:37 AM
Subject: [JAVA3D] Networked virtual world

I need help writing an application that shares a virtual world between users
connected by the net.I don't understand how various users connected across
the net can interact with the same JAVA3D object .Could anyone give me some few basic guidlines or simply address me to an helping resouce?
 
Ale.

Reply via email to