Networked Graphics Building Networked Virtual Environments and Networked Games Chapter 2: One on one (101)
BOIDS
Three Forces Acting on a Boid CohesionAlignmentSeparation
PiPi ViVi A P’ i V’ i At time t At time t+ t One Time Step of a Boid
Data Model Simulation Renderer Software Client
DISTRIBUTED BOIDS: CONCEPTS
Data-Push Client B Client A
Client B Data-Sharing
Client B Client A Data-Coupled
DISTRIBUTED BOIDS: IMPLEMENTATION
Data Model Simulation NetworkRenderer Software Modem Client Router Software Modem Client
Boids Implementation Data model Local Flock Remote Flock Screen (Renderer Output) Network Internet Router Simulation
Create socket local port X _socket = DatagramSocket(); Read packet _packet = _socket.read() Write packet to remote address and port _socket.write(_packet) Close _socket Write packet to remote address and port _socket.write(_packet) Read packet _packet = _socket.read() Close _socket Create socket local port X _socket = DatagramSocket(); Create Datagram Packet to receive and send _packet = DatagramPacket(); Create Datagram Packet to receive and send _packet = DatagramPacket();
Create socket to listen to requests on local port X _listenSocket = ServerSocket(); Wait for incoming connection requests _connectionSocket = _listenSocket.accept(); Read messages on _connectionSocket Write messages on _connectionSocket Close _connectionSocket Connect to remote address and port _clientSocket = _Socket(); Write messages on _clientSocket Read messages on _clientSocket Close _clientSocket Setup streams _connectionSocket Setup streams _connectionSocket
REFLECTION
X Client A t X Client B t+t Network Boid i wall clock time
X Client A t X wall clock time Client B t+t Network Boid i t+t Network t Boid j Boid i
t X wall clock time Client A t X wall clock time Client B t Network Boid j Boid i t Network Boid j Boid i
a) At time t b) At time t+t Network c) At time t+2.t Network ClientAClientB ClientAClientB ClientAClientB