Project Progress Report - Chu Hai College of Higher Education

1.) Aim of project
This project aims to provide a platform independent environment for interactive
3D graphics on web-based collaborative systems. Its main objectives are:
„
„
to understand some of the key issues for developers of real-time
collaborative applications, and
to demonstrate the benefits that can be obtained by the use of Javabased technology to achieve a high-performance visual simulation
environment.
2.) Progress and achievement
Nowadays, the system provides the following features:
„
„
„
„
„
„
„
Registration system: when a client first time visits our system, he need
register his own account. His login name and password will store in
database.
Login system: if client has registered before, his has a right to login our
system to play game. He needs type in the login name and password which
he register before to login our system.
3D environment: our system can provide a 3D environment which has some
building, floor, sky for client to play.
Collision: in the 3D environment, there are collision feature, which mean
the client will collision the building. After he collision, he need restart his
game.
Sound effect: our system provides sound effect when client playing game.
For example, when the client collision a building, he will hear a bomb
sound.
Multi-users: our system support multi-users playing, all client play in single
environment.
Interactive: because of multi-users environment, our system provides an
interactive function to all clients.
1
3.) Programming and database design
3.1) Java 3D programming
Our project uses the Java 3D Applet to build the environment. It needs a browser to
execute. Internet Explorer( IE ) and Netscape also can be used. We use Java 2
Platform, Standard Edition, v 1.4.2 (J2SE) and Java 3D(TM) API 1.3.1(OpenGL
version) to develop our scene and control process. You can find these tools at internet.
http://java.sun.com/j2se/1.4.2/download.html and http://java.sun.com/products/javamedia/3D/download.html. To build the scene, we find that Java3D API to input a 3D
model is more efficiency and simple than to create a 3D model by itself. That means
higher performance. We use a 3D model loader called “Loader3DS”, it used to load a
3DS MAX(.3ds) model into the scene.
Figure 1 show the interface of our project’s environment. It is the first person flight
program. The user can use a keyboard to control the flying process.
Figure1. JavaFlight Diagrams
Other features illustrated by the JavaFlight Applet:
2
„
„
„
„
„
„
„
The sounds (background and collision) have been load initially.
Plane control using Behavior subclasses.
A simple first person camera that adjusts the user’s viewpoint as the plane
moves.
Obstacles which a plane cannot pass through (represented by buildings in
Figure1). A plane is also prevented from moving off or below the checkered
floor.
A “colltest” text file to load obstacle and scenery information.
The scenery models (e.g. the building) are loaded with PropManager objects;
some text file also to load to set model’s position, rotation and scale.
The world’s background is drawn using a scaled JPG;
3.2) Network programming
Following, we would like to show the data flow status through networking. Because
our program is multi-users interactive system, there are a lot of data pass through all
client machine and server. The important communication information is the updated
client location. In our program, we need to know all other client location.
Traditionally, the locations are store at data base, but this method will drop the
performance. So I decided make an array at server program to store all location of
client. All clients get the updated array, which store client location, from server
method written by RMI API. Also, when client make “move” instruction, his location
will change, so he need tell all other clients to update his location. He can do that by
use RMI API too. The following is the data flow diagram:
3
Client
Server
Request array which store all clients location
getArray()
getArray()
Transfer Array which store all clients
Update local Array
printLocation()
Move()
setArray()
Transfer Array which updates the client location
setArray()
Update local Array
3.3) Database design
Requirements:
Softwares Required:
Linux operating system 8.0 or above
Mysql database server 4.0 or above
Jdbc driver connector/J
Tomcat application server 5.0 or above
Java development kit j2sdk1.4 or above
4
project requirement:
Offer an interface for user inputting their personal information.
This interface is mainly composed of two major parts: the login interface and
register interface. Login interface offers a few of text fields for user entering
their personal data such as the name and password, which would be used
later in this game. Register interface offers a platform for user, who wants to
play this game, to register a new account. It also offers some of fields to
receive user registered information.
Build a relational database which stores all the relational data about the game.
The data in database can be divided into two kinds. One for user and one for
administrator. For user, the data always contains user name, password,
userID, etc. these data is used to identify each user. For administrator, the
data would contain the logging message about the user such as when to login,
where to login, what actions haven been taken, etc. This information is very
useful to administrator. Based on them, he (or she ) can monitoring all the
game players to prevent them from destroy the system or disturb other
players.
Offer a monitoring interface for administrator. (Optional)
It is better to create a monitoring interface for administrator, so the administrator
can control the system more easy. This interface would show the current
status of the entire system, which includes the list of players, the status of
each player, the resources of the system, etc. Also, this interface can contains
some control tools, so the administrator can act quickly as to some dangerous
actions made by players.
Database installation and design
Install mysql database server.
Here we recommends mysql 4.0 or above. (You can get it from www.mysql.com.) As
we run the database in Linux, if you have chosen the mysql package when installed
Linux red-hat 8.0(downloaded from www.redhat.com ), please remove the old one
before install a new version.(User can get the installation document from
www.mysql.com)
Database Design
Before design a database, we need to understand one basic concept -----what is a
database? In briefly, a database is an organized collection of logically related data.
5
And here we have to ask another question what data should we need? The answer is
clearly: the user personal data, program data and the administrator data. All of them
make the database.
Personal Data
Here we define the personal data as some information that is useful for system
to identify and describe each player. It may include player name, password,
player-id, Emil address and more other information. Based on these, we design
a table called players. It has four columns: playerID, name , password and
group.
we would like to point out that the name and password appeared in this table has
no any privilege to access the database. It is just a account for user to login and
play this game.
Administrator Data.
We define the administrator data as some information that is useful for
administrator to understand the current status of the system and control the
system. This kind of information may include the player’s IP address, player’s
login and logout time. For example, we have designed a tabled called logs. It
has four fields logID,playerID,logCount and lastLog
Program Data
We define program data as some information that is useful to construct the
game environment. For example a table that stores the data about the graphic
model of the landscape.
According to the description mentioned above, we set up a database called 3dprojet
which contains tables: players, logs, playerReviews, scores, graphicModels, images,
sounds, classes.
players: stores user’s personal information.
logs :stores log information about each user.
pcores saves user’s score about the game.
graphicModels, images, sounds and classes all are used to save the information about
the game component for maintenance utility
6
players
name
logs
passowrd
lastLog
logCount
playerID
group
logID
playerReviews
playerID
coodY
time
coodZ
reviewID
playerID
coodX
scores
scoreID
gameModel
playerID
name
topScore
currentScore
graphicModels
modelID
size
name
location
type
images
imageID
size
name
location
type
7
sounds
soundID
size
name
location
type
classes
classID
function
name
location
type
has
players
1
has
1..*
logs
belongs to
has
0..*
0..*
scores
playerReviews
ER diagram of system
8
Using JDBC
After building a database, we need to consider how to interact with database. Here we
use JAVA JDBC(Java Database Connectivity). JDBC is a Java API that enables Java
programs to execute SQL statements. It allows Java programs to interact with any
SQL-compliant database.
register
0..*
Driver
DriverManager
Provides
0..*
1 creates
Connection
0..*
Statement
1 retrieve 0..*
1
ResultSet
1
Provides
provides
1
1
PreparedStatement
DatabaseMetaData
ResultSetMetaData
CallableStatement
The basic classes and interfaces of the JDBC API
Application
JDBC
MySQL Database
JDBC Architecture
The next stage is to choose a suitable JDBC Driver. There are four types of JDBC
driver.
9
Type 1
These drivers use a bridging technology to access a database. The JDBCODBC bridge that comes with JDK 1.2 is a good example of this kind of driver. It
provides a gateway to the ODBC API. Implementations of this API in turn do the
actual database access. Bridge solutions generally require software to be installed on
client systems, meaning that they are not good solutions for applications that do not
allow you to install software on the client.
Type 2
Type 2 drivers are native API drivers. This means that the driver contains Java
code that calls native C or C++ methods provided by the individual database vendors
that perform the database access. Again, this solution requires software on the client
system.
Type 3
Type 3 drivers provide a client with a generic network API that is then
translated into database-specific access at the server level. In other words, the JDBC
driver on the client uses sockets to call a middleware application on the server that
translates the client requests into an API specific to the desired driver. As it turns out,
this kind of driver is extremely flexible, since it requires no code installed on the
client and a single driver can actually provide access to multiple databases.
Type 4
Using network protocols built into the database engine, type 4 drivers talk
directly to the database using Java sockets. This is the most direct pure Java solution.
For this project we choose a driver called Connector/J (downloaded from
www.mysql.com),the type 4 driver. MySQL Connector/J is a native Java driver that
converts JDBC (Java Database Connectivity) calls into the network protocol used by
the MySQL database. It lets developers working with the Java programming language
easily build programs and applets that interact with MySQL and connect all corporate
data, even in a heterogeneous environment.
10
4.) Change from the original design
Because of different problems when we design the system, we make some changes
from the original design. The changes will conclude in three parts: Java3D, database
and networking.
Design changes in networking
In original design, the system is used Java socket API to implement the
connectivity, build a multi-users interactive environment. After discussion, the
socket API is replaced by Java RMI API. There are some reasons why we choose
RMI whether than socket:
„
socket is a very low level API
„
„
„
RMI is powerful in a remote access environment
RMI is a newer and advanced technology over than socket
Be a Computer Science student, we would like to study and challenge a
advanced technology
RMI is means Remote Method Invocation, it is a Java API which is designed to
make communication between two Java program, running on separate Java
Virtual Machine, as much like making a method call inside a single process as
possible. One side machine (client) can make a method call which in other
machine (server), and the server’s method which the client call will return the
result to the client. At the point of client’s view, the method look like run in local
machine, in fact it is run in remote machine.
RMI Client
RMI Server
…
Call remote method
Server.printString();
printString()
…
{
Return result
System.out.println(“Hello”);
C:\>java testrmi
}
Hello
C:\>
11
Above, there are a sample of RMI mode. In the client program, it make a method
called name Server.printString(), but itself hasn’t any code to execute. That is because
the method is remote call to server. When server received the call from client, it run
the code write in server’s program and return the string “ Hello” to client. Then client
print the string “Hello” to screen.
5.) System Architecture
Usually, user can connect a database directly or indirectly.
By directly, user can directly retrieve the database without involving the middle level.
This is called two-tier model .it is composed of two parts :the user interface and
server side database.
Client
MySQL
Two-tier architecture
This way seems insecurity and inefficiency. There are some reasons:
1. User may need to know the structure of table. For example the column name.
so it is failed to protect table information.
2. it is hard to ensure all users do the right thing
3) increase the complexity about play this game, because user need to know more
detail information.
4) It is difficult for administrator to control the behaviour of each user.
According to these reasons mentioned above, we use indirect method for user to
connect database in this project. That is the user information gathering from user
interface would be firstly past to a middle level ---the application server, and then the
application server retrieves the database. This is what we called three-tier
architecture.
12
Client
Application Server
MySQL
Three-tier architecture
As what you see, the middle-tier in this architecture is the application server Tomcat
which we haven’t mentioned in our proposal.
Tomcat (you can get it from http://jakarta.apache.org/tomcat/index.html) is
one of famous application servers. It is the servlet container that is used in the official
Reference Implementation for the Java Servlet and JSP (Java Server Pages)
technologies. Java servlets are a key component fo server-side development. A
servlet is a small, pluggable extension to a server that enhances the server’s
functionality. JSPs(Java Server Pages) are an extension to the Java servlet technology.
JSPs have dynamic scripting capability that works in tandem with HTML code,
separating the page logic from the static elements -- the actual design and display of
the page -- to help make the HTML more functional. A JSP is translated into Java
servlet before being run, and it processes HTTP requests and generates responses like
any servlet.
In order to receive user information from user interface and connect database
for processing these information, we have built a web application which is called
3dproject. This application now is only composed of two major components: JSP and
JAVABEAN. JavaBeans is a platform-neutral specification for creating software
components. This javabean we called ConnectDB is written for connect database only.
After application server is started , the JSPs are translated into servlets and loaded.
These servlets would fetch user’s information and use javabean to connect our
database to search relative data.
User Interface
Register Interface
13
This interface offers a platform for user to register a new account. If a user has not a
account, he or she is not allowed to play this game. A user who wants to play this
game must offer all the information required when registering. After user presses the
submit button, these information would be sent to the system for checking, If success,
a new account would be add to database and the game starts. If failed, it would back
to the register interface for user to register again.
Login Interface
This interface office a place for user who have registered a account to login. After
user press button, these login information is sent to system for checking. If success,
the game would be loaded at once. If failed, it would return a html which contains two
hyper links. One for re-login and one for register.
Monitoring Interface (under construction)
This interface is for administrator only. It shows the relative information about the
current status of the system. Also, it may contains some control functions such as
kicks somebody out from this system, so he (or she ) can protect and maintain the
system well.
14
6.) Block diagram
Following is a block diagram of system:
USER
Login.html
Register.html
Login failed
register failed
Login.jsp
Register.jsp
ConnectDB(JAVABEAN)
connect database
MySQL Database Server
success
CheckerFloor
Java
Applet
JavaFlight
PropManager
Obstacles
KeyBehavior
Block diagram of system
(1) user enters the login interface—login.html and inputs the required information.
(2) login.jsp receives the login information and ask the javabean ConnectDB to
connect database.
(3) login.jsp checks the vality of users login information using database data.
15
if correct ,load java applet(step 7) .if wrong, go to step (1)for login again or go to
step (4) for register a new account
(4) users go to register interface—register.html for register a new account..
(5) register.jsp receives the register informaton and calls ConnectDB to connect
database.
(6) register.jsp checks the register information using database data. If success , adds a
new account into database and loads the java applet.(step 7 ). If failed, go to step 4
for register again.
(7) After the user’s information have been checked in database, the user will go to
Java Applet .html.
(8) Java Applet will load JavaFlight class, which contains the main body of the whole
program, all sounds have been initialized.
(9) Checkered floor have also been builded at the beginning.
(10) Many 3D models were loaded by calling PropManager.
(11) After all models have been loaded, the Obstacles will setup BoungingSpheres to
each model for collision.
(12) After that, all settings have been finished. The user can control the flying plane
through the KeyBehavior.
7.) Class diagram
In this section, we will show the entire class diagram in Java3D, networking and
database.
7.1) Java 3D class diagram
Figure 2 show all the class diagrams of Java 3D and their relationship. The class name,
class attributes and public methods are shown.
16
PopManager
TransformGroup moveTG,
rotTG, scaleTG
Transform3D t3d, chgT3d
Java.net.URL urlBase
double xRot, yRot, zRot,
Scale
PropManager(URL,
Boolean, URL, URL)
loadFile(URL)
getTG( )
getFileCoords(URL)
setCurrentPosn(String)
setCurrentRotation(String)
setCurrentScale(String)
JavaFlight
KeyBehavior
SimpleUniverse su
BranchGroup scencBG
BoundingSphere bounds
Java.net.URL backgurl,
collurl
BackgroundSound bgSd
PointSound collSd
String objstr[ ],
coordsstr[ ]
Vector3d DOWN, UP
FWD, BACK,
LEFT, RIGHT
Transform3D toRot,
t3d, toMove
double radius
long SLEEP_TIME
Thread newThread
boolean isStop
JavaFlight( )
init( )
createSceneGraph( )
lightScene( )
addBackground( )
initUserControl( )
makeScenery(URL, URL)
initBgSound(URL)
initSound(URL)
destroy( )
main( )
KeyBehavior(
TransformGroup,
Obstacles, PointSound )
initViewerPosition(
TransformGroup)
initialize( )
processStimulus(
Enumeration)
processKeyEvent(
KeyEvent)
standardMove(int)
moveBy(Vector3d)
tryMove(Vector3d)
rotateX(double)
rotateY(double)
rotateZ(double)
doMove(Vector3d)
reStart( )
stop( )
run( )
CheckerFloor
Color3f green
BranchGroup floorBG
QuadArray plane
int FLOOR_LEN
ChecherFloor( )
getBG( )
Obstacles
int FLOOR_LEN
boolean obs[ ][ ]
BoundingSphere
obsBound[ ][ ]
Obstacles( )
store(String, float,
float, float, float,
float, float)
markObstacles(int,
int, float,float,
float, float,
float, float)
nearObstacle(Point3d,
double)
Figure2. Class Diagrams
1. JavaFlight
JavaFlight is the top-level for the applet, su is a SimpleUniverse. BranchGroup
scencBG just like a container, it contain all the TransformGroup to form a scene. URL
backgurl and collurl used to store background image and a text file location for
17
collision. String objstr[ ] and coordsstr[ ] used to store all 3D models name and their
coordinates files name. The clsaa use method createSceneGraph( ) to create scene
graph. It setup the directional lights and background image by lightScene( ) and
addBackground( ). It calls PopManager class to load some 3D models to build the
scene. The method makeScenery(URL, URL) used to make obstacles for detect
collision between plane (viewer camera) and models. The initUserControl( ) call
KeyBehavior class to control the plane’s behavior.Background and collision sounds
also be add by initBgSound(URL) and initSound(URL).
We use two kinds of sound nodes in Java 3D: a BackgroundSound object allows a
sound to permeate the entire scene, located at no particular place, a PointSound object
has a location, and so its volume varies as the user moves away from it (or the sound
node moves away from the user). All two are subclasses of the Sound class.
BackgroundSound will start as applet start but PointSound just occur when collision
have been detected.
Figure 3 show the scene graph for the world.
Figure3. Scene Graph
18
2. PopManager (3D models)
Java 3D supports external model loading through its Loader interface and the Scene
class.Loader takes as input the model’s filename and flags for enabling/disabling the
loading of certain elements of the model, such as light nodes, sound nodes, and view
the graphs.
This class used to load some 3D models through a modle loader called “Loader3DS”
A 3D Max Studio models should be used. Figure 4 show out the Coordinate Axes in
3D Studio Max and Java 3D. TransformGroup moveTG, rotTG and scaleTG will
store model’s coordinates, rotation and scale information. .URL urlBase important for
store the location of texture for all models.
The method loadFile(URL) used to load a model by a URL(model’s name) and the
getFileCoords(URL) function will read a text file though a URL, the text file contains
model’s name, position, rotation and scale. Why use a text file? Because it can be
easy to setup and correct model’s information without to recompile the program again.
The
three
methods
setCurrentPosn(String),
setCurrentRotation(String)and
setCurrentScale(String) will adjust the coordinate, rotation and scale of the model.
The data will store in four double xRot, yRot, zRot, and Scale.
Each model loaded in a TramsformGroup and then return to JavaFlight.class by
getTG( )
Figure4.
Coordinate Axes in 3D Studio Max and Java 3D
19
3. CheckerFloor
CheckerFloor class just does a simple function, but it is very important during the
collision detection. The int FLOOR_LEN store the total floor length and Color3f
green set the color of the floor plane. QuadArray plane make the shape of a floor just
like a flat plane. ChecherFloor( ) used to build the floor plane for the scene. The
method getBG( ) used to return a BranchGroup floorBG to the main program.
4. Obstacles(collision)
This class used to setup and detect the obstacles(buildings) in the scene. It also check
the plane is moving off or below the checkered floor.
The method store(String, float, float, float, float, float, float) used to read a text file
called “colltest” to get the coordinates of obstacles. It set the two dimension array
boolean obs[ ][ ] should be ture or false. The BoundingSphere obsBound[ ][ ] store
the position of BoundingSphere in a model.
The markObstacles(int, int, float, float, float, float) and nearObstacles(Point3d, double)
are used to mark obstacles on a checkered floor like a two dimension array and detect
the collision between obstacles and flying plane.
Figure 5 show how to use a two dimension array on the floor to setup obstacles
collision.
20
Figure5. Setup Collision
(1)Use a 2D array(obsBound[ ][ ]) to represent a floor .
(2)If a model had set on the floor,make one or many BoundingSphere to represent
the size of the model,like Model 1 and Model 2 in figure 5. The size of
BoundingSphere can be different and BoundingSpheres can be intersected.
(3)Use a 2D boolean array(obs[ ][ ]) to mark which position had made
BoundSphere.The boolean array size must match the 2D array size in (1).
(4)Make a BoundingSphere on a flying plane,when flying plane moves
BoundingSphere also moved.
(5)When a flying plane’s BoundingSphere intersect with model’s BoundindSphere,
collision occur.
(6)We use a many layers of 2D array to solve the collision on Y-Intercept.
Figure 6 show the three layers 2D array on a model.
21
Figure6. BoundingSphere of a model
5. KeyBehavior
This class used to control the flying plane(viewer camera) behaviour. It simulate the
plane flying in the real world. Use key presses to move the viewpoint and.
Movement is restricted to: forward, stop, rotate left, rotate right, rotate up, rotate
down and rotate at Z-axis. The Vector3d DOWN, UP, FWD, BACK, LEFT and
RIGHT set the movement of the plane.
Transform3D toRot is the rotation, t3d and toMove are position of the flying plane in
Transform3D format. The method moveBy(Vector3d) used to detect the collision
between the obstacles and the flying plane, it calculates plane’s next position by
calling tryMove(Vector3d).
The method tryMove(Vector3d) used to make the plane to a virtual move and
doMove(Vector3d) is actually move. The rotateX(double), rotateY(double) and
rotateZ(double) used to make a plane to rotate at all direction.
A double radius set the radius of BoundingSphere for the flying plane.
22
Thread newThread use a Thread to control the forward movement of the plane. The
Time for a Thread to sleep is store in long SLEEP_TIME.
A boolean isStop can check the plane is move or stop and reStart( ) function can make
all events to stop and set the environment just like to start a again.
Figure 7 show the flying behavior of a plane.
Figure7. Flying behavior of a plane
23
7.2) RMI networking class diagram
RMI Server
Client
int localArray[][]
int counter
int x
int y
String ADDRESS
Int getArray(int x, int
y)
Int getCounter()
Void clientConnect()
Void setArray(int id;
int x; int y; int z; int a)
Static int serverArray[][]
Static int counter
0...*
connect
1
Int getArray(int x, int y)
Int getCounter()
Void clientConnect()
Void setArray(int id; int x;
int y; int z; int a)
Client class:
„
„
„
„
„
„
„
„
„
Int localArray[][] : Store all clients location which receives from server.
Int counter: Store the number of clients.
Int x: select element in array.
Int y: select element in array.
String ADDRESS: store RMI Server’s address.
Int getArray(int x, int y): RMI method that request array in RMI Server which
store all client location.
Int getCounter(): RMI method that request RMI Server the number of clients.
Void clientConnect(): RMI method that tell RMI Server there are a client
connect to the server.
Void setArray(int id; int x; int y; int z; int a): RMI method that update the
client’s location to the RMI Server and store in server’s array.
RMI Server class:
„
„
„
„
Static int serverArray[][]: store all client’s location.
Static int counter: store the number of client connect to server.
Int getArray(int x, int y): RMI method that called by client to return the array
which store all client’s location.
Int getCounter(): RMI method that called by client to return the number the
24
„
„
client connect to server.
Void clientConnect(): RMI method that called by client to notify server there are
a client connecting.
Void setArray(int id; int x; int y; int z; int a): RMI method that called by client to
update their location and store to server’s array.
8.) Implementation techniques
8.1) Why use JAVA 3D to develop a flight simulation?
Java 3D API is an application programming interface used for writing threedimensional graphics applications and applets. It gives developers high-level
constructs for creating and manipulating 3D geometry and for constructing the
structures used in rendering that geometry. Application developers can describe very
large virtual worlds using these constructs, which provide Java 3D with enough
information to render these worlds efficiently.
Java 3D delivers Java's "write once, run anywhere" benefit to developers of 3D
graphics applications. Java 3D is part of the JavaMedia suite of APIs, making it
available on a wide range of platforms. It also integrates well with the Internet
because applications and applets written using the Java 3D API have access to the
entire set of Java classes.
The Java 3D API draws its ideas from existing graphics APIs and from new
technologies. Java 3D's low-level graphics constructs synthesize the best ideas found
in low-level APIs such as Direct3D, OpenGL, QuickDraw3D, and XGL. Similarly, its
higher-level constructs synthesize the best ideas found in several scene graph-based
systems. Java 3D introduces some concepts not commonly considered part of the
graphics environment, such as 3D spatial sound. Java 3D's sound capabilities help to
provide a more immersive experience for the user.
Java 3D was designed with several goals in mind. Chief among them is high
performance. Several design decisions were made so that Java 3D implementations
can deliver the highest level of performance to application users. In particular, when
trade-offs were made, the alternative that benefited runtime execution was chosen.
25
Java 3D API is a free tool to develop many programs. You can download the most
new version at Java.Sun.com. There are many code resources and reference notes in a
internet. You can find it easily.
8.2) Polling? Call back?
In our system, there are multi-users environment, so all the client need update the
location of all clients. There are two methods to update location: client-side polling
and server-side call back. In our case, the polling method is better then call back. This
is because our system is a Applet program. Following is detail:
„ Client-side Polling
There are two reasons to use client-side polling. The first is that, architecturally,
it’s simpler. In this model, the client application calls the server application. The
server doesn’t have to actually call them back. This makes for simpler code and
makes it easier to have multiple types of clients, should that be necessary.
The second reason to use client-side polling is that sometimes clients can’t
accept socket connections from the server. One typical case for this is when the
client is an applet. Most of the time, applets are forbidden from creating any
instances of ServerSocket at all. This completely rules out the applet containing
an RMI server.
Another typical case is when firewalls are involved. A firewall separates two
parts of the network and restricts network traffic to certain sockets (or only
allows data to flow in certain directions). The upshots is that sometimes, even if
the client application is capable of creating instances of ServerSocket and thus,
can actually contain an RMI server, the server application may not be able to
connect to it.
„ Server-side call back
The second common solution is server-side call back involves having an RMI
server inside the client application. The server application receives a reference to
this client-side server and uses it to call the call back when the server has
finished the original request. That is, we have the following sequence of action:
26
1.
2.
The client application makes a remote invocation on the server application.
As part of this invocation, it passes in a reference to an RMI server inside
the client application.
When the server application finishes handling the request, it makes a remote
method invocation on the RMI server inside the client application.
Server-side call backs have several advantages over client-side polling. The most
important of these advantages are decreased bandwidth and decreased serverside processing.
The downside to server-side call back is that the code itself (and its deployment)
becomes slightly more complex. To implement server-side call back, we need to
perform the following three steps:
1.
Define a client-side call back interface referred to as the call back object.
2.
Implement the client-side interface, using the reporting code we’ve already
written inside the call back object, to report to the user.
Write the server associate requests with the call back object, and call the
client back when requests are completed.
3.
9.) Difficulties encountered and solution
9.1) Java 3D difficulties
„ 3DModels problem
Java 3D’s utilities package includes two subclasses of Loader aimed at particular file
formats: Lw3dLoader handles Lightwave 3D scene files, and ObjectFile(ObjLoad)
processes Wavefront .obj files. A third subclass, LoaderBase, implements the Loader
interface in a generic way to encourage the building of loaders for other 3D formats
through subclassing.
We find that it is difficulty to find a 3D models as Lightwave 3D and Wavefront
format. Although we found a little 3D models in these format, we can not use the
Lw3dLoader and ObjectFile to load. Why? The answer maybe the 3D model change
27
their format, since Lw3dLoader and ObjLoad was developed at 1998.
We spent much time to find a suitable 3D models loader. Some loader can support
many model format, such as .OBJ, .DXF, .LWS, .AC3D, VRML97 and .3DS , but it
cannot use in the Java Applet through Internet Explorer( IE ). At last we choose a
loader called “Loader3DS”, it can load .3DS models in Java Applet. The internet had
more resources about.3DS format. But it still difficult to find a useful and suitable
models.
„ Read text file problem
To make our program more flexible to setup some 3D models coordination, rotation,
scale and collision. We use a text file to store the information of the model in a
different folder. The user can set or correct the information of a model in a text file,
then save it. The program will execute the new result without recompile the program
code.
At first, we find that Java applet in Internet Explorer( IE ) cannot read a file. Why? It
is due to a network security problem, we need to set a suitable security level. Let Java
applet had a right to read a text file in a server and a full path URL address should be
given to the loader to load a 3D model.
„ Flight simulation problem
We find that it is very difficult to use a program to build a virtual world to simulate a
real world flying. Although our program can let a plane to fly in all direction and it
can fly from a zero speed accelerate to form a maximum speed(Fly).It also can
decelerate to zero speed( Stop) and a collision detection.The flight simulation is not
very like a flying plane in the real world. To make the flight simulate more accurate,
we need more concept and knowledge in mathematic! But it is difficult problem in
our group member. In future our group member will find more reference book, try to
make a better simulation.
28
9.2) Networking difficulties
„ Can’t use call back
Because our system is a Applet program, there are restrict to act as a client which has
server process. Because RMI call back method need client include a server method to
wait server call back, so our program can’t use call back method. However, there are
polling method we can use.
9.3) Database difficulties
„ Load jdbc driver
At the beginning of this project, we chose two-tier model to construct our system.
Under this model, each user has to load a JDBC driver, the Connector/J we chose. But
it doesn’t work correctly. It always fails to load this driver through applet even it do
works through java application. This problem is solved by using three-tire model to
construct our system instead of two-tier model. Because the client doesn’t need to
load driver through applet. This job is passed to ConnectDB.
29
10.) Expect Difficulties
Management problem with three-tier model
Although the three-tier architecture provides some important advantages, it also has
its downside. The chief drawback is the level of complexity it adds to the system. Our
system has more distinct components, and therefore more to manage.
Restrict on Internet
Because our program use a remote method call method to build a multi-users
interactive environment, we are face the security restrict problem. Some ISP (Internet
Service Provider) may block the remote method call to protect the machine without
attack.
30
Download PDF
Similar pages