Chapter 4 - Networked Graphics

Download Report

Transcript Chapter 4 - Networked Graphics

Networked Graphics
Building Networked Virtual
Environments and Networked Games
Chapter 4: More Than Two
BOIDS
Config
BoidsSystem
Datamodel
Network
IBoids
IProtocol
Renderer
Behavior
IBoids
Datamodel
-_remoteFlocks : Collection
-_localFlock : Flock
-_numBoids : int
FlockRemote
-_port : int
-_ip : string
Flock
Boid
-_flockID : int
-_color : Color3f
-_flock : Collection
-_geometry : Shape3D
-_position : Vector3f
-_velocity : Vector3f
SIMPLE PEER TO PEER
IBoids
Datamodel
-_remoteFlocks : Collection
-_localFlock : Flock
-_numBoids : int
FlockRemote
-_port : int
-_ip : string
FlockRemoteFlag
Flock
Boid
-_flockID : int
-_color : Color3f
-_flock : Collection
-_geometry : Shape3D
-_position : Vector3f
-_velocity : Vector3f
«interface»IProtocol
+code(in flock : Flock) : string
+decode(in str : string)
+setDatamodel(in datamodel : Datamodel)
+setRenderer(in renderer : Renderer)
+setNetwork(in network : Network)
Datamodel
Network
UDPNetwork
-_sendSocket : DatagramSocket
-_receiveSocket : DatagramSocket
«interface»IProtocol
+code(in flock : Flock) : string
+decode(in str : string)
+setDatamodel(in datamodel : Datamodel)
+setRenderer(in renderer : Renderer)
+setNetwork(in network : Network)
Datamodel
Protocol
Network
Renderer
ProtocolP2PSimple
PEER TO PEER WITH MASTER
Host
E
Host
E
Host
D
Host
A
Host
C
Host
D
Host
B
Host
A
Host
C
Host
E
Host
E
Host
D
Host
A
Host
C
Host
B
Host
B
Host
D
Host
A
Host
C
Host
B
IBoids
Datamodel
-_remoteFlocks : Collection
-_localFlock : Flock
-_numBoids : int
FlockRemote
-_port : int
-_ip : string
Flock
Boid
-_flockID : int
-_color : Color3f
-_flock : Collection
-_geometry : Shape3D
-_position : Vector3f
-_velocity : Vector3f
code(Flock flock)
create Announce message
send message to master host
Inactive
Active
code(Flock flock)
create State message
send message to every participating host
decode(String str) and Announce message
decode(String str) and Announce message
extract flock from received str
add FlockRemoteFlag to the Datamodel
add FlockRemoteFlag to the Renderer
extract flock from received str
add FlockRemoteFlag to the Datamodel
add FlockRemoteFlag to the Renderer
create an Announce message for local flock
send the created Announce message to the remote host
for each registered remote flock {
send the received Announce to remote flock
create Announce message for remote flock
send created Announce message to sender of flock
}
Inactive/
Active
Inactive/
Active
decode(String str) and State message
extract flock identifier from received str
retrieve FlockRemoteFlag from Datamodel
update FlockRemote from data on str
decode(String str) and State message
extract flock identifier from received str
retrieve FlockRemoteFlag from Datamodel
update FlockRemote from data on str
PEER TO PEER WITH RENDEZVOUS
Rendez
vous
Server
Rendez
vous
Server
Rendez
vous
Server
Hos
tA
Hos
tA
Hos
tA
Hos
tB
Hos
tB
Host
C
Hos
tB
Host
C
Hos
tB
Host
C
Rendez
vous
Server
Rendez
vous
Server
Rendez
vous
Server
Hos
tA
Hos
tA
Hos
tA
Host
C
Hos
tB
Host
C
Hos
tB
Host
C
IBoids
Datamodel
-_remoteFlocks : Collection
-_localFlock : Flock
-_numBoids : int
FlockRemote
-_port : int
-_ip : string
Flock
Boid
-_flockID : int
-_color : Color3f
-_flock : Collection
-_geometry : Shape3D
-_position : Vector3f
-_velocity : Vector3f
decode(String str) and Announce message
code(Flock flock)
create Announce message
send message to server
Inactive
Active
extract flock from received str
add FlockRemoteFlag to the Datamodel
add FlockRemoteFlag to the Renderer
Inactive/
Active
code(Flock flock)
decode(String str) and State message
create State message
send message to server
extract flock identifier from received str
retrieve FlockRemoteFlag from Datamodel
update FlockRemote from data on str
receive() and Announce message
extract flock from received str
add FlockRemote to the datamodel
for each registered remote flock {
send the received Announce to remote flock
create Announce message for remote flock
send created Announce message to sender of flock
}
Inactive/
Active
CLIENT/SERVER
Server
Server
Server
Ho
st
A
Ho
st
A
Ho
st
A
Ho
st
B
Ho
st
B
Host
C
Ho
st
B
Host
C
Ho
st
B
Host
C
Server
Server
Server
Ho
st
A
Ho
st
A
Ho
st
A
Host
C
Ho
st
B
Host
C
Ho
st
B
Host
C
IBoids
Datamodel
-_remoteFlocks : Collection
-_localFlock : Flock
-_numBoids : int
Flock
Boid
-_flockID : int
-_color : Color3f
-_flock : Collection
-_geometry : Shape3D
-_position : Vector3f
-_velocity : Vector3f
«interface»IProtocol
+code(in flock : Flock) : string
+decode(in str : string)
+setDatamodel(in datamodel : Datamodel)
+setRenderer(in renderer : Renderer)
+setNetwork(in network : Network)
Datamodel
Network
UDPNetwork
-_sendSocket : DatagramSocket
-_receiveSocket : DatagramSocket
UDPNetworkClient
decode(String str) and Announce message
code(Flock flock)
create Announce message
send message to rendezvous server
Inactive
Active
code(Flock flock)
create State message
send message to every participating host
extract flock from received str
add Flock to the Datamodel
add Flock to the Renderer
Inactive/
Active
decode(String str) and State message
extract flock identifier from received str
retrieve Flock from Datamodel
update Flock from data on str
decode(String str) and Announce message
extract flock from received str
add FlockRemote to the Datamodel
for each registered remote flock {
create stripped version of the received Announce
send the stripped Announce to remote flock
create Announce message for remote flock
send created Announce message to sender of flock
}
Inactive/
Active
decode(String str) and State message
extract flock identifier from received str
for each registered remote flock that is not the sender {
send the received State to remote flock
}
MULTICAST
Hos
tE
Hos
tE
Hos
tD
Host
A
Hos
tC
Hos
tD
Hos
tB
Host
A
Hos
tC
Hos
tE
Hos
tE
Hos
tD
Host
A
Hos
tC
Hos
tB
Hos
tB
Hos
tD
Host
A
Hos
tC
Hos
tB
IBoids
Datamodel
-_remoteFlocks : Collection
-_localFlock : Flock
-_numBoids : int
Flock
Boid
-_flockID : int
-_color : Color3f
-_flock : Collection
-_geometry : Shape3D
-_position : Vector3f
-_velocity : Vector3f
«interface»IProtocol
+code(in flock : Flock) : string
+decode(in str : string)
+setDatamodel(in datamodel : Datamodel)
+setRenderer(in renderer : Renderer)
+setNetwork(in network : Network)
Datamodel
Network
UDPNetworkMulticast
-_sendSocket : DatagramSocket
-_receiveSocket : MulticastSocket
code(Flock flock)
Joined
Inactive
create Announce message
send message to multicast group
code(Flock flock)
join multicast group
Active
Inactive
code(Flock flock)
create State message
send message to multicast group
decode(String str) and Announce message
extract flock from received str
add Flock to the Datamodel
add Flock to the Renderer
Inactive/
Active
decode(String str) and State message
extract flock identifier from received str
retrieve Flock from Datamodel
update Flock from data on str
SUMMARY