Virtual Worlds

screenshot of virtual worlds! screenshot of virtual worlds!

 

Description:

This was an exercise made for the Virtual Worlds course of my masters. It's goal was to get acquanted with persistent worlds, physics and (secure) networking.

The application is a kind of ball path, the player can shoot cubes or balls down the path. The physics system, implemented using ODE, then takes into account air drag, collisions, gravity and material properties like softness. The object will then fall and bounce down the ball path according to the laws of physics.

The second part of the exercise was to make a persistent world out of this exercise, implement a secure way of connecting and add dead reckoning to it. This led to the final product, where the user has to start a server and connect to it with the client. After disconnecting, the objects the player shot will stay behind in the persistent world. To reduce network load the client shows the path of the object by using dead reckoning. The server sends corrections only when needed.


Challenges:

Implementing the correct physics for the balls and cubes, including the physics for spinning objects was quite challenging. Not only did I have to come up with the correct formula's, I also had to learn to use the ODE engine.

Another big challenge was the dead-reckoning. The network communication was set up using RakNet, which was fairly easy to use. The dead-reckoning was implemented with zeroth, first and second order prediction algorithms.


Features:

  • Realistic physics
  • Persistent world
  • Dead-reckoning
  • Secure login
  • Physics and dead-reckoning settings can be adjusted in a .txt file

Media:

screenshot of virtual worlds! screenshot of virtual worlds! screenshot of virtual worlds! screenshot of virtual worlds!

Code Snippets:

run()
Function of the client system that handles the packet updates and uses dead-reckoning if no update is received for a particular object.

update()
The server update function. Updates the position of all objects and checks to see if the client has to be informed about the real position of the object.

calcDrag()
Function that calculates and applies the force of the airdrag and wind to the given objects.

Downloads:

You can download the game here.
To run it, first unzip it, then go to the bin/release/ folder and start the server first. Choose a port for the server to listen on.
Then start the client. The client can run on the same machine as the server, just enter "localhost" as the server's ip address and enter the same port number as you entered by the server. Then you'll have to enter a username and password to login. There are two user/pass combinations that work: user1/password1 and user2/password2.
An Ogre3D window will open, adjust the settings to your liking and press OK to start the game.
Once the application runs, you can move the camera with the right mouse button and turn it with the left mouse button. Use the N and M buttons to shoot balls/cubes. The longer you press one of those buttons, the further the object will fly. Have Fun!.

You might need to install the visual C++ 2005 redistributable to play this game, you can download it here.
You also need to have DirectX 9 installed, you can get that here.