public void TestSyncOffline() { var serverpm = new SimpleServerPacketManager(); var clientpm = serverpm.CreateClient(); var vertexDeclarationPool = new VertexDeclarationPool(); vertexDeclarationPool.SetVertexElements <TangentVertex>(TangentVertex.VertexElements); var texturePool = new TexturePool(); var meshPartPool = new MeshPartPool(); var renderer = new SimpleMeshRenderer(texturePool, meshPartPool, vertexDeclarationPool); var mesh = DefaultMeshes.CreateGuildHouseMesh( new TheWizards.OBJParser.OBJToRAMMeshConverter(new RAMTextureFactory())); var meshFactory = new SimpleMeshFactory(); meshFactory.AddMesh(mesh); var builder = new SimpleStaticWorldObjectFactory(renderer, meshFactory); var client = new ClientStaticWorldObjectSyncer(clientpm, builder); var server = new ServerStaticWorldObjectSyncer(serverpm); var game = new XNAGame(); game.AddXNAObject(renderer); game.AddXNAObject(vertexDeclarationPool); game.AddXNAObject(texturePool); game.AddXNAObject(meshPartPool); game.InitializeEvent += delegate { }; game.UpdateEvent += delegate { if (game.Keyboard.IsKeyPressed(Microsoft.Xna.Framework.Input.Keys.F)) { var o = server.CreateNew(); var obj = o; obj.Mesh = mesh; obj.WorldMatrix = Matrix.CreateTranslation(game.SpectaterCamera.CameraPosition); } server.Update(game.Elapsed); client.Update(game.Elapsed); }; game.Run(); }
public void TestSyncOffline() { var serverpm = new SimpleServerPacketManager(); var clientpm = serverpm.CreateClient(); var clientSyncer = new ClientSyncer(clientpm); var serverSyncer = new ServerSyncer(serverpm); var physicsEngine = new PhysicsEngine(); StillDesign.PhysX.Scene serverScene = null; PhysicsDebugRendererXNA debugRenderer; PhysicsDebugRendererXNA debugRendererServer; var game = new XNAGame(); float totalTime = 0; float timeSinceTick = 0; float tickRate = 1 / 30f; int tickNumber = 0; float packetLoss = 0.25f; var rand = new Random(); game.InitializeEvent += delegate { physicsEngine.Initialize(); serverScene = physicsEngine.CreateScene(physicsEngine.Scene.Gravity, true); debugRenderer = new PhysicsDebugRendererXNA(game, physicsEngine.Scene); game.AddXNAObject(debugRenderer); debugRendererServer = new PhysicsDebugRendererXNA(game, serverScene); game.AddXNAObject(debugRendererServer); ActorDescription actorDesc; SphereShapeDescription shape; shape = new SphereShapeDescription(1); actorDesc = new ActorDescription(shape); actorDesc.BodyDescription = new BodyDescription(10); var server = serverSyncer.CreateActor(serverScene.CreateActor(actorDesc)); ((WorldPhysxSyncActor)server.Actor).Actor.AddForce(Vector3.UnitX * 200, ForceMode.Impulse); shape = new SphereShapeDescription(1); actorDesc = new ActorDescription(shape); actorDesc.BodyDescription = new BodyDescription(10); var client = clientSyncer.CreateActor(physicsEngine.Scene.CreateActor(actorDesc)); client.ID = server.ID; // Identify }; game.UpdateEvent += delegate { physicsEngine.Update(game); physicsEngine.UpdateScene(game.Elapsed, serverScene); serverSyncer.Update(game.Elapsed); clientSyncer.Update(game.Elapsed); }; game.Run(); physicsEngine.Dispose(); }
public VirtualNetworkConnectorClient CreateClient() { return(new VirtualNetworkConnectorClient(spm.CreateClient())); }