Simulation Service

API Documentation mv3d.server.sim.SimulationServer.

The Simulation Service is what does nearly all of the work of actually simulating the virtual world. Sim servers host multiple items which can be in one or more areas. They run the physics simulation and report any changes to items they keep track of to other servers. Mainly, other Simulation Servers and Player Servers. Sim Servers should belong to a SimCluster? which is used to distribute simulation of related items across multiple servers.

Each object uses the normal MV3D security permissions. Because of this, some items can be hidden from clients or they can be modifiable by clients. It's completely up to you! The Simulation Service is in charge of storing all these items. For moving items, they are stored when they transition from moving to stationary. This means that if a character falls off the edge of the world by accident, if you restart the server, the character will revert back to the last position it was stationary. Since some properties of items may be saved automatically, it is entirely possible that the item is saved while moving, but generally, it will only save the changed attributes not including position and rotation.

There are two types of items: objects and areas. Areas contain objects. Objects can contain other objects as well, but areas are specifically created to do this. As of this writing, there's one type of area: OctreeArea. OctreeAreas? are named after how they segregate the objects inside of them. Naturally, they use an Octree. As more objects are added, the area will split into 8 sections. Each of those sections will then split into 8 whenever there are too many objects in them. This makes sure that any section of the area doesn't have too many objects for a single server process. OctreeAreas? will be able to move sections from one server to another.

Here are some of the major types of Objects. It is generally expected that other virtual worlds or games will subclass these and add in their own logic:

  • BasicPhysicalObject? - Most objects will use this class. It can be stationary or moving.
  • PhysicalBiped? - Used exclusively for player characters. This is generally overkill for NPCs. It does physics simulation for a biped by casting a ray to the floor and simulating legs with it.
  • WaterPlane? - Currently used for the ocean.

Objects generally contain game related data. Data that wouldn't necessarily be something tha tshould be sent to the client. Most types of objects hold a body. Bodies are used for physics simulation, but they also are sent to the client. There are several types of bodies:

  • StationaryBody? - While this type of body can be moved, it can't have velocity or any sort of movement over time.
  • MobileBody? - The basic moving body. This type of body can move and have velocity and acceleration.
  • BipedBody? - Used for simulating bipeds, this is owned by the PhysicalBiped? object.