Networking Physics

OvermindDL1

05-07-2006 18:18:06

I have a simulator setup (not a game) that simulates some things physics related. It will be based on user input of how the things react and operate. It is currently setup as a client/server style right now, although it does little more then connect. I need to start networking the physics objects so I need to handle things like the server being authoritative, the clients need to interpolate, the clients will need to send their own input (and should see the reactions of their own input as quick as possible) to the server so it can then be replicated elsewhere. This is a relatively simple setup and the entire world will be replicated to each client in full. Does anyone have good experience networking up Newton/OgreNewt physics worlds and have thoughts about how best to keep everything synced up? Or shall I just attempt the usual setup about replicating an object in full when it is created, and send updates when forces change, along with the occasional position/orientation update to help keep it synced and so forth, and just deal with the usual hickup and jump?

For note, the objects are created similar to this:
class SimpleCube(PhysicsObject):
Name = "Simple Cube"
Mesh = "SimpleCube"
Description = "The basic cube"
Collision = CollProx.Cube((-1,-1,-1),(1,1,1))
Mass = 8
# etc...
PhysicsObject.registerClass(SimpleCube)


The collision is generated by classes that generate the collision based on some more params (like should the thing be stretched and so on). The objects are able to have callbacks registered on them (onTouch, onHit, etc...). This class definition is basically dumb (I was thinking of making it so more advanced things could be registered on them, but went against that in favor of larger meta-objects that hold onto and control any number of normal physics objects, which may or may not be compounded together, joints, etc... The objects (as you can see) are specified in python and passed to my C++ engine in the registerClass function. When created in world, it reads the class definition and creates a physics object out of it (if I had the script definitions be smart, able to register their own things and define functions, then I'd have to serialize the script across the network too, not fun...). If anyone has a better way of setting up collisions as well I'd be interested to hear.