An Overview of NetTour3D


Chapter 32. A Networked Virtual Environment

This chapter utilizes the threaded client/server model, which first appeared in the multiplayer chat system in Chapter 30 and now appears in the service of a networked virtual environment (NVE).

When clients connect to the server, they appear as a 3D sprite in a shared world filled with sprites representing other users. The scenery is the familiar checkerboard seen in many of the earlier Java 3D examples, along with a castle and some red poles. Users can move their sprites around the world but cannot pass through the poles.

Figure 32-1 shows the NetTour3D application being run by two clients. Each window is the clients' view of the shared world, represented by a third-person camera that follows the clients' sprite as it moves. All the visitors use the same robot image, but each user's name floats above their robot.

Figure 32-1. Two visitors to the NetTour3D world


Key features demonstrated include:


Local and distributed sprites

Each user is represented by two kinds of sprites: a local sprite on the users' machine, and distributed sprites present on every other machine. When users moves their local sprites, the distributed sprites are updated as well via messages sent from the client, through the server, and finally to the other clients. The local and distributed sprites are subclasses of a Sprite3D class, so they share a great deal of functionality.


Fast local updates

Local sprites are updated directly by the client, rather than by transmitting a message to the server and waiting for it to be echoed back. This removes latency delays for local sprite updates. The sprite's changes are transmitted to the server but only for delivery to the other clients


Fat clients, thin server

A copy of the world is directly created by every client, rather than transmitted to the client from the server. This reduces the data flow sent over the network at the expense of duplicating information about the world on every client.

Each client is essentially a version of the Tour3D application described in Chapter 18, with additional networking code lifted from the threaded client/server chat application in Chapter 30. Read those chapters before reading this one.


Since the clients do most of the work, the server is demoted to little more than a mail boy, routing messages between its high-powered clients.


Activity diagram design

As in the last chapter, considerable use if made of activity diagrams to specify client activity (joining the world, moving about, leaving) and to depict the communication between the clients via the server

A simplification in the application is that sprites cannot communicate with each other. However, adding a multiplayer chat component to NetTour3D would be easy. NetTour3D is a simple NVE, so I'll begin by describing NVEs. Information on NVEs coded in Java and Java 3D are given at the end of the chapter.



Killer Game Programming in Java
Killer Game Programming in Java
ISBN: 0596007302
EAN: 2147483647
Year: 2006
Pages: 340

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net